/* =============================================================================
   airtrunk.css: Blue Water Shipping · AirTrunk OSE portal
   BWS house design system (matches the Newmont Ghana portal): BWS navy brand,
   strategic blue accent, light default + dark toggle (html[data-theme="dark"]).
   All tokens are CSS variables so the theme flips with one attribute. Same class
   vocabulary as the sibling Newmont portal plus a few AirTrunk-specific
   components (ring / seg / tabs / toast / attn / thread): all token-driven.
   ============================================================================= */

/* ---- tokens : LIGHT (default, BWS house) ---------------------------------- */
:root {
  --bg:           #f6f8fb;
  --surface:      #ffffff;
  --surface-2:    #f1f4f9;
  --surface-3:    #e9eef6;
  --rail:         #ffffff;
  --rail-active:  #eef3fd;
  --overlay:      rgba(15, 23, 42, .42);

  --border:       #e4e8f0;
  --border-2:     #d4dae5;

  --text:         #0f1b35;
  --text-2:       #4a5878;
  --text-3:       #7a879f;
  --text-inv:     #ffffff;

  --brand:        #0a2a6b;        /* BWS navy */
  --brand-2:      #123a92;
  --accent:       #1f6feb;        /* strategic interactive blue */
  --accent-2:     #1759c4;
  --accent-weak:  #e7f0ff;
  --ring:         rgba(31, 111, 235, .35);

  --good:         #0a8f5b; --good-bg: #e6f6ee; --good-bd:#bce6d1;
  --warn:         #b06d12; --warn-bg: #fdf2e1; --warn-bd:#f3dcb4;
  --bad:          #cf2440; --bad-bg:  #fdeaed; --bad-bd:#f4c6cd;
  --info:         #1f6feb; --info-bg: #e7f0ff; --info-bd:#c5dbff;
  --neutral:      #6a7790; --neutral-bg:#eef1f6; --neutral-bd:#dde3ec;

  --c1:#1f6feb; --c2:#0a8f5b; --c3:#b06d12; --c4:#cf2440; --c5:#7c5cff; --c6:#0e9aa7; --c7:#d2691e;

  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(16,28,56,.06), 0 1px 1px rgba(16,28,56,.04);
  --sh-2: 0 4px 14px -6px rgba(16,28,56,.18);
  --sh-3: 0 18px 48px -22px rgba(16,28,56,.40);
  --ease: cubic-bezier(.2,.6,.2,1);

  --sans: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --rail-w: 252px;
  --topbar-h: 60px;
}

/* ---- tokens : DARK --------------------------------------------------------- */
html[data-theme="dark"] {
  --bg:           #0a0f1d;
  --surface:      #121a2d;
  --surface-2:    #0f1626;
  --surface-3:    #182238;
  --rail:         #0c1322;
  --rail-active:  #16223c;
  --overlay:      rgba(2, 6, 16, .60);

  --border:       #1f2a41;
  --border-2:     #2b3a57;

  --text:         #e7edf8;
  --text-2:       #a7b4cd;
  --text-3:       #74829e;
  --text-inv:     #0a0f1d;

  --brand:        #4d83f0;
  --brand-2:      #6a9bff;
  --accent:       #5b9dff;
  --accent-2:     #79b0ff;
  --accent-weak:  rgba(91,157,255,.14);
  --ring:         rgba(91,157,255,.40);

  --good:#34d399; --good-bg:rgba(52,211,153,.13); --good-bd:rgba(52,211,153,.30);
  --warn:#f0b34e; --warn-bg:rgba(240,179,78,.13); --warn-bd:rgba(240,179,78,.30);
  --bad: #ff6b82; --bad-bg: rgba(255,107,130,.13); --bad-bd:rgba(255,107,130,.32);
  --info:#5b9dff; --info-bg:rgba(91,157,255,.13); --info-bd:rgba(91,157,255,.30);
  --neutral:#9aa7c0; --neutral-bg:rgba(154,167,192,.12); --neutral-bd:rgba(154,167,192,.26);

  --c1:#5b9dff; --c2:#34d399; --c3:#f0b34e; --c4:#ff6b82; --c5:#a78bfa; --c6:#22d3ee; --c7:#fb923c;

  --sh-1: 0 1px 2px rgba(0,0,0,.30);
  --sh-2: 0 6px 18px -8px rgba(0,0,0,.55);
  --sh-3: 0 22px 56px -24px rgba(0,0,0,.72);
}

