/* Macro Intelligence: design system. Dark financial-terminal look.
   Blue = information, green = bullish, red = bearish, gold = gold-related, purple = AI. */
:root {
  --bg: #060a13; --bg2: #08101e; --panel: #0c1322; --panel2: #111b2e; --panel3: #16223a; --line: #1a2540; --line2: #243150;
  --text: #e6ebf5; --text2: #c3cbdb; --muted: #8391ab; --faint: #5b6782;
  --blue: #3b82f6; --blue2: #1d4ed8; --green: #22c55e; --red: #ef4444; --gold: #f5b642; --purple: #a78bfa; --amber: #f59e0b; --cyan: #22d3ee;
  --green-bg: rgba(34, 197, 94, .12); --red-bg: rgba(239, 68, 68, .12); --blue-bg: rgba(59, 130, 246, .12);
  --gold-bg: rgba(245, 182, 66, .12); --purple-bg: rgba(167, 139, 250, .10); --amber-bg: rgba(245, 158, 11, .12);
  --r: 14px; --r-sm: 9px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --side-w: 236px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .tiny { font-size: 11px; }
.up { color: var(--green) !important; } .down { color: var(--red) !important; } .flat { color: var(--muted) !important; }
.goldc { color: var(--gold); } .aic { color: var(--purple); } .bluec { color: var(--blue); }
.spacer { flex: 1; }
.hide { display: none !important; }

/* ------------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, #0a1120, #070c17); border-right: 1px solid var(--line);
  padding: 18px 12px 14px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 30; }
.brand { display: flex; gap: 11px; align-items: center; padding: 2px 8px 20px; }
.brand img { width: 38px; height: 38px; }
.brand b { display: block; font-size: 15px; line-height: 1.15; } .brand small { color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--text2); font-weight: 500; font-size: 13.5px; }
.nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav a.on { background: linear-gradient(90deg, var(--blue2), var(--blue)); color: #fff; box-shadow: 0 6px 18px rgba(59, 130, 246, .25); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .foot { margin-top: auto; padding: 12px 8px 0; font-size: 11px; color: var(--muted); line-height: 1.55; border-top: 1px solid var(--line); }
.side .foot .row { display: flex; align-items: center; gap: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: rgba(6, 10, 19, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { font-size: 19px; }
.top .menu { display: none; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; width: 36px; height: 34px; cursor: pointer; }
.top .clock { font-family: var(--mono); font-size: 12px; color: var(--text2); }
.content { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.scrim { display: none; }

/* ------------------------------------------------------------------ status pills / badges */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line); color: var(--text2); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.LIVE, .pill.ok { color: var(--green); } .pill.LIVE .dot, .pill.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
.pill.STALE, .pill.warn { color: var(--amber); } .pill.STALE .dot, .pill.warn .dot { background: var(--amber); }
.pill.DISCONNECTED, .pill.NO_DATA, .pill.OFFLINE, .pill.ERROR, .pill.bad { color: #fca5a5; }
.pill.DISCONNECTED .dot, .pill.NO_DATA .dot, .pill.OFFLINE .dot, .pill.ERROR .dot, .pill.bad .dot { background: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.badge.demo, .badge.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid rgba(245, 158, 11, .35); }
.badge.real, .badge.ok { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34, 197, 94, .3); }
.badge.bad { background: var(--red-bg); color: #fca5a5; border: 1px solid rgba(239, 68, 68, .3); }
.badge.info { background: var(--blue-bg); color: #93c5fd; border: 1px solid rgba(59, 130, 246, .3); }
.badge.ai { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(167, 139, 250, .3); }
.badge.gold { background: var(--gold-bg); color: var(--gold); border: 1px solid rgba(245, 182, 66, .3); }
.badge.muted { background: var(--panel3); color: var(--muted); border: 1px solid var(--line); }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag.bull { background: var(--green-bg); color: var(--green); }
.tag.bear { background: var(--red-bg); color: var(--red); }
.tag.neut { background: rgba(131, 145, 171, .14); color: var(--text2); }
.tag.lg { font-size: 15px; padding: 5px 12px; border-radius: 9px; }
.conf { font-size: 11px; font-weight: 700; letter-spacing: .3px; color: var(--muted); }
.conf.HIGH, .conf.VERY.HIGH { color: var(--green); } .conf.MODERATE { color: var(--amber); } .conf.LOW { color: var(--muted); }
.imp { display: inline-block; min-width: 54px; text-align: center; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.imp.i3 { background: var(--red-bg); color: #fca5a5; } .imp.i2 { background: var(--amber-bg); color: var(--amber); } .imp.i1 { background: var(--panel3); color: var(--muted); }

/* ------------------------------------------------------------------ cards & grid */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; } .c12 { grid-column: span 12; }
.card { background: linear-gradient(180deg, var(--panel), #0a111f); border: 1px solid var(--line); border-radius: var(--r); min-width: 0;
  display: flex; flex-direction: column; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.card-h h3 { font-size: 14.5px; display: flex; align-items: center; gap: 9px; }
.card-h h3 .ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--blue-bg); color: var(--blue); }
.card-h h3 .ic svg { width: 15px; height: 15px; }
.card-h h3 .ic.gold { background: var(--gold-bg); color: var(--gold); } .card-h h3 .ic.ai { background: var(--purple-bg); color: var(--purple); }
.card-h h3 .ic.green { background: var(--green-bg); color: var(--green); } .card-h h3 .ic.red { background: var(--red-bg); color: var(--red); }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-b { padding: 4px 16px 16px; flex: 1; min-width: 0; }
.card.ai { border-color: rgba(167, 139, 250, .28); background: linear-gradient(180deg, rgba(167, 139, 250, .06), var(--panel) 60%); }
.card.goldish { border-color: rgba(245, 182, 66, .22); }
.foot-note { padding: 0 16px 14px; color: var(--faint); font-size: 11px; line-height: 1.5; }

/* KPI market cards */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; padding: 14px 16px 12px; border-radius: var(--r); border: 1px solid var(--line); background: linear-gradient(180deg, var(--panel), #0a111f);
  overflow: hidden; min-width: 0; }
.kpi.gold { border-color: rgba(245, 182, 66, .28); background: linear-gradient(160deg, rgba(245, 182, 66, .10), var(--panel) 55%); }
.kpi .name { color: var(--text2); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 24px; font-weight: 700; font-family: var(--mono); letter-spacing: -.02em; margin: 6px 0 2px; }
.kpi .chg { font-size: 12.5px; font-weight: 600; font-family: var(--mono); }
.kpi .meta { color: var(--faint); font-size: 10.5px; margin-top: 6px; line-height: 1.35; }
.kpi .spark { display: block; width: 100%; height: 34px; margin-top: 8px; opacity: .95; }
.kpi .bias { margin-top: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* horizon outlook tiles */
.horizons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.hz { background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 10px; text-align: center; min-width: 0; }
.hz small { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 7px; font-weight: 600; }
.hz .tag { font-size: 14px; }
.hz .conf { display: block; margin-top: 6px; }
.hz .score { display: block; font-family: var(--mono); color: var(--faint); font-size: 11px; margin-top: 2px; }
.hz.bull { border-color: rgba(34, 197, 94, .3); } .hz.bear { border-color: rgba(239, 68, 68, .3); }

/* key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13px; }
.kv > span:nth-child(odd) { color: var(--muted); }
.kv > span:nth-child(even) { text-align: right; font-family: var(--mono); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--text2); line-height: 1.45; }
.list li .b { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; margin-top: 1px; }
.list li .b.bull { background: var(--green-bg); color: var(--green); } .list li .b.bear { background: var(--red-bg); color: var(--red); }
.list li .b.neut { background: var(--panel3); color: var(--muted); } .list li .b.ai { background: var(--purple-bg); color: var(--purple); }
.list li .b.info { background: var(--blue-bg); color: var(--blue); }

/* diverging factor bars */
.fbars { display: flex; flex-direction: column; gap: 6px; }
.fbar { display: grid; grid-template-columns: 128px 1fr 58px; align-items: center; gap: 10px; font-size: 13px; padding: 4px 0; cursor: default; }
.fbar .lab { color: var(--text2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fbar .track { position: relative; height: 12px; background: var(--panel2); border-radius: 6px; }
.fbar .track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line2); }
.fbar .fill { position: absolute; top: 0; bottom: 0; border-radius: 6px; }
.fbar .fill.pos { left: 50%; background: linear-gradient(90deg, rgba(34, 197, 94, .55), var(--green)); }
.fbar .fill.neg { right: 50%; background: linear-gradient(270deg, rgba(239, 68, 68, .55), var(--red)); }
.fbar .v { text-align: right; font-family: var(--mono); font-weight: 600; }
.fbar.na .lab, .fbar.na .v { color: var(--faint); }
.fbar-axis { display: grid; grid-template-columns: 128px 1fr 58px; gap: 10px; font-size: 10.5px; color: var(--faint); }
.fbar-axis div { display: flex; justify-content: space-between; }

/* tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid rgba(26, 37, 64, .6); vertical-align: top; color: var(--text2); }
.tbl tr:hover td { background: rgba(17, 27, 46, .6); }
.tbl td.n, .tbl th.n { text-align: right; font-family: var(--mono); white-space: nowrap; }
.tbl .tt { color: var(--text); font-weight: 500; }

/* segmented controls / tabs / buttons */
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--blue); color: #fff; }
.seg.gold button.on { background: var(--gold); color: #1a1205; }
.btn { display: inline-flex; align-items: center; gap: 7px; background: var(--blue); color: #fff; border: 0; border-radius: 9px; padding: 8px 14px;
  font-weight: 700; font-size: 13px; cursor: pointer; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: wait; }
.btn.ghost { background: var(--panel2); color: var(--text2); border: 1px solid var(--line); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ai { background: linear-gradient(90deg, #7c3aed, var(--purple)); }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; font-size: 12.5px; font-weight: 600; padding: 0; }
select, input, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  font-family: inherit; font-size: 13px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--blue); }

/* empty / loading / notices */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted);
  padding: 26px 16px; font-size: 13px; border: 1px dashed var(--line2); border-radius: 11px; background: rgba(17, 27, 46, .35); }
.empty b { color: var(--text2); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }
.spin { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 11px; font-size: 13px; line-height: 1.45; }
.notice.warn { background: var(--amber-bg); border: 1px solid rgba(245, 158, 11, .3); color: #fcd34d; }
.notice.err { background: var(--red-bg); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; }
.notice.info { background: var(--blue-bg); border: 1px solid rgba(59, 130, 246, .28); color: #bfdbfe; }
.notice.ai { background: var(--purple-bg); border: 1px solid rgba(167, 139, 250, .28); color: #ddd6fe; }
.disclaimer { color: var(--faint); font-size: 11px; text-align: center; padding-top: 6px; }

/* charts */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 380px; } .chart-box.short { height: 220px; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text2); padding: 0 0 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-explain { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 8px; }
svg.curve text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* misc blocks */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.box { background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; min-width: 0; }
.box h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.box.bull { border-color: rgba(34, 197, 94, .25); } .box.bear { border-color: rgba(239, 68, 68, .25); } .box.ai { border-color: rgba(167, 139, 250, .25); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { color: var(--muted); font-size: 11.5px; } .stat .v { font-size: 20px; font-weight: 700; font-family: var(--mono); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.gauge { display: flex; align-items: center; gap: 14px; }
.verdict { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 11px; font-weight: 700; }
.verdict.agree { background: var(--green-bg); color: var(--green); } .verdict.disagree { background: var(--red-bg); color: #fca5a5; }
.verdict.neutral { background: var(--panel2); color: var(--text2); }
details.more summary { cursor: pointer; color: var(--blue); font-size: 12.5px; font-weight: 600; list-style: none; padding: 6px 0; }
details.more summary::-webkit-details-marker { display: none; }
.event-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(26, 37, 64, .6); font-size: 13px; }
.event-row:last-child { border-bottom: 0; }
.event-row .t { font-family: var(--mono); font-size: 12px; color: var(--text2); line-height: 1.3; }
.event-row .t small { display: block; color: var(--faint); font-size: 10.5px; }
.event-row .nm { color: var(--text); font-weight: 500; } .event-row .nm small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat .log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 16px 12px; }
.msg { padding: 11px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; max-width: 100%; }
.msg.me { background: var(--blue); color: #fff; align-self: flex-end; max-width: 80%; border-bottom-right-radius: 4px; }
.msg.ai { background: var(--purple-bg); border: 1px solid rgba(167, 139, 250, .25); border-bottom-left-radius: 4px; white-space: normal; }
.msg.ai h4 { margin: 10px 0 4px; font-size: 11px; color: var(--purple); text-transform: uppercase; letter-spacing: .5px; }
.msg.ai ul { margin: 0; padding-left: 18px; } .msg.ai li { margin: 2px 0; }
.msg.err { background: var(--red-bg); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; }
.msg .meta { color: var(--muted); font-size: 11px; margin-top: 8px; }
.chat form { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.chat textarea { flex: 1; resize: none; height: 44px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--panel2); border: 1px solid var(--line); color: var(--text2); border-radius: 999px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.chips button:hover { border-color: var(--purple); color: var(--text); }
.chips button.on { border-color: var(--purple); background: var(--purple-bg); color: var(--purple); }

/* ------------------------------------------------------------------ technical workspace */
.work { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 16px; min-height: calc(100vh - 120px); }
.chartcard { min-height: 560px; }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tool { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; font-weight: 600; }
.tool:hover { color: var(--text); } .tool.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.legend { font-family: var(--mono); font-size: 12px; color: var(--muted); padding: 7px 12px 0; min-height: 24px; }
.legend b { color: var(--text); font-weight: 600; }
.chartwrap { position: relative; flex: 1; min-height: 420px; margin: 0 4px 4px; }
#chart { position: absolute; inset: 0; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.banner { position: absolute; z-index: 4; left: 50%; top: 12px; transform: translateX(-50%); padding: 7px 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; display: none; max-width: 90%; text-align: center; }
.banner.show { display: block; }
.banner.warn { background: rgba(60, 40, 5, .9); color: var(--amber); border: 1px solid rgba(245, 158, 11, .4); }
.banner.err { background: rgba(60, 10, 10, .9); color: #fca5a5; border: 1px solid rgba(239, 68, 68, .4); }
.side-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.levels { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
.levels td { padding: 5px 0; border-top: 1px solid var(--line); }
.levels td:last-child { text-align: right; font-family: var(--mono); }
.note { color: var(--muted); font-size: 11.5px; line-height: 1.5; margin-top: 8px; }
.tech-chat .log { max-height: 460px; min-height: 160px; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(800px 400px at 20% 10%, rgba(59, 130, 246, .12), transparent), radial-gradient(600px 300px at 90% 90%, rgba(245, 182, 66, .08), transparent), var(--bg); }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login .brand { padding: 0 0 22px; }
.login h2 { font-size: 20px; margin-bottom: 4px; } .login p { color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.login input { width: 100%; margin-bottom: 12px; padding: 11px 12px; }
.login .btn { width: 100%; justify-content: center; padding: 11px; }
.login .error { color: #fca5a5; font-size: 12px; margin-bottom: 10px; min-height: 16px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1360px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1200px) {
  .c3, .c4 { grid-column: span 6; } .c5, .c7, .c8, .c9 { grid-column: span 12; } .c6 { grid-column: span 12; }
  .work { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 25; }
  .top .menu { display: inline-grid; place-items: center; }
  .top { padding: 10px 16px; } .content { padding: 14px 16px 30px; }
  .c3, .c4, .c6 { grid-column: span 12; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .stats { grid-template-columns: 1fr 1fr; }
  .top .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .fbar, .fbar-axis { grid-template-columns: 96px 1fr 48px; }
  .event-row { grid-template-columns: 76px 1fr; } .event-row > :last-child { grid-column: 2; }
  .chart-box { height: 240px; } .chartwrap { min-height: 340px; }
}

/* research chat page */
.card.research { height: calc(100vh - 150px); min-height: 520px; }
.card.research .chips { padding-top: 14px !important; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cal-day { margin: 14px 0 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.cal-day:first-child { margin-top: 0; }
.src-ok { color: var(--green); } .src-bad { color: #fca5a5; } .src-warn { color: var(--amber); }
.scen { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--panel2); }
.scen h4 { margin: 0 0 6px; font-size: 14px; }
.scen .chain { font-size: 12px; color: var(--text2); margin: 8px 0; }
.scen .cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.scen .cols b { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
@media (max-width: 900px) { .scen .cols { grid-template-columns: 1fr; } .card.research { height: auto; } .card.research .log { max-height: 60vh; } }
