/* ============================================================
   Psynapse analytics portal, design system
   Tokens follow the Psynapse brand (indigo on warm paper).
   Light theme. UK English. Accent is a single swappable token.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&display=swap');

/* Self-hosted brand faces (web/fonts/). Cabinet Grotesk for headings,
   Satoshi for UI text. Fraunces (above) stays for numerals. */
@font-face { font-family: 'Cabinet Grotesk'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/CabinetGrotesk-500.woff2') format('woff2'); }
@font-face { font-family: 'Cabinet Grotesk'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/CabinetGrotesk-700.woff2') format('woff2'); }
@font-face { font-family: 'Cabinet Grotesk'; font-weight: 800; font-style: normal; font-display: swap; src: url('../fonts/CabinetGrotesk-800.woff2') format('woff2'); }
@font-face { font-family: 'Satoshi'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/Satoshi-400.woff2') format('woff2'); }
@font-face { font-family: 'Satoshi'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/Satoshi-500.woff2') format('woff2'); }
@font-face { font-family: 'Satoshi'; font-weight: 700; font-style: normal; font-display: swap; src: url('../fonts/Satoshi-700.woff2') format('woff2'); }
@font-face { font-family: 'Satoshi'; font-weight: 900; font-style: normal; font-display: swap; src: url('../fonts/Satoshi-900.woff2') format('woff2'); }

/* The `hidden` attribute must always win, even over component display rules
   like `.state { display: flex }` (otherwise a hidden #errorState stays visible). */
[hidden] { display: none !important; }

:root {
  /* Surfaces & ink (Psynapse brand palette) */
  --paper: #FFFBF7;            /* warm off-white page bg */
  --surface: #ffffff;
  --ink: #1B1633;              /* deep ink */
  --ink-muted: #6E6A85;        /* muted body text */
  --rule: #EDE7F3;             /* soft hairline */

  /* Brand & status (Psynapse indigo) */
  --primary: #4A2FED;          /* indigo: actions, accents */
  --primary-ink: #fff;         /* text on primary */
  --primary-dark: #3A22C9;     /* hover / pressed */
  --primary-light: #A79BFF;    /* lavender */
  --navy: #1B1633;             /* dark bands (= --ink) */
  --cta: #FF6A3D;              /* hero call-to-action (coral) */
  --cta-dark: #F0502A;         /* hero CTA hover */
  --status-online: #0A8F66;    /* positive / up-trend */
  --assistant-bg: #F1EEFB;     /* soft lavender fill */

  /* Dark shell panels (sidebar + top bar) */
  --panel: #1B1633;            /* deep ink */
  --panel-ink: #ffffff;
  --panel-muted: rgba(255, 255, 255, 0.66);
  --panel-hover: rgba(255, 255, 255, 0.08);
  --panel-line: rgba(255, 255, 255, 0.12);
  /* Card outline: more visible than --rule so white cards lift off the page */
  --card-line: #E4DEF0;

  /* Derived accent tints (from --primary, calm) */
  --primary-soft: color-mix(in oklab, var(--primary) 12%, var(--surface));
  --primary-softer: color-mix(in oklab, var(--primary) 7%, var(--surface));
  --primary-line: color-mix(in oklab, var(--primary) 26%, var(--rule));
  --danger: #b3201e;
  --danger-soft: color-mix(in oklab, var(--danger) 12%, var(--surface));
  --good-soft: color-mix(in oklab, var(--status-online) 14%, var(--surface));

  /* Calm categorical chart scale (extends tokens; mirror in CSS vars) */
  --c-terracotta: #c25a2e;
  --c-teal: #4f8a86;
  --c-clay: #c69a6d;
  --c-slate: #6a7384;
  --c-green: #22a06b;

  /* Type */
  --font-display: 'Cabinet Grotesk', 'Satoshi', system-ui, sans-serif;
  --font-ui: 'Satoshi', 'Segoe UI', system-ui, sans-serif;
  --font-numeral: 'Fraunces', Georgia, serif;

  /* Shape */
  --r-card: 24px;
  --r-panel: 18px;
  --r-input: 12px;
  --r-pill: 999px;

  /* House shadow (ink-tinted) */
  --shadow: 0 24px 60px -22px rgba(27, 22, 51, 0.22),
            0 8px 24px -12px rgba(27, 22, 51, 0.08);
  --shadow-sm: 0 1px 2px rgba(27, 22, 51, 0.05),
               0 6px 16px -12px rgba(27, 22, 51, 0.12);

  /* Motion */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --t: 200ms var(--ease);

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 68px;
  --gut: 22px;
}

/* ------------------------------------------------------------ reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--primary-soft); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; line-height: 1.12; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* utility */
.tnum { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--font-numeral); }
.muted { color: var(--ink-muted); }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.10em;
  text-transform: uppercase; color: var(--ink-muted);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ============================================================ app shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--panel-line);
  display: flex; flex-direction: column;
  padding: 20px 16px;
  z-index: 40;
}
.sidebar .brand-name { color: var(--panel-ink); }
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  background: var(--primary); color: var(--primary-ink);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; font-size: 19px;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-name small { display: block; font-family: var(--font-ui); font-weight: 500; font-size: 11px; color: var(--ink-muted); letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.nav-label { padding: 14px 10px 6px; }
.nav-label { color: var(--panel-muted); }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-input);
  color: var(--panel-muted); font-weight: 500; font-size: 14.5px;
  transition: background var(--t), color var(--t);
}
.nav-item svg { width: 18px; height: 18px; flex: none; stroke-width: 1.7; }
.nav-item:hover { background: var(--panel-hover); color: var(--panel-ink); }
.nav-item.is-active { background: rgba(82, 126, 255, 0.20); color: var(--primary-light); font-weight: 600; }
.nav-item.is-active svg { stroke: var(--primary-light); }
.nav-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--panel-line); }
.nav-tenant { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.nav-tenant, .nav-tenant .muted { color: var(--panel-muted); }
.nav-tenant > div > div:first-child { color: var(--panel-ink); }
.nav-tenant .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--primary-light); flex: none; }

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--panel-line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(18px, 4vw, 40px);
}
.topbar .hamburger { display: none; color: var(--panel-ink); }
.topbar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.topbar-title h1 { font-size: 19px; font-weight: 600; color: var(--panel-ink); }
.topbar-title .assistant { font-size: 13px; color: var(--panel-muted); white-space: nowrap; }
.topbar-title .assistant b { color: var(--panel-ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.account {
  display: flex; align-items: center; gap: 9px; padding: 5px 6px 5px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-pill);
  background: var(--surface); transition: border-color var(--t), box-shadow var(--t);
}
.account:hover { border-color: var(--primary-line); box-shadow: var(--shadow-sm); }
.account .who { font-size: 13px; font-weight: 500; line-height: 1.15; }
.account .who small { display: block; color: var(--ink-muted); font-weight: 400; font-size: 11px; }

.content { padding: clamp(20px, 3.4vw, 38px) clamp(18px, 4vw, 40px) 64px; flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h2 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 500; }
.page-head p { color: var(--ink-muted); margin-top: 6px; max-width: 56ch; }
.page-head .spacer { flex: 1; }

/* ============================================================ avatar */
.avatar {
  position: relative; width: 32px; height: 32px; border-radius: 50%;
  background: var(--assistant-bg); color: var(--ink);
  display: grid; place-items: center; flex: none;
  font-weight: 600; font-size: 13px; overflow: visible;
}
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.avatar .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--status-online); border: 2px solid var(--surface);
}

