:root {
  color-scheme: light;
  --bg: oklch(98.5% 0.004 248);
  --canvas: oklch(97.4% 0.006 248);
  --surface: oklch(100% 0 0);
  --surface-soft: oklch(95.5% 0.009 248);
  --surface-warm: oklch(91.5% 0.012 96);
  --sidebar: oklch(96.6% 0.009 248);

  --fg: oklch(33% 0.020 248);
  --fg-subtle: oklch(49.47% 0.0202 248.24);
  --muted: oklch(53% 0.017 248);
  --muted-warm: oklch(55% 0.0239 76.41);

  --border: oklch(88.5% 0.010 248);
  --border-strong: oklch(76% 0.014 248);

  --accent: oklch(65.09% 0.0649 249.58);
  --accent-hover: oklch(58% 0.070 249);
  --accent-soft: oklch(93.5% 0.021 249);
  --accent-ink: oklch(43% 0.058 249);

  --success: oklch(60% 0.080 155);
  --success-soft: oklch(94.5% 0.026 155);
  --success-ink: oklch(41% 0.072 155);
  --warning: oklch(62% 0.050 76);
  --warning-soft: oklch(94% 0.022 76);
  --warning-ink: oklch(45% 0.055 76);
  --danger: oklch(55% 0.090 28);
  --danger-soft: oklch(95% 0.022 28);
  --danger-ink: oklch(46% 0.115 28);

  --profit: oklch(48% 0.125 27);
  --profit-soft: oklch(95.5% 0.022 27);
  --loss: oklch(45% 0.085 155);
  --loss-soft: oklch(95.5% 0.026 155);

  --font-display: "SF Pro Display", "Geist Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-body: "SF Pro Text", "Geist Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Geist Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-card: 0 1px 2px color-mix(in oklch, var(--fg) 7%, transparent);
  --shadow-popover: 0 10px 30px color-mix(in oklch, var(--fg) 14%, transparent);
  --shadow-modal: 0 24px 70px color-mix(in oklch, var(--fg) 22%, transparent);
  --ease-out: cubic-bezier(0.175, 0.885, 0.32, 1.06);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;
  --sidebar-w: 208px;
  --topbar-h: 56px;
}

