/* Unified "instrument / engineering-spec" identity — matches the /product page:
   steel paper + blueprint grid, safety-orange accent, deep steel-blue, mono labels. */
:root {
  --blue-900: #0d3a86;
  --blue-800: #12467f;   /* steel — headings */
  --blue-700: #1550a8;
  --blue-500: #1f63cf;
  --blue-050: #e9eff8;
  --orange:   #d95e07;   /* safety-orange accent (product) */
  --orange-600: #b34d05;
  --steel:    #12467f;
  --ink:      #0e1621;
  --muted:    #586675;
  --line:     #cdd6df;
  --line-soft:#dde4eb;
  --gray-50:  #eef2f6;   /* light steel surface */
  --surface-2:#f3f6f9;
  --bg:       #e8ecf1;   /* steel paper ground */
  --console:  #0f1620;
  --white:    #ffffff;
  --danger:   #b23b2e;
  --grid:     rgba(18, 70, 127, 0.06);
  --shadow:   0 1px 2px rgba(14, 22, 33, 0.05), 0 14px 40px rgba(14, 22, 33, 0.08);
  --chat-w:   400px;   /* fixed chat width; the viz dock stops at its left edge */
  --topbar-h: 58px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  /* theme-adaptive surfaces / accents / tints (light values; dark below) */
  --surface:  #ffffff;
  --ink-accent: #12467f;   /* heading / number / accent TEXT (lightens in dark) */
  --fg-good:  #1e7a44;     /* AI analysis text */
  --fg-mail:  #1550a8;     /* e-mail-sourced text */
  --hover:    #f2f6fc;
  --tint-good: #e5f4ec; --tint-amber: #fdf1d8; --tint-crit: #fbe6e3;
  --tint-data: #eef2f6; --tint-analysis: #fdeede; --tint-email: #e5eefc;
  --tint-error: #fdecea; --seg-head: #e3e9f2;
  --think-bg: #fff7f0; --think-line: #f3ddc7; --think-fg: #5b4636;
  --fg-amber: #9a6a05;
}

/* ---- dark theme: follows the OS, and an explicit toggle can override it ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue-050: #16233a;
    --ink: #e6edf4; --muted: #93a3b4; --line: #22303f; --line-soft: #1a2531;
    --gray-50: #141f2c; --surface-2: #141f2c; --bg: #0a0f17; --console: #0a0f16;
    --surface: #111a26; --ink-accent: #6ea0dc; --orange-600: #e0742a; --danger: #e2675a;
    --fg-good: #4bbd7d; --fg-mail: #6ea0dc; --hover: #182634;
    --grid: rgba(110,160,220,.07);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 44px rgba(0,0,0,.5);
    --tint-good: #12301f; --tint-amber: #33260a; --tint-crit: #3a1a17;
    --tint-data: #1a2634; --tint-analysis: #33240f; --tint-email: #16273f;
    --tint-error: #3a1a17; --seg-head: #26303c;
    --think-bg: #1c1608; --think-line: #33280f; --think-fg: #cbb896; --fg-amber: #d5a53a;
  }
}
:root[data-theme="dark"] {
  --blue-050: #16233a;
  --ink: #e6edf4; --muted: #93a3b4; --line: #22303f; --line-soft: #1a2531;
  --gray-50: #141f2c; --surface-2: #141f2c; --bg: #0a0f17; --console: #0a0f16;
  --surface: #111a26; --ink-accent: #6ea0dc; --orange-600: #e0742a; --danger: #e2675a;
  --fg-good: #4bbd7d; --fg-mail: #6ea0dc; --hover: #182634;
  --grid: rgba(110,160,220,.07);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 44px rgba(0,0,0,.5);
  --tint-good: #12301f; --tint-amber: #33260a; --tint-crit: #3a1a17;
  --tint-data: #1a2634; --tint-analysis: #33240f; --tint-email: #16273f;
  --tint-error: #3a1a17; --seg-head: #26303c;
  --think-bg: #1c1608; --think-line: #33280f; --think-fg: #cbb896; --fg-amber: #d5a53a;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.hidden { display: none !important; }

/* -------------------------------------------------------------- logo */
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .5px; }
.logo .gear { color: var(--orange); font-size: 1.1em; line-height: 1; }
.logo .brand { color: var(--ink-accent); }
.logo .brand .dot { color: var(--orange); }