/* ============================================================ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-input);
  font-weight: 600; font-size: 14px; border: 1px solid transparent;
  transition: transform var(--t), background var(--t), border-color var(--t), box-shadow var(--t);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in oklab, var(--primary) 90%, black); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--rule); }
.btn-secondary:hover { border-color: var(--primary-line); }
.btn-ghost { background: transparent; color: var(--ink-muted); }
.btn-ghost:hover { background: var(--assistant-bg); color: var(--ink); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }

/* ============================================================ pills / tags */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--assistant-bg); color: var(--ink-muted);
  white-space: nowrap;
}
.tag .pip { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-lead { background: var(--primary-soft); color: var(--primary); }
.tag-escalated { background: var(--danger-soft); color: var(--danger); }
.tag-intent { background: var(--assistant-bg); color: var(--ink); }
.tag-good { background: var(--good-soft); color: var(--status-online); }

/* ============================================================ cards / grid */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gut); }
.card {
  background: var(--surface); border: 1.5px solid var(--card-line);
  border-radius: var(--r-card); padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card.raised { box-shadow: var(--shadow); border-color: transparent; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 17px; font-weight: 600; }
.card-head .sub { font-size: 13px; color: var(--ink-muted); }
.card-head .spacer { flex: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* spans */
.col-3 { grid-column: span 3; } .col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; } .col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; } .col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* ============================================================ KPI tile */
.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi .label { font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-muted); }
.kpi .num { font-family: var(--font-numeral); font-weight: 500; font-size: clamp(34px, 4.2vw, 46px); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta svg { width: 14px; height: 14px; }
.delta.up { color: var(--status-online); }
.delta.down { color: var(--danger); }
.kpi .spark { margin-top: 2px; }

/* ============================================================ data table */
.table-wrap { overflow-x: auto; border-radius: var(--r-card); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data thead th {
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-muted);
  padding: 0 14px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--ink); }
