/* The app's design layer ("UI v2", adopted 2026-10-03). Every rule is scoped under :root.ui-v2, which
   base.html and login.html put on <html> server-side — remove that class to fall back to the bare
   style.css look. Loaded after style.css and the page stylesheets, so equal-shaped selectors win on order
   and the extra .ui-v2 class wins on specificity. Direction: the Orders tab's look (soft cards, serif
   month names, compact label+number stats, colour only where it means something) across the whole app.
   Purely visual: it never hides or adds controls — what each instance shows is still decided by the
   templates and config flags (e.g. Marcin's ENABLE_SUMMARY_DOWNLOAD buttons). */

/* ================================================================ tokens */

:root.ui-v2 {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e6e8ec;
  --border-soft: #eef0f3;
  --border-strong: #d5d9e0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --navy: #0f172a;
  --navy-hover: #1e293b;
  --on-primary: #ffffff;
  --link: #4f46e5;
  --focus: #6366f1;
  --focus-ring: rgba(99, 102, 241, 0.22);

  --ok: #047857;
  --ok-bg: #ecfdf5;
  --ok-line: #10b981;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-line: #f59e0b;
  --bad: #be123c;
  --bad-bg: #fff1f2;
  --bad-line: #f43f5e;
  --info: #4338ca;
  --info-bg: #eef2ff;
  --info-line: #6366f1;
  --grey: #475569;
  --grey-bg: #f1f5f9;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -10px rgba(15, 23, 42, 0.14), 0 2px 6px -2px rgba(15, 23, 42, 0.05);
  --topbar-bg: rgba(255, 255, 255, 0.82);
}

/* Same token set, dark. Higher specificity than the light block above, and it redefines EVERY token
   that block sets, so dark mode never inherits a light value. */
:root.ui-v2[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #13161d;
  --surface-2: #181c24;
  --border: #252a34;
  --border-soft: #1d2129;
  --border-strong: #343b48;
  --text: #e7e9ee;
  --text-2: #c2c8d3;
  --muted: #8b93a3;
  --navy: #4f46e5;        /* white on it ~6.3:1; the lighter #6366f1 fell just under AA */
  --navy-hover: #4338ca;  /* hover darkens (was lightening to ~3:1) */
  --on-primary: #ffffff;
  --link: #a5b4fc;
  --focus: #818cf8;
  --focus-ring: rgba(129, 140, 248, 0.28);

  --ok: #34d399;
  --ok-bg: #0c2a20;
  --ok-line: #10b981;
  --warn: #fbbf24;
  --warn-bg: #2e2309;
  --warn-line: #f59e0b;
  --bad: #fb7185;
  --bad-bg: #331219;
  --bad-line: #f43f5e;
  --info: #a5b4fc;
  --info-bg: #1b1a42;
  --info-line: #818cf8;
  --grey: #cbd5e1;
  --grey-bg: #1d222b;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 28px -12px rgba(0, 0, 0, 0.7), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --topbar-bg: rgba(19, 22, 29, 0.82);
}

/* ================================================================ base */

.ui-v2 body { font-size: 14px; line-height: 1.55; }
.ui-v2 h2 { font-family: var(--font-ui); font-size: 17px; font-weight: 650; letter-spacing: -0.01em; margin: 30px 0 12px; }
.ui-v2 h3 { font-size: 14.5px; font-weight: 650; }
.ui-v2 :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ================================================================ shell: sticky, translucent topbar */

.ui-v2 .topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.ui-v2 .topbar-inner { padding: 12px 28px 10px; gap: 10px 18px; }

.ui-v2 .brand { gap: 9px; }
.ui-v2 .brand .eyebrow {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}

.ui-v2 .company-switch {
  padding: 3px;
  gap: 2px;
  background: var(--grey-bg);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
}
.ui-v2 .company-switch a { padding: 5px 13px; border-radius: 8px; font-size: 13px; }
.ui-v2 .company-switch a.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--border-soft);
}

.ui-v2 .user-box { gap: 6px; }

/* Section tabs as pills (was an underline strip). */
.ui-v2 .topbar-tabs { padding: 0 28px 10px; gap: 2px; }
.ui-v2 .topbar-tabs .tab {
  padding: 6px 13px;
  border-bottom: 0;
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
}
.ui-v2 .topbar-tabs .tab:hover { color: var(--text); background: var(--grey-bg); }
.ui-v2 .topbar-tabs .tab.active {
  background: var(--navy);
  color: var(--on-primary);
  font-weight: 600;
}