html[data-gaincolor="green-up"] {
  --profit: oklch(45% 0.085 155);
  --profit-soft: oklch(95.5% 0.026 155);
  --loss: oklch(48% 0.125 27);
  --loss-soft: oklch(95.5% 0.022 27);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font-body); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { min-height: 100%; margin: 0; font-size: 14px; line-height: 1.5; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg { max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; }
::selection { background: var(--accent-soft); color: var(--fg); }
:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.gain { color: var(--profit); }
.loss { color: var(--loss); }
.flat { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; background: var(--surface); }
html[data-nav="collapsed"] .app { grid-template-columns: 64px minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--border);
  padding: 12px 10px 10px; z-index: 40; min-width: 0;
}
.brand { display: flex; align-items: center; gap: 9px; height: 44px; padding: 0 6px; text-decoration: none; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; flex: 0 0 24px; border: 1px solid var(--fg); border-radius: 5px; position: relative; overflow: hidden; }
.brand-mark::before { content: ""; position: absolute; inset: 4px; border-left: 1px solid var(--fg); border-bottom: 1px solid var(--fg); }
.brand-mark::after { content: ""; position: absolute; left: 8px; top: 5px; width: 6px; height: 6px; background: var(--accent); }
.brand-text { min-width: 0; }
.brand-name { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand-sub { display: block; margin-top: 1px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); letter-spacing: 0.06em; white-space: nowrap; }
.nav-scroll { flex: 1; overflow-y: auto; margin-top: 10px; scrollbar-width: none; }
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-group { margin-bottom: 6px; }
.nav-label { padding: 6px 8px 4px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; white-space: nowrap; }
.nav-link { display: flex; align-items: center; gap: 9px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--fg-subtle); font-size: 13px; font-weight: 500; white-space: nowrap; text-decoration: none; transition: background var(--dur-fast), color var(--dur-fast); }
.nav-link:hover { background: color-mix(in oklch, var(--surface) 76%, transparent); color: var(--fg); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-link .nav-ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.82; }
.nav-link.active .nav-ico { opacity: 1; }
.nav-link .nav-count { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 6px 2px; }
.sidebar-week { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.sidebar-week strong { color: var(--fg); font-family: var(--font-mono); font-size: 11px; }
.nav-collapse { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 30px; margin-top: 8px; border: 1px solid var(--border); background: transparent; border-radius: var(--radius-sm); color: var(--muted); font-size: 11px; }
.nav-collapse:hover { background: var(--surface); color: var(--fg); }
html[data-nav="collapsed"] .brand-text,
html[data-nav="collapsed"] .nav-label,
html[data-nav="collapsed"] .nav-link span,
html[data-nav="collapsed"] .sidebar-week span,
html[data-nav="collapsed"] .nav-collapse span { display: none; }
html[data-nav="collapsed"] .brand { justify-content: center; padding: 0; }
html[data-nav="collapsed"] .nav-link { justify-content: center; padding: 0; }
html[data-nav="collapsed"] .sidebar-week { justify-content: center; }
html[data-nav="collapsed"] .nav-collapse { justify-content: center; }

.workspace { min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); flex: 0 0 var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: color-mix(in oklch, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-crumb .sep { color: var(--border-strong); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-week { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface); color: var(--fg-subtle); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.topbar-week .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.topbar-week.frozen .dot { background: var(--success); }
.avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface-soft); color: var(--fg-subtle); display: grid; place-items: center; font-size: 11px; font-weight: 600; }
.nav-toggle { display: none; }
.main { padding: 22px 28px 56px; min-width: 0; flex: 1; }
.page { max-width: 1420px; margin: 0 auto; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head-main { min-width: 0; }
.page-title { font-family: var(--font-display); font-size: 27px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.page-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 7px; color: var(--muted); font-size: 12.5px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dot-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.btn:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--fg); border-color: var(--fg); color: oklch(98% 0 0); }
.btn.primary:hover { background: oklch(27% 0.02 248); border-color: oklch(27% 0.02 248); color: oklch(98% 0 0); }
.btn.accent { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn.accent:hover { background: oklch(38% 0.058 249); border-color: oklch(38% 0.058 249); color: #fff; }
.btn.danger { border-color: color-mix(in oklch, var(--danger) 55%, var(--border)); color: var(--danger-ink); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--fg-subtle); }
.btn.ghost:hover { background: var(--surface-soft); color: var(--fg); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
.btn.lg { height: 40px; padding: 0 16px; font-size: 14px; }
.btn.block { width: 100%; }
.btn .ico { width: 14px; height: 14px; }
.btn-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--accent-ink); font-size: 12.5px; font-weight: 550; padding: 0; text-decoration: none; }
.btn-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg-subtle); }
.icon-btn:hover { background: var(--surface-soft); color: var(--fg); border-color: var(--border-strong); }
.icon-btn .ico { width: 15px; height: 15px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); min-width: 0; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 0; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.panel-body { padding: 14px 16px 16px; min-width: 0; }
.panel-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.panel-link { font-size: 12px; color: var(--muted); }
.panel-link:hover { color: var(--accent-ink); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 7px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--surface-soft); color: var(--fg-subtle); font-size: 10.5px; font-weight: 550; white-space: nowrap; }
.badge.accent { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 30%, var(--border)); color: var(--accent-ink); }
.badge.warn { background: var(--warning-soft); border-color: color-mix(in oklch, var(--warning) 35%, var(--border)); color: var(--warning-ink); }
.badge.ok { background: var(--success-soft); border-color: color-mix(in oklch, var(--success) 32%, var(--border)); color: var(--success-ink); }
.badge.danger { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 32%, var(--border)); color: var(--danger-ink); }
.badge.demo { font-family: var(--font-mono); letter-spacing: 0.03em; }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); }
.seg button { height: 26px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--fg-subtle); font-size: 11.5px; font-weight: 550; white-space: nowrap; }
.seg button:hover { color: var(--fg); background: color-mix(in oklch, var(--surface) 70%, transparent); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 1px color-mix(in oklch, var(--fg) 8%, transparent); }