table.data thead th .arrow { opacity: 0; margin-left: 4px; font-size: 10px; }
table.data thead th[aria-sort] .arrow { opacity: 1; color: var(--primary); }
table.data thead th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody td { padding: 13px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data tbody tr { transition: background var(--t); }
table.data tbody tr:hover { background: var(--assistant-bg); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
.cell-id { display: flex; align-items: center; gap: 11px; }
.cell-id .who { line-height: 1.2; }
.cell-id .who small { display: block; color: var(--ink-muted); font-size: 12px; }
.cell-id .anon { color: var(--ink-muted); font-style: italic; }

.table-foot { display: flex; align-items: center; gap: 12px; padding: 14px 4px 2px; color: var(--ink-muted); font-size: 13px; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.pager button { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--rule); background: var(--surface); color: var(--ink-muted); }
.pager button:hover:not(:disabled) { border-color: var(--primary-line); color: var(--ink); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager .at { color: var(--ink); font-weight: 600; }

/* ============================================================ filter / search bar */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.search {
  display: flex; align-items: center; gap: 9px; flex: 1 1 260px; max-width: 380px;
  height: 40px; padding: 0 14px; background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-input);
  transition: border-color var(--t), box-shadow var(--t);
}
.search:focus-within { border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.search svg { width: 16px; height: 16px; color: var(--ink-muted); flex: none; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; font: inherit; color: var(--ink); }
.search input::placeholder { color: var(--ink-muted); }

.select {
  height: 40px; padding: 0 34px 0 14px; border: 1px solid var(--rule);
  border-radius: var(--r-input); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 500; font-size: 14px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b6764' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color var(--t);
}
.select:hover { border-color: var(--primary-line); }
.input {
  height: 40px; padding: 0 14px; border: 1px solid var(--rule);
  border-radius: var(--r-input); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; width: 100%;
  transition: border-color var(--t), box-shadow var(--t);
}
.input:focus { outline: 0; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--ink-muted); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 500; }

/* ---- date-range segmented ---- */
.segment { display: inline-flex; padding: 3px; background: var(--panel-hover); border: 1px solid var(--panel-line); border-radius: var(--r-input); }
.segment button { height: 32px; padding: 0 13px; border: 0; background: transparent; border-radius: 9px; color: var(--panel-muted); font-weight: 600; font-size: 13px; transition: background var(--t), color var(--t); }
.segment button.is-active { background: #ffffff; color: var(--navy); }
.segment button:hover:not(.is-active) { color: var(--panel-ink); }

/* ============================================================ bar list (top products / gaps) */
.barlist { display: flex; flex-direction: column; gap: 3px; }
.barlist-row { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 11px 12px; border-radius: 11px; transition: background var(--t); }
.barlist-row:hover { background: var(--assistant-bg); }
.barlist-row .fill { position: absolute; inset: 4px auto 4px 0; border-radius: 8px; background: var(--primary-softer); z-index: 0; }
.barlist-row .name, .barlist-row .val { position: relative; z-index: 1; }
.barlist-row .name { font-weight: 500; display: flex; align-items: center; gap: 9px; min-width: 0; }
.barlist-row .name .rank { color: var(--ink-muted); font-size: 12px; font-variant-numeric: tabular-nums; width: 16px; flex: none; }
.barlist-row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-row .val { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.barlist-row .val small { color: var(--ink-muted); font-weight: 500; margin-left: 4px; }

/* ============================================================ transcript bubbles */
.transcript { display: flex; flex-direction: column; gap: 14px; padding: 4px; }
.bubble-row { display: flex; gap: 10px; max-width: 86%; }
.bubble-row.user { margin-left: auto; flex-direction: row-reverse; }
.bubble { padding: 11px 15px; border-radius: 18px; font-size: 14px; line-height: 1.5; }
.bubble-row.assistant .bubble { background: var(--assistant-bg); color: var(--ink); border-bottom-left-radius: 6px; }
.bubble-row.user .bubble { background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 6px; }
.bubble-row .meta { font-size: 11px; color: var(--ink-muted); margin: 4px 4px 0; }
.bubble-row.user .meta { text-align: right; }
/* Knowledge-gap "jump to the exact message": highlight the matched turn + its reply. */
.bubble-row.gap-hit .bubble { outline: 2px solid var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.bubble-row.gap-reply .bubble { outline: 1px dashed var(--primary-line); }
/* Inline "Correct answer" affordance on assistant replies (in-portal training). */
.bubble-row.assistant .meta .correct-btn { margin-left: 6px; padding: 1px 8px; font-size: 11px; opacity: 0; transition: opacity var(--t); }
.bubble-row.assistant:hover .meta .correct-btn, .bubble-row.assistant .meta .correct-btn:focus { opacity: 1; }
/* Shared correction modal (portal.js openCorrectionForm). */
.pc-modal { position: fixed; inset: 0; z-index: 340; background: rgba(17,35,55,.45); display: grid; place-items: center; padding: 20px; }
.pc-modal .pc-panel { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); width: min(540px,100%); max-height: 88vh; display: flex; flex-direction: column; }
.pc-modal .pc-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--rule); }
.pc-modal .pc-head h3 { font-family: var(--font-display); font-size: 18px; }
.pc-modal .pc-body { padding: 16px 22px; overflow: auto; }
.pc-modal .pc-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--rule); }
.pc-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); margin: 14px 0 6px; }
.pc-eyebrow:first-child { margin-top: 0; }
.pc-pre { white-space: pre-wrap; font-size: 13px; line-height: 1.5; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; padding: 12px; color: var(--ink); }
.pc-area { width: 100%; min-height: 120px; resize: vertical; font: inherit; font-size: 14px; padding: 11px 13px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink); }
.pc-area:focus { outline: 0; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.pc-input { width: 100%; font: inherit; font-size: 14px; padding: 10px 13px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); color: var(--ink); }
.pc-input:focus { outline: 0; border-color: var(--primary-line); box-shadow: 0 0 0 3px var(--primary-soft); }
.pc-hint { text-transform: none; letter-spacing: 0; color: var(--ink-muted); font-weight: 400; }
.pc-check { display: flex; gap: 9px; align-items: flex-start; margin-top: 14px; font-size: 13px; color: var(--ink-muted); line-height: 1.45; cursor: pointer; }
.pc-check input { margin-top: 2px; flex: none; }
.pc-note { font-size: 13px; padding: 10px 12px; border-radius: 10px; margin-top: 10px; }
.pc-note.ok { background: var(--primary-softer); color: var(--primary); }
.pc-note.warn { background: rgba(210,150,20,.14); color: #a9761a; }
.bubble .products { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.bubble .product-chip { display: flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--rule); border-radius: 11px; padding: 6px 9px; font-size: 12px; color: var(--ink); }
.bubble .product-chip .thumb { width: 22px; height: 22px; border-radius: 6px; background: var(--assistant-bg); flex: none; }

/* ============================================================ drawer / modal */
.scrim { position: fixed; inset: 0; background: rgba(22, 21, 19, 0.32); opacity: 0; visibility: hidden; transition: opacity var(--t), visibility var(--t); z-index: 90; backdrop-filter: blur(1px); }
.scrim.open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 94vw);
  background: var(--surface); box-shadow: var(--shadow); z-index: 100;
  transform: translateX(100%); transition: transform 240ms var(--ease);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px; border-bottom: 1px solid var(--rule); }