/* ---- base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; color: var(--text); }
::selection { background: var(--accent-weak); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
svg.ic { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---- app shell ------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.rail { width: var(--rail-w); flex: 0 0 var(--rail-w); background: var(--rail);
  border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; transition: width .18s var(--ease); z-index: 40; }
.rail .brand { display: flex; align-items: center; gap: 11px; padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border); }
.rail .brand .mark {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: -.04em;
  box-shadow: 0 0 0 1px rgba(31,111,235,.22), 0 4px 14px -4px rgba(10,42,107,.5); }
.rail .brand .bt { font-weight: 800; font-size: 14.5px; line-height: 1.05; letter-spacing: -.02em; }
.rail .brand .bs { font-size: 10px; color: var(--text-3); letter-spacing: .16em; text-transform: uppercase; margin-top: 2px; }
.rail nav { padding: 12px; overflow-y: auto; flex: 1; }
.nav-grp { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin: 16px 10px 7px; }
.nav-grp:first-child { margin-top: 2px; }
.nav-a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-2); font-weight: 550; font-size: 13.5px; margin-bottom: 2px; position: relative;
  transition: background .12s var(--ease), color .12s var(--ease); }
.nav-a:hover { background: var(--surface-2); color: var(--text); }
.nav-a.on { background: var(--rail-active); color: var(--brand); font-weight: 650; }
html[data-theme="dark"] .nav-a.on { color: var(--brand-2); }
.nav-a .cnt { margin-left: auto; font: 600 11px/1 var(--mono); background: var(--surface-3);
  color: var(--text-2); padding: 3px 7px; border-radius: 20px; }
.nav-a .cnt.bad { background: var(--bad-bg); color: var(--bad); }
.nav-a .cnt.warn { background: var(--warn-bg); color: var(--warn); }
.nav-a .cnt.accent { background: var(--accent-weak); color: var(--accent); }
.rail .foot { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); }

.app.rail-collapsed .rail { width: 64px; flex-basis: 64px; }
.app.rail-collapsed .rail .bt, .app.rail-collapsed .rail .bs,
.app.rail-collapsed .nav-a span, .app.rail-collapsed .nav-grp,
.app.rail-collapsed .nav-a .cnt, .app.rail-collapsed .rail .foot { display: none; }
.app.rail-collapsed .nav-a { justify-content: center; padding: 10px; }

/* ---- main + topbar --------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--border); }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  background: transparent; transition: background .12s var(--ease), color .12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-3); min-width: 0; }
.crumbs a { color: var(--text-2); }
.crumbs .sep { opacity: .6; }
.crumbs .cur { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.cmd-trigger { display: inline-flex; align-items: center; gap: 9px; height: 34px; padding: 0 11px;
  border: 1px solid var(--border-2); border-radius: var(--r-sm); background: var(--surface);
  color: var(--text-3); font-size: 12.5px; cursor: pointer; min-width: 210px; }
.cmd-trigger:hover { border-color: var(--accent); color: var(--text-2); }
.cmd-trigger .kbd { margin-left: auto; font: 600 10.5px/1 var(--mono); color: var(--text-3);
  border: 1px solid var(--border-2); border-radius: 5px; padding: 3px 5px; background: var(--surface-2); }
.chip-user { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 6px 0 11px;
  border-radius: 30px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; }
.chip-user .av { width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.topbar .bell { position: relative; }
.topbar .bell .dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--bad); border: 2px solid var(--bg); }

/* ---- content --------------------------------------------------------------- */
.content { padding: 22px 24px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
.page-head .ph-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }

.lineage { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 30px; padding: 5px 12px; }
.lineage .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.lineage.stale .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }

/* ---- cards + bento --------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--sh-1); padding: 18px; }
.card.pad-lg { padding: 22px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { font-size: 14.5px; font-weight: 650; }
.card-h .ic { width: 17px; height: 17px; color: var(--accent); }
.card-h .more { margin-left: auto; font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.bento > .col-3 { grid-column: span 3; } .bento > .col-4 { grid-column: span 4; }
.bento > .col-5 { grid-column: span 5; } .bento > .col-6 { grid-column: span 6; }
.bento > .col-7 { grid-column: span 7; } .bento > .col-8 { grid-column: span 8; }
.bento > .col-12 { grid-column: span 12; }
@media (max-width: 1100px) { .bento > [class^="col-"] { grid-column: span 6; } }
@media (max-width: 720px)  { .bento > [class^="col-"] { grid-column: span 12; } }

/* ---- KPI cards ------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(166px,1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 15px 16px; box-shadow: var(--sh-1); position: relative; overflow: hidden; }
.kpi .lbl { font-size: 11px; color: var(--text-3); font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; display: flex; align-items: center; gap: 7px; }
.kpi .lbl .ic { width: 15px; height: 15px; color: var(--text-3); }
.kpi .val { font-size: 28px; font-weight: 720; letter-spacing: -.02em; margin: 7px 0 1px;
  font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--text-2); }
.kpi.hot .val  { color: var(--accent); }
.kpi.good .val { color: var(--good); }
.kpi.warn .val { color: var(--warn); }
.kpi.bad .val  { color: var(--bad); }

/* ---- badges / states ------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 650;
  padding: 3px 9px; border-radius: 30px; border: 1px solid transparent; letter-spacing: .01em; white-space: nowrap; }
.badge.good{color:var(--good);background:var(--good-bg);border-color:var(--good-bd)}
.badge.warn{color:var(--warn);background:var(--warn-bg);border-color:var(--warn-bd)}
.badge.bad{color:var(--bad);background:var(--bad-bg);border-color:var(--bad-bd)}
.badge.info{color:var(--info);background:var(--info-bg);border-color:var(--info-bd)}
.badge.neutral{color:var(--neutral);background:var(--neutral-bg);border-color:var(--neutral-bd)}
.badge.accent{color:var(--accent);background:var(--accent-weak);border-color:var(--ring)}
.dotled::before { content:""; display:inline-block; width:7px; height:7px; border-radius:50%; margin-right:6px;
  background: currentColor; vertical-align: middle; }
.pulse { animation: pulse 1.6s ease infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

/* preservation / readiness ring */
.ring { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.ring::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 3px solid; }
.ring.ok, .ring.ready { color: var(--good); } .ring.ok::before, .ring.ready::before { border-color: var(--good); background: transparent; }
.ring.due_soon, .ring.attention { color: var(--warn); } .ring.due_soon::before, .ring.attention::before { border-color: var(--warn); }
.ring.overdue, .ring.blocked { color: var(--bad); } .ring.overdue::before, .ring.blocked::before { border-color: var(--bad); animation: pulse 1.6s ease infinite; }
.ring.none, .ring.na { color: var(--text-3); } .ring.none::before, .ring.na::before { border-color: var(--border-2); }