/* -------------------------------------------------------------- login */
#login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(31,99,207,.18), transparent 60%),
    var(--gray-50);
}
.login-card {
  width: 420px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow);
}
.login-head {
  background: linear-gradient(135deg, var(--blue-800), var(--blue-500));
  color: var(--white); padding: 28px 28px 22px;
}
.login-head .logo { font-size: 26px; }
.login-head .logo .brand, .login-head .logo .brand .dot { color: #fff; }
.login-head .sub { margin-top: 6px; font-size: 13px; opacity: .9; font-weight: 500; }
.sim-note { margin-top: 12px; font-size: 12px; font-weight: 600; color: #ffe3c2;
  background: rgba(236,102,8,.28); border: 1px solid rgba(255,255,255,.25);
  display: inline-block; padding: 4px 10px; border-radius: 20px; }
.login-body { padding: 24px 28px 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field select, .field input {
  width: 100%; padding: 11px 12px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink);
}
.field select:focus, .field input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(31,99,207,.15); }
.field input:disabled { background: var(--gray-50); color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 700; padding: 11px 16px;
  background: var(--blue-700); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--blue-800); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-orange { background: var(--orange); }
.btn-orange:hover { background: var(--orange-600); }
.btn-block { width: 100%; }
.login-note { margin-top: 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* -------------------------------------------------------------- app shell */
#app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
  color: #fff; padding: 0 18px; height: 58px; flex: 0 0 auto;
  box-shadow: 0 2px 10px rgba(13,58,134,.25);
}
.topbar .logo { font-size: 20px; }
.topbar .logo .brand, .topbar .logo .brand .dot { color: #fff; }
.topbar .logo .tag { font-weight: 600; font-size: 12px; opacity: .8; margin-left: 8px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.3); }