.kpi-band { display: grid; grid-template-columns: 1.18fr 1fr 1fr 1fr 0.9fr; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--border); gap: 1px; overflow: hidden; }
.kpi { background: var(--surface); padding: 13px 16px 12px; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.kpi-label { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.kpi-value { font-family: var(--font-display); font-size: 29px; line-height: 1.05; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-value.nav { font-size: 40px; letter-spacing: -0.035em; }
.kpi-value .unit { margin-left: 2px; font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-foot { display: flex; align-items: center; gap: 6px; min-height: 17px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.kpi-foot .gain, .kpi-foot .loss { font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; }
.baseline-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 9px; padding: 0 2px; color: var(--muted); font-size: 11.5px; }
.baseline-note strong { font-weight: 600; color: var(--fg-subtle); font-variant-numeric: tabular-nums; }
.baseline-note .quiet { color: var(--muted-warm); }

.layout-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-9 { grid-column: span 9; }

.chart-card .panel-head { padding-bottom: 8px; }
.chart-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chart-toolbar .select { height: 28px; font-size: 11.5px; }
.chart-legend { display: flex; align-items: center; gap: 14px; padding: 0 16px 4px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 16px; height: 2px; background: var(--fg); }
.legend-swatch.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px); }
.legend-swatch.dd { height: 7px; background: color-mix(in oklch, var(--muted-warm) 38%, transparent); border-top: 1px solid var(--muted-warm); }
.chart-host { position: relative; padding: 0 6px 0 2px; min-width: 0; }
.chart-host svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-note { padding: 2px 16px 12px; color: var(--muted); font-size: 11px; }
.chart-tip { position: absolute; z-index: 4; pointer-events: none; min-width: 128px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-popover); padding: 7px 9px; font-size: 11px; line-height: 1.55; }
.chart-tip strong { display: block; font-family: var(--font-mono); font-size: 11px; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.chart-tip .row b { color: var(--fg); font-weight: 550; font-variant-numeric: tabular-nums; }
.chart-empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 12px; }

.rail { display: grid; gap: 16px; }
.rail-card { padding: 14px 16px; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail-title { font-size: 13px; font-weight: 600; }
.rail-sub { margin-top: 2px; color: var(--muted); font-size: 11px; }
.ratio-row { display: grid; grid-template-columns: 58px 1fr 52px; align-items: center; gap: 8px; margin-top: 11px; }
.ratio-label { color: var(--fg-subtle); font-size: 11.5px; white-space: nowrap; }
.ratio-val { text-align: right; font-family: var(--font-mono); font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; }
.bar-track { height: 6px; background: var(--surface-soft); border-radius: 1px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--fg-subtle); border-radius: 0; transition: width var(--dur-base); }
.bar-fill.accent { background: var(--accent); }
.bar-fill.soft { background: var(--border-strong); }
.bar-target { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--muted-warm); }
.cash-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border); }
.cash-line span { color: var(--muted); font-size: 11.5px; }
.cash-line strong { font-family: var(--font-mono); font-size: 16px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.formula { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 9px; }
.formula summary { cursor: pointer; color: var(--muted); font-size: 11px; list-style: none; }
.formula summary::-webkit-details-marker { display: none; }
.formula summary::before { content: "＋"; display: inline-block; width: 12px; color: var(--border-strong); }
.formula[open] summary::before { content: "－"; }
.formula p { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.formula code { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-subtle); background: var(--surface-soft); padding: 1px 4px; border-radius: 3px; }

.todo-list { display: grid; gap: 8px; margin-top: 10px; }
.todo { display: flex; align-items: flex-start; gap: 8px; font-size: 11.5px; color: var(--fg-subtle); line-height: 1.45; }
.todo .dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; flex: 0 0 6px; background: var(--warning); }
.todo.done .dot { background: var(--success); }
.todo a { color: var(--fg-subtle); }
.todo small { display: block; color: var(--muted); font-size: 10.5px; }

