/* ============================================================
   RankPilot AI — Design System
   AEO + SEO Automation Platform (Thai-first)
   Faithful to Project Concept PDF v1.0
   ============================================================ */

:root {
  /* Brand */
  --brand-500: #6366f1;
  --brand-600: #5b52e5;
  --brand-700: #4f46e5;
  --brand-800: #4338ca;
  --brand-900: #3730a3;
  --purple-700: #6d28d9;
  --purple-600: #7c3aed;
  --grad-start: #5b6ef5;
  --grad-end: #17b978;

  /* Semantic */
  --green-500: #16a34a;
  --green-600: #15803d;
  --green-bg: #dcfce7;
  --green-text: #15803d;
  --red-500: #dc2626;
  --red-bg: #fee2e2;
  --red-text: #b91c1c;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-bg: #fef3c7;
  --amber-text: #b45309;
  --blue-bg: #dbeafe;
  --blue-text: #1d4ed8;
  --purple-bg: #ede9fe;
  --purple-text: #6d28d9;
  --gold-bg: #fdf0c8;
  --gold-text: #92600a;

  /* Neutrals (light) */
  --navy: #1e2749;
  --navy-2: #22284a;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #faf9ff;
  --row-alt: #f6f4fc;
  --border: #e6e6f0;
  --border-2: #eceaf6;
  --text: #1f2340;
  --text-muted: #6b7091;
  --text-soft: #8a8fad;
  --link: #2563eb;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(30, 39, 73, .06);
  --shadow: 0 6px 24px rgba(50, 50, 93, .07), 0 2px 8px rgba(30, 39, 73, .04);
  --shadow-lg: 0 18px 50px rgba(50, 50, 93, .14), 0 8px 20px rgba(30, 39, 73, .07);
  --sidebar-w: 264px;
  --font: 'Sarabun', 'Prompt', 'IBM Plex Sans Thai', 'Noto Sans Thai',
          'Leelawadee UI', 'Segoe UI', Tahoma, system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --navy: #0e1330;
  --navy-2: #12173a;
  --bg: #0b0e22;
  --surface: #141834;
  --surface-2: #171c3d;
  --row-alt: #191e41;
  --border: #262b52;
  --border-2: #2a2f5a;
  --text: #e7e8f5;
  --text-muted: #a3a8cc;
  --text-soft: #7b81aa;
  --green-bg: #113524;
  --red-bg: #3a1620;
  --amber-bg: #3a2a0c;
  --blue-bg: #14284f;
  --purple-bg: #241a4a;
  --gold-bg: #3a2f12;
  --gold-text: #f4d585;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(99,102,241,.22); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 20px 20px 16px;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; overflow: hidden;
  box-shadow: 0 6px 16px rgba(91,110,245,.35);
}
.brand .logo img, .auth-brand .logo img { width: 100%; height: 100%; display: block; }
.brand .name { font-weight: 800; font-size: 17px; letter-spacing: .2px; }
.brand .name span { color: var(--brand-700); }
.brand .tag { font-size: 11px; color: var(--text-soft); margin-top: -2px; }

.nav { padding: 4px 10px 12px; overflow-y: auto; flex: 1; }
.nav-section {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 1.4px;
  color: var(--text-muted); text-transform: uppercase;
  padding: 15px 12px 7px;
}
.nav-section::after { content: ""; flex: 1; height: 1px; background: var(--border); opacity: .7; }
.nav > .nav-section:first-child { padding-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 11px; margin: 2px 0; border-radius: 11px;
  color: var(--text-muted); font-weight: 600; font-size: 14.5px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  position: relative;
  transition: background .13s, color .13s, transform .08s;
}
.nav-item .ico { font-size: 18px; width: 24px; text-align: center; flex: 0 0 24px; }
.nav-item .lbl { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .code {
  font-size: 10px; font-weight: 800; color: var(--text-soft);
  background: var(--bg); border-radius: 6px; padding: 1px 6px;
}
.nav-item .n-tag {
  font-size: 9.5px; font-weight: 800; letter-spacing: .3px;
  padding: 1px 7px; border-radius: 999px; flex: 0 0 auto;
  background: var(--surface-2); color: var(--text-soft);
}
.nav-item .n-tag.live { background: #dcfce7; color: #166534; display: inline-flex; align-items: center; gap: 4px; }
.nav-item .n-tag.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #22c55e; animation: nav-blink 1.4s infinite; }
.nav-item .n-tag.count { background: rgba(99,102,241,.12); color: var(--brand-700); }
@keyframes nav-blink { 0%,90%,100% { opacity: 1 } 95% { opacity: .3 } }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:active { transform: scale(.98); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,.16), rgba(23,185,120,.10));
  color: var(--brand-700); font-weight: 800;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 22%; bottom: 22%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-600, #6366f1);
}
[data-theme="dark"] .nav-item.active { color: #c3c1ff; }
.nav-item.active .code { color: var(--brand-700); background: rgba(99,102,241,.16); }
.nav-adv > summary.nav-section { cursor: pointer; user-select: none; }
.nav-adv > summary.nav-section::-webkit-details-marker { display: none; }
.nav-adv[open] > summary.nav-section { color: var(--brand-700); }

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-soft);
}
.sidebar-foot b { color: var(--text-muted); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30;
}
.topbar .crumbs { font-size: 13px; color: var(--text-soft); }
.topbar .crumbs b { color: var(--text); font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .mode-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700; padding: 6px 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-muted);
}
.topbar .mode-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber-500); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; font-size: 17px;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.content { padding: 26px; max-width: 1360px; width: 100%; margin: 0 auto; }
.mobile-nav-btn { display: none; }