.userbox { position: relative; }
.userchip {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22);
  border-radius: 24px; padding: 6px 12px 6px 6px; color: #fff;
}
.userchip:hover { background: rgba(255,255,255,.2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff;
}
.userchip .who { line-height: 1.1; text-align: left; }
.userchip .who .u-name { font-size: 13px; font-weight: 700; }
.userchip .who .u-role { font-size: 11px; opacity: .85; }
.userchip .caret { font-size: 10px; opacity: .8; }

.menu {
  position: absolute; right: 0; top: 48px; min-width: 220px;
  background: var(--surface); color: var(--ink); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 20;
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: none; background: none; text-align: left; cursor: pointer;
  padding: 12px 14px; font-size: 13.5px; color: var(--ink);
}
.menu button:hover { background: var(--blue-050); }
.menu .sep { height: 1px; background: var(--line); }

/* -------------------------------------------------- topbar button + modal */
.topright { display: flex; align-items: center; gap: 12px; }
.topbtn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--orange); color: #fff; border: none; border-radius: 20px;
  padding: 7px 14px; font-size: 13px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(236, 102, 8, .35);
}
.topbtn:hover { background: var(--orange-600); }
.topbtn-badge { background: var(--white); color: var(--orange-600); border-radius: 10px; font-size: 11px; font-weight: 800; padding: 1px 7px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(13, 33, 66, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: 14px; width: min(1040px, 96vw); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700)); color: #fff; padding: 14px 20px;
}
.modal-title { font-size: 15px; font-weight: 800; }
.modal-close { background: rgba(255,255,255,.15); border: none; color: #fff; cursor: pointer; width: 30px; height: 30px; border-radius: 50%; font-size: 14px; }
.modal-close:hover { background: rgba(255,255,255,.3); }
.modal-body { padding: 18px 20px; overflow: auto; }

.kpis { display: flex; gap: 12px; margin-bottom: 14px; }
.kpi { flex: 1; background: var(--gray-50); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.kpi-v { font-size: 24px; font-weight: 800; color: var(--ink-accent); }
.kpi-l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { cursor: pointer; font-size: 12px; padding: 4px 11px; border-radius: 16px; background: var(--gray-50); border: 1px solid var(--line); color: var(--muted); font-weight: 600; }
.chip:hover { background: var(--blue-050); }
.chip.active { background: var(--blue-700); color: #fff; border-color: var(--ink-accent); }

.stand-wrap { overflow-x: auto; }
table.stand { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.stand th { text-align: left; color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.stand td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--ink); vertical-align: top; }
table.stand tr:hover td { background: var(--hover); }
.days-badge { display: inline-block; font-weight: 800; font-size: 11.5px; padding: 2px 8px; border-radius: 10px; color: #fff; }
.days-badge.d-red { background: var(--danger); }
.days-badge.d-orange { background: var(--orange); }
.days-badge.d-green { background: #2e9e5b; }
.st-awaiting { color: var(--orange-600); font-weight: 700; }
.st-open { color: var(--ink-accent); font-weight: 700; }
.stand-empty, .stand-loading { text-align: center; color: var(--muted); padding: 20px; }

/* -------------------------------------------------- visualization dock (left area only) */
.viz-dock {
  position: fixed; left: 0; right: var(--chat-w); top: var(--topbar-h); bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(13, 58, 134, .18);
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .28s ease;
}
.viz-dock.has-data { transform: translateY(calc(100% - 42px)); }   /* handle peeks at the bottom */
.viz-dock.has-data.open { transform: translateY(0); }              /* full height to the header */
.viz-handle {
  height: 42px; flex: 0 0 42px; display: flex; align-items: center; justify-content: flex-start; gap: 20px;
  padding: 0 16px; cursor: pointer; color: #fff; font-weight: 700; font-size: 13px;
  background: linear-gradient(90deg, var(--blue-900), var(--blue-700));
}
#vizHandleLabel { flex: 0 0 auto; white-space: nowrap; }
.viz-actions { margin-left: auto; }
/* Always-visible key for the reply colour/tool coding */
.viz-legend-bar { display: flex; flex-wrap: nowrap; align-items: center; gap: 14px; min-width: 0; overflow: hidden;
  font-size: 10.5px; font-weight: 600; color: rgba(255,255,255,.92); }
.viz-legend-bar .vl { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.viz-legend-bar .vl-sep { padding-left: 14px; border-left: 1px solid rgba(255,255,255,.3); }
.viz-legend-bar .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.viz-legend-bar .sw.green { background: #34d17f; }
.viz-legend-bar .sw.blue { background: #6ea8ff; }
.viz-dock.has-data .viz-handle { background: linear-gradient(90deg, var(--blue-900), var(--blue-700)); }
.viz-actions { display: flex; align-items: center; gap: 12px; }
.viz-clear { cursor: pointer; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 14px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; }
.viz-clear:hover { background: rgba(255,255,255,.25); }
.viz-caret { transition: transform .28s ease; }
.viz-dock.open .viz-caret { transform: rotate(180deg); }

.viz-feed { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
/* Feed cards are flex items: keep their natural height so the feed OVERFLOWS
   and scrolls, instead of shrinking every card to fit (which clips them). */
.viz-feed > * { flex: 0 0 auto; }
.viz-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(13,58,134,.05); }
.viz-card-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--gray-50); border-bottom: 1px solid var(--line); }
.viz-card-title { font-size: 12px; font-weight: 700; color: var(--ink-accent); }
.viz-card-tabs { display: flex; gap: 6px; }
.vc-tab { cursor: pointer; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.vc-tab:hover { background: var(--blue-050); }
.vc-tab.active { background: var(--blue-700); color: #fff; border-color: var(--ink-accent); }
.viz-card-body { padding: 12px; overflow-x: auto; }
.viz-note { margin-top: 8px; font-size: 10px; color: var(--muted); }

table.viz-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.viz-table th { position: sticky; top: 0; background: var(--gray-50); text-align: left; color: var(--ink-accent); font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; padding: 6px 9px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.viz-table td { padding: 6px 9px; border-bottom: 1px solid var(--line); color: var(--ink); }
table.viz-table tr:hover td { background: var(--hover); }
table.viz-table th.sortable { cursor: pointer; user-select: none; }
table.viz-table th.sortable:hover { color: var(--orange-600); }

.bars { display: flex; flex-direction: column; gap: 6px; padding-right: 74px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 10px; font-size: 10.5px; }
.bar-label { text-align: right; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; background: var(--gray-50); border-radius: 5px; height: 18px; border: 1px solid var(--line); }
.bar-fill { position: absolute; top: 0; height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); border-radius: 5px; }
.bar-fill.neg { background: linear-gradient(90deg, #9c2f22, var(--danger)); }
.zero-line { position: absolute; top: -1px; height: 20px; width: 2px; background: var(--ink); opacity: .4; z-index: 2; }
.bar-num { text-align: right; font-size: 9.5px; font-weight: 700; color: var(--ink-accent); white-space: nowrap; }
.bar-num.neg { color: var(--danger); }
.barsig { padding-right: 0; }
.barsig .bar-row { grid-template-columns: 130px 1fr 82px; }
.bar-track.cmp { display: flex; }
.bar-track.cmp .seg { height: 100%; }
.bar-track.cmp .seg.green { background: #2e9e5b; }
.bar-track.cmp .seg.red { background: var(--danger); }
.bar-track.cmp .seg.head { background: var(--seg-head); }
.in-val { position: absolute; top: 50%; transform: translateY(-50%); font-size: 9.5px; font-weight: 700; color: var(--ink-accent); padding-left: 4px; white-space: nowrap; pointer-events: none; }
.in-val.over { color: var(--danger); }
.in-val.under { color: #2e9e5b; }
.tgt-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink-accent); z-index: 2; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 10px; color: var(--muted); }
.viz-legend .lg { display: inline-flex; align-items: center; gap: 4px; }
.viz-legend .sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.viz-legend .sw.green { background: #2e9e5b; }
.viz-legend .sw.red { background: var(--danger); }
.viz-legend .sw.head { background: var(--seg-head); border: 1px solid var(--line); }
.viz-legend .sw.mark { background: var(--ink-accent); width: 3px; height: 12px; border-radius: 1px; }
.bar-val { text-align: right; font-weight: 700; color: var(--ink-accent); }

/* ------------------------------------------------- financial-ratio KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.kpi { border: 1px solid var(--line); border-left: 3px solid var(--muted); border-radius: 9px;
  padding: 10px 11px; background: var(--surface); }
.kpi.green { border-left-color: #2e9e5b; }
.kpi.amber { border-left-color: #e0a516; }
.kpi.red   { border-left-color: var(--danger); }
.kpi.wide  { grid-column: 1 / -1; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-title { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.kpi-badge { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.kpi-badge.green { background: var(--tint-good); color: var(--fg-good); }
.kpi-badge.amber { background: var(--tint-amber); color: var(--fg-amber); }
.kpi-badge.red   { background: var(--tint-crit); color: var(--danger); }
.kpi-val { font-size: 21px; font-weight: 800; color: var(--ink-accent); margin: 4px 0 8px; letter-spacing: -.3px; }
.kpi-unit { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.gauge { position: relative; margin: 2px 0 9px; }
.gzbar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; }
.gz { height: 100%; opacity: .45; }
.gz.green { background: #2e9e5b; } .gz.amber { background: #e0a516; } .gz.red { background: var(--danger); }
.gmark { position: absolute; top: -2px; width: 3px; height: 11px; background: var(--ink);
  border-radius: 2px; transform: translateX(-50%); box-shadow: 0 0 0 1.5px var(--surface); }
.kpi-cap { font-size: 10px; color: var(--muted); line-height: 1.35; }
/* Card commentary is the AI's value-add — always green (analysis + proposal). */
.kpi-eval, .kpi-act { font-size: 10.5px; line-height: 1.4; margin-top: 7px; color: var(--fg-good); }
.kpi-act { color: var(--fg-good); }
.kpi-lbl { display: inline-block; font-size: 8.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; padding: 1px 5px; border-radius: 4px; margin-right: 5px; vertical-align: 1px;
  background: var(--gray-50); color: var(--muted); border: 1px solid var(--line); }
.kpi-act .kpi-lbl { background: var(--blue-050); color: var(--ink-accent); border-color: #cdddf5; }
.kpi-foot { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); font-style: italic; }
/* final summary card */
.kpi-summary { margin-top: 12px; border: 1px solid var(--line); border-top: 3px solid var(--blue-700);
  border-radius: 9px; background: var(--blue-050); padding: 12px 14px; }
.sum-head { font-size: 13px; font-weight: 800; color: var(--ink-accent); margin-bottom: 6px; }
.sum-overall { font-size: 11.5px; color: var(--fg-good); line-height: 1.5; margin-bottom: 10px; }   /* AI assessment = green */
.sum-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.sum-list li { font-size: 11px; line-height: 1.45; color: var(--ink); display: flex; gap: 7px; align-items: baseline; }
.sum-rank { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; background: var(--blue-700);
  color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.sum-list .kpi-badge { flex: 0 0 auto; }
.mbars { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 8px; }
.mb-row { display: flex; align-items: center; gap: 8px; }
.mb-lab { font-size: 10.5px; font-weight: 600; color: var(--ink); width: 78px; flex: 0 0 auto; }
.mb-track { flex: 1 1 auto; background: var(--gray-50); border: 1px solid var(--line); border-radius: 5px; height: 15px; }
.mb-fill { height: 100%; border-radius: 5px; }
.mb-fill.green { background: #2e9e5b; } .mb-fill.red { background: var(--danger); }
.mb-val { font-size: 10.5px; font-weight: 700; color: var(--ink-accent); width: 62px; text-align: right; flex: 0 0 auto; }

/* -------------------------------------------------------------- body columns */
.main { flex: 1 1 auto; display: flex; min-height: 0; }

.canvas {
  flex: 3 1 0; min-width: 0; padding: 20px; overflow: auto;
}
.canvas-inner {
  height: 100%; border: 2px dashed var(--line); border-radius: 14px;
  background:
    linear-gradient(0deg, rgba(31,99,207,.02), rgba(31,99,207,.02)),
    var(--white);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; padding: 28px;
}
.canvas-inner h2 { margin: 6px 0 4px; color: var(--ink-accent); font-size: 20px; }
.canvas-inner .canvas-lead { margin: 0 0 6px; font-size: 13.5px; color: var(--muted); }
.canvas-inner .canvas-note { margin-top: 14px; font-size: 12.5px; opacity: .7; }

.sim-banner {
  max-width: 620px; font-size: 13px; color: #8a4b12; font-weight: 500;
  background: #fff4e8; border: 1px solid #f4d6b3; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 6px;
}
.sim-banner b { color: var(--orange-600); }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; width: 100%; max-width: 720px; margin: 16px 0 4px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 10px; box-shadow: 0 2px 8px rgba(13,58,134,.05);
}
.stat-v { font-size: 20px; font-weight: 800; color: var(--ink-accent); line-height: 1.1; }
.stat-l { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* -------------------------------------------------- landing: vision + tree */
.landing { max-width: 960px; margin: 0 auto; padding: 6px 6px 44px; }
.landing .sim-banner { display: block; text-align: center; margin: 0 auto 18px; max-width: 720px; }

.hero { text-align: center; margin: 6px 0 18px; }
.hero h1 { font-size: 26px; font-weight: 800; color: var(--ink-accent); margin: 4px 0 10px; }
.hero .vision { font-size: 14px; line-height: 1.75; color: var(--ink); max-width: 780px; margin: 0 auto; }
.hero .vision b { color: var(--orange-600); }
.pillars { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.pillar { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 190px; box-shadow: 0 2px 8px rgba(13,58,134,.06); }
.pillar .pi { font-size: 22px; }
.pillar b { display: block; color: var(--ink-accent); margin-top: 4px; font-size: 13.5px; }
.pillar small { color: var(--muted); font-size: 11.5px; }

.spotlight {
  position: relative; display: flex; align-items: center; gap: 16px;
  max-width: 820px; margin: 18px auto 6px; padding: 16px 20px;
  background: linear-gradient(100deg, #fff6ec, #fdece0);
  border: 1px solid #f4c99a; border-radius: 14px;
  box-shadow: 0 8px 26px rgba(236, 102, 8, 0.16);
}
.spotlight-badge {
  position: absolute; top: -10px; left: 18px;
  background: var(--orange); color: #fff; font-size: 10.5px; font-weight: 800;
  letter-spacing: 1px; padding: 3px 10px; border-radius: 10px;
}
.spotlight-icon { font-size: 30px; flex: 0 0 auto; }
.spotlight-text h3 { margin: 0 0 4px; color: var(--orange-600); font-size: 16px; }
.spotlight-text p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--think-fg); }
.spotlight-text b { color: var(--ink-accent); }
.spotlight-text .mgmt { color: var(--orange-600); font-weight: 700; white-space: nowrap; }
.spotlight-stats { margin-top: 8px; font-size: 12px; color: #7a5a3a; background: rgba(255,255,255,.6);
  border: 1px solid #f0d3b0; border-radius: 8px; padding: 6px 10px; display: inline-block; }
.spotlight-stats b { color: var(--orange-600); }

.tree-root { text-align: center; margin-top: 8px; }
.root-node { display: inline-block; background: linear-gradient(90deg, var(--blue-800), var(--blue-500)); color: #fff; font-weight: 800; font-size: 14px; padding: 8px 20px; border-radius: 22px; box-shadow: var(--shadow); }
.tree-root::after { content: ""; display: block; width: 2px; height: 18px; background: var(--line); margin: 8px auto 0; }

.dept-group { margin-bottom: 8px; }
.group-title { text-align: center; font-size: 11.5px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--orange-600); margin: 14px 0 9px; }
.group-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

.dept-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: 0 2px 8px rgba(13,58,134,.05); }
.dept-card.current { border-color: var(--orange); background: var(--surface); box-shadow: 0 6px 22px rgba(236,102,8,.18); }
.dept-head { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-accent); font-weight: 700; }
.dept-icon { font-size: 18px; }
.badge-you { margin-left: auto; background: var(--orange); color: #fff; font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 10px; letter-spacing: .5px; }
.dept-scope { font-size: 11.5px; color: var(--muted); margin: 6px 0 9px; }
.dept-examples { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.dept-examples .ex { font-size: 12px; color: var(--ink); background: var(--gray-50); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; line-height: 1.4; }
.dept-examples .ex.clickable { cursor: pointer; background: var(--blue-050); border-color: #cfe0fb; }
.dept-examples .ex.clickable:hover { background: var(--blue-050); border-color: var(--blue-500); }
/* AI capability-level tags on sample questions + the legend */
.lvtag { display: inline-block; font-size: 8.5px; font-weight: 800; letter-spacing: .3px; padding: 1px 5px;
  border-radius: 5px; margin-right: 6px; vertical-align: 1px; color: #fff; }
.lvtag.lv1 { background: #64748b; } .lvtag.lv2 { background: #0f8a8a; } .lvtag.lv3 { background: var(--orange); }
.lvtag.lv4 { background: #7a3ea8; } .lvtag.lv5 { background: var(--danger); }
.lv-legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px;
  margin: 4px 0 14px; font-size: 11px; color: var(--muted); }
.lv-legend-title { font-weight: 700; color: var(--ink); }
.lv-item { display: inline-flex; align-items: center; }

/* Colour-coded reply content: green = AI's own analysis/recommendation,
   blue = information sourced from the e-mail / communication data. */
.ai-wisdom { color: var(--fg-good); font-weight: 600; }
.ai-email { color: var(--fg-mail); font-weight: 600; }
.reply-legend { font-size: 10.5px; font-weight: 600; color: var(--muted); margin-left: auto; display: inline-flex; align-items: center; gap: 5px; }
.reply-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.reply-legend .dot.green { background: #34d17f; } .reply-legend .dot.blue { background: #6ea8ff; }
.reply-legend .dot.blue { margin-left: 8px; }

.data-strip { margin-top: 22px; text-align: center; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 14px; line-height: 1.95; }
.data-strip b { color: var(--ink-accent); }

.chat {
  flex: 0 0 var(--chat-w); width: var(--chat-w); min-width: var(--chat-w); max-width: var(--chat-w);
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); min-height: 0;
}
.chat-head {
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--ink-accent);
  display: flex; align-items: center; gap: 8px;
}
.chat-head .badge { background: var(--orange); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }

.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.messages > * { flex: 0 0 auto; }   /* keep message height so the log scrolls, not shrinks */
.msg { max-width: 92%; padding: 10px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; white-space: normal; }
.msg.user { align-self: flex-end; background: var(--blue-700); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot  { align-self: flex-start; background: var(--gray-50); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.bot.error { background: var(--tint-error); border-color: #f5c6c0; color: var(--danger); }
.msg .tools { margin-top: 8px; font-size: 11px; color: var(--muted); }
.msg .tools .tool { display: inline-block; border: 1px solid; border-radius: 6px; padding: 1px 7px; margin: 2px 4px 0 0; font-weight: 600; }
.msg .tools .tool.data     { background: var(--tint-data); color: #64748b; border-color: #dfe5ee; }   /* 🔎 data lookup */
.msg .tools .tool.analysis { background: var(--tint-analysis); color: #c25e06; border-color: #f4d3ac; }   /* 📊 analysis */
.msg .tools .tool.email    { background: var(--tint-email); color: var(--fg-mail); border-color: #c7dcfb; }   /* ✉ e-mail */
.msg .think { margin-top: 8px; font-size: 12px; }
.msg .think summary { cursor: pointer; color: var(--orange-600); font-weight: 700; user-select: none; }
.msg .think .think-step { margin-top: 6px; padding: 8px 10px; background: var(--think-bg); border: 1px solid var(--think-line); border-radius: 8px; color: var(--think-fg); line-height: 1.5; }
.msg.typing { color: var(--muted); font-style: italic; }
.dots span { animation: blink 1.2s infinite both; }
.dots span:nth-child(2){ animation-delay:.2s } .dots span:nth-child(3){ animation-delay:.4s }
@keyframes blink { 0%,80%,100%{opacity:.2} 40%{opacity:1} }

/* animated stage ticker: finished stage slides up + fades out, new one rises in.
   The current line stays in normal flow (so text + height are reliable); only the
   leaving line is pulled out absolutely to overlap during the swap. */
.stage-ticker { position: relative; overflow: hidden; }
.stage-line { transition: transform .45s cubic-bezier(.22,.61,.36,1), opacity .45s ease; }
.stage-line.enter { transform: translateY(75%); opacity: 0; }      /* start: below, hidden */
.stage-line.leaving { position: absolute; left: 0; right: 0; top: 0;
  transform: translateY(-75%); opacity: 0; }                       /* exit: rise up, fade out */
@media (prefers-reduced-motion: reduce) {
  .stage-line { transition: opacity .2s ease; }
  .stage-line.enter, .stage-line.leaving { transform: none; }
}

.composer { border-top: 1px solid var(--line); padding: 12px; }
.composer textarea {
  width: 100%; resize: none; font-family: inherit; font-size: 13.5px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; color: var(--ink);
}
.composer textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(31,99,207,.12); }
.composer .row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 10px; }
.composer .hint { font-size: 11px; color: var(--muted); }

/* -------------------------------------------------------------- perf footer */
.perf {
  flex: 0 0 auto; text-align: center; padding: 8px 12px;
  background: var(--surface); border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.perf b { color: var(--ink-accent); }
.perf .sep { margin: 0 10px; color: var(--line); }
.perf .spin { color: var(--orange); font-weight: 600; }

/* ---------------------------------------------- language switch + product */
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.lang-switch button { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 12px; padding: 5px 11px; cursor: pointer; letter-spacing: .03em; }
.lang-switch button.active { background: var(--blue-700); color: #fff; }
.topbar .lang-switch { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.1); }
.topbar .lang-switch button { color: rgba(255,255,255,.8); }
.topbar .lang-switch button.active { background: var(--white); color: var(--ink-accent); }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-top .lang-switch { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.12); }
.login-top .lang-switch button { color: rgba(255,255,255,.85); }
.login-top .lang-switch button.active { background: var(--white); color: var(--ink-accent); }
.login-product { display: block; text-align: center; margin-top: 14px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-accent); text-decoration: none; }
.login-product:hover { color: var(--orange-600); text-decoration: underline; }
.topbtn.ghost { text-decoration: none; }
/* product call-to-action row on the landing */
.landing-cta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 6px 0 20px; }
.landing-cta a { font-size: 13px; font-weight: 700; text-decoration: none; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); color: var(--ink-accent); background: var(--surface); transition: border-color .15s, transform .15s; }
.landing-cta a.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.landing-cta a:hover { transform: translateY(-1px); border-color: var(--orange); }

/* ---------------------------------------------- e-mail viewer (rows + modal) */
.viz-table.email-row, tr.email-row { cursor: pointer; }
tr.email-row:hover td { background: var(--blue-050); }
.email-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.email-link:hover { text-decoration-style: solid; }
#emailBody { display: flex; flex-direction: column; gap: 12px; }
.email-item { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.email-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--gray-50); border-bottom: 1px solid var(--line); }
.email-subj { font-weight: 700; font-size: 13.5px; color: var(--ink-accent); }
.email-dir { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 12px; white-space: nowrap; }
.email-dir.in { background: var(--tint-good); color: var(--fg-good); }
.email-dir.out { background: var(--blue-050); color: var(--ink-accent); }
.email-hdr { padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px dashed var(--line); }
.email-body { padding: 12px 14px; font-size: 13.5px; line-height: 1.55; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.email-empty { color: var(--muted); font-style: italic; }
.email-summary { padding: 8px 14px 12px; font-size: 12px; line-height: 1.5; color: var(--muted); border-top: 1px dashed var(--line); background: var(--gray-50); }
.email-summary b { color: var(--ink-accent); }

/* ============================================================================
   UNIFIED PRODUCT THEME
   Brings the app into the same visual family as the /product pitch page:
   steel paper + faint blueprint grid, a monospace "instrument voice" for
   technical labels/numbers, sharp hairline cards, and an orange-rail spotlight.
   Appended last so these win the cascade for the elements they touch.
   ============================================================================ */

/* blueprint grid on the home canvas — the same background as the product hero */
.canvas {
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--bg);
}

/* monospace = the technical instrument voice (labels, chips, tags, headers) */
.lvtag, .kpi-lbl, .kpi-badge, .group-title, .dept-scope, .data-strip,
.viz-card-title, .viz-legend-bar, .lang-switch button, .viz-note, .perf,
.reply-legend, .lv-legend, .msg .tools, .msg .tools .tool, .spotlight-badge,
.badge-you, .topbar .logo .tag, .landing-cta a, .btn, .topbtn,
table.viz-table th, table.stand th, .vc-tab, .chip {
  font-family: var(--mono);
}
/* tabular numerals on the "spec" figures */
.kpi-val, .stat-v, .kpi-v, .bar-num, .mb-val, .in-val, .spotlight-stats,
.days-badge, .sum-rank {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}
.btn, .topbtn, .landing-cta a { letter-spacing: .02em; }

/* sharper, hairline cards — crisp like the spec sheet (leave chat bubbles alone) */
.viz-card, .dept-card, .pillar, .kpi, .kpi-summary, .stat, .login-card,
.modal, .email-item, .spotlight { border-radius: 9px; }
.viz-card, .dept-card, .pillar, .stat, .kpi { box-shadow: var(--shadow); }

/* group headings become product-style eyebrows: mono, hairline rule, accent */
.group-title {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px; letter-spacing: .18em; color: var(--orange-600);
  text-align: left; justify-content: flex-start;
}
.group-title::before { content: ""; width: 24px; height: 1px; background: var(--orange); display: inline-block; }
.dept-group { margin-bottom: 14px; }

/* spotlight: in-theme steel card with an orange accent rail (not the warm cream) */
.spotlight {
  background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--orange);
  box-shadow: var(--shadow);
}
.spotlight-text p { color: var(--muted); }
.spotlight-text b { color: var(--ink-accent); }
.spotlight-text h3 { color: var(--orange-600); }
.spotlight-stats { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.spotlight-stats b { color: var(--orange-600); }

/* sim banner in-theme */
.sim-banner { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.sim-banner b { color: var(--orange-600); }

/* hero heading + root node in steel */
.hero h1 { color: var(--ink-accent); letter-spacing: -.02em; }
.root-node { background: linear-gradient(90deg, var(--steel), var(--blue-700)); }

/* card panel heads read as steel labels */
.viz-card-head { background: var(--surface-2); }
.viz-card-title { color: var(--ink-accent); letter-spacing: .04em; }
table.viz-table th, table.stand th { color: var(--ink-accent); }

/* theme toggle (light/dark) */
.theme-toggle { cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14px; line-height: 1; border-radius: 8px; padding: 5px 9px; }
.theme-toggle:hover { border-color: var(--orange); }
.topbar .theme-toggle { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.1); }
.login-ctrls { display: inline-flex; align-items: center; gap: 8px; }
.login-top .theme-toggle { border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.12); color: #fff; }
