:root {
  --bg: #060912;
  --bg2: #0c1224;
  --panel: rgba(18, 28, 52, 0.72);
  --panel-solid: #121c34;
  --border: rgba(110, 168, 254, 0.14);
  --text: #eef3ff;
  --muted: #8fa3c9;
  --accent: #6ea8fe;
  --accent2: #a78bfa;
  --ok: #34d399;
  --err: #f87171;
  --glow: 0 0 40px rgba(110, 168, 254, 0.15);
  --sidebar-w: 260px;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(110,168,254,.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(167,139,250,.12), transparent 50%),
    linear-gradient(180deg, var(--bg2), var(--bg));
}

.console-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  background: rgba(8, 12, 24, 0.85);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .5rem .75rem 1.25rem;
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: var(--glow);
}
.sidebar-brand strong { display: block; font-size: .95rem; }
.sidebar-brand small { color: var(--muted); font-size: .72rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  width: 100%; text-align: left;
  padding: .7rem .85rem;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  transition: .15s ease;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-item.active {
  color: var(--text);
  border-color: var(--border);
  background: linear-gradient(135deg, rgba(110,168,254,.12), rgba(167,139,250,.08));
  box-shadow: var(--glow);
}
.nav-icon { opacity: .85; width: 1.1rem; text-align: center; }

.sidebar-foot { padding: .75rem; }
.logout-link { color: var(--muted); text-decoration: none; font-size: .85rem; }
.logout-link:hover { color: var(--accent); }

.workspace {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 2rem 2.5rem;
  overflow: auto;
}

.panel { display: none; animation: fadeIn .25s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.panel-head h1 { margin: .15rem 0 .35rem; font-size: 1.65rem; letter-spacing: -.02em; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: .68rem; color: var(--accent); }
.lede { margin: 0; color: var(--muted); max-width: 52ch; line-height: 1.5; }

.badge {
  font-size: .72rem; padding: .35rem .65rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge.ok { border-color: rgba(52,211,153,.35); color: var(--ok); }

.grid { display: grid; gap: 1rem; }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.grid.two { grid-template-columns: 1fr 1fr; }
.connect-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  backdrop-filter: blur(10px);
}
.card h2, .card h3 { margin: 0 0 .75rem; font-size: 1rem; }
.stat-card .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat { font-size: 2rem; margin: .2rem 0 0; font-weight: 600; }
.stat.sm { font-size: 1.25rem; }

.ask-bar {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 200px) auto;
  gap: .65rem;
  margin-bottom: .85rem;
}
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--muted);
  border-radius: 999px;
  padding: .4rem .85rem;
  font-size: .82rem;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: rgba(110,168,254,.35); }

.ask-status { color: var(--muted); margin-bottom: .75rem; font-size: .9rem; }
.ask-status.hidden, .hidden { display: none !important; }

.ask-results { display: grid; gap: .75rem; }
.result-group h3 { margin: 0 0 .5rem; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.result-card {
  padding: .9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.02);
  cursor: pointer;
  transition: .15s ease;
}
.result-card:hover { border-color: rgba(110,168,254,.35); background: rgba(110,168,254,.06); }
.result-card .title { font-weight: 600; margin-bottom: .25rem; }
.result-card .meta { font-size: .78rem; color: var(--muted); margin-bottom: .35rem; }
.result-card .snippet { color: var(--muted); font-size: .88rem; line-height: 1.45; }

.note-drawer {
  position: fixed; top: 0; right: 0; width: min(520px, 92vw); height: 100vh;
  background: var(--panel-solid);
  border-left: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  overflow: auto;
  z-index: 50;
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
}
.drawer-close {
  position: absolute; top: .75rem; right: .75rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.5rem; cursor: pointer;
}
.note-drawer pre {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: .82rem;
  line-height: 1.55;
  color: #dbeafe;
}

input, select, button, textarea {
  background: rgba(8, 12, 24, .85);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  padding: .65rem .85rem;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid rgba(110,168,254,.35); border-color: transparent; }
button[type="submit"], .ask-bar button {
  background: linear-gradient(135deg, #3b6cff, var(--accent));
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.btn-ghost, .btn-secondary {
  background: rgba(255,255,255,.05) !important;
  border: 1px solid var(--border) !important;
  font-weight: 500 !important;
}
.btn-row { display: flex; gap: .5rem; margin: .65rem 0; }

.filters, .stack-form { display: flex; flex-direction: column; gap: .55rem; margin-bottom: 1rem; }
.filters { flex-direction: row; flex-wrap: wrap; align-items: center; }

.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: .7rem .85rem; border-bottom: 1px solid var(--border); text-align: left; font-size: .88rem; }
th { color: var(--muted); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.browse-row { cursor: pointer; }
.browse-row:hover { background: rgba(110,168,254,.06); }

.graph {
  height: min(72vh, 680px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(8, 12, 24, .5);
}

.alert { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; }
.alert.ok { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.25); }
.alert.err { background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.25); }
.token-banner code { display: block; word-break: break-all; margin: .5rem 0; font-family: var(--mono); font-size: .78rem; }

.code-block {
  margin: 0;
  padding: .85rem 1rem;
  border-radius: 10px;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.5;
  overflow: auto;
  max-height: 220px;
  white-space: pre-wrap;
}

.steps { margin: .75rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .88rem; line-height: 1.55; }
.muted { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.project-list, .client-list, .activity { list-style: none; padding: 0; margin: 0; }
.project-list li, .client-list li { display: flex; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.activity { max-height: 420px; overflow: auto; }
.activity li { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .85rem; line-height: 1.4; }
.activity small { display: block; color: var(--muted); margin-top: .15rem; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card {
  width: min(420px, 92vw);
  padding: 2rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--glow);
}
.login-card h1 { margin: 0 0 .35rem; }
.login-card .tagline { color: var(--muted); margin: 0 0 1.25rem; font-size: .9rem; }
.login-card label { display: block; margin: .75rem 0; font-size: .85rem; color: var(--muted); }
.login-card input { width: 100%; margin-top: .35rem; }

@media (max-width: 960px) {
  .console-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .ask-bar { grid-template-columns: 1fr; }
  .grid.two { grid-template-columns: 1fr; }
  .workspace { padding: 1rem; }
}