.ui-v2 .page { padding: 32px 28px 72px; }

/* ================================================================ page header */

.ui-v2 .page-header { margin-bottom: 26px; gap: 14px 24px; }
.ui-v2 .page-title .eyebrow {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--text-2);
  font-size: 10.5px;
  letter-spacing: 0.1em;
}
.ui-v2 .page-header h1 {
  margin-top: 8px;
  font-size: clamp(28px, 3vw, 36px);
  letter-spacing: -0.02em;
}
.ui-v2 .subheading { margin-top: 4px; font-size: 14px; }

.ui-v2 .toolbar { gap: 8px; margin-bottom: 18px; }

/* ================================================================ cards */

.ui-v2 .card {
  border-color: var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.ui-v2 .card-title { font-size: 14.5px; font-weight: 650; letter-spacing: -0.005em; }
.ui-v2 .grid-cards { gap: 14px; }

/* ================================================================ stats: tiles with a status dot */

.ui-v2 .stats { gap: 12px; margin-bottom: 26px; }
.ui-v2 .stat {
  padding: 16px 18px 15px;
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.ui-v2 .stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: 0.09em;
}
.ui-v2 .stat.good .stat-label::before,
.ui-v2 .stat.warn .stat-label::before,
.ui-v2 .stat.bad .stat-label::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.ui-v2 .stat.good .stat-label::before { background: var(--ok-line); box-shadow: 0 0 0 3px var(--ok-bg); }
.ui-v2 .stat.warn .stat-label::before { background: var(--warn-line); box-shadow: 0 0 0 3px var(--warn-bg); }
.ui-v2 .stat.bad .stat-label::before { background: var(--bad-line); box-shadow: 0 0 0 3px var(--bad-bg); }
/* State tiles borrow the Orders "Amount spent" card: a soft tint of their meaning, nothing louder. */
.ui-v2 .stat.good { background: linear-gradient(135deg, rgba(16, 185, 129, 0.10), rgba(16, 185, 129, 0.015) 70%), var(--surface); border-color: rgba(16, 185, 129, 0.30); }
.ui-v2 .stat.warn { background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.015) 70%), var(--surface); border-color: rgba(245, 158, 11, 0.36); }
.ui-v2 .stat.bad  { background: linear-gradient(135deg, rgba(244, 63, 94, 0.10), rgba(244, 63, 94, 0.015) 70%), var(--surface); border-color: rgba(244, 63, 94, 0.32); }
.ui-v2 .stat-spent { background: linear-gradient(135deg, rgba(16, 185, 129, 0.10), rgba(16, 185, 129, 0.015) 70%), var(--surface); border-color: rgba(16, 185, 129, 0.30); }
.ui-v2 .stat-value { margin-top: 6px; font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.ui-v2 .stat-note { margin-top: 3px; }

/* ================================================================ tables: no grey header band */

.ui-v2 .table-wrap {
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.ui-v2 .card .table-wrap { box-shadow: none; }   /* a framed table inside a card: one shadow, not two */
.ui-v2 table.data { font-size: 13.5px; }
.ui-v2 table.data th {
  padding: 11px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.ui-v2 table.data td { padding: 12px 16px; border-bottom-color: var(--border-soft); }
.ui-v2 table.data tbody tr { transition: background-color 0.1s; }
.ui-v2 table.data tbody tr:hover td { background: var(--surface-2); }
/* The row you jumped to (after saving a note/link) keeps its highlight under the cursor too. */
.ui-v2 table.data tbody tr:target > td { background: var(--warn-bg); }
.ui-v2 table.data td.empty { padding: 36px 16px; }
/* th.right / th.center never aligned (style.css th { text-align:left } outranks them). */
.ui-v2 table.data th.right { text-align: right; }
.ui-v2 table.data th.center { text-align: center; }
.ui-v2 table.data tfoot td { background: var(--surface-2); }
.ui-v2 table.data.order-table th, .ui-v2 table.data.order-table td { padding-left: 11px; padding-right: 11px; }

/* Day-state edge marker: a rounded bar inset from the edge instead of a hard full-height stripe. */
.ui-v2 tr.row-open > td:first-child,
.ui-v2 tr.row-ready > td:first-child,
.ui-v2 tr.row-closed > td:first-child,
.ui-v2 tr.row-attn > td:first-child,
.ui-v2 tr.row-settled > td:first-child,
.ui-v2 tr.row-inactive > td:first-child { position: relative; box-shadow: none; }
.ui-v2 tr.row-open > td:first-child::before,
.ui-v2 tr.row-ready > td:first-child::before,
.ui-v2 tr.row-closed > td:first-child::before,
.ui-v2 tr.row-attn > td:first-child::before,
.ui-v2 tr.row-settled > td:first-child::before,
.ui-v2 tr.row-inactive > td:first-child::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
}
.ui-v2 tr.row-open > td:first-child::before { background: var(--border-strong); }
.ui-v2 tr.row-ready > td:first-child::before,
.ui-v2 tr.row-attn > td:first-child::before { background: var(--warn-line); }
.ui-v2 tr.row-closed > td:first-child::before,
.ui-v2 tr.row-settled > td:first-child::before { background: var(--ok-line); }
.ui-v2 tr.row-inactive > td:first-child::before { background: var(--bad-line); opacity: 0.5; }

/* ================================================================ month accordion (Invoices + Orders) */

.ui-v2 .month {
  margin-bottom: 12px;
  border-color: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.ui-v2 .month:hover { border-color: var(--border-strong); }
.ui-v2 .month[open] { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.ui-v2 .month-summary { padding: 16px 20px; }
.ui-v2 .month-head { gap: 12px; }
.ui-v2 .month-name { font-size: 20px; letter-spacing: 0.03em; }
/* The month's own day table sits flush inside the card (one border, not a box in a box). Only the
   DIRECT child — Cancellations nests per-day tables that keep their own frame. */
.ui-v2 .month > .table-wrap { border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; box-shadow: none; margin: 0; }
/* Invoices: the per-month action row had no padding of its own, so its buttons touched the card edge. */
.ui-v2 .month > .month-actions {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
/* Cancellations: per-day blocks also sat against the card edge. */
.ui-v2 .month > .cancel-day { margin: 0; padding: 4px 20px 8px; }
.ui-v2 .month > summary + .cancel-day { border-top: 1px solid var(--border-soft); padding-top: 14px; }
.ui-v2 .month > .cancel-day:last-child { padding-bottom: 20px; }
/* Per-day heading keeps its own small size — .ui-v2 h2 (the section look) would otherwise win. */
.ui-v2 .cancel-day-head { font-family: var(--font-ui); font-size: 15px; font-weight: 600; letter-spacing: 0; margin: 10px 0 8px; }
.ui-v2 .month > .cancel-day > .table-wrap { margin-bottom: 8px; }
.ui-v2 .mstat-label { font-size: 10.5px; letter-spacing: 0.08em; }
.ui-v2 .mstat-value { font-size: 15.5px; }
.ui-v2 .month-meta { gap: 10px 18px; }

/* ================================================================ pills + chips */

.ui-v2 .pill { padding: 2px 10px; font-size: 11.5px; font-weight: 600; line-height: 19px; }
.ui-v2 .pill::before { width: 6px; height: 6px; }
.ui-v2 .tab-count { border-radius: 999px; font-size: 10.5px; }
.ui-v2 .flag { border-radius: 6px; border-color: var(--border); background: var(--surface-2); }
.ui-v2 .pending-chip { padding: 2px 10px; }

/* ================================================================ progress */

/* Track only — the bar keeps style.css's semantic colours (green = complete, amber = partial). */
.ui-v2 .progress { height: 6px; background: var(--grey-bg); }

/* ================================================================ buttons */

.ui-v2 .btn {
  height: 34px;
  padding: 0 14px;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  font-weight: 550;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s, transform 0.06s;
}
.ui-v2 .btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.ui-v2 .btn:active { transform: translateY(1px); }
.ui-v2 .btn-small { height: 30px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; }
.ui-v2 .btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--on-primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.ui-v2 .btn-primary:hover { background: var(--navy-hover); border-color: var(--navy-hover); }
/* .ui-v2 .btn above outranks style.css's .btn-ghost, so restore the borderless look explicitly. */
.ui-v2 .btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.ui-v2 .btn-ghost:hover { background: var(--grey-bg); border-color: transparent; color: var(--text); }
/* Ghost-danger stays borderless (.ui-v2 .btn-danger below would otherwise win the border on order). */
.ui-v2 .btn-ghost.btn-danger { color: var(--bad); border-color: transparent; }
.ui-v2 .btn-ghost.btn-danger:hover { background: var(--bad-bg); border-color: transparent; }
.ui-v2 .btn-danger { color: var(--bad); border-color: var(--border); }
.ui-v2 .btn-danger:hover { background: var(--bad-bg); border-color: var(--bad-line); }

/* ================================================================ forms */

.ui-v2 input[type="text"], .ui-v2 input[type="email"], .ui-v2 input[type="password"],
.ui-v2 input[type="number"], .ui-v2 input[type="date"], .ui-v2 input[type="month"],
.ui-v2 input[type="search"], .ui-v2 input[type="url"], .ui-v2 input:not([type]),
.ui-v2 select, .ui-v2 textarea {
  height: 36px;
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.ui-v2 textarea { height: auto; }
.ui-v2 input:focus, .ui-v2 select:focus, .ui-v2 textarea:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.ui-v2 .field > label, .ui-v2 .field > .field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.ui-v2 .checkbox input, .ui-v2 table.data input[type="checkbox"] { accent-color: var(--navy); }

/* ================================================================ messages: tinted with an accent edge */

.ui-v2 .flash, .ui-v2 .notice {
  padding: 11px 16px 11px 18px;
  border: 1px solid var(--info-bg);
  border-left: 3px solid var(--info-line);
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: var(--info);
}
.ui-v2 .flash { font-weight: 500; }
/* Compound selectors so a variant always outranks the base rule above (equal specificity + a later
   shorthand would otherwise reset the accent edge). */
.ui-v2 .flash.flash-ok { background: var(--ok-bg); border-color: var(--ok-bg); border-left-color: var(--ok-line); color: var(--ok); }
.ui-v2 .flash.flash-error { background: var(--bad-bg); border-color: var(--bad-bg); border-left-color: var(--bad-line); color: var(--bad); }
.ui-v2 .flash.flash-warn,
.ui-v2 .notice.notice-warn { background: var(--warn-bg); border-color: var(--warn-bg); border-left-color: var(--warn-line); color: var(--warn); }

.ui-v2 .empty {
  padding: 44px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.ui-v2 table.data td.empty, .ui-v2 .table-wrap .empty { border: 0; border-radius: 0; background: none; }

/* ================================================================ in-page tabs: segmented control */

.ui-v2 .subtabs {
  display: inline-flex;
  max-width: 100%;
  gap: 2px;
  margin-bottom: 18px;
  padding: 3px;
  background: var(--grey-bg);
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  box-shadow: none;
}
.ui-v2 .subtabs .tab {
  padding: 6px 12px;
  border-bottom: 0;
  border-radius: 8px;
  font-size: 13px;
}
.ui-v2 .subtabs .tab:hover { color: var(--text); }
.ui-v2 .subtabs .tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--border-soft);
}
.ui-v2 .tab.active .tab-count { background: var(--navy); color: var(--on-primary); }

/* ================================================================ expandable */

.ui-v2 details.expand { border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* ================================================================ page slices: tokens instead of
   hardcoded light colours (these used to stay pale-on-dark in dark mode) */

.ui-v2 .dropzone { border-radius: 16px; border-color: var(--border-strong); background: var(--surface-2); }
.ui-v2 .dropzone:hover { border-color: var(--muted); background: var(--grey-bg); }
.ui-v2 .dropzone.has-files { border-color: var(--ok-line); background: var(--ok-bg); }
.ui-v2 .dropzone.is-dragover { border-color: var(--focus); background: var(--info-bg); }

.ui-v2 .run-error {
  border: 1px solid var(--bad-bg);
  border-left: 3px solid var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad);
}
.ui-v2 .control-ok { background: var(--ok-bg); border-color: var(--ok-bg); color: var(--ok); }
.ui-v2 .control-bad { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad); }
.ui-v2 .spinner { border-color: var(--border); border-top-color: var(--navy); }

.ui-v2 .import-switch { border-radius: 16px; background: var(--grey-bg); border-color: var(--border-soft); }
.ui-v2 .import-switch-option { border-radius: 12px; }
.ui-v2 .import-switch-option.active { background: var(--navy); color: var(--on-primary); box-shadow: var(--shadow-md); }
.ui-v2 .import-switch-option.active .import-switch-sub { color: var(--on-primary); opacity: 0.9; }

.ui-v2 .cookie-paste-form { border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-md); }

/* Card forms built from .field blocks but missing the .form wrapper (Accounts, Discord) had no vertical
   rhythm: fields, help text and the submit button sat flush against each other. Fixed for the preview
   here; add class="form" in users.html / webhooks.html if v2 is adopted. */
.ui-v2 .card > form:has(> .field) { display: flex; flex-direction: column; gap: 16px; }
.ui-v2 .card > form:has(> .field) > .btn { align-self: flex-start; }
.ui-v2 .field:has(> .checkbox) { gap: 7px; }
.ui-v2 .field:has(> .checkbox) > .help { margin-top: 2px; }

/* Discord tab: its two event checkboxes are bare labels split by <br> (no .checkbox class). */
.ui-v2 form[action$="/webhooks"] br { display: none; }
.ui-v2 form[action$="/webhooks"] .field:has(input[type="checkbox"]) { gap: 8px; }
.ui-v2 form[action$="/webhooks"] label:has(> input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.ui-v2 form[action$="/webhooks"] input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); }

/* Orders: keep the look that started this, just in the shared shape. */
.ui-v2 .shoe-grid { gap: 14px; }
.ui-v2 .shoe-card {
  border-color: var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.ui-v2 .shoe-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.ui-v2 .shoe-photo { border-radius: 10px; background: var(--grey-bg); }
.ui-v2 .size-chip { background: var(--grey-bg); color: var(--text-2); font-weight: 500; }
.ui-v2 .spend-total { border-radius: var(--radius); }

/* ================================================================ sign-in */

.ui-v2 .auth-body {
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--info-bg), transparent 70%),
    var(--bg);
}
.ui-v2 .auth { max-width: 400px; }
.ui-v2 .auth-brand .eyebrow { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; text-transform: none; }
.ui-v2 .auth-card { padding: 32px; border-radius: 18px; box-shadow: var(--shadow-md); }
.ui-v2 .auth-card h1 { font-size: 32px; letter-spacing: -0.02em; }
.ui-v2 .auth-card .btn-primary { height: 40px; }

/* ================================================================ responsive */

@media (max-width: 720px) {
  .ui-v2 .topbar-inner { padding: 10px 16px 8px; }
  .ui-v2 .topbar-tabs { padding: 0 16px 8px; }
  .ui-v2 .page { padding: 22px 16px 56px; }
  .ui-v2 .card { padding: 16px; }
  .ui-v2 .stat-value { font-size: 23px; }
  .ui-v2 .subtabs { display: flex; }
  .ui-v2 .month-name { font-size: 17px; }
}

/* ================================================================ audit fixes (dark-mode pass)
   From a read-only multi-reviewer audit of full-page dark screenshots + a static cascade sweep. */

/* Segmented controls in dark: the selected segment (--surface) was DARKER than its --grey-bg track and
   lost its ring + shadow, so it read as a hole punched into the bar. Raise it one step instead. */
:root.ui-v2[data-theme="dark"] .company-switch a.active,
:root.ui-v2[data-theme="dark"] .subtabs .tab.active {
  background: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), inset 0 0 0 1px var(--border-strong);
}
:root.ui-v2[data-theme="dark"] .import-switch-option:not(.active):hover { background: var(--border); }