/* ---- chips / segmented filter ---------------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; font-size: 12.5px;
  border-radius: 30px; border: 1px solid var(--border-2); background: var(--surface); color: var(--text-2); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-sm); overflow: hidden; }
.seg a { padding: 7px 13px; font-size: 12.5px; font-weight: 600; color: var(--text-2); background: var(--surface); }
.seg a + a { border-left: 1px solid var(--border-2); }
.seg a.on { background: var(--accent); color: #fff; }

/* ---- buttons --------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 15px; font-size: 13px;
  font-weight: 600; border-radius: var(--r-sm); border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text); cursor: pointer; transition: background .12s var(--ease), border-color .12s, transform .04s;
  font-family: var(--sans); }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12px; }
.btn .ic { width: 16px; height: 16px; }
.btn.danger { color: var(--bad); border-color: var(--bad-bd); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- forms ----------------------------------------------------------------- */
.inp, select.inp, textarea.inp { width: 100%; height: 36px; padding: 0 12px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-sm); }
textarea.inp { height: auto; padding: 9px 12px; resize: vertical; }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); outline: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.check { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); cursor: pointer; font-size: 12.5px; }
.check:hover { border-color: var(--accent); }
.check input { accent-color: var(--accent); }

/* ---- tables ---------------------------------------------------------------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-3);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; text-align: left;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl a.serial, .serial-link { font-family: var(--mono); font-weight: 600; color: var(--accent); letter-spacing: .01em; }

/* ---- collaboration thread -------------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: 12px; }
.tmsg { display: flex; gap: 11px; align-items: flex-start; }
.tmsg .who { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; }
.tmsg .who.client { background: var(--brand); }
.tmsg .who.bws { background: var(--accent); }
.tmsg .who.system, .tmsg .who.ai { background: var(--surface-3); color: var(--accent); }
.tmsg .body { flex: 1; min-width: 0; }
.tmsg .meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.tmsg .meta b { color: var(--text-2); font-weight: 650; }
.tmsg .bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px;
  padding: 9px 13px; font-size: 13px; color: var(--text); }
.tmsg.mine .bubble { background: var(--accent-weak); border-color: var(--ring); }
.tmsg.sys .bubble { background: transparent; border-style: dashed; color: var(--text-2); font-size: 12.5px; }
.tmsg.sys .bubble .tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); margin-right: 7px; }
.thread-compose { display: flex; gap: 9px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.thread-compose textarea { flex: 1; height: 40px; max-height: 120px; }

/* ---- assistant / briefing / insight ---------------------------------------- */
.briefing li { margin: 4px 0; }
.insight-head { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.insight-head .halo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent); }
.insight-body p { margin: 0 0 8px; font-size: 13.5px; }
.insight-body .rec { display: flex; gap: 9px; align-items: flex-start; padding: 8px 0; border-top: 1px dashed var(--border); }
.insight-body .rec .n { width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; margin-top: 1px; }
.attn { display: flex; flex-direction: column; gap: 9px; }
.attn a { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface-2); color: var(--text); }
.attn a:hover { border-color: var(--accent); }
.attn .t { font-weight: 600; font-size: 13px; }
.attn .s { font-size: 12px; color: var(--text-3); }
.attn .flag { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 8px; }
.attn .flag.bad { background: var(--bad); animation: pulse 1.6s ease infinite; }
.attn .flag.warn { background: var(--warn); } .attn .flag.info { background: var(--info); }

/* ---- modal ----------------------------------------------------------------- */
.modal-bg { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: center;
  justify-content: center; z-index: 80; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { width: min(480px, 94vw); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: 20px; }
.modal h3 { font-size: 15.5px; margin-bottom: 4px; }
.modal .sub { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }

/* ---- feed / timeline ------------------------------------------------------- */
.feed { display: flex; flex-direction: column; }
.feed .fe { display: flex; gap: 11px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.feed .fe:last-child { border-bottom: none; }
.feed .fe .when { color: var(--text-3); font-family: var(--mono); font-size: 11px; white-space: nowrap; padding-top: 1px; }
.feed .fe .what b { font-weight: 650; }

/* ---- empty / error --------------------------------------------------------- */
.state { text-align: center; padding: 48px 20px; color: var(--text-2); }
.state .ic { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 12px; }
.state h3 { font-size: 15px; margin-bottom: 6px; }
.state p { font-size: 13px; color: var(--text-3); max-width: 400px; margin: 0 auto 14px; }
.state.err .ic { color: var(--bad); }

/* ---- command palette ------------------------------------------------------- */
.cmdk { position: fixed; inset: 0; background: var(--overlay); display: none; align-items: flex-start;
  justify-content: center; z-index: 90; padding-top: 12vh; }
.cmdk.open { display: flex; }
.cmdk .box { width: min(620px, 92vw); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); overflow: hidden; }
.cmdk input { width: 100%; height: 52px; padding: 0 18px; font: inherit; font-size: 15px; border: none;
  background: transparent; color: var(--text); border-bottom: 1px solid var(--border); }
.cmdk input:focus { outline: none; }
.cmdk .results { max-height: 360px; overflow-y: auto; padding: 7px; }
.cmdk .res { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text-2); font-size: 13.5px; }
.cmdk .res.sel, .cmdk .res:hover { background: var(--accent-weak); color: var(--text); }
.cmdk .res .k { margin-left: auto; font: 600 10.5px/1 var(--mono); color: var(--text-3); }