.drawer-head h3 { font-size: 19px; font-weight: 600; }
.drawer-head .sub { font-size: 13px; color: var(--ink-muted); margin-top: 3px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 16px 24px; border-top: 1px solid var(--rule); display: flex; gap: 10px; align-items: center; }

/* PII affordance */
.pii-note { display: flex; align-items: center; gap: 9px; padding: 10px 13px; border-radius: 12px; background: var(--primary-softer); border: 1px solid var(--primary-line); color: var(--primary); font-size: 12.5px; font-weight: 500; }
.pii-note svg { width: 16px; height: 16px; flex: none; }

/* ============================================================ toast */
.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--paper); padding: 11px 16px; border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500; animation: toastin 240ms var(--ease); }
.toast svg { width: 16px; height: 16px; color: var(--status-online); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px) scale(0.96); } }

/* ============================================================ empty / error / skeleton */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 56px 28px; gap: 6px; }
.state .glyph { width: 56px; height: 56px; border-radius: 16px; background: var(--assistant-bg); display: grid; place-items: center; color: var(--ink-muted); margin-bottom: 8px; }
.state .glyph svg { width: 26px; height: 26px; stroke-width: 1.6; }
.state.error .glyph { background: var(--danger-soft); color: var(--danger); }
.state h3 { font-size: 18px; font-weight: 600; }
.state p { color: var(--ink-muted); max-width: 40ch; }
.state .btn { margin-top: 14px; }