/* Count chips on inactive filter tabs vanished into the track (both were --grey-bg). */
.ui-v2 .subtabs .tab:not(.active) .tab-count { background: var(--surface); }
:root.ui-v2[data-theme="dark"] .subtabs .tab:not(.active) .tab-count { background: var(--border-strong); color: var(--text-2); }

/* Drop zones: keyboard focus was invisible (the input is a hidden 1px element, and .ui-v2 .dropzone beat
   the page's :focus-within border). Keyboard-only ring. */
.ui-v2 .dropzone:has(input[type="file"]:focus-visible) { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }

/* The big submit buttons had shrunk to the ordinary 34px button. */
.ui-v2 .upload-submit .btn { height: 42px; padding: 0 24px; }
.ui-v2 .cookie-submit .btn { height: 40px; padding: 0 22px; }

/* Money in dark: one green (the --ok mint the bars and pills use) instead of two side by side.
   The "Amount spent" card itself is deliberately left exactly as it is. */
:root.ui-v2[data-theme="dark"] .spend-amount .spend-value,
:root.ui-v2[data-theme="dark"] .mstat-money:not(.mstat-vat) .mstat-value,
:root.ui-v2[data-theme="dark"] .stat-spent .stat-value { color: var(--ok); }

/* Dark placeholders were brighter than the helper text, so empty fields looked filled in. */
:root.ui-v2[data-theme="dark"] input::placeholder,
:root.ui-v2[data-theme="dark"] textarea::placeholder { color: var(--muted); opacity: 0.75; }

