/* ==========================================================================
   Commercial Report — styles
   Colour roles are tokens; dark mode redefines the same roles.
   ========================================================================== */

:root {
  color-scheme: light;
  --page: #f3f2ee;
  --surface: #fcfcfb;
  --surface-2: #f4f3ef;
  --surface-3: #ebeae4;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e7e6e0;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.08);
  --border-strong: rgba(11, 11, 11, 0.15);
  --shadow: 0 1px 2px rgba(20, 20, 10, 0.04), 0 6px 20px -12px rgba(20, 20, 10, 0.12);
  --band: #f0efea;
  --hover-wash: rgba(11, 11, 11, 0.035);

  /* data colours: blue = money / volume in, orange = money out */
  --c-in: #2a78d6;
  --c-out: #eb6834;
  --c-in-track: #cde2fb;
  --c-muted: #c9c8c0;

  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: rgba(42, 120, 214, 0.1);

  /* status (fixed) */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --bad-text: #b3261e;

  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222221;
    --surface-3: #2b2b29;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --band: #222221;
    --hover-wash: rgba(255, 255, 255, 0.05);
    --c-in: #3987e5;
    --c-out: #d95926;
    --c-in-track: #0d366b;
    --c-muted: #4a4a46;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --good-text: #0ca30c;
    --bad-text: #f07b7b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222221;
  --surface-3: #2b2b29;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --band: #222221;
  --hover-wash: rgba(255, 255, 255, 0.05);
  --c-in: #3987e5;
  --c-out: #d95926;
  --c-in-track: #0d366b;
  --c-muted: #4a4a46;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --good-text: #0ca30c;
  --bad-text: #f07b7b;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-2); }
.skip-link { position: absolute; left: 12px; top: -48px; background: var(--ink); color: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 28px;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px; }
.brand-mark {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 11px; background: var(--ink); color: var(--surface);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 12px; color: var(--ink-2); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px; margin: -12px 0 -8px 8px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); text-decoration: none;
}
.back-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back-link:hover { color: var(--accent-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background-color .15s, color .15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a .n { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav a.active .n { color: var(--accent-ink); }

.sidebar-foot {
  margin-top: auto; padding: 14px 10px 4px;
  border-top: 1px solid var(--border);
  display: grid; gap: 2px; font-size: 12.5px;
}
.foot-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
.foot-label:first-child { margin-top: 0; }

.main { min-width: 0; }
.content { max-width: 1240px; margin: 0 auto; padding: 32px 40px 72px; }

/* ---------- top bar & filters ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 22px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent-ink); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.topbar h1 { font-size: clamp(28px, 3.4vw, 38px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.lede { color: var(--ink-2); margin-top: 8px; font-size: 15px; max-width: 60ch; }
.topbar-actions { display: flex; gap: 8px; flex: none; }

.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 13.5px; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.icon-btn { width: 38px; padding: 0; }
.btn:hover, .icon-btn:hover { background: var(--surface-2); }
.btn svg, .icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-sm svg { width: 15px; height: 15px; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

.filterbar {
  position: sticky; top: 0; z-index: 15;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 -12px 8px; padding: 12px;
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}
.filter-label { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.filter-note { font-size: 13px; color: var(--ink-2); margin-left: 4px; }
.filter-note strong { color: var(--ink); font-weight: 600; }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: 11px;
}
.seg button {
  border: 0; background: transparent; color: var(--ink-2);
  font-weight: 500; font-size: 13px;
  padding: 6px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--border); }
.seg-sm { padding: 2px; border-radius: 9px; }
.seg-sm button { font-size: 12px; padding: 4px 10px; border-radius: 7px; }

.select, .input {
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 13px;
}
.select { padding-right: 30px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 15px;
}
.select.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- sections ---------- */
.section { padding-top: 36px; }
.section + .section { margin-top: 20px; border-top: 1px solid var(--border); }
.section-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.section-num {
  flex: none; margin-top: 3px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 7px;
}
.section-head h2 { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.section-head p { color: var(--ink-2); margin-top: 2px; }
.section > * + * { margin-top: 16px; }
.section > .section-head + * { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 0; }
.card-head h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }

/* ---------- overview ---------- */
.overview-top { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; }
.overview-bottom { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 16px; margin-top: 16px; }

.hero {
  padding: 22px 24px 20px;
  display: flex; flex-direction: column;
  background:
    radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--c-in) 11%, transparent), transparent 60%),
    var(--surface);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.hero-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.hero-label span { font-weight: 500; }
.hero-value { font-size: clamp(46px, 5.4vw, 62px); font-weight: 650; letter-spacing: -0.04em; line-height: 1; margin: 18px 0 10px; }
.hero-sub { color: var(--ink-2); font-size: 13px; }
.hero-spark { margin-top: auto; padding-top: 18px; }
.hero-spark-caption { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.tile-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.tile-label i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tile-value { font-size: 25px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; }
.tile-foot { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 2px 7px 2px 5px; border-radius: 999px; white-space: nowrap;
}
.delta svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.delta.good { color: var(--good-text); background: color-mix(in srgb, var(--good) 12%, transparent); }
.delta.bad { color: var(--bad-text); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.delta.flat { color: var(--ink-2); background: var(--surface-3); }

/* P&L */
.pnl { padding: 18px 20px 20px; display: flex; flex-direction: column; }
.pnl h3 { font-size: 15px; font-weight: 600; }
.pnl-rows { margin-top: 12px; display: grid; }
.pnl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.pnl-row .v { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.pnl-row .lbl { color: var(--ink-2); }
.pnl-row.sub { font-weight: 600; }
.pnl-row.sub .lbl { color: var(--ink); }
.pnl-row .pct { font-size: 11.5px; color: var(--ink-2); font-weight: 500; margin-left: 6px; }
.pnl-row.net { border-bottom: 0; border-top: 1.5px solid var(--ink); margin-top: 4px; padding-top: 12px; font-size: 16px; font-weight: 650; }
.pnl-row.net .lbl { color: var(--ink); }
.pnl-meter { margin-top: auto; padding-top: 16px; }
.pnl-meter-cap { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }

/* stat strip */
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { padding: 16px 20px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat:first-child { border-left: 0; }
.stat-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-foot { font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- charts ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 12px 20px 0; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.sw-line { display: inline-block; width: 16px; height: 2px; border-radius: 2px; }
.sw-rect { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sw-line.k-in, .sw-rect.k-in, .tip-key.k-in, .tile-label i.k-in { background: var(--c-in); }
.sw-line.k-out, .sw-rect.k-out, .tip-key.k-out, .tile-label i.k-out { background: var(--c-out); }

.chart-body { padding: 8px 12px 14px 6px; min-height: 120px; }
.chart-body svg { width: 100%; overflow: visible; }
.hb-body { padding: 16px 20px 20px; }
.chart-table { padding: 12px 0 6px; }

.grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.x-label { fill: var(--muted); font-size: 11px; }
.x-label.sel { fill: var(--ink); font-weight: 600; }
.band { fill: var(--band); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.k-in { stroke: var(--c-in); }
.line.k-out { stroke: var(--c-out); }
.area.k-in { fill: var(--c-in); opacity: .1; }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.k-in { fill: var(--c-in); }
.dot.k-out { fill: var(--c-out); }
.col { pointer-events: none; transition: opacity .2s; }
.col.k-in { fill: var(--c-in); }
.col.k-out { fill: var(--c-out); }
.col.k-muted { fill: var(--c-muted); }
.col.dim { opacity: .3; }
.hit { fill: transparent; cursor: crosshair; outline: none; }
.hit:hover, .hit.focus { fill: var(--hover-wash); }
.crosshair { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.end-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.peak-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.plot-overlay { fill: transparent; cursor: crosshair; outline: none; }

/* horizontal bars (HTML) */
.hb { display: grid; gap: 12px; }
.hb-row {
  display: grid; grid-template-columns: minmax(84px, 34%) minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 3px 6px; margin: -3px -6px; border-radius: 8px; cursor: default; outline: none;
}
.hb-row:hover, .hb-row:focus-visible { background: var(--hover-wash); }
.hb-label { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hb-bar {
  height: 14px; flex: none;
  width: calc((100% - 84px) * var(--p));
  min-width: 3px;
  border-radius: 0 4px 4px 0;
  transition: width .35s cubic-bezier(.2,.8,.2,1);
}
@media (prefers-reduced-motion: reduce) { .hb-bar { transition: none; } }
.hb-bar.k-in { background: var(--c-in); }
.hb-bar.k-out { background: var(--c-out); }
.hb-bar.k-muted { background: var(--c-muted); }
.hb-val { font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { padding: 28px 20px; text-align: center; color: var(--ink-2); font-size: 13px; }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

/* tooltip */
#tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  min-width: 160px; max-width: 280px;
  padding: 10px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: 11px;
  box-shadow: 0 12px 28px -10px rgba(0, 0, 0, 0.28);
  font-size: 12.5px;
}
.tip-title { color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; line-height: 1.7; }
.tip-row strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-row span:last-child { color: var(--ink-2); }
.tip-key { width: 12px; height: 2px; border-radius: 2px; }
.tip-row.sep { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

/* ---------- tables ---------- */
.table-card { overflow: hidden; }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 20px; }
.dt-search { position: relative; flex: 1 1 200px; max-width: 300px; }
.dt-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.dt-search .input { width: 100%; padding-left: 32px; }
.dt-spacer { flex: 1 1 auto; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-2);
  padding: 10px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.dt th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dt th button:focus-visible { outline: 2px solid var(--accent); border-radius: 4px; }
.dt th .arrow { width: 10px; opacity: .8; font-size: 10px; }
.dt th:first-child, .dt td:first-child { padding-left: 20px; }
.dt th:last-child, .dt td:last-child { padding-right: 20px; }
.dt td { padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr:hover td { background: var(--hover-wash); }
.dt .num { text-align: right; font-variant-numeric: tabular-nums; }
.dt th.num button { flex-direction: row-reverse; }
.dt .id { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.dt .strong { font-weight: 600; }
.dt .sub { display: block; font-size: 11.5px; color: var(--ink-2); }
.dt tfoot td { background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.dt-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--ink-2); }
.dt-foot strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface); cursor: pointer; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.pager button:hover:not(:disabled) { background: var(--surface-2); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .pg { padding: 0 8px; font-variant-numeric: tabular-nums; }

.dir { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.dir i { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; }
.dir i svg { width: 13px; height: 13px; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dir.in i { background: color-mix(in srgb, var(--c-in) 14%, transparent); }
.dir.in i svg { stroke: var(--c-in); }
.dir.out i { background: color-mix(in srgb, var(--c-out) 14%, transparent); }
.dir.out i svg { stroke: var(--c-out); }

/* status badges: colour on the icon, text stays ink */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 6px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
}
.badge svg { width: 14px; height: 14px; flex: none; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.badge.good { background: color-mix(in srgb, var(--good) 9%, var(--surface)); border-color: color-mix(in srgb, var(--good) 24%, transparent); }
.badge.good svg { stroke: var(--good); }
.badge.warning { background: color-mix(in srgb, var(--warning) 12%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 34%, transparent); }
.badge.warning svg { stroke: color-mix(in srgb, var(--warning) 80%, var(--ink)); }
.badge.serious { background: color-mix(in srgb, var(--serious) 11%, var(--surface)); border-color: color-mix(in srgb, var(--serious) 30%, transparent); }
.badge.serious svg { stroke: var(--serious); }
.badge.critical { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); border-color: color-mix(in srgb, var(--critical) 28%, transparent); }
.badge.critical svg { stroke: var(--critical); }
.badge.neutral svg { stroke: var(--muted); }

.stage { display: inline-flex; align-items: center; gap: 8px; }
.stage-dots { display: inline-flex; gap: 3px; }
.stage-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.stage-dots i.on { background: var(--c-in); box-shadow: none; }

.meter { height: 8px; border-radius: 999px; background: var(--c-in-track); overflow: hidden; }
.meter > span { display: block; height: 100%; width: calc(var(--p) * 100%); background: var(--c-in); border-radius: 999px; }
.meter.sm { height: 6px; width: 72px; display: inline-block; vertical-align: middle; }
.meter.sm > span { height: 6px; }
.meter-cell { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- settlement ---------- */
.fs-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.fs-list { display: flex; flex-direction: column; gap: 8px; }
.fs-item {
  all: unset; box-sizing: border-box; cursor: pointer;
  display: grid; gap: 8px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.fs-item:hover { border-color: var(--border-strong); }
.fs-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fs-item[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fs-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.fs-item-name { font-weight: 600; font-size: 13.5px; }
.fs-item-client { font-size: 12px; color: var(--ink-2); }
.fs-item-amt { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); display: flex; justify-content: space-between; }

.statement { padding: 28px 32px 30px; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.st-kicker { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: var(--accent-ink); }
.st-title { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; }
.st-company { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.st-no { text-align: right; display: grid; gap: 8px; justify-items: end; }
.st-no .id { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.st-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.st-meta div { display: grid; gap: 2px; min-width: 0; }
.st-meta span { font-size: 11.5px; color: var(--ink-2); }
.st-meta strong { font-size: 13.5px; font-weight: 600; }
.st-lines { margin-top: 8px; }
.st-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.st-row .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-row .lbl small { display: block; font-size: 12px; color: var(--ink-2); }
.st-row.less .lbl, .st-row.less .v { color: var(--ink-2); }
.st-row.total { font-weight: 650; border-bottom: 1.5px solid var(--ink); }
.st-row.grand {
  margin-top: 14px; padding: 16px 18px; border: 0; border-radius: 12px;
  background: var(--surface-2); font-size: 17px; font-weight: 650;
}
.st-row.outstanding { border: 0; padding: 10px 18px; font-weight: 600; }
.st-progress { margin-top: 22px; }
.st-progress-cap { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.st-progress-cap strong { color: var(--ink); }
.st-sign { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 34px; }
.st-sign div { border-top: 1px solid var(--border-strong); padding-top: 8px; font-size: 12px; color: var(--ink-2); }
.st-actions { display: flex; gap: 8px; }

/* ---------- payments ---------- */
.status-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-tile { padding: 16px 18px; display: grid; gap: 6px; }
.status-tile .top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.status-tile .top i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); }
.status-tile .top svg { width: 15px; height: 15px; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.status-tile .v { font-size: 24px; font-weight: 650; letter-spacing: -0.025em; }
.status-tile .s { font-size: 12px; color: var(--ink-2); }
.ic-in svg { stroke: var(--c-in); }
.ic-out svg { stroke: var(--c-out); }
.ic-warning svg { stroke: color-mix(in srgb, var(--warning) 80%, var(--ink)); }
.ic-critical svg { stroke: var(--critical); }

.page-foot { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 12.5px; display: grid; gap: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .overview-top, .overview-bottom { grid-template-columns: minmax(0, 1fr); }
  .status-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1020px) {
  .app { display: block; }
  .sidebar {
    position: sticky; top: 0; z-index: 30; height: auto;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; }
  .brand-text, .sidebar-foot, .back-link { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 7px 11px; }
  .nav a svg, .nav a .n { display: none; }
  .filterbar { position: static; }
  .content { padding: 24px 24px 56px; }
  html { scroll-padding-top: 64px; }
  .fs-layout { grid-template-columns: minmax(0, 1fr); }
  .fs-list { flex-direction: row; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
  .fs-item { flex: 0 0 250px; scroll-snap-align: start; }
}
@media (max-width: 760px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--border); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--border); }
  .st-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statement { padding: 22px 18px; }
  .st-sign { grid-template-columns: minmax(0, 1fr); gap: 26px; }
}
@media (max-width: 560px) {
  .content { padding: 18px 16px 48px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions { justify-content: flex-start; }
  .filterbar { margin: 0 0 8px; padding: 0 0 12px; gap: 8px; }
  .filter-label { display: none; }
  .filter-note { flex-basis: 100%; margin: 0; }
  .seg button { padding: 6px 10px; }
  .status-tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .tile, .status-tile { padding: 14px; }
  .tile-value { font-size: 21px; }
  .status-tile .v { font-size: 20px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 19px; }
  .card-head { padding: 16px 16px 0; flex-wrap: wrap; }
  .hb-body { padding: 14px 16px 18px; }
  .dt-toolbar { padding: 12px 16px; }
  .dt-search { max-width: none; flex-basis: 100%; }
  .dt th:first-child, .dt td:first-child { padding-left: 16px; }
  .dt-foot { padding: 12px 16px; }
  .hero { padding: 18px; }
  .st-row.grand { font-size: 15px; padding: 14px; }
}

/* ---------- print ---------- */
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light;
    --page: #fff; --surface: #fff; --surface-2: #f4f3ef; --surface-3: #ebeae4;
    --ink: #0b0b0b; --ink-2: #52514e; --grid: #e7e6e0; --axis: #c3c2b7;
    --border: rgba(11,11,11,.12); --border-strong: rgba(11,11,11,.2);
    --band: #f0efea; --c-in: #2a78d6; --c-out: #eb6834; --c-in-track: #cde2fb; --c-muted: #c9c8c0;
    --accent-ink: #1c5cab; --good-text: #006300; --bad-text: #b3261e;
  }
  body { background: #fff; font-size: 12px; }
  .app { display: block; }
  .sidebar, .topbar-actions, .view-toggle, .dt-toolbar, .pager, .st-actions, .skip-link, #tooltip { display: none !important; }
  .filterbar { position: static; padding: 0; margin: 0 0 8px; background: none; backdrop-filter: none; }
  .filterbar .seg, .filterbar .select, .filter-label { display: none; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .section { break-before: page; padding-top: 0; }
  .section:first-of-type { break-before: auto; }
  .section + .section { border-top: 0; }
  .fs-layout { grid-template-columns: minmax(0, 1fr); }
  .fs-list { display: none; }
  body.print-statement * { visibility: hidden; }
  body.print-statement #statement, body.print-statement #statement * { visibility: visible; }
  body.print-statement #statement { position: absolute; inset: 0 0 auto 0; border: 0; }
}

/* ==========================================================================
   Data sheet, notices, view switch
   ========================================================================== */
body[data-view="sheet"] .report-only { display: none !important; }
body:not([data-view="sheet"]) .sheet-view { display: none; }
.sheet-view { padding-top: 12px; }
.sheet-view > * + * { margin-top: 14px; }

.nav a.nav-sheet { margin-top: 12px; position: relative; }
.nav a.nav-sheet::before { content: ""; position: absolute; left: 10px; right: 10px; top: -7px; border-top: 1px solid var(--border); }

.notice {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 10px;
  border-radius: 12px; font-size: 13.5px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
}
.notice > svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent-ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notice .grow { flex: 1 1 260px; min-width: 0; }
.notice .grow strong { font-weight: 600; }
.notice .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.notice.local { background: color-mix(in srgb, var(--warning) 11%, var(--surface)); border-color: color-mix(in srgb, var(--warning) 36%, transparent); }
.notice.local > svg { stroke: color-mix(in srgb, var(--warning) 75%, var(--ink)); }

.btn-ghost { background: transparent; }
.btn.danger:hover { color: var(--bad-text); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--surface)); }

.sheet-bar { display: flex; }
.sheet-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.sheet-tabs::-webkit-scrollbar { display: none; }
@media (min-width: 761px) { .sheet-tabs { flex-wrap: wrap; overflow-x: visible; } } /* show every tab on wide screens */
.sheet-tabs button .cnt { margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.sheet-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 16px; }
.sheet-head h3 { font-size: 15px; font-weight: 600; margin-right: 6px; }
.sheet-head .count { font-size: 12.5px; color: var(--ink-2); }
.sheet-scroll { overflow: auto; max-height: min(68vh, 760px); border-top: 1px solid var(--border); overscroll-behavior: contain; }
table.sheet-grid { border-collapse: separate; border-spacing: 0; font-size: 13px; width: max-content; min-width: 100%; }
.sheet-grid th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--ink-2);
  text-align: left; font-weight: 500; font-size: 12px; white-space: nowrap;
  padding: 9px 10px; border-bottom: 1px solid var(--border-strong); border-right: 1px solid var(--border);
}
.sheet-grid th.num { text-align: right; }
.sheet-grid td { padding: 0; background: var(--surface); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.sheet-grid .rn {
  position: sticky; left: 0; z-index: 1;
  width: 46px; min-width: 46px; text-align: center;
  background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.sheet-grid th.rn { z-index: 3; }
.sheet-grid tbody tr:hover td { background: color-mix(in srgb, var(--surface) 95%, var(--ink)); }
.sheet-grid tbody tr:hover td.rn { background: var(--surface-3); }
.cell {
  display: block; width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 13px;
}
.cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); position: relative; z-index: 1; border-radius: 0; }
.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
select.cell { appearance: none; cursor: pointer; padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 13px; }
select.cell option { background: var(--surface); color: var(--ink); }
.cell.bad { box-shadow: inset 0 -2px 0 var(--critical); }
.del-btn {
  display: grid; place-items: center; width: 38px; height: 36px;
  border: 0; background: transparent; color: var(--ink-2); cursor: pointer; opacity: .45;
}
.del-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
tr:hover .del-btn, .del-btn:focus-visible { opacity: 1; }
.del-btn:hover { color: var(--bad-text); }
.sheet-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--ink-2); }
.sheet-empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }

.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; padding: 20px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field small { font-size: 11.5px; color: var(--muted); }
.field .input { width: 100%; }
.field.wide { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 120;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px); padding: 11px 14px 11px 16px;
  background: var(--ink); color: var(--surface); border-radius: 12px;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.45); font-size: 13px;
}
.toast[hidden] { display: none; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 650; text-decoration: underline; cursor: pointer; padding: 2px 4px; }

@media (max-width: 1020px) {
  .nav a.nav-sheet { margin-top: 0; }
  .nav a.nav-sheet::before { display: none; }
}
@media (max-width: 760px) {
  .settings-form { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .sheet-scroll { max-height: 70vh; }
}
@media (max-width: 560px) {
  .topbar-actions { flex-wrap: wrap; }
  .view-seg { flex: 1 1 100%; }
  .view-seg button { flex: 1; }
}
@media print {
  .sheet-view, .notice, .view-seg, .toast { display: none !important; }
}

/* ==========================================================================
   Daily report additions
   ========================================================================== */
.date-nav { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.date-input { height: 36px; font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: .45; cursor: default; }
.glance { margin-top: 18px; }
.dt td.wrap { white-space: normal; min-width: 200px; max-width: 360px; line-height: 1.4; }
.hero-sub strong { color: var(--ink); font-weight: 600; }
.hero-sub .delta { margin-left: 4px; }
.tile-foot .delta svg { width: 13px; height: 13px; }
@media (max-width: 560px) {
  .date-nav { flex: 1 1 auto; }
  .date-input { flex: 1 1 auto; min-width: 0; }
  .dt td.wrap { min-width: 160px; }
}

/* Sidebar: scroll when the menu is taller than the screen */
@media (min-width: 1021px) {
  .sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  .sidebar::-webkit-scrollbar { width: 6px; }
  .sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
}
@media (min-width: 1021px) and (max-height: 860px) {
  .sidebar { gap: 16px; padding-top: 16px; padding-bottom: 12px; }
  .nav a { padding-top: 6px; padding-bottom: 6px; }
  .nav-group { margin-top: 8px; }
  .sidebar-foot { padding-top: 10px; }
}

/* ---------- week production schedule (one row per job, Monday to Sunday) ---------- */
.gt { --gt-label: minmax(150px, 1.9fr); display: grid; gap: 4px; padding: 8px 8px 6px 14px; }
.gt-weeks { justify-self: start; margin-bottom: 10px; }
.gt-weeks .gt-range { color: var(--muted); font-weight: 400; }
.gt-weeks .cnt { margin-left: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gt-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); padding-bottom: 8px; }
.gt-legend span { display: inline-flex; align-items: center; gap: 7px; }
.gt-sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.gt-sw.pin { width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); background: var(--ink); }
.gt-list { display: grid; gap: 4px; }
.gt-row { display: grid; grid-template-columns: var(--gt-label) repeat(7, minmax(0, 1fr)); align-items: center; min-height: 42px; border-radius: 8px; }
.gt-row > * { grid-row: 1; }
.gt-list .gt-row:hover, .gt-list .gt-row:focus-visible { background: var(--hover-wash); outline: none; }
.gt-list .gt-row:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.gt-head { min-height: 0; padding-bottom: 2px; }
.gt-day { text-align: center; font-size: 11.5px; color: var(--muted); line-height: 1.2; }
.gt-day span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.gt-day.today, .gt-day.today span { color: var(--accent-ink); }
.gt-label { grid-column: 1; min-width: 0; padding: 0 10px 0 8px; display: grid; line-height: 1.25; }
.gt-label strong { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-label span { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gt-cell { align-self: stretch; border-left: 1px solid var(--grid); }
.gt-cell.today { background: var(--accent-soft); }
.gt-bar { height: 16px; margin: 0 4px; border-radius: 4px; z-index: 1; }
.gt-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.gt-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.gt-bar.planned, .gt-sw.planned { background: var(--c-in-track); box-shadow: inset 0 0 0 1.5px var(--c-in); }
.gt-bar.active, .gt-sw.active { background: var(--c-in); }
.gt-bar.done, .gt-sw.done { background: var(--good); }
.gt-bar.late, .gt-sw.late { background: var(--critical); }
.gt-pin { justify-self: center; width: 11px; height: 11px; border-radius: 2px; transform: rotate(45deg); background: var(--ink); box-shadow: 0 0 0 2px var(--surface); z-index: 2; }
@media (max-width: 560px) {
  .gt { --gt-label: minmax(96px, 1.1fr); padding: 4px 0 4px 6px; }
  .gt-bar { margin: 0 2px; }
  .gt-day { font-size: 10.5px; }
  .gt-weeks .gt-range { display: none; }
}
@media (forced-colors: active) { .gt-bar, .gt-sw, .gt-pin { forced-color-adjust: none; border: 1px solid CanvasText; } }

/* ==========================================================================
   Online mode: status screens, save status
   ========================================================================== */
body.locked .app { filter: blur(6px); pointer-events: none; user-select: none; }
.auth { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--page) 72%, transparent); overflow-y: auto; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .35); padding: 24px; display: grid; gap: 14px; }
.auth-head { display: flex; align-items: center; gap: 12px; }
.auth-head div { display: grid; line-height: 1.3; }
.auth-head span { font-size: 12.5px; color: var(--ink-2); }
.auth-card h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.auth-error { color: var(--bad-text); font-size: 13px; min-height: 0; }
.auth-error:empty { display: none; }
.auth-links { font-size: 13px; color: var(--ink-2); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent-ink); font: inherit; cursor: pointer; text-decoration: underline; }
.account-chip { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.sync-state { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.sync-state svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sync-state.saved { color: var(--good-text); }
.sync-state.saving { color: var(--ink-2); }
.sync-state.error { color: var(--bad-text); }
.cell:disabled, .settings-form .input:disabled { color: var(--ink); opacity: 1; cursor: default; -webkit-text-fill-color: var(--ink); }
/* the account chip makes the actions wider, so let them wrap under the title */
body:not([data-role="local"]) .topbar { flex-wrap: wrap; row-gap: 16px; }
body:not([data-role="local"]) .topbar > :first-child { flex: 1 1 auto; min-width: min(420px, 100%); }
body:not([data-role="local"]) .topbar-actions { flex-wrap: wrap; flex: 0 1 auto; }