.skel { background: linear-gradient(100deg, var(--assistant-bg) 30%, color-mix(in oklab, var(--assistant-bg) 50%, var(--surface)) 50%, var(--assistant-bg) 70%); background-size: 200% 100%; border-radius: 8px; animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-num { height: 40px; width: 70%; border-radius: 10px; }

/* ============================================================ charts (inline svg) */
.chart { width: 100%; display: block; }
.chart .axis-x { font-size: 11px; fill: var(--ink-muted); }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; }
.chart .area { fill: url(#areaFill); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--surface); stroke: var(--primary); stroke-width: 2.5; }

.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut-center { font-family: var(--font-numeral); }

/* ============================================================ responsive */
.hamburger {
  width: 40px; height: 40px; border-radius: var(--r-input); border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); display: grid; place-items: center;
}
.hamburger svg { width: 20px; height: 20px; }

@media (max-width: 1080px) {
  .col-3 { grid-column: span 6; } .col-4 { grid-column: span 6; }
  .col-5, .col-7, .col-8 { grid-column: span 12; }
}
@media (max-width: 980px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; width: 270px; height: 100vh;
    transform: translateX(-100%); transition: transform 240ms var(--ease);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .hamburger { display: grid; }
  .topbar-title h1 { font-size: 17px; }
}
@media (max-width: 720px) {
  .grid { gap: 14px; }
  .col-3, .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }
  .account .who { display: none; }
  .page-head { margin-bottom: 18px; }
  .card { padding: 18px; }
  .topbar-title .assistant { display: none; }
}