/* Dark: a --surface button on the --surface-2 action band looked sunken / disabled. */
:root.ui-v2[data-theme="dark"] .month > .month-actions { background: transparent; }

/* Sessions cookie popover: the page rule (higher specificity) kept a navy shadow that's invisible on
   dark, so the open form blended into the table rows. */
.ui-v2 table.data td .cookie-paste[open] .cookie-paste-form { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

/* Day page: the per-row note / link disclosure buttons are meant to stay quiet. */
.ui-v2 .note-edit > summary.btn-ghost, .ui-v2 .tracking-edit > summary.btn-ghost { color: var(--muted); }
.ui-v2 .note-edit > summary.btn-ghost:hover, .ui-v2 .tracking-edit > summary.btn-ghost:hover { color: var(--text); }

/* Run pages: the header status pill keeps its larger size. */
.ui-v2 .pill.run-status { font-size: 13px; padding: 3px 12px; }

/* Header action rows mixed 34px buttons with 30px .btn-small. */
.ui-v2 .page-actions .btn-small { height: 34px; padding: 0 14px; border-radius: var(--radius-sm); font-size: 13.5px; }

/* "Copy sizelist" (ghost) lines up with the card's text column. */
.ui-v2 .copy-sizelist { margin-left: -12px; }

/* Day-code titles (BM08-29): Georgia's old-style figures made the 0 read as an "o". Codes get compared
   and copied, so those titles use the UI font; every other title keeps the serif. */
.ui-v2 .page-header:has(.deal-meta) h1 { font-family: var(--font-ui); font-weight: 650; letter-spacing: -0.02em; }

/* ✓ / ✗ check pills: the glyph is the marker — drop the generic pill dot. */
.ui-v2 .pill.pill-icon::before { display: none; }

/* Sessions: the note under the stat tiles belongs to them, not to the buttons below it. */
.ui-v2 .stats + .help { margin: -14px 0 20px; }

/* Accounts: the checkbox options were styled exactly like their group headings. */
.ui-v2 .field > label.checkbox { font-size: 13.5px; font-weight: 500; color: var(--text); }

/* Accounts: the in-table password field matches the 30px "Set" button next to it. */
.ui-v2 table.data .inline-form input[type="password"],
.ui-v2 table.data .inline-form input[type="text"] { height: 30px; border-radius: 8px; font-size: 13px; }

/* Month header stats line up as columns from one month card to the next (desktop only). */
@media (min-width: 721px) {
  .ui-v2 .month-stats .mstat { min-width: 52px; }
  .ui-v2 .month-stats .mstat-money { min-width: 104px; }
}
@media (max-width: 720px) {
  .ui-v2 table.data td .cookie-paste[open] .cookie-paste-form { box-shadow: none; }
}

/* ================================================================ final review fixes (Marcin flags,
   open day, run pages, phones) — all visual-only: nothing here hides or adds a control. */

/* Stat rows: when one label wraps to two lines its number dropped below its neighbours'. Pin numbers to
   the tile bottom — only for plain label+value rows (rows with a note / progress under the number keep
   today's flow). Browsers without :has() simply keep the old look. */
.ui-v2 .stats:not(:has(.stat-note, .progress, .progress-label)) > .stat { display: flex; flex-direction: column; }
.ui-v2 .stats:not(:has(.stat-note, .progress, .progress-label)) > .stat > .stat-label { margin-bottom: 6px; }
.ui-v2 .stats:not(:has(.stat-note, .progress, .progress-label)) > .stat > .stat-value { margin-top: auto; }

/* The status dot sits by the FIRST line of a wrapped label (one-line labels look exactly the same). */
.ui-v2 .stat-label { align-items: flex-start; }
.ui-v2 .stat-label::before { margin-top: calc((1.55em - 7px) / 2); }

/* Sessions puts the state class on .stat-value instead of .stat — give those tiles the same tint + dot. */
.ui-v2 .stat:has(> .stat-value.warn) { background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.015) 70%), var(--surface); border-color: rgba(245, 158, 11, 0.36); }
.ui-v2 .stat:has(> .stat-value.good) { background: linear-gradient(135deg, rgba(16, 185, 129, 0.10), rgba(16, 185, 129, 0.015) 70%), var(--surface); border-color: rgba(16, 185, 129, 0.30); }
.ui-v2 .stat:has(> .stat-value.warn) > .stat-label::before,
.ui-v2 .stat:has(> .stat-value.good) > .stat-label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ui-v2 .stat:has(> .stat-value.warn) > .stat-label::before { background: var(--warn-line); box-shadow: 0 0 0 3px var(--warn-bg); }
.ui-v2 .stat:has(> .stat-value.good) > .stat-label::before { background: var(--ok-line); box-shadow: 0 0 0 3px var(--ok-bg); }