/* ---------- Page header ---------- */
.page-head { margin-bottom: 20px; }
.page-head .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 800; letter-spacing: .4px;
  color: var(--brand-700); text-transform: uppercase; margin-bottom: 4px;
}
.page-head h1 { font-size: 25px; font-weight: 800; margin: 0 0 4px; letter-spacing: .2px; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 14.5px; max-width: 820px; }
.accent-bar { height: 4px; width: 60px; border-radius: 4px;
  background: linear-gradient(90deg, var(--grad-start), var(--grad-end)); margin: 12px 0 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.card-head .sub { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.mb { margin-bottom: 18px; }
.mb-l { margin-bottom: 26px; }

/* ---------- KPI / stat tiles ---------- */
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(var(--grad-start), var(--grad-end));
}
.kpi .k-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.kpi .k-value { font-size: 32px; font-weight: 800; line-height: 1.1; margin: 6px 0 2px; letter-spacing: -.5px; }
.kpi .k-value.pos { color: var(--green-600); }
.kpi .k-value.brand { color: var(--purple-700); }
.kpi .k-foot { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 6px; }
.kpi .trend-up { color: var(--green-600); font-weight: 700; }
.kpi .trend-down { color: var(--red-text); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: transform .05s, box-shadow .12s, background .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-800); }
.btn-green { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.btn-green:hover { background: var(--green-600); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); color: var(--text-muted);
}
.badge.green { background: var(--green-bg); color: var(--green-text); }
.badge.red { background: var(--red-bg); color: var(--red-text); }
.badge.amber { background: var(--amber-bg); color: var(--amber-text); }
.badge.blue { background: var(--blue-bg); color: var(--blue-text); }
.badge.purple { background: var(--purple-bg); color: var(--purple-text); }
.badge.gold { background: var(--gold-bg); color: var(--gold-text); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
}
.chip.on { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.chip.lock { cursor: default; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl thead th {
  background: var(--navy); color: #eef; text-align: left;
  font-weight: 700; font-size: 12.5px; padding: 12px 16px; white-space: nowrap;
}
table.tbl thead th:first-child { border-top-left-radius: 10px; }
table.tbl thead th:last-child { border-top-right-radius: 10px; }
table.tbl tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:nth-child(even) { background: var(--row-alt); }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl .num { font-variant-numeric: tabular-nums; font-weight: 700; }
table.tbl .muted { color: var(--text-soft); }
.tbl-title { font-weight: 700; color: var(--text); }
.tbl-title a { color: var(--link); font-weight: 700; }
.tbl-sub { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 5px; margin-top: 2px; }

/* rank medal */
.rank-cell { display: flex; align-items: center; gap: 8px; }
.rank-medal {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 13px;
  background: var(--gold-bg); color: var(--gold-text); padding: 4px 9px; border-radius: 999px;
}
.rank-num {
  display: inline-grid; place-items: center; min-width: 30px; height: 26px;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 800; font-size: 13px; color: var(--text-muted); padding: 0 6px;
}

/* trend */
.trend { font-weight: 700; font-size: 12.5px; display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 999px; }
.trend.up { background: var(--green-bg); color: var(--green-text); }
.trend.down { background: var(--red-bg); color: var(--red-text); }
.trend.same { background: var(--bg); color: var(--text-soft); }

/* history / link button in tables */
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px;
  color: var(--brand-700); background: none; border: none; padding: 4px 6px; border-radius: 8px;
}
.link-btn:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Search / inputs ---------- */
.field {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 3px 6px 3px 14px;
}
.field:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.field .ico { color: var(--text-soft); font-size: 17px; }
.field input {
  flex: 1; border: none; outline: none; background: none; color: var(--text);
  font-size: 15px; font-family: inherit; padding: 9px 0;
}
.select, .input {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
  background: var(--surface); color: var(--text); font-family: inherit; font-size: 14px;
}

/* ---------- Progress ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--grad-start), var(--grad-end)); }
.bar.green > span { background: var(--green-500); }
.bar.amber > span { background: var(--amber-500); }
.bar.thin { height: 6px; }

.ring { --p: 0; --sz: 92px; width: var(--sz); height: var(--sz); border-radius: 50%;
  background: conic-gradient(var(--brand-600) calc(var(--p)*1%), var(--bg) 0);
  display: grid; place-items: center; position: relative; }
.ring::before { content: ""; position: absolute; inset: 10px; background: var(--surface); border-radius: 50%; }
.ring .ring-val { position: relative; font-weight: 800; font-size: 20px; }

/* ---------- Loop stepper ---------- */
.loop { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.loop .step {
  flex: 1; min-width: 130px; border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; background: var(--surface-2); position: relative;
}
.loop .step .n { font-size: 11px; font-weight: 800; color: var(--brand-700); letter-spacing: .5px; }
.loop .step .t { font-weight: 800; font-size: 14px; margin: 3px 0; }
.loop .step .d { font-size: 12px; color: var(--text-muted); }
.loop .arrow { align-self: center; color: var(--text-soft); font-size: 18px; }

/* ---------- Split panels ---------- */
.panel { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 800; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 14px 16px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 700; font-size: 14px; }
.list-row .s { font-size: 12px; color: var(--text-soft); }

/* intent columns (M1) */
.intent-col { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.intent-head { padding: 14px 16px; display: flex; align-items: center; gap: 10px; color: #fff; }
.intent-head.rec { background: linear-gradient(120deg, #6d28d9, #8b5cf6); }
.intent-head.prob { background: linear-gradient(120deg, #0f766e, #14b8a6); }
.intent-head .ic { font-size: 20px; }
.intent-head .h { font-weight: 800; font-size: 15px; }
.intent-head .c { font-size: 12px; opacity: .9; }
.intent-head .count { margin-left: auto; background: rgba(255,255,255,.22); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: 13px; }
.kw-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.kw-row:last-child { border-bottom: none; }
.kw-row .kw { flex: 1; min-width: 0; }
.kw-row .kw .txt { font-weight: 600; font-size: 14px; }
.kw-row .kw .meta { font-size: 11.5px; color: var(--text-soft); display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.score-pill { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.score-pill.hi { background: var(--green-bg); color: var(--green-text); }
.score-pill.mid { background: var(--amber-bg); color: var(--amber-text); }
.score-pill.low { background: var(--red-bg); color: var(--red-text); }

/* page1 status */
.p1 { font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.p1.yes { background: var(--green-bg); color: var(--green-text); }
.p1.no { background: var(--bg); color: var(--text-soft); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,18,40,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .16s;
}
.modal-back.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: 18px; max-width: 720px; width: 100%;
  box-shadow: var(--shadow-lg); transform: translateY(10px); transition: transform .16s;
  max-height: calc(100vh - 80px); overflow: auto;
}
.modal-back.open .modal { transform: translateY(0); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 800; }
.modal-head .sub { font-size: 12.5px; color: var(--text-soft); }
.modal-body { padding: 20px 22px; }
.modal-close { margin-left: auto; }

/* verify banner */
.verify-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 14px;
  background: linear-gradient(120deg, rgba(22,163,74,.12), rgba(23,185,120,.06));
  border: 1px solid rgba(22,163,74,.3);
}
.verify-banner .big { font-size: 26px; }
.verify-banner .t { font-weight: 800; color: var(--green-600); }
.verify-banner .s { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Sparkline / mini-chart ---------- */
.spark { display: block; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* bars chart */
.vbars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.vbars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.vbars .col .bar-v { width: 60%; max-width: 44px; border-radius: 8px 8px 0 0;
  background: linear-gradient(var(--grad-start), var(--grad-end)); position: relative; min-height: 4px; }
.vbars .col .cap { font-size: 11.5px; color: var(--text-soft); }
.vbars .col .val { font-size: 12px; font-weight: 800; }

/* ---------- Utility ---------- */
.row { display: flex; align-items: center; gap: 12px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap-s { gap: 8px; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12.5px; }
.b { font-weight: 700; }
.bb { font-weight: 800; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hint {
  font-size: 12.5px; color: var(--text-muted); background: var(--surface-2);
  border: 1px dashed var(--border); border-radius: 10px; padding: 10px 14px;
}
.note-box {
  border-left: 4px solid var(--brand-600); background: var(--purple-bg);
  border-radius: 8px; padding: 13px 16px; font-size: 13.5px; color: var(--text);
}
.warn-box {
  border-left: 4px solid var(--red-500); background: var(--red-bg);
  border-radius: 8px; padding: 13px 16px; font-size: 13.5px;
}
.ok-box {
  border-left: 4px solid var(--green-500); background: var(--green-bg);
  border-radius: 8px; padding: 13px 16px; font-size: 13.5px;
}
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.tag-list { display: flex; gap: 7px; flex-wrap: wrap; }

/* fade-in */
.view { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: fade .2s; }
.toast .ok { color: #7ee2a8; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .mobile-nav-btn { display: grid; }
  .content { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .intent-wrap { grid-template-columns: 1fr !important; }
}
@media (max-width: 620px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
}
.scrim { display: none; }
.scrim.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }

/* ---------- Auth (login/signup) ---------- */
.auth-screen {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(99,102,241,.28), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(23,185,120,.22), transparent 55%),
    var(--bg);
  overflow: auto;
}
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg); padding: 30px 30px 26px; animation: fade .3s ease;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand .logo {
  width: 44px; height: 44px; border-radius: 12px; overflow: hidden;
  box-shadow: 0 8px 20px rgba(91,110,245,.4);
}
.auth-brand .name { font-weight: 800; font-size: 19px; }
.auth-brand .name span { color: var(--brand-700); }
.auth-card h2 { margin: 6px 0 2px; font-size: 20px; font-weight: 800; }
.auth-card .sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 18px; }
.auth-field { margin-bottom: 12px; }
.auth-field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.auth-field input {
  width: 100%; border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px;
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 15px;
}
.auth-field input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.auth-tabs { display: flex; gap: 6px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; border: none; background: none; padding: 8px; border-radius: 9px; font-weight: 700; font-size: 13.5px; color: var(--text-muted); cursor: pointer; }
.auth-tabs button.on { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-sm); }
.auth-foot { text-align: center; margin-top: 14px; font-size: 12px; color: var(--text-soft); }
.auth-or { text-align: center; color: var(--text-soft); font-size: 12px; margin: 12px 0; position: relative; }
.auth-or::before, .auth-or::after { content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: var(--border); }
.auth-or::before { left: 0; } .auth-or::after { right: 0; }

/* ---------- Onboarding overlay ---------- */
.onb-overlay {
  position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 24px;
  background: rgba(15,18,40,.6); backdrop-filter: blur(4px); overflow: auto;
}
.onb-card {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px;
  box-shadow: var(--shadow-lg); overflow: hidden; animation: fade .25s ease;
}
.onb-hero { padding: 26px 28px 18px; background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(23,185,120,.10)); }
.onb-hero .step-dots { display: flex; gap: 7px; margin-bottom: 14px; }
.onb-hero .step-dots i { width: 26px; height: 5px; border-radius: 3px; background: var(--border); }
.onb-hero .step-dots i.on { background: linear-gradient(90deg, var(--grad-start), var(--grad-end)); }
.onb-hero .ic { font-size: 34px; }
.onb-hero h2 { margin: 8px 0 4px; font-size: 22px; font-weight: 800; }
.onb-hero p { margin: 0; color: var(--text-muted); font-size: 14px; }
.onb-body { padding: 20px 28px; }
.onb-foot { display: flex; align-items: center; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--border); }
.onb-foot .spacer { flex: 1; }
.onb-feature { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.onb-feature:last-child { border-bottom: none; }
.onb-feature .fi { font-size: 20px; width: 26px; text-align: center; }
.onb-feature .ft { font-weight: 700; font-size: 14px; }
.onb-feature .fs { font-size: 12.5px; color: var(--text-soft); }

/* ---------- User chip (sidebar) ---------- */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 8px; }
.user-chip .ua { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; background: linear-gradient(135deg, var(--grad-start), var(--grad-end)); flex: 0 0 34px; }
.user-chip .uinfo { flex: 1; min-width: 0; }
.user-chip .un { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .ur { font-size: 11px; color: var(--text-soft); }

/* ---------- Getting-started checklist ---------- */
.gs-list { display: grid; gap: 2px; }
.gs-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.gs-row .gk { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: 0 0 22px; }
.gs-row .gk.done { background: var(--green-bg); color: var(--green-text); }
.gs-row .gk.todo { background: var(--bg); color: var(--text-soft); border: 1px dashed var(--border); }
.gs-row .gt { flex: 1; font-size: 13.5px; }
.gs-row.done .gt { color: var(--text-muted); }
