:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #111a2d;
  --panel-2: #172238;
  --line: rgba(255,255,255,.09);
  --text: #eef3ff;
  --muted: #9aa9c2;
  --blue: #79a9ff;
  --purple: #a78bfa;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  background: radial-gradient(ellipse at 50% -15%, #1e3157 0, var(--bg) 55%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
}
.app { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 22px; }
.topbar { display:flex; align-items:center; gap:13px; flex-wrap:wrap; }
.brand-mark {
  width:44px;height:44px;border-radius:14px;display:grid;place-items:center;
  font-weight:800;font-size:17px;color:#091326;
  background:linear-gradient(135deg,#8cc4ff,#b8a4ff);
  box-shadow:0 8px 30px rgba(100,145,255,.2);
}
h1 { font-size:18px; margin:0; letter-spacing:.2px; }
.topbar p { margin:3px 0 0; color:var(--muted); font-size:12px; }
.status { margin-left:12px; display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12px; }
.dot { width:8px;height:8px;border-radius:50%;background:#eab35d; }
.status.online .dot { background:#4ade80; box-shadow:0 0 12px #4ade8080; }
.status.offline .dot { background:#fb7185; }
.intro { padding:40px 0 24px; }
.eyebrow { color:#9dbaff; font-size:10px; letter-spacing:2px; font-weight:700; }
.intro h2 { font-size:clamp(28px,4.5vw,40px); letter-spacing:-1.2px; margin:10px 0 8px; }
.intro p { color:var(--muted); margin:0; font-size:14px; }
.model-line { display:flex; flex-wrap:wrap; gap:8px; margin-top:16px; }
.model-pill { border:1px solid var(--line); background:#ffffff08; padding:6px 10px; border-radius:30px; color:#bdc9dc; font-size:11px; }
.chat-panel { background:rgba(17,26,45,.88); border:1px solid var(--line); border-radius:20px; overflow:hidden; box-shadow:0 25px 80px #0004; }
.messages { min-height:360px; max-height:56vh; overflow-y:auto; padding:24px; }
.welcome { text-align:center; max-width:560px; margin:20px auto 16px; }
.spark { color:#a99aff; font-size:30px; }
.welcome h3 { margin:8px 0; font-size:20px; }
.welcome p { color:var(--muted); font-size:13px; line-height:1.6; margin:0 auto 18px; }
.suggestion { display:block; width:100%; margin:8px 0; text-align:left; padding:12px 14px; border-radius:11px; color:#dce6f8; background:#ffffff06; border:1px solid var(--line); cursor:pointer; font-size:12px; }
.suggestion:hover { border-color:#789fff88; background:#789fff12; }
.message { display:flex; margin:0 0 20px; gap:10px; }
.message.user { justify-content:flex-end; }
.bubble { max-width:min(85%,720px); padding:13px 15px; border-radius:15px; font-size:13px; line-height:1.65; white-space:pre-wrap; overflow-wrap:anywhere; }
.user .bubble { background:#294878; border:1px solid #6d9fe944; border-bottom-right-radius:4px; }
.assistant .bubble { background:#1a2942; border:1px solid var(--line); border-bottom-left-radius:4px; }
.message-label { color:#9dbaff; font-size:10px; margin:0 0 5px 2px; display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.tool-badge { background:#79a9ff22; border:1px solid #79a9ff55; color:#b8d4ff; padding:2px 7px; border-radius:12px; font-size:10px; font-weight:600; }
.typing { color:#aab8d0; font-size:12px; padding:12px; }
.composer { border-top:1px solid var(--line); padding:15px; background:#0e1729; }
textarea { display:block; width:100%; resize:vertical; min-height:55px; max-height:180px; border:0; outline:0; background:transparent; color:var(--text); font:inherit; font-size:14px; line-height:1.5; }
textarea::placeholder { color:#72819b; }
.composer-bottom { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:8px; color:#75849e; font-size:10px; }
#sendButton { border:0; border-radius:10px; padding:9px 13px; color:#071326; background:linear-gradient(135deg,#8bc3ff,#b9a5ff); font-weight:700; cursor:pointer; display:flex; gap:12px; align-items:center; }
#sendButton:disabled { opacity:.5; cursor:wait; }
footer { display:flex; justify-content:space-between; color:#71809a; font-size:11px; padding:14px 4px; }
footer button { border:0; background:transparent; color:#a9c3ff; cursor:pointer; font:inherit; }
.error { color:#fecaca; border-color:#fb718544 !important; background:#7f1d1d22 !important; }

.auth-bar { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.auth-user { font-size: 12px; color: #9dbaff; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-btn { border: 1px solid var(--line); background: #ffffff10; color: var(--text); border-radius: 10px; padding: 7px 12px; font-size: 12px; cursor: pointer; }
.auth-btn:hover { border-color: #79a9ff88; background: #79a9ff20; }

.login-dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 0; width: min(420px, calc(100% - 24px)); }
.login-dialog.modal-wide { width: min(760px, calc(100% - 24px)); max-height: 90vh; overflow-y: auto; }
.login-dialog::backdrop { background: rgba(4, 8, 18, 0.76); }
.login-card { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.login-card h3 { margin: 0; font-size: 18px; }
.login-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.login-card input, .login-card select { width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: #0e1729; color: var(--text); font: inherit; font-size: 12px; margin-top: 4px; }
.login-error { color: #93c5fd; font-size: 12px; min-height: 16px; }
.login-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.auth-mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #0b1220; padding: 4px; border-radius: 10px; border: 1px solid var(--line); }
.mode-tab { border: 0; background: transparent; color: var(--muted); padding: 8px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; }
.mode-tab.active { background: #1d2f52; color: var(--text); }
.auth-separator { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 11px; margin: 4px 0; }
.auth-separator::before, .auth-separator::after { content: ""; flex: 1; border-bottom: 1px solid var(--line); }
.auth-separator span { padding: 0 10px; }
.social-login-row { display: flex; flex-direction: column; gap: 8px; }
.social-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: #0e1729; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.social-btn:hover { border-color: #79a9ff88; background: #162440; }
.social-icon { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; }
.google-btn .social-icon { background: #ffffff; color: #ea4335; }
.facebook-btn .social-icon { background: #1877f2; color: #ffffff; }
.auth-footnote { font-size: 11px !important; color: #7e91b0 !important; text-align: center; margin-top: 2px !important; }
.btn-ghost { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-size: 12px; }
.btn-ghost:hover { color: var(--text); border-color: #79a9ff66; }
.btn-primary { border: 0; border-radius: 10px; padding: 8px 16px; background: linear-gradient(135deg,#8bc3ff,#b9a5ff); color: #071326; font-weight: 700; cursor: pointer; font-size: 12px; }
.btn-small { border: 1px solid #79a9ff66; border-radius: 8px; padding: 6px 12px; background: #79a9ff22; color: var(--text); cursor: pointer; font-size: 11px; white-space: nowrap; }

.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tabs-bar { display: flex; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 10px; flex-wrap: wrap; }
.tab-btn { border: 1px solid var(--line); background: #ffffff06; color: var(--muted); border-radius: 9px; padding: 7px 12px; font-size: 12px; cursor: pointer; }
.tab-btn.active { background: #79a9ff24; border-color: #79a9ff88; color: var(--text); font-weight: 600; }
.tab-panel { display: none; flex-direction: column; gap: 12px; }
.tab-panel.active { display: flex; }
.tab-note { font-size: 12px; color: var(--muted); background: #0e1729; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }

.login-dialog.modal-wide { width: min(980px, calc(100% - 24px)); }
.connection-groups { display: flex; flex-direction: column; gap: 20px; padding-bottom: 6px; }
.connection-group { display: flex; flex-direction: column; gap: 9px; }
.connection-group h4 { margin: 0; color: #b8d4ff; font-size: 13px; letter-spacing: .15px; }
.integration-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(265px, 1fr)); gap: 9px; }
.integration-card { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0e1729; transition: border-color .15s ease, background .15s ease; }
.integration-card:hover { border-color: #79a9ff66; background: #111d33; }
.integration-card.connected { border-color: #22c55e55; }
.integration-card.planned { border-color: #ef444455; background: #1b1420; }
.integration-card.planned:hover { border-color: #f87171aa; background: #211720; }
.integration-heading { min-width: 0; display: flex; align-items: center; gap: 11px; }
.integration-logo { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid #ffffff18; border-radius: 12px; background: #fff; color: #14223d; font-size: 13px; font-weight: 800; letter-spacing: -.3px; }
.integration-logo img { display: block; width: 28px; height: 28px; object-fit: contain; }
.integration-name { color: var(--text); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.integration-footer { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 7px; }
.integration-status { color: #8b9ab4; font-size: 10px; white-space: nowrap; }
.integration-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #8591a5; }
.integration-status.is-connected { color: #86efac; }
.integration-status.is-connected::before { background: #22c55e; box-shadow: 0 0 9px #22c55e80; }
.integration-status.is-planned { color: #fca5a5; }
.integration-status.is-planned::before { background: #ef4444; box-shadow: 0 0 9px #ef444480; }
.integration-plan-label { padding: 5px 8px; border: 1px solid #ef444455; border-radius: 8px; color: #fecaca; background: #ef444414; font-size: 10px; font-weight: 650; white-space: nowrap; }
.planned-group { border-top: 1px solid var(--line); padding-top: 9px; }
.planned-group summary { color: #cbd5e1; font-size: 12px; cursor: pointer; }
.planned-group[open] { gap: 10px; }
.connection-roadmap-header { border-top: 1px solid var(--line); padding-top: 16px; }
.connection-roadmap-header h4 { margin: 0; color: #fca5a5; font-size: 13px; }
.connection-roadmap-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.integration-action { min-width: 100px; padding: 7px 11px; border: 1px solid #79a9ff66; border-radius: 9px; background: #79a9ff20; color: #cfe1ff; font-size: 11px; font-weight: 650; cursor: pointer; }
.integration-action:hover { border-color: #91b7ff; background: #79a9ff32; }
.integration-action.disconnect { border-color: #ffffff1c; background: #ffffff08; color: #bdc9dc; }
.integration-action.disconnect:hover { border-color: #fb718566; color: #fecaca; background: #fb718511; }
.integration-action:disabled { opacity: .55; cursor: wait; }

.mcp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.mcp-item { background: #0e1729; border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mcp-title { font-weight: 700; font-size: 13px; }
.mcp-desc { font-size: 11px; color: var(--muted); line-height: 1.45; }
.mcp-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; padding-top: 6px; }
.badge-ok { font-size: 10px; padding: 3px 8px; border-radius: 12px; background: #22c55e22; color: #4ade80; border: 1px solid #22c55e55; }
.badge-off { font-size: 10px; padding: 3px 8px; border-radius: 12px; background: #ffffff08; color: var(--muted); border: 1px solid var(--line); }
.preset-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: #14223d; border: 1px solid #79a9ff44; border-radius: 12px; padding: 12px 14px; flex-wrap: wrap; }
.preset-banner strong { font-size: 13px; color: #b8d4ff; }
.preset-banner p { margin: 4px 0 0; font-size: 11px; color: var(--muted); max-width: 480px; }
.optional-fields { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #ffffff04; }
.optional-fields summary { color: var(--muted); font-size: 11px; cursor: pointer; }
.optional-fields .form-row { margin-top: 10px; }
.cert-status-box { font-size: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #0c1424; color: var(--muted); }
.cert-status-box.connected { border-color: #22c55e66; background: #22c55e14; color: #86efac; }
.checkbox-line { flex-direction: row !important; align-items: center; gap: 8px; margin-top: 4px; cursor: pointer; }
.checkbox-line input { width: auto !important; margin: 0 !important; }
.mini-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.mini-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11px; background: #0b1220; border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; }
.inline-inputs { display: flex; gap: 6px; align-items: center; }
.inline-inputs input { margin-top: 0; }

.provider-list { display: flex; flex-wrap: wrap; gap: 6px; }
.prov-pill { font-size: 11px; padding: 4px 9px; border-radius: 14px; border: 1px solid var(--line); background: #0e1729; color: var(--muted); cursor: pointer; }
.prov-pill.connected { border-color: #4ade8088; background: #22c55e18; color: #86efac; }
.sub-form { display: flex; flex-direction: column; gap: 10px; background: #0c1424; padding: 14px; border-radius: 12px; border: 1px solid var(--line); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.form-row label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; }

@media(max-width:600px) {
  .app { width:calc(100% - 20px); padding-top:16px; }
  .intro { padding:28px 0 18px; }
  .messages { padding:15px; min-height:320px; }
  .bubble { max-width:94%; }
}
.cred-field { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; }
.cred-docs-link { display: inline-block; margin-top: 6px; font-size: 11px; color: #9dbaff; }
.cred-actions { display: flex; justify-content: flex-end; gap: 8px; }
.attach-btn { cursor: pointer; margin-right: 6px; font-size: 14px; }
.attach-chip { border: 1px solid #79a9ff66; background: #79a9ff22; color: var(--text); border-radius: 8px; padding: 2px 8px; font-size: 11px; margin-right: 6px; cursor: pointer; }
.bubble a { color: #9dbaff; word-break: break-all; }
.diag-link { color: var(--muted); font-size: 12px; margin-right: 10px; text-decoration: none; }
.diag-link:hover { color: var(--text); }