/* Invoices month band (Marcin): the grey status sentence sat between the buttons. Visual order only —
   every button stays, they just come first and the sentence goes last (on DE it already was last). */
.ui-v2 .month > .month-actions > span.muted { order: 1; }

/* Empty state: centre the message (drop the inner paragraph's bottom margin) and give the "As of" line
   under it some air. */
.ui-v2 .empty > :last-child { margin-bottom: 0; }
.ui-v2 .empty + p.small { margin-top: 12px; }

/* Cancelled / Returns: every per-day table shares the same column edges on wide screens. These widths
   act as minimums (table-layout stays auto) — a wider value still grows and is never clipped. */
@media (min-width: 1100px) {
  .ui-v2 table.cancellations th:nth-child(1) { width: 170px; }
  .ui-v2 table.cancellations th:nth-child(3) { width: 80px; }
  .ui-v2 table.cancellations th:nth-child(4) { width: 64px; }
  .ui-v2 table.cancellations th:nth-child(5) { width: 130px; }
  .ui-v2 table.cancellations th:nth-child(6) { width: 150px; }
  .ui-v2 table.cancellations th:nth-child(7) { width: 130px; }
}

/* Day page order table: the first ghost action / note / link disclosure lines up with the cell's text
   edge instead of sitting 12px in (the hover fill stays inside the cell; focus ring drawn inside). */