/* ---- chat ------------------------------------------------------------------ */
.fab { position: fixed; right: 22px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer; box-shadow: var(--sh-3);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.fab .ic { width: 24px; height: 24px; }
.chatwin { position: fixed; right: 22px; bottom: 90px; width: 392px; max-width: calc(100vw - 28px);
  height: 560px; max-height: calc(100vh - 120px); background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); display: none; flex-direction: column; z-index: 50; overflow: hidden; }
.chatwin.open { display: flex; }
.chatwin .ch-h { padding: 13px 15px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 9px; font-weight: 650; }
.chatwin .ch-h .ic { width: 18px; height: 18px; color: var(--accent); }
.chatwin .ch-b { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.msg.u { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.b { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.msg.b .chart { width: 100%; height: 200px; margin-top: 8px; }
.msg .act { display:block; margin-top:8px; padding:7px 10px; border:1px solid var(--ring); border-radius:8px;
  background:var(--accent-weak); font-size:12.5px; color:var(--text); cursor:pointer; width:100%; text-align:left; }
.chatwin .ch-f { padding: 11px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chatwin .ch-f textarea { flex: 1; height: 38px; max-height: 110px; }
.offline-pill { font-size: 10.5px; color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-bd);
  border-radius: 20px; padding: 2px 8px; margin-left: auto; }

.chat-page { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; height: calc(100vh - 170px); }
.chat-page .ch-b { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 2px 14px; }
.chat-page .ch-f { display: flex; gap: 9px; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-page .msg { max-width: 78%; font-size: 13.5px; }
.chat-page .msg.b .chart { height: 240px; }
.suggests { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }

/* ---- internal (BWS) tabs --------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-2);
  cursor: pointer; }
.tabs a.on { color: var(--brand); }
html[data-theme="dark"] .tabs a.on { color: var(--brand-2); }
.tabpane { display: none; } .tabpane.on { display: block; }

/* ---- utilities ------------------------------------------------------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.right { margin-left: auto; }
.hide { display: none !important; }
.nowrap { white-space: nowrap; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.note { font-size: 12px; color: var(--text-3); }
.echart { width: 100%; height: 280px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 95;
  background: var(--brand); border: 1px solid var(--brand-2); color: #fff;
  padding: 10px 18px; border-radius: 30px; font-size: 13px; box-shadow: var(--sh-3); display: none; }
.toast.show { display: block; animation: toastin .18s var(--ease); }
.toast.err { background: var(--bad); border-color: var(--bad); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* mobile */
.rail-toggle-m { display: none; }
@media (max-width: 900px) {
  .rail { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s var(--ease); }
  .app.rail-open .rail { transform: translateX(0); box-shadow: var(--sh-3); }
  .rail-toggle-m { display: inline-flex; }
  .cmd-trigger { min-width: 0; }
  .cmd-trigger .lbl-cmd, .cmd-trigger .kbd { display: none; }
  .content { padding: 16px 14px 50px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
