/* Signal — app stylesheet. Tokens first; light is the default, dark follows the OS. */

@font-face { font-family: 'Hanken Grotesk'; src: url('../fonts/hanken-grotesk.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/space-grotesk.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }

:root {
  --chrome: #0B0B0C;            /* sidebar, mobile bar, system title/status bar */
  --accent: #B2F415;
  --accent-ink: #0B0B0C;
  --bg: #F1F1F0;
  --card: #FFFFFF;
  --soft: #FAFAF9;
  --track: #F0F1EE;
  --line: #E6E7E4;
  --line-strong: #D9DAD6;
  --ink: #0A0A0A;
  --ink-2: #3A3D42;
  --muted: #6C6F73;
  --faint: #9A9C9F;
  --neg: #C2372B;
  --neg-bg: #FCE9E7;
  --ok-bg: #EEF9D2;
  --hero: #0F0F12;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --pop: 0 20px 44px rgba(0, 0, 0, .16);
  --s1: #B2F415; --s2: #131316; --s3: #9BA0A6; --s4: #5C6169; --s5: #D2D5D9; --s6: #7C828A;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113; --card: #19191C; --soft: #1E1E22; --track: #26262A;
    --line: #2A2A2E; --line-strong: #3A3A3F;
    --ink: #F4F4F2; --ink-2: #D0D2D6; --muted: #A0A3A8; --faint: #7C7F85;
    --neg: #FF8A7D; --neg-bg: #3A1B18; --ok-bg: #2A3310; --hero: #0B0B0C;
    --shadow: none; --pop: 0 20px 44px rgba(0, 0, 0, .6);
    --s2: #F1F1F0; --s4: #6E737B; --s5: #44474D;
  }
}

* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { font-family: var(--body); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--chrome); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.01em; margin: 0; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.noscript { color: #fff; padding: 40px; text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- loading screen ---- */
.boot { position: fixed; inset: 0; background: var(--chrome); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; z-index: 100; }
.boot-bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.boot-bar span { display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--accent); animation: boot 1.1s ease-in-out infinite; }
@keyframes boot { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.loading { display: flex; align-items: center; justify-content: center; padding: 70px 0; }
.loading .boot-bar { background: var(--track); }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ---- buttons and forms ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; padding: 9px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; color: var(--ink); }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--card); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { color: var(--neg); border-color: var(--neg-bg); background: var(--neg-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--track); border-color: transparent; color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 7px; }
.btn-block { width: 100%; padding: 12px 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.input, select.input, textarea.input { width: 100%; background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 14px; color: var(--ink); min-width: 0; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(178, 244, 21, .35); }
.input-sm { padding: 6px 9px; font-size: 13px; border-radius: 8px; }
textarea.input { min-height: 96px; resize: vertical; }
.hint { font-size: 12px; color: var(--faint); }
.error { background: var(--neg-bg); color: var(--neg); border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.notice { background: var(--ok-bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); flex: none; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; font-size: 12px; color: var(--faint); }
.rules li { display: flex; align-items: center; gap: 6px; }
.rules li.ok { color: var(--ink); }
.rules li svg.i { width: 12px; height: 12px; }
.pw { position: relative; }
.pw .input { padding-right: 42px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 7px; background: var(--track); color: var(--muted); white-space: nowrap; }
.badge-accent { background: var(--accent); color: var(--accent-ink); }
.badge-warn { background: var(--neg-bg); color: var(--neg); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--track); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

/* ---- auth screens ---- */
.auth { min-height: 100%; background: var(--chrome); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(28px, env(safe-area-inset-top)) 18px 28px; gap: 22px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: #fff; }
.brand img { height: 26px; width: auto; display: block; }
.brand b { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; line-height: 1; display: block; }
.brand small { display: block; font-size: 10px; letter-spacing: .14em; color: rgba(255, 255, 255, .4); margin-top: 4px; text-transform: uppercase; }
.auth-card { width: 100%; max-width: 410px; background: var(--card); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card.wide { max-width: 760px; }
.auth-card h1 { font-size: 23px; }
.auth-foot { font-size: 12px; color: rgba(255, 255, 255, .45); text-align: center; }
.auth-foot a { color: rgba(255, 255, 255, .7); }
.prose { font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.prose h2 { font-size: 17px; margin: 26px 0 8px; color: var(--ink); }
.prose p, .prose ul, .prose table { margin: 0 0 12px; }
.prose ul { padding-left: 20px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 13px; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--soft); }

/* ---- app shell ---- */
.shell { display: flex; height: 100%; overflow: hidden; background: var(--chrome); }
.side { width: 252px; flex: none; background: var(--chrome); color: #fff; display: flex; flex-direction: column; height: 100%; border-right: 1px solid rgba(255, 255, 255, .07); padding-top: env(safe-area-inset-top); }
.side-brand { padding: 22px 20px 16px; }
.side-label { font-size: 10px; letter-spacing: .14em; color: rgba(255, 255, 255, .35); text-transform: uppercase; padding: 10px 22px 8px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .62); padding: 10px 14px; border-radius: 9px; font-size: 14px; font-weight: 500; text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.side-link:hover { background: rgba(255, 255, 255, .06); }
.side-link.on { color: var(--accent); background: rgba(178, 244, 21, .10); font-weight: 700; }
.side-link svg.i { width: 17px; height: 17px; }
.side-link .tag { margin-left: auto; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .4); border: 1px solid rgba(255, 255, 255, .18); border-radius: 5px; padding: 1px 5px; font-weight: 600; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .07); padding: 13px 14px calc(13px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.sync { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: rgba(255, 255, 255, .55); padding: 0 4px; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(178, 244, 21, .2); flex: none; }
.sync.off i { background: #8a8d92; box-shadow: none; }
.userchip { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; border-radius: 10px; padding: 6px 4px; min-width: 0; flex: 1; }
.userchip:hover { background: rgba(255, 255, 255, .06); }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; display: flex; align-items: center; justify-content: center; font: 700 11px var(--display); }
.userchip b { display: block; font-size: 12.5px; font-weight: 600; }
.userchip span span { display: block; font-size: 10.5px; color: rgba(255, 255, 255, .45); }
.side-foot .btn-ghost { color: rgba(255, 255, 255, .5); }
.side-foot .btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.switch { padding: 6px 14px 10px; position: relative; }
.switch-btn { width: 100%; display: flex; align-items: center; gap: 11px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09); border-radius: 11px; padding: 9px 11px; cursor: pointer; text-align: left; color: #fff; }
.switch-btn:hover { background: rgba(255, 255, 255, .09); }
.switch-btn.static { cursor: default; }
.switch-btn.static:hover { background: rgba(255, 255, 255, .05); }
.chip { width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font: 700 13px var(--display); }
.chip.dim { background: rgba(255, 255, 255, .12); color: #fff; }
.chip.sm { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; }
.switch-btn b, .switch-item b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.switch-btn small, .switch-item small { display: block; font-size: 11px; color: rgba(255, 255, 255, .45); line-height: 1.2; }
.switch-menu { position: absolute; left: 14px; right: 14px; top: calc(100% - 6px); z-index: 60; background: #17171A; border: 1px solid rgba(255, 255, 255, .12); border-radius: 12px; padding: 6px; box-shadow: 0 18px 40px rgba(0, 0, 0, .55); max-height: 60vh; overflow-y: auto; }
.switch-item { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; border-radius: 8px; padding: 8px 9px; cursor: pointer; text-align: left; color: #fff; text-decoration: none; }
.switch-item:hover, .switch-item.on { background: rgba(255, 255, 255, .08); }
.switch-item svg.i { color: var(--accent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; background: var(--bg); position: relative; }
.mobilebar { display: none; align-items: center; gap: 12px; background: var(--chrome); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.mobilebar .btn-ghost { color: #fff; }
.mobilebar .brand img { height: 20px; }
.mobilebar .brand b { font-size: 16px; }
.scrim { display: none; }
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 18px 30px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 27px; font-weight: 700; letter-spacing: -.02em; }
.topbar .sub { font-size: 13.5px; color: var(--muted); margin-top: 4px; }
.content { flex: 1; overflow-y: auto; padding: 24px 30px 60px; }
.content-narrow { max-width: 980px; }
.offline { background: var(--neg-bg); color: var(--neg); font-size: 12.5px; font-weight: 600; text-align: center; padding: 6px 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; flex-wrap: wrap; }
.card h2, .card-title { font-family: var(--display); font-weight: 600; font-size: 15px; }
.section-title { font-family: var(--display); font-weight: 600; font-size: 17px; margin: 26px 0 12px; }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg.i { width: 26px; height: 26px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--ink); font-family: var(--display); font-size: 16px; margin-bottom: 4px; }

.tabs { display: flex; gap: 4px; background: var(--track); border-radius: 10px; padding: 3px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 13px; border-radius: 8px; cursor: pointer; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tab.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 13px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.item:first-child { border-top: 0; }
.item b { font-weight: 600; }
.item-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--track); display: flex; align-items: center; justify-content: center; flex: none; color: var(--ink-2); }
.item .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
a.item { text-decoration: none; }
a.item:hover { background: var(--soft); }
.panel { background: var(--soft); border-top: 1px solid var(--line); padding: 18px 22px; }
.confirm { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--neg); }

/* ---- popovers ---- */
.pop-wrap { position: relative; }
.ctl { display: flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 12px; cursor: pointer; text-align: left; min-height: 42px; }
.ctl:hover { border-color: var(--faint); }
.ctl.on { border-color: var(--accent); }
.ctl small { display: block; font-size: 9.5px; letter-spacing: .08em; color: var(--faint); text-transform: uppercase; line-height: 1.15; }
.ctl b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.15; max-width: 180px; }
.ctl > svg.i:last-child { width: 12px; height: 12px; color: var(--faint); }
.pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 236px; max-width: min(320px, 92vw); background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; padding: 6px; box-shadow: var(--pop); max-height: min(440px, 70vh); overflow-y: auto; }
.pop.left { right: auto; left: 0; }
.pop-label { font-size: 10px; letter-spacing: .12em; color: var(--faint); text-transform: uppercase; padding: 8px 10px 5px; }
.pop-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: transparent; border: 0; border-radius: 8px; padding: 9px 10px; cursor: pointer; text-align: left; font-size: 13.5px; font-weight: 500; }
.pop-item:hover, .pop-item.on { background: var(--track); }
.pop-item.on { font-weight: 700; }
.pop-item small { display: block; font-size: 11px; color: var(--faint); font-weight: 400; }
.pop-item.danger { color: var(--neg); }
.pop-sep { border-top: 1px solid var(--line); margin: 5px 0; }
.pop-form { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.pop .check { padding: 6px 10px; border-radius: 8px; }
.pop .check:hover { background: var(--track); }

/* ---- dashboard widgets ---- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.w3 { grid-column: span 3; } .w4 { grid-column: span 4; } .w6 { grid-column: span 6; }
.w8 { grid-column: span 8; } .w9 { grid-column: span 9; } .w12 { grid-column: span 12; }
.widget { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); min-width: 0; position: relative; }
.widget.pad { padding: 20px 22px; }
.widget-title { font-family: var(--display); font-weight: 600; font-size: 15px; }
.widget-msg { color: var(--faint); font-size: 13px; padding: 18px 0 6px; }
.kpi { padding: 16px 17px; display: flex; flex-direction: column; gap: 11px; border-radius: 14px; }
.kpi-label { font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--muted); text-transform: uppercase; }
.kpi-value { font-family: var(--display); font-weight: 700; font-size: 27px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-foot { display: flex; align-items: center; gap: 8px; min-height: 22px; font-size: 11.5px; color: var(--faint); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; background: var(--track); color: var(--muted); }
.delta.pos { background: var(--accent); color: var(--accent-ink); }
.delta.neg { background: var(--neg-bg); color: var(--neg); }
.delta svg.i { width: 11px; height: 11px; stroke-width: 3; }

.trend-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.trend-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.trend-side { display: flex; flex-direction: column; gap: 11px; align-items: flex-end; max-width: 100%; }
.legend { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 7px; }
.legend i { width: 16px; height: 3px; border-radius: 2px; background: var(--ink); }
.legend i.dash { height: 0; border-top: 2px dashed var(--faint); background: none; }
.widget.hero { background: var(--hero); border-color: var(--hero); color: #fff; }
.hero .trend-sub, .hero .legend { color: rgba(255, 255, 255, .5); }
.hero .tabs { background: rgba(255, 255, 255, .07); }
.hero .tab { color: rgba(255, 255, 255, .62); }
.hero .tab.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.hero .legend i { background: var(--accent); }
.hero .legend i.dash { border-color: rgba(255, 255, 255, .55); background: none; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--body); font-size: 11px; fill: var(--faint); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .line-cmp { fill: none; stroke: var(--faint); stroke-width: 1.75; stroke-dasharray: 5 5; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { fill: var(--ink); stroke: var(--card); stroke-width: 2.5; }
.chart .area-top { stop-color: var(--ink); stop-opacity: .14; }
.chart .area-end { stop-color: var(--ink); stop-opacity: 0; }
.chart .col { fill: var(--ink); }
.chart .col-cmp { fill: var(--line-strong); }
.chart .guide { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }
.hero .chart text { fill: rgba(255, 255, 255, .5); }
.hero .chart .grid-line { stroke: rgba(255, 255, 255, .09); }
.hero .chart .line { stroke: var(--accent); }
.hero .chart .line-cmp { stroke: rgba(255, 255, 255, .55); }
.hero .chart .dot { fill: var(--accent); stroke: var(--hero); }
.hero .chart .area-top { stop-color: var(--accent); stop-opacity: .38; }
.hero .chart .area-end { stop-color: var(--accent); stop-opacity: .02; }
.hero .chart .col { fill: var(--accent); }
.hero .chart .col-cmp { fill: rgba(255, 255, 255, .25); }
.hero .chart .guide { stroke: rgba(255, 255, 255, .4); }
.tip { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: var(--card); border-radius: 9px; padding: 7px 10px; font-size: 12px; line-height: 1.4; white-space: nowrap; z-index: 5; box-shadow: var(--pop); }
.tip b { display: block; font-variant-numeric: tabular-nums; }
.tip span { opacity: .65; }
.hero .tip { background: #fff; color: #0A0A0A; }

.donut { display: flex; align-items: center; gap: 22px; margin-top: 16px; flex-wrap: wrap; }
.donut svg { width: 150px; height: 150px; flex: none; }
.donut .center { font: 700 19px var(--display); fill: var(--ink); }
.donut .center-sub { font: 400 10.5px var(--body); fill: var(--faint); }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; min-width: 180px; }
.donut-legend div { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.donut-legend i, .dot-sq { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend b { font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-legend em { font-style: normal; font-size: 12px; color: var(--faint); width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; flex-direction: column; gap: 13px; margin-top: 18px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-row > span { width: 148px; flex: none; font-size: 12.5px; color: var(--ink-2); }
.bar-track { flex: 1; height: 22px; background: var(--track); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; min-width: 2px; }
.bar-row > b { width: 78px; flex: none; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.c1 { background: var(--s1); } .c2 { background: var(--s2); } .c3 { background: var(--s3); }
.c4 { background: var(--s4); } .c5 { background: var(--s5); } .c6 { background: var(--s6); }
.k1 { stroke: var(--s1); } .k2 { stroke: var(--s2); } .k3 { stroke: var(--s3); }
.k4 { stroke: var(--s4); } .k5 { stroke: var(--s5); } .k6 { stroke: var(--s6); }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.data th { text-align: right; padding: 11px 16px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; user-select: none; background: var(--soft); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover, table.data th.on { color: var(--ink); }
table.data th svg.i { width: 11px; height: 11px; vertical-align: -1px; margin-left: 3px; }
table.data td { text-align: right; padding: 13px 16px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th.l, table.data td.l { text-align: left; }
table.data td.l { font-weight: 600; color: var(--ink); max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.data tbody tr:hover { background: var(--soft); }
table.data tfoot td { font-weight: 700; color: var(--ink); background: var(--soft); border-top: 2px solid var(--line-strong); border-bottom: 0; }
.table-foot { padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--faint); }
.text-widget { white-space: pre-wrap; color: var(--ink-2); font-size: 14px; line-height: 1.6; margin-top: 8px; }
.footnote { margin-top: 18px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 11.5px; color: var(--faint); flex-wrap: wrap; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- builder ---- */
.builder { display: flex; flex: 1; min-height: 0; }
.builder .content { padding-bottom: 80px; }
.inspector { width: 340px; flex: none; border-left: 1px solid var(--line); background: var(--card); overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.inspector h3 { font-size: 15px; }
.widget.editable { cursor: pointer; }
.widget.editable:hover { border-color: var(--faint); }
.widget.selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.widget-tools { position: absolute; top: 8px; right: 8px; display: none; gap: 2px; background: var(--card); border: 1px solid var(--line-strong); border-radius: 9px; padding: 2px; z-index: 4; box-shadow: var(--pop); color: var(--ink); }
.widget.editable:hover .widget-tools, .widget.selected .widget-tools { display: flex; }
.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette button { display: flex; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); cursor: pointer; font-size: 13px; font-weight: 600; text-align: left; }
.palette button:hover { border-color: var(--ink); }
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; padding: 5px 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.pick.on { background: var(--ink); border-color: var(--ink); color: var(--card); }
.pick sup { font-size: 9px; opacity: .7; }
.icon-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-pick button { aspect-ratio: 1; border: 1px solid var(--line-strong); background: var(--card); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.icon-pick button.on { background: var(--ink); border-color: var(--ink); color: var(--card); }
.map-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.map-table th { text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; }
.map-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.map-table td.sample { color: var(--faint); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- toast ---- */
.toasts { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600; box-shadow: var(--pop); max-width: 90vw; }
.toast.bad { background: var(--neg); color: #fff; }

/* ---- responsive ---- */
@media (max-width: 1180px) {
  .w3 { grid-column: span 6; } .w4 { grid-column: span 6; }
  .w8, .w9 { grid-column: span 12; }
  .inspector { width: 300px; }
}
@media (max-width: 900px) {
  .side { position: fixed; z-index: 90; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 80; }
  .mobilebar { display: flex; }
  .topbar { padding: 14px 16px; position: static; }
  .topbar h1 { font-size: 22px; }
  .content { padding: 16px 16px 60px; }
  .w6 { grid-column: span 12; }
  .builder { flex-direction: column; overflow-y: auto; }
  .builder .content { overflow: visible; flex: none; }
  .inspector { width: auto; border-left: 0; border-bottom: 1px solid var(--line); order: -1; overflow: visible; }
  .card-head, .item, .panel, .card-pad, .widget.pad { padding-left: 16px; padding-right: 16px; }
  .pop { right: auto; left: 0; }
}
@media (max-width: 560px) {
  .grid { gap: 10px; }
  .w4 { grid-column: span 12; }
  .kpi-value { font-size: 22px; }
  .kpi { padding: 13px 14px; }
  .bar-row > span { width: 96px; }
  .bar-row > b { width: 64px; }
  .auth-card { padding: 22px 18px; }
  .rules { grid-template-columns: 1fr; }
  .ctl b { max-width: 120px; }
}

/* ---- print / save as PDF ---- */
@media print {
  html, body { height: auto; background: #fff; }
  .side, .mobilebar, .topbar .controls, .toasts, .filters, .widget-tools, .offline, .inspector { display: none !important; }
  .shell, .main { display: block; height: auto; overflow: visible; background: #fff; }
  .content { overflow: visible; padding: 0; }
  .topbar { position: static; border: 0; padding: 0 0 14px; background: none; }
  .widget { break-inside: avoid; box-shadow: none; }
  .widget.hero, .delta.pos, .bar-fill, .donut svg, .chip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