.ui-v2 .order-table .cell-actions > .inline-form:first-child > .btn-ghost,
.ui-v2 .order-table .note-edit > summary.btn-ghost,
.ui-v2 .order-table .tracking-edit > summary.btn-ghost { margin-left: -11px; }
.ui-v2 .order-table .cell-actions > .inline-form:first-child > .btn-ghost:focus-visible,
.ui-v2 .order-table .note-edit > summary.btn-ghost:focus-visible,
.ui-v2 .order-table .tracking-edit > summary.btn-ghost:focus-visible { outline-offset: -2px; }

@media (max-width: 720px) {
  /* Phones: the Orders month header (Days / Orders / Pairs / Spent / VAT) is wider than the card, and the
     card clips its overflow — the VAT (and on Marcin the zł Spent) figure got cut off. Let it wrap. */
  .ui-v2 .month-meta { max-width: 100%; }
  .ui-v2 .month-stats { flex-wrap: wrap; row-gap: 8px; }

  /* Phones: brand + company switch + tabs would take a third of the screen as a sticky bar — it scrolls
     away like the old look did — and the section tabs wrap, so the active one is always visible
     (it used to sit off-screen at the end of a hidden-scrollbar strip on Sessions / Discord). */
  .ui-v2 .topbar { position: static; }
  .ui-v2 .topbar-tabs { flex-wrap: wrap; row-gap: 4px; overflow-x: visible; }

  /* Toolbars with a mid-row spacer: on a phone the spacer becomes a line break, so the run actions
     (e.g. Sessions' Check deliveries + Fetch all) start together on their own row. */
  .ui-v2 .toolbar > .spacer:not(:first-child) { flex: 0 0 100%; height: 0; }
}