.summary-card { padding: 0; overflow: hidden; }
.summary-top { padding: 13px 16px 11px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.summary-week { font-family: var(--font-mono); font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.summary-date { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.summary-body { padding: 10px 16px 12px; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 11.5px; }
.summary-row span { color: var(--muted); }
.summary-row b { font-family: var(--font-mono); font-weight: 550; font-variant-numeric: tabular-nums; }
.summary-row .unprovided { color: var(--muted-warm); font-family: var(--font-body); font-size: 10.5px; }
.summary-foot { padding: 10px 16px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pin-hint { color: var(--muted); font-size: 10.5px; }

.alloc-list { display: grid; gap: 10px; margin-top: 14px; }
.alloc-row { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px 42px 46px; gap: 8px; align-items: center; font-size: 11.5px; }
.alloc-name { color: var(--fg-subtle); white-space: nowrap; }
.alloc-bar { position: relative; height: 8px; background: var(--surface-soft); border-radius: 1px; overflow: visible; }
.alloc-fill { height: 100%; background: var(--fg-subtle); border-radius: 0; }
.alloc-target { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--surface); border-left: 1px solid var(--muted-warm); }
.alloc-pct { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.alloc-dev { text-align: right; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.alloc-dev.over { color: var(--muted-warm); }
.alloc-legend { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 10.5px; flex-wrap: wrap; }
.alloc-legend .tick { display: inline-block; width: 1px; height: 9px; background: var(--muted-warm); margin-right: 4px; vertical-align: -1px; }

.attr-list { display: grid; gap: 8px; margin-top: 13px; }
.attr-row { display: grid; grid-template-columns: 66px minmax(0, 1fr) 62px; gap: 8px; align-items: center; font-size: 11.5px; }
.attr-label { color: var(--fg-subtle); white-space: nowrap; }
.attr-track { height: 7px; background: var(--surface-soft); position: relative; border-radius: 1px; }
.attr-track .zero { position: absolute; top: -2px; bottom: -2px; width: 1px; background: var(--border-strong); }
.attr-bar { position: absolute; top: 0; height: 7px; border-radius: 0; }
.attr-bar.pos { background: color-mix(in oklch, var(--profit) 72%, var(--surface)); }
.attr-bar.neg { background: color-mix(in oklch, var(--loss) 62%, var(--surface)); }
.attr-val { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11px; }
.attr-total { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.attr-total b { color: var(--fg); font-family: var(--font-mono); font-weight: 600; }

.mini-list { display: grid; margin-top: 6px; }
.mini-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.mini-row:last-child { border-bottom: 0; }
.mini-row:hover { background: var(--surface-soft); text-decoration: none; }
.mini-date { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.mini-main { min-width: 0; }
.mini-title { font-size: 11.5px; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { margin-top: 1px; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-amt { text-align: right; font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; min-width: 760px; font-size: 12.5px; }
.data-table.compact { min-width: 560px; }
.data-table th { height: 32px; padding: 0 12px; text-align: left; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid var(--border); white-space: nowrap; background: color-mix(in oklch, var(--surface-soft) 55%, var(--surface)); }
.data-table td { height: 42px; padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--dur-fast); }
.data-table tbody tr:hover { background: var(--surface-soft); }
.data-table tbody tr.selected { background: var(--accent-soft); }
.data-table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table .td-main { font-weight: 550; }
.data-table .td-sub { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.data-table .action-cell { text-align: right; white-space: nowrap; }
.data-table tr.clickable { cursor: pointer; }
.data-table .row-btn { border: 0; background: transparent; padding: 2px 4px; color: var(--accent-ink); font-size: 11.5px; }
.data-table .row-btn:hover { text-decoration: underline; }

.type-tag { display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface-soft); color: var(--fg-subtle); font-size: 10px; font-weight: 550; white-space: nowrap; }
.type-tag.buy { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 28%, var(--border)); color: var(--accent-ink); }
.type-tag.sell { background: var(--surface-warm); border-color: color-mix(in oklch, var(--muted-warm) 30%, var(--border)); color: var(--muted-warm); }
.type-tag.green { background: var(--success-soft); border-color: color-mix(in oklch, var(--success) 28%, var(--border)); color: var(--success-ink); }
.type-tag.red { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 26%, var(--border)); color: var(--danger-ink); }
.type-tag.gray { background: var(--surface-soft); color: var(--fg-subtle); }

.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--fg-subtle); white-space: nowrap; }
.status-badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--success); }
.status-badge.void::before { background: var(--border-strong); }
.status-badge.warn::before { background: var(--warning); }
.status-badge.fail::before { background: var(--danger); }
.status-badge.pending::before { background: var(--border-strong); }

.toolbar { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .field { min-width: 0; }
.toolbar .grow { flex: 1 1 180px; }
.toolbar .spacer { flex: 1 1 auto; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { color: var(--muted); font-size: 10.5px; font-weight: 550; letter-spacing: 0.02em; }
.input, .select, .textarea {
  width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font-size: 12.5px; min-width: 0;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.textarea { height: auto; min-height: 74px; padding: 8px 9px; resize: vertical; line-height: 1.5; }
.select { padding-right: 6px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 22%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in oklch, var(--danger) 16%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-soft); color: var(--muted); cursor: not-allowed; }
.input.sm, .select.sm { height: 28px; font-size: 11.5px; }
.field-error { color: var(--danger-ink); font-size: 10.5px; line-height: 1.4; }
.field-help { color: var(--muted); font-size: 10.5px; line-height: 1.4; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

.callout { border: 1px solid var(--border); background: var(--surface-soft); border-radius: var(--radius-md); padding: 11px 12px; color: var(--fg-subtle); font-size: 11.5px; line-height: 1.55; }
.callout.warm { background: var(--surface-warm); border-color: color-mix(in oklch, var(--muted-warm) 26%, var(--border)); color: var(--muted-warm); }
.callout.info { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 25%, var(--border)); color: var(--accent-ink); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in oklch, var(--danger) 26%, var(--border)); color: var(--danger-ink); }
.callout strong { font-weight: 600; }
.callout .btn { margin-top: 8px; }

.empty { padding: 30px 18px; text-align: center; }
.empty-title { font-size: 13px; font-weight: 600; }
.empty-copy { max-width: 44ch; margin: 5px auto 0; color: var(--muted); font-size: 11.5px; line-height: 1.55; }
.empty .btn { margin-top: 12px; }

.kv { display: grid; gap: 8px; }
.kv-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.step-btn { display: flex; align-items: center; gap: 9px; padding: 10px 12px; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--fg-subtle); }
.step-btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-soft); }
.step-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.step-btn[aria-current="step"] { border-color: var(--fg); background: var(--fg); color: oklch(98% 0 0); }
.step-num { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mono); font-size: 10.5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--fg-subtle); }
.step-btn[aria-current="step"] .step-num { border-color: color-mix(in oklch, #fff 50%, transparent); color: #fff; background: transparent; }
.step-btn.done .step-num { background: var(--success-soft); border-color: color-mix(in oklch, var(--success) 40%, var(--border)); color: var(--success-ink); }
.step-name { font-size: 12px; font-weight: 600; white-space: nowrap; }
.step-sub { display: block; margin-top: 1px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.step-btn[aria-current="step"] .step-sub { color: color-mix(in oklch, #fff 72%, transparent); }

.cause-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.cause-option { position: relative; display: flex; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.cause-option:hover { border-color: var(--border-strong); background: var(--surface-soft); }
.cause-option input { position: absolute; opacity: 0; }
.cause-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent) 18%, transparent); background: var(--surface); }
.cause-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.cause-title { font-size: 11.5px; font-weight: 600; }
.cause-desc { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.impact { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); padding: 10px 12px; }
.impact-row { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; padding: 3px 0; }
.impact-row span { color: var(--muted); }
.impact-row b { font-family: var(--font-mono); font-weight: 550; }

.quote-table { min-width: 680px; }
.quote-price { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.quote-row-failed { background: var(--danger-soft) !important; }
.manual-val { width: 110px; height: 28px; font-family: var(--font-mono); }
.manual-flag { color: var(--muted-warm); font-size: 10px; }

.snapshot-card { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-md); overflow: hidden; }
.snapshot-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.snapshot-id { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.snapshot-body { padding: 12px 14px; }
.snapshot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 16px; }
.snapshot-item span { display: block; color: var(--muted); font-size: 10px; }
.snapshot-item strong { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.snapshot-foot { padding: 9px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10.5px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-copy { min-width: 0; }
.toggle-title { font-size: 12.5px; font-weight: 550; }
.toggle-desc { margin-top: 2px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.switch { position: relative; width: 34px; height: 20px; flex: 0 0 34px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background var(--dur-fast); pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.18); transition: transform var(--dur-fast); }
.switch input:checked + span { background: var(--fg); }
.switch input:checked + span::after { transform: translateX(14px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.45; }
.switch input:disabled { cursor: not-allowed; }

.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-track { flex: 1; height: 6px; background: var(--surface-soft); border-radius: 1px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); }
.progress-val { font-family: var(--font-mono); font-size: 11px; min-width: 38px; text-align: right; }

.target-grid { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.target-grid .tg-row { display: grid; grid-template-columns: 90px 1fr 1fr 1.2fr; gap: 8px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 11.5px; }
.target-grid .tg-row:last-child { border-bottom: 0; }
.target-grid .tg-head { background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.target-grid .tg-row .num { text-align: right; }
.target-input { width: 66px; height: 28px; text-align: right; font-family: var(--font-mono); }

.drawer-root { position: fixed; inset: 0; z-index: 80; display: flex; justify-content: flex-end; }
.drawer-scrim { position: absolute; inset: 0; background: color-mix(in oklch, oklch(20% 0.02 248) 38%, transparent); animation: fadeIn var(--dur-base) var(--ease-out); }
.drawer-panel { position: relative; width: min(620px, 100%); height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-modal); display: flex; flex-direction: column; animation: slideIn var(--dur-slow) var(--ease-out); }
.drawer-panel.wide { width: min(680px, 100%); }
.drawer-head { flex: 0 0 auto; padding: 16px 20px 13px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.drawer-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.drawer-sub { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; min-height: 0; }
.drawer-foot { flex: 0 0 auto; padding: 12px 20px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: flex-end; gap: 8px; background: var(--surface); }
.drawer-foot .left { margin-right: auto; color: var(--muted); font-size: 11px; }

.modal-root { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal-scrim { position: absolute; inset: 0; background: color-mix(in oklch, oklch(20% 0.02 248) 42%, transparent); animation: fadeIn var(--dur-base); }
.modal { position: relative; width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal); animation: popIn var(--dur-slow) var(--ease-out); }
.modal-head { padding: 16px 18px 8px; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 0 18px 16px; color: var(--fg-subtle); font-size: 12.5px; line-height: 1.6; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-popover); font-size: 12px; line-height: 1.45; animation: toastIn var(--dur-base) var(--ease-out); }
.toast .dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 5px; flex: 0 0 6px; background: var(--success); }
.toast.error .dot { background: var(--danger); }
.toast.warn .dot { background: var(--warning); }
.toast strong { display: block; font-size: 12px; font-weight: 600; }
.toast p { margin-top: 1px; color: var(--muted); font-size: 11px; }

.form-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section-title { margin-bottom: 10px; font-size: 11.5px; font-weight: 600; color: var(--fg-subtle); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.seg-cats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.cat-btn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg-subtle); font-size: 11.5px; font-weight: 550; text-align: left; }
.cat-btn:hover { background: var(--surface-soft); border-color: var(--border-strong); }
.cat-btn[aria-pressed="true"] { border-color: var(--fg); background: var(--fg); color: #fff; }
.cat-btn .cat-idx { font-family: var(--font-mono); font-size: 9px; opacity: 0.55; }
.preview-box { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); padding: 10px 12px; }
.preview-title { font-size: 10.5px; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 7px; }
.preview-row { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 3px 0; }
.preview-row span { color: var(--muted); }
.preview-row b { font-family: var(--font-mono); font-weight: 550; font-variant-numeric: tabular-nums; text-align: right; }
.draft-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; margin-bottom: 12px; border: 1px solid color-mix(in oklch, var(--warning) 30%, var(--border)); background: var(--warning-soft); color: var(--warning-ink); border-radius: var(--radius-sm); font-size: 10.5px; }
.draft-chip button { border: 0; background: none; color: inherit; text-decoration: underline; font-size: 10.5px; padding: 0; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.settings-card { padding: 16px; }
.settings-card h2 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.settings-card .desc { color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: 0; }
.settings-row label { font-size: 12px; color: var(--fg-subtle); }
.settings-row .input, .settings-row .select { width: 150px; height: 30px; }

.big-number { font-family: var(--font-display); font-size: 32px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); }
.metric-row b { font-family: var(--font-mono); font-weight: 550; font-variant-numeric: tabular-nums; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.stat-tile { background: var(--surface); padding: 12px 14px; }
.stat-tile span { display: block; color: var(--muted); font-size: 10.5px; }
.stat-tile strong { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: 19px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.index-page { max-width: 980px; margin: 0 auto; padding: 48px 24px 64px; }
.index-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.index-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.index-hero { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 32px; padding: 40px 0 30px; align-items: end; }
.index-title { font-family: var(--font-display); font-size: 42px; line-height: 1.08; font-weight: 600; letter-spacing: -0.035em; }
.index-lead { max-width: 56ch; margin-top: 14px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.index-actions { display: flex; align-items: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.index-stats { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; display: grid; gap: 9px; }
.index-stat { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.index-stat span { color: var(--muted); }
.index-stat b { font-family: var(--font-mono); font-weight: 550; font-variant-numeric: tabular-nums; }
.index-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin-top: 24px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--border); overflow: hidden; }
.index-link { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 11px 14px; background: var(--surface); color: var(--fg); text-decoration: none; }
.index-link:hover { background: var(--surface-soft); text-decoration: none; }
.index-num { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.index-name { font-size: 12.5px; font-weight: 550; }
.index-desc { margin-top: 1px; color: var(--muted); font-size: 10.5px; }
.index-go { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.index-note { margin-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.6; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.mobile-scrim { display: none; }
#nav-scrim { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes popIn { from { transform: translateY(6px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1279px) {
  .main { padding: 20px 22px 48px; }
  .kpi-value { font-size: 26px; }
  .kpi-value.nav { font-size: 36px; }
  .span-3 { grid-column: span 4; }
  .span-4 { grid-column: span 6; }
  .span-5 { grid-column: span 6; }
  .span-7 { grid-column: span 6; }
  .span-8 { grid-column: span 12; }
}

@media (max-width: 1023px) {
  .app, html[data-nav="collapsed"] .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: 100vh;
    transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease-out);
    box-shadow: var(--shadow-modal); border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand-text, .sidebar .nav-label, .sidebar .nav-link span, .sidebar .sidebar-week span, .sidebar .nav-collapse span { display: block; }
  .sidebar .nav-link { justify-content: flex-start; padding: 0 8px; }
  .sidebar .brand { justify-content: flex-start; padding: 0 6px; }
  .sidebar .nav-collapse { display: none; }
  .nav-toggle { display: inline-grid; }
  #nav-scrim.open { display: block; position: fixed; inset: 0; z-index: 35; background: color-mix(in oklch, oklch(20% 0.02 248) 38%, transparent); }
  .topbar { padding: 0 18px; }
  .main { padding: 18px 18px 44px; }
  .kpi-band { grid-template-columns: repeat(3, 1fr); }
  .kpi-value { font-size: 28px; }
  .kpi-value.nav { font-size: 38px; }
  .span-4, .span-5, .span-3, .span-6, .span-7 { grid-column: span 12; }
  .layout-grid { gap: 14px; }
  .rail { grid-template-columns: 1fr 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .index-hero { grid-template-columns: 1fr; gap: 20px; }
  .index-page { padding-top: 28px; }
  .index-title { font-size: 36px; }
}

@media (max-width: 760px) {
  .topbar { height: 52px; flex-basis: 52px; padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .topbar-week { display: none; }
  .topbar .avatar { display: none; }
  .main { padding: 14px 14px 40px; }
  .page-head { margin-bottom: 14px; gap: 12px; }
  .page-title { font-size: 23px; }
  .page-sub { font-size: 11.5px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .kpi-band { grid-template-columns: 1fr; }
  .kpi { padding: 11px 14px; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; row-gap: 1px; }
  .kpi-value { font-size: 25px; text-align: right; }
  .kpi-value.nav { font-size: 34px; }
  .kpi-foot { grid-column: 1 / -1; justify-content: flex-end; }
  .baseline-note { font-size: 10.5px; gap: 6px 10px; }
  .rail { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .step-btn { padding: 8px 10px; }
  .step-sub { display: inline; margin-left: 6px; }
  .form-grid, .field-row, .field-row.three { grid-template-columns: 1fr; }
  .seg-cats { grid-template-columns: 1fr 1fr; }
  .cause-grid { grid-template-columns: 1fr; }
  .drawer-panel, .drawer-panel.wide { width: 100%; }
  .drawer-body { padding: 14px 14px; }
  .drawer-head { padding: 12px 14px; }
  .drawer-foot { padding: 10px 14px; }
  .toolbar { padding: 10px 12px; }
  .toolbar .field { flex: 1 1 140px; }
  .toolbar .spacer { display: none; }
  .alloc-row { grid-template-columns: 42px minmax(0, 1fr) 42px 38px 44px; gap: 6px; }
  .data-table th, .data-table td { padding-left: 10px; padding-right: 10px; }
  .snapshot-grid { grid-template-columns: 1fr 1fr; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .index-list { grid-template-columns: 1fr; }
  .index-page { padding: 20px 16px 48px; }
  .index-title { font-size: 30px; }
  .index-hero { padding: 28px 0 22px; }
  .target-grid .tg-row { grid-template-columns: 62px 1fr 1fr 1.4fr; gap: 5px; padding: 8px; font-size: 10.5px; }
  .target-input { width: 54px; }
  .toast-root { right: 12px; bottom: 12px; }
}

@media (max-width: 520px) {
  .topbar .btn .btn-label { display: none; }
  .topbar .btn { width: 32px; padding: 0; }
  .page-title { font-size: 22px; }
  .panel-head { padding: 12px 12px 0; }
  .panel-body { padding: 12px; }
  .chart-legend { padding: 0 12px 4px; gap: 10px; }
  .chart-note { padding: 2px 12px 10px; }
  .summary-top, .summary-body, .summary-foot { padding-left: 12px; padding-right: 12px; }
  .rail-card { padding: 12px; }
  .kpi-value { font-size: 23px; }
  .kpi-value.nav { font-size: 31px; }
  .alloc-row { grid-template-columns: 40px minmax(0, 1fr) 40px; }
  .alloc-dev, .alloc-legend { display: none; }
  .attr-row { grid-template-columns: 58px minmax(0, 1fr) 56px; }
  .mini-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .settings-card { padding: 12px; }
  .index-stats { padding: 12px; }
  .snapshot-grid { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .sidebar, .topbar, .drawer-root, .toast-root, .mobile-scrim { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
}

.asset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.asset-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.asset-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.asset-name { font-size: 13px; font-weight: 600; }
.asset-desc { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.asset-mark { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-soft); color: var(--fg-subtle); font-family: var(--font-mono); font-size: 10px; }
.asset-value { font-family: var(--font-display); font-size: 27px; line-height: 1.1; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.asset-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.asset-meta span { display: block; color: var(--muted); font-size: 10px; }
.asset-meta b { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 11.5px; font-weight: 550; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 16px; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.form-actions .left { margin-right: auto; color: var(--muted); font-size: 11px; }
.sum-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-soft); font-size: 12px; }
.sum-line b { font-family: var(--font-mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.section-title { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: -0.01em; }
.quote-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.quote-line:last-child { border-bottom: 0; }
.quote-code { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.quote-val { font-family: var(--font-mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.note-list { display: grid; gap: 6px; margin-top: 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.note-list li { padding-left: 12px; position: relative; }
.note-list li::before { content: "·"; position: absolute; left: 2px; color: var(--border-strong); }

@media (max-width: 1023px) {
  .asset-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .asset-grid { grid-template-columns: 1fr; }
  .asset-meta { grid-template-columns: repeat(3, 1fr); }
}
.warn-text { color: var(--warning-ink); }
.bench-table { width: 100%; min-width: 0; table-layout: fixed; font-size: 11.5px; }
.bench-table th, .bench-table td { padding-left: 8px; padding-right: 8px; height: 36px; }
.bench-table th:first-child, .bench-table td:first-child { width: 36%; }
.bench-table .td-sub { font-size: 9.5px; }
@media (max-width: 520px) {
  .alloc-row { grid-template-columns: 42px minmax(0, 1fr) 44px; row-gap: 2px; }
  .alloc-row .alloc-pct:last-child { display: none; }
}

.session-connection { display:flex; gap:16px; align-items:center; flex-wrap:wrap; padding:12px 24px; border-bottom:1px solid var(--border); background:var(--bg); color:var(--fg); }

/* Extra aggregate KPIs share each row without leaving empty grid cells. */
.kpi-band-extended{display:flex;flex-wrap:wrap}.kpi-band-extended>.kpi{flex:1 0 calc(25% - 1px);min-width:0}.attribution-chart text{fill:var(--muted)}
@media(max-width:760px){.kpi-band-extended>.kpi{flex-basis:100%}}

.kpi-band:has(>.kpi:only-child){grid-template-columns:1fr}

@media(max-width:640px){.attribution-chart text{font-size:20px}}

.account-tags{display:block;margin-top:4px;color:var(--muted);font-size:12px}

.topbar-right .account-session .btn{width:auto;min-width:80px;white-space:nowrap}
