/* =====================================================================
   CRAVALAI — visual system
   CRAVAL identity: deep teal (#165355, website), CRAVAL report green (#008A3E / #00B050),
   logo red → green gradient, warm off-white canvas (#F3F1F0), Crimson Text + Nunito Sans.
   ===================================================================== */
:root {
  --bg: #F3F1F0;
  --surface: #FFFFFF;
  --surface-2: #F9F8F7;
  --surface-3: #EFECE9;
  --line: #E3DFDB;
  --line-strong: #CFC9C3;
  --ink: #1B2226;
  --text: #434A56;
  --muted: #7A828C;
  --brand: #008A3E;
  --brand-strong: #006D31;
  --brand-bright: #00B050;
  --brand-soft: #E6F3EB;
  --teal: #165355;
  --side: #0E3336;
  --side-2: #0A2527;
  --side-text: #CFE0DD;
  --side-muted: #7FA3A0;
  --red: #9E1B1B;
  --red-soft: #FBEAEA;
  --amber: #A15C00;
  --amber-soft: #FFF3DF;
  --series-a: #2B7BB9;
  --series-b: #00873E;
  --map-empty: #E7E3DF;
  --map-line: #FFFFFF;
  --shadow: 0 1px 2px rgba(20, 30, 30, .05), 0 4px 16px rgba(20, 40, 40, .05);
  --radius: 14px;
  --radius-sm: 9px;
  --serif: 'Crimson Text', Georgia, 'Times New Roman', serif;
  --sans: 'Nunito Sans', 'Segoe UI', Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0A1C1D;
  --surface: #10292B;
  --surface-2: #133033;
  --surface-3: #183A3D;
  --line: #1F4447;
  --line-strong: #2C5A5E;
  --ink: #EEF3F2;
  --text: #C4D1CF;
  --muted: #8BA3A1;
  --brand: #2FA863;
  --brand-strong: #46C07A;
  --brand-bright: #3DBE72;
  --brand-soft: #16392E;
  --side: #071718;
  --side-2: #051112;
  --red-soft: #3A1717;
  --amber: #F0B35A;
  --amber-soft: #3A2A12;
  --series-a: #4A8FC6;
  --series-b: #2FA863;
  --map-empty: #1C3C3F;
  --map-line: #10292B;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 30px; letter-spacing: -.01em; }
h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; }
h3 { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.sub { color: var(--muted); font-size: 12.5px; }
.i { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.grow { flex: 1; }

/* ---------------- layout ---------------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 244px; flex: none; background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 4px; color: #fff; }
.wordmark { font-family: var(--sans); font-weight: 300; font-size: 23px; letter-spacing: .14em; color: #fff; }
.wordmark b { font-weight: 800; background: linear-gradient(90deg, #E0453A, #34B36A); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: .06em; }
.side-tag { padding: 0 20px 18px 70px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); }
.side-nav { display: flex; flex-direction: column; padding: 6px 12px; gap: 2px; overflow-y: auto; }
.side-sec { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); padding: 16px 10px 6px; }
.side-nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--side-text); font-weight: 600; font-size: 13.5px; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-nav a.active { background: rgba(52, 179, 106, .16); color: #fff; box-shadow: inset 3px 0 0 #34B36A; }
.side-foot { margin-top: auto; padding: 16px 20px 22px; }
.stage-badge { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--side-text); background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); padding: 8px 10px; border-radius: 10px; }
.stage-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #F0B35A; box-shadow: 0 0 0 3px rgba(240, 179, 90, .18); flex: none; }
.side-motto { margin-top: 14px; font-size: 10.5px; letter-spacing: .3em; color: #8CC63F; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.logo-plate { background: #fff; border-radius: 10px; padding: 6px 12px; box-shadow: 0 0 0 1px var(--line); display: flex; }
.logo-frame { display: block; width: 150px; height: 41px; overflow: hidden; position: relative; }
/* original logo file, framed to its artwork (no distortion / no redraw) */
.logo-frame img { position: absolute; width: 184px; left: -17px; top: -70px; max-width: none; }
.icon-btn.menu-btn { display: none; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.view { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------------- controls ---------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: 700 13px var(--sans); padding: 9px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.import-btn { letter-spacing: .03em; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }
.chip-btn { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 5px 11px; font: 700 11px var(--sans); letter-spacing: .06em; cursor: pointer; }
.select, .input, textarea.input {
  font: 600 13px var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 12px; outline: none;
}
.select:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.select.sm { padding: 6px 8px; font-size: 12px; }
.input { width: 100%; }
textarea.input { resize: vertical; min-height: 90px; font-weight: 500; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; margin-top: 2px; }

/* universe tabs */
.universe-switch { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.universe-switch button { border: 0; background: transparent; color: var(--text); font: 800 12px var(--sans); letter-spacing: .05em; padding: 8px 14px; border-radius: 9px; cursor: pointer; white-space: nowrap; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.universe-switch button small { font-weight: 600; font-size: 10px; color: var(--muted); letter-spacing: .02em; }
.universe-switch button.active { background: var(--brand); color: #fff; }
.universe-switch button.active small { color: rgba(255, 255, 255, .8); }
.universe-switch button.soon { opacity: .55; }
.universe-switch button.soon small { color: var(--amber); }

/* dataset switch */
.dataset-switch { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.dataset-switch button { border: 0; background: transparent; padding: 8px 12px; font: 800 10.5px var(--sans); letter-spacing: .08em; color: var(--muted); cursor: pointer; display: flex; align-items: center; gap: 7px; }
.dataset-switch button .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dataset-switch button.active[data-ds="REAL"] { background: var(--brand-soft); color: var(--brand-strong); }
.dataset-switch button.active[data-ds="DEMO"] { background: var(--amber-soft); color: var(--amber); }
.demo-ribbon { display: flex; align-items: center; gap: 8px; justify-content: center; background: var(--amber-soft); color: var(--amber); padding: 7px 16px; font-size: 12.5px; border-bottom: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); }

/* ---------------- cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-h .sub { font-size: 14px; margin-top: 4px; }

/* ---------------- filters ---------------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ms { position: relative; }
.ms-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; cursor: pointer; font: 800 10.5px var(--sans); letter-spacing: .07em; color: var(--muted); max-width: 240px; }
.ms-btn .val { font-weight: 700; color: var(--ink); letter-spacing: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.ms-btn.on { border-color: var(--brand); background: var(--brand-soft); }
.ms-btn .info { color: var(--brand); display: inline-grid; }
.ms-btn .i { width: 14px; height: 14px; }
.ms-pop { position: absolute; top: calc(100% + 6px); left: 0; width: 290px; max-height: 380px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .16); z-index: 50; }
.ms-pop .input { border-radius: 12px 12px 0 0; border: 0; border-bottom: 1px solid var(--line); }
.ms-list { overflow-y: auto; padding: 6px; }
.ms-list label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; cursor: pointer; color: var(--ink); }
.ms-list label:hover { background: var(--surface-2); }
.ms-list input { accent-color: var(--brand); }
.ms-foot { display: flex; justify-content: space-between; padding: 8px; border-top: 1px solid var(--line); }
.clear-filters { font: 700 12px var(--sans); color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: underline; }

/* ---------------- KPIs ---------------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand); }
.kpi .k { font-size: 10.5px; letter-spacing: .1em; font-weight: 800; color: var(--muted); text-transform: uppercase; }
.kpi .v { font-size: 26px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -.01em; }
.kpi .n { font-size: 11.5px; color: var(--muted); }
.kpi.na .v { color: var(--muted); font-size: 20px; }

/* ---------------- dashboard grid ---------------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(360px, 1fr); gap: 16px; }
.map-card { padding: 12px 14px; display: flex; flex-direction: column; }
.map { width: 100%; height: 540px; }
.map-tools { display: flex; gap: 8px; align-items: center; }
.charts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.chart { width: 100%; height: 300px; }
.chart-card .card-h { margin-bottom: 4px; }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t th { text-align: left; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr:hover td { background: var(--surface-2); }
table.t.craval th { background: var(--brand); color: #fff; }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell i { display: block; height: 6px; border-radius: 0 3px 3px 0; background: var(--brand); opacity: .85; }

/* ---------------- CRAVALAI panel ---------------- */
.ai-dock, .ai-full { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.ai-dock { height: 612px; }
.ai-full { height: calc(100vh - 140px); min-height: 560px; }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, color-mix(in srgb, var(--teal) 9%, var(--surface)), var(--surface)); }
.ai-head .t { font-family: var(--serif); font-size: 21px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.ai-head .s { font-size: 11.5px; color: var(--muted); }
.ai-head .acts { margin-left: auto; display: flex; gap: 6px; }
.ai-avatar { position: relative; width: 46px; height: 46px; display: grid; place-items: center; flex: none; }
.ai-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--teal); color: #fff; border-radius: 14px 14px 4px 14px; padding: 9px 13px; max-width: 88%; font-weight: 600; }
.msg .meta { font-size: 10.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; letter-spacing: .04em; }
.msg .meta .i { width: 13px; height: 13px; }
.answer { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 14px 14px 14px; padding: 13px 14px; display: flex; flex-direction: column; gap: 10px; }
.answer .a-title { font-weight: 800; color: var(--ink); font-size: 14px; }
.answer .a-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 800; letter-spacing: .07em; padding: 3px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text); text-transform: uppercase; }
.tag.real { background: var(--brand-soft); color: var(--brand-strong); }
.tag.demo { background: var(--amber-soft); color: var(--amber); }
.answer .headline { color: var(--ink); font-size: 14px; line-height: 1.55; }
.answer ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.answer li { font-size: 13px; }
.answer .ai-narr { border-left: 3px solid var(--brand); padding-left: 10px; font-size: 13.5px; color: var(--ink); }
.notice { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; padding: 8px 10px; border-radius: 9px; background: var(--surface-3); color: var(--text); }
.notice.demo { background: var(--amber-soft); color: var(--amber); }
.notice .i { width: 15px; height: 15px; margin-top: 1px; }
.mini-kpis { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-kpis div { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; }
.mini-kpis b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.mini-kpis span { font-size: 9.5px; letter-spacing: .08em; font-weight: 800; color: var(--muted); }
.sources { border-top: 1px dashed var(--line-strong); padding-top: 8px; display: grid; gap: 4px; font-size: 11.5px; }
.sources .src { display: flex; gap: 8px; align-items: baseline; }
.sources .src b { font-size: 10px; letter-spacing: .08em; min-width: 172px; color: var(--muted); }
.sources .src.on b { color: var(--brand-strong); }
.a-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.a-actions .btn { padding: 5px 9px; font-size: 11.5px; border-radius: 8px; }
.a-actions .btn .i { width: 15px; height: 15px; }
.a-chart { width: 100%; height: 230px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 6px 11px; font: 600 12px var(--sans); cursor: pointer; text-align: left; }
.suggestions button:hover { border-color: var(--brand); color: var(--brand-strong); }
.transcript { border: 1px solid var(--brand); background: var(--brand-soft); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.transcript .lbl { font-size: 10.5px; font-weight: 800; letter-spacing: .1em; color: var(--brand-strong); text-transform: uppercase; }
.ai-input { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.ai-input .bar { display: flex; gap: 8px; align-items: flex-end; }
.ai-input textarea { flex: 1; min-height: 44px; max-height: 140px; resize: none; font: 600 13.5px var(--sans); padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); outline: none; }
.ai-input textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.mic-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: grid; place-items: center; cursor: pointer; position: relative; flex: none; }
.mic-btn.on { background: var(--red); color: #fff; border-color: var(--red); }
.mic-btn.on::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--red); opacity: .5; animation: ring 1.2s ease-out infinite; }
.send-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.voice-opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); }
.voice-opts label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.voice-opts input { accent-color: var(--brand); }
.voice-opts select { font: 700 11px var(--sans); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 2px 4px; }
.player { display: flex; gap: 6px; align-items: center; }
.player .icon-btn { width: 30px; height: 30px; border-radius: 8px; }
.player .icon-btn .i { width: 15px; height: 15px; }
.thinking { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12.5px; }

/* emblem & states */
.emblem { display: block; overflow: visible; }
.emblem-sm { display: grid; place-items: center; width: 40px; height: 40px; }
.state-listening .em-pulse circle { animation: pulse 1.4s ease-out infinite; }
.state-listening .em-pulse circle:nth-child(2) { animation-delay: .7s; }
.state-listening .em-bars rect { transform-origin: bottom; transform-box: fill-box; animation: bars .6s ease-in-out infinite alternate; }
.state-listening .em-bars rect:nth-child(2) { animation-delay: .15s; }
.state-listening .em-bars rect:nth-child(3) { animation-delay: .3s; }
.state-listening .em-bars rect:nth-child(4) { animation-delay: .45s; }
.state-listening .em-nodes circle { animation: blink 0.9s ease-in-out infinite alternate; }
.state-listening .emblem { transform: scale(calc(1 + var(--level, 0) * .18)); transition: transform .08s linear; }
.state-thinking .em-ring { transform-origin: 60px 60px; animation: spin 1.3s linear infinite; }
.state-speaking .em-bars rect { transform-origin: bottom; transform-box: fill-box; animation: bars .45s ease-in-out infinite alternate; }
.state-speaking .em-bars rect:nth-child(odd) { animation-delay: .2s; }
@keyframes pulse { 0% { r: 50; opacity: .55; } 100% { r: 64; opacity: 0; } }
@keyframes ring { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes bars { from { transform: scaleY(.55); } to { transform: scaleY(1.05); } }
@keyframes blink { from { opacity: .45; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(300deg); } }
.listen-banner { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--red); font-size: 13px; }
.level { display: flex; gap: 3px; align-items: center; height: 18px; }
.level i { width: 3px; border-radius: 2px; background: var(--red); height: calc(4px + var(--h, 0) * 14px); transition: height .08s; }

/* ask page */
.ask-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
.ask-side { display: flex; flex-direction: column; gap: 16px; }
.ask-side .map { height: 440px; }
.ctx-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* map page */
.map-page { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.map-card.big .map { height: calc(100vh - 210px); min-height: 520px; }
.map-list { max-height: calc(100vh - 186px); overflow-y: auto; }

/* ---------------- import wizard ---------------- */
.steps { display: flex; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.steps div { flex: 1; padding: 10px 8px; text-align: center; font: 800 11px var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); border-right: 1px solid var(--line); position: relative; }
.steps div:last-child { border-right: 0; }
.steps div.done { color: var(--brand-strong); background: var(--brand-soft); }
.steps div.cur { color: #fff; background: var(--brand); }
.steps b { display: block; font-size: 16px; }
.drop { border: 2px dashed var(--line-strong); border-radius: 16px; padding: 42px 16px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop .big { font-size: 16px; font-weight: 800; color: var(--ink); margin-top: 10px; }
.url-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; font: 700 13px var(--sans); color: var(--ink); }
.url-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: Consolas, monospace; }
.summary-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.sum { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface); }
.sum b { display: block; font-size: 24px; color: var(--ink); font-variant-numeric: tabular-nums; }
.sum span { font-size: 10.5px; letter-spacing: .08em; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.sum.good { border-color: color-mix(in srgb, var(--brand) 45%, transparent); background: var(--brand-soft); }
.sum.good b { color: var(--brand-strong); }
.sum.bad b { color: var(--red); }
.sum.warn b { color: var(--amber); }
.sum.total { background: var(--teal); border-color: var(--teal); }
.sum.total b, .sum.total span { color: #fff; }
.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.map-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.map-row .fname { font: 800 12px var(--sans); color: var(--ink); letter-spacing: .03em; }
.map-row .req { color: var(--red); font-size: 10px; margin-left: 4px; }
.map-row.ok .fname::after { content: ' ✓'; color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 8px 12px; font: 800 11.5px var(--sans); letter-spacing: .06em; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; text-transform: uppercase; }
.tabs button.active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.status { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; }
.status.COMPLETED { background: var(--brand-soft); color: var(--brand-strong); }
.status.ROLLED_BACK, .status.FAILED { background: var(--red-soft); color: var(--red); }
.status.IN_PROGRESS { background: var(--amber-soft); color: var(--amber); }

/* ---------------- reports / kb / methodology ---------------- */
.two-col { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 16px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 12px; }
.fmt-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fmt-pick button { border: 1px solid var(--line-strong); background: var(--surface); padding: 9px 4px; border-radius: 10px; font: 800 12px var(--sans); color: var(--ink); cursor: pointer; }
.fmt-pick button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.scope-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.meth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.meth { border-left: 4px solid var(--brand); }
.meth h3 { color: var(--brand-strong); margin-bottom: 8px; }
.meth p { margin: 0; font-size: 14px; line-height: 1.65; }
.src-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.src-bars div { background: var(--brand-bright); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; padding: 12px; border-radius: 8px; text-align: center; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ---------------- modal & toast ---------------- */
.modal-host { position: fixed; inset: 0; background: rgba(8, 20, 20, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 14px; }
.modal .mh { display: flex; justify-content: space-between; align-items: center; }
.toast-host { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 110; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 380px; animation: tin .2s ease-out; }
.toast.err { background: var(--red); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------------- Stage 2: authentication screens ---------------- */
.auth { position: fixed; inset: 0; z-index: 90; background: var(--bg); overflow-y: auto; }
.auth-wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, 1fr); min-height: 100%; }
.auth-brand {
  position: relative; overflow: hidden; color: #fff; padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(1200px 600px at 110% 110%, rgba(52, 179, 106, .22), transparent 60%), radial-gradient(900px 500px at -10% -20%, rgba(224, 69, 58, .16), transparent 60%), linear-gradient(160deg, #0E3336 0%, #0A2527 60%, #061a1b 100%);
}
.auth-brand::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .07); box-shadow: 0 0 0 60px rgba(255, 255, 255, .025), 0 0 0 140px rgba(255, 255, 255, .02); }
.auth-brand-top { display: flex; align-items: center; gap: 14px; }
.auth-brand-top .wordmark { font-size: 32px; }
.auth-brand-mid { max-width: 520px; position: relative; z-index: 1; }
.auth-tag { font-size: 11px; letter-spacing: .22em; color: #8CC63F; font-weight: 800; }
.auth-brand-mid h1 { color: #fff; font-size: clamp(34px, 4vw, 52px); line-height: 1.05; margin: 18px 0 14px; }
.auth-brand-mid p { color: var(--side-text); font-size: 16px; margin: 0; }
.auth-side { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.auth-card h2 { font-size: 26px; }
.auth-sub { margin: -6px 0 0; font-size: 13.5px; }
.auth-link { font-size: 13px; font-weight: 700; text-align: center; }
.auth-secure { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.auth-secure .i { width: 14px; height: 14px; }
.btn.block { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.notice.err { background: var(--red-soft); color: var(--red); }
.notice.ok { background: var(--brand-soft); color: var(--brand-strong); }
.stage-badge.secure .dot { background: #34B36A; box-shadow: 0 0 0 3px rgba(52, 179, 106, .2); }

/* user menu */
.user-menu { position: relative; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; font: 800 13px var(--sans); color: #fff; background: linear-gradient(135deg, var(--teal), var(--brand)); letter-spacing: .04em; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 270px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .18); padding: 8px; z-index: 60; display: flex; flex-direction: column; }
.user-pop-h { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-pop-h b { color: var(--ink); }
.user-pop-h span { font-size: 12px; color: var(--muted); }
.user-pop-h .tag { align-self: flex-start; }
.user-pop a, .user-pop button { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--ink); font: 600 13px var(--sans); cursor: pointer; text-align: left; }
.user-pop a:hover, .user-pop button:hover { background: var(--surface-2); }
.tag.role-SUPER_ADMIN { background: #3b1414; color: #ffd9d6; }
:root[data-theme="light"] .tag.role-SUPER_ADMIN { background: #FBEAEA; color: #9E1B1B; }
.tag.role-ADMIN { background: var(--teal); color: #fff; }
.tag.role-ANALYST { background: var(--brand-soft); color: var(--brand-strong); }
.tag.role-CLIENT { background: #E8F0FA; color: #1F5E99; }
.tag.role-VIEWER { background: var(--surface-3); color: var(--text); }
:root[data-theme="dark"] .tag.role-CLIENT { background: #16314a; color: #9cc8f0; }
.tag.crit { background: var(--red-soft); color: var(--red); }
.kpi.alert::before { background: var(--red); }
.kpi.alert .v { color: var(--red); }

/* administration */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.client-card { display: flex; flex-direction: column; gap: 12px; }
.client-card.off { opacity: .7; }
dl.grants { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
dl.grants dt { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
dl.grants dd { margin: 0; color: var(--ink); }
.warn-text { color: var(--amber); font-weight: 700; }
.modal.wide { width: min(860px, 100%); }
fieldset.grant-group { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 14px; margin: 0; }
fieldset.grant-group legend { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-strong); padding: 0 6px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; max-height: 190px; overflow-y: auto; margin-top: 6px; }
.check-grid .check { font-size: 12.5px; }
.check.all { margin-bottom: 4px; }
table.t.audit td.detail { white-space: normal; font-family: Consolas, monospace; font-size: 11px; color: var(--muted); max-width: 520px; }
.empty-scope { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 40px 16px; }
.empty-scope .i { width: 34px; height: 34px; color: var(--amber); }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-brand { padding: 24px 20px; min-height: 220px; }
  .auth-brand-mid h1 { font-size: 30px; }
}
@media (max-width: 1560px) {
  .universe-switch button { padding: 7px 10px; }
  .universe-switch button small { display: none; }
  .logo-frame { width: 120px; height: 33px; }
  .logo-frame img { width: 147px; left: -13px; top: -56px; }
  .top { gap: 10px; padding: 10px 18px; flex-wrap: wrap; }
  .top-right { gap: 8px; }
}
@media (max-width: 1350px) {
  .kpi .v { font-size: 22px; }
  .dataset-switch button { padding: 8px 9px; font-size: 9.5px; }
  .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .universe-switch button small { display: none; }
}
@media (max-width: 1100px) {
  .dash-grid, .ask-grid, .map-page, .two-col { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ai-full { height: 70vh; }
  .top { flex-wrap: wrap; }
  .map-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .app.menu-open .side { transform: none; }
  .icon-btn.menu-btn { display: inline-grid; }
  .top { padding: 10px 16px; gap: 10px; }
  .top-right { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .universe-switch { order: 5; width: 100%; overflow-x: auto; }
  .view { padding: 16px 16px 32px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts-grid, .meth-grid, .summary-grid, .src-bars { grid-template-columns: 1fr 1fr; }
  .map { height: 380px; }
  .import-btn { order: -1; }
  .logo-frame { width: 120px; height: 33px; }
  .logo-frame img { width: 147px; left: -13px; top: -56px; }
  .map-row { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .charts-grid, .meth-grid, .src-bars { grid-template-columns: 1fr; }
  .kpi .v { font-size: 21px; }
  .dataset-switch button { padding: 7px 8px; font-size: 9.5px; }
}
