@font-face {
  font-family: Inter;
  src: url("/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #e3e7ee;
  --text: #111827;
  --muted: #5b6474;
  --accent: #1b5fd0;
  --accent-ink: #ffffff;
  --series: #2a78d6;
  --good: #17754a;
  --good-bg: #e3f3ea;
  --warn: #8a5a00;
  --warn-bg: #fbf0d9;
  --bad: #b8332a;
  --bad-bg: #fbe7e4;
  --info: #1d5fc4;
  --info-bg: #e4eefb;
  --plain: #5e5d57;
  --plain-bg: #ecece8;
  --shadow: 0 12px 40px rgb(0 0 0 / 18%);
  --radius: 14px;
  --card-shadow: 0 1px 2px rgb(16 24 40 / 5%), 0 6px 20px rgb(16 24 40 / 5%);
  font-family: Inter, "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv11", "ss03";
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0f16;
    --surface: #131923;
    --surface-2: #1d2531;
    --line: #273142;
    --text: #eef1f6;
    --muted: #a3adbd;
    --accent: #78aef5;
    --accent-ink: #0d1a2b;
    --series: #3987e5;
    --good: #6fd3a1;
    --good-bg: #16352a;
    --warn: #eac06c;
    --warn-bg: #3a2d12;
    --bad: #f39a90;
    --bad-bg: #431f1b;
    --info: #9cc3f7;
    --info-bg: #1b2e49;
    --plain: #b4b3a9;
    --plain-bg: #2c2c2a;
    --shadow: 0 12px 40px rgb(0 0 0 / 55%);
    --card-shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: anywhere;
}

h1, h2, h3, p, ul, dl, dd { margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.015em; }
h2 { font-size: 1rem; }
ul { padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 0.82rem; color: var(--muted); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Shell */

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100dvh; }

.side {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--text); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }

.side {
  /* Always the dark panel, in both colour schemes. */
  --surface: #0c1320;
  --surface-2: #18233a;
  --line: #1e2a42;
  --text: #f3f5f9;
  --muted: #9aa6bc;
  --info: #a9cbfb;
  --info-bg: #1b2d4e;
  color: var(--text);
}

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
#nav a:hover { background: var(--surface-2); text-decoration: none; }
#nav a[aria-current] { background: var(--info-bg); color: var(--info); }
#nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.account-link { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); font-weight: 550; }
.account-link:hover { background: var(--surface-2); text-decoration: none; }
.account-link small { display: block; font-weight: 400; }
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  font-weight: 650;
  text-transform: uppercase;
}

main { min-width: 0; outline: none; }
.screen { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 1180px; margin: 0 auto; padding: 26px 28px 48px; }

/* Page furniture */

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head-actions, .action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.back { color: var(--muted); font-size: 0.9rem; margin-bottom: -10px; }
.back::before { content: "‹ "; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn.danger-text { color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.9rem; }
.btn.wide { width: 100%; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.link:hover { text-decoration: underline; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--good); background: var(--good-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.plain { color: var(--plain); background: var(--plain-bg); }

.banner { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); color: var(--warn); font-weight: 550; }
.notes { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); white-space: pre-wrap; }
.note-warn { display: block; color: var(--warn); font-weight: 600; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 260px; }
.toolbar select { flex: 0 1 170px; }

input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button {
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* Tables */

.rows { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rows th { padding: 9px 14px; text-align: left; font-size: 0.82rem; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.rows th.num { text-align: right; }
.rows td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.rows small { display: block; }
.rows .title a, .rows .title b { font-weight: 600; }
.rows .row-end { text-align: right; white-space: nowrap; }
.rows tr[data-href], .rows tr.clickable { cursor: pointer; }
.rows tbody tr[data-href]:hover, .rows tbody tr.clickable:hover { background: var(--surface-2); }

.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; font-size: 0.9rem; }
.empty { display: grid; justify-items: start; gap: 12px; padding: 32px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }

/* Dashboard */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.tile:hover { border-color: var(--muted); text-decoration: none; }
.tile-label { font-size: 0.88rem; color: var(--muted); }
.tile-value { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 0.82rem; color: var(--muted); }

.board { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.columns.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px 0; }
.panel > header a { font-size: 0.88rem; }
.panel-empty { padding: 10px 16px 16px; }

.todo { padding: 6px 0; }
.todo li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; }
.todo li[data-href] { cursor: pointer; }
.todo li[data-href]:hover { background: var(--surface-2); }
.todo li > div { min-width: 0; }
.todo small { display: block; }

.specs { padding: 8px 16px 14px; }
.specs > div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.specs > div:last-child { border-bottom: 0; }
.specs dt { color: var(--muted); }
.specs dd { text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }
.panel .notes { margin: 0 16px 14px; }
.totals { border-top: 1px solid var(--line); }

/* Chart: one series, recessive axes, a tooltip on each month, and a table for the exact figures. */

.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; padding: 22px 16px 10px; }
.chart-axis { position: relative; width: 48px; height: 190px; font-size: 0.75rem; color: var(--muted); }
.chart-axis span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; }
.chart-plot { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.chart-lines { position: absolute; top: 0; left: 0; right: 0; height: 190px; }
.chart-lines i { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.chart-col { position: relative; display: grid; grid-template-rows: 190px auto; justify-items: center; outline-offset: -2px; border-radius: 6px; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { filter: brightness(1.12); }
.chart-track { position: relative; width: 100%; height: 190px; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: min(24px, 60%); background: var(--series); border-radius: 4px 4px 0 0; }
.chart-value { position: absolute; left: 50%; transform: translate(-50%, -4px); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.chart-month { padding: 6px 0 2px; font-size: 0.78rem; color: var(--muted); }
.chart-tip {
  position: absolute;
  bottom: 44px;
  left: 50%;
  z-index: 3;
  display: none;
  gap: 1px;
  width: max-content;
  max-width: 200px;
  padding: 7px 10px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  pointer-events: none;
}
.chart-col.near-start .chart-tip { left: 0; transform: none; }
.chart-col.near-end .chart-tip { left: auto; right: 0; transform: none; }
.chart-col:hover .chart-tip, .chart-col:focus .chart-tip { display: grid; }

.chart-table { padding: 8px 16px 14px; font-size: 0.9rem; }
.chart-table summary { color: var(--accent); cursor: pointer; }
.chart-table table { width: 100%; margin-top: 8px; border-collapse: collapse; }
.chart-table th, .chart-table td { padding: 5px 0; text-align: left; border-bottom: 1px solid var(--line); }
.chart-table .num { text-align: right; }

/* Attendance */

.panel-foot { padding: 4px 16px 14px; }
.register-wrap { margin-top: 8px; overflow-x: auto; }
.register { border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.register th, .register td { min-width: 26px; padding: 5px 3px; text-align: center; border-top: 1px solid var(--line); }
.register thead th { color: var(--muted); font-weight: 600; border-top: 0; }
.register th:first-child { position: sticky; left: 0; z-index: 1; min-width: 104px; padding-left: 16px; text-align: left; background: var(--surface); white-space: nowrap; font-weight: 600; }
.register td.num { min-width: 38px; padding-inline: 6px; text-align: center; font-weight: 600; }
.mark-in { color: var(--good); font-weight: 600; }
.mark-late { color: var(--warn); background: var(--warn-bg); font-weight: 700; }
.mark-out { color: var(--bad); font-weight: 600; }
.off { color: var(--muted); }
.register-key { padding: 8px 16px 14px; font-size: 0.82rem; }

/* Scanner demo */

.scan-start { display: grid; gap: 12px; justify-items: start; }
.drop { position: relative; display: grid; gap: 4px; width: 100%; padding: 34px 20px; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.scan-frame { position: relative; width: min(420px, 100%); aspect-ratio: 8 / 5; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); }
.scan-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-line { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--accent); box-shadow: 0 0 14px 4px var(--accent); animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { to { top: calc(100% - 3px); } }
@media (prefers-reduced-motion: reduce) { .scan-line { animation: none; top: 50%; } }
.scan-status { margin-top: 8px; }
.scan-actions { margin-top: 12px; }
.specimen { position: relative; display: grid; gap: 10px; align-content: center; height: 100%; padding: 22px; background: var(--surface); }
.specimen i { display: block; height: 9px; border-radius: 4px; background: var(--surface-2); }
.specimen i:nth-of-type(2) { width: 72%; }
.specimen i:nth-of-type(3) { width: 86%; }
.specimen i:nth-of-type(4) { width: 58%; }
.specimen-mark { position: absolute; top: 12px; right: 14px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }

/* Dialogs */

.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(0 0 0 / 45%); }
.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; }
.modal h2 { font-size: 1.1rem; }
.modal-body { display: grid; gap: 12px; padding: 4px 18px 16px; overflow-y: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > span, .field > label { font-size: 0.88rem; font-weight: 550; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.field-error, .form-error { color: var(--bad); font-weight: 550; }
.form-error { font-size: 0.92rem; }

.picker { position: relative; }
.picker-row { display: flex; gap: 8px; }
.picker-row input { flex: 1; min-width: 0; }
.picker-row .btn { flex: none; }
.picker-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 220px;
  margin-top: 4px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.picker-list button { display: block; width: 100%; padding: 8px 12px; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.picker-list button:hover, .picker-list button:focus { background: var(--surface-2); }
.picker-list b { display: block; font-weight: 600; }
.picker-empty { padding: 10px 12px; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-weight: 550; }
.toast.bad { background: var(--bad); color: var(--surface); }

/* Sign-in */

.login { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100dvh; background: var(--surface); }
.login-card { display: grid; gap: 14px; place-self: center; width: min(380px, 100%); padding: 26px; }

/* Receipt */

.receipt { display: grid; gap: 20px; width: 100%; max-width: 760px; padding: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.receipt > header { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 16px; border-bottom: 2px solid var(--text); }
.receipt-meta { text-align: right; }
.receipt-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.receipt h3 { margin-bottom: 4px; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th, .receipt td { padding: 8px 0; text-align: left; border-bottom: 1px solid var(--line); }
.receipt .num { text-align: right; }
.receipt tfoot th { border-bottom: 2px solid var(--text); }
.receipt-note { font-size: 0.85rem; }
.signatures { display: flex; justify-content: space-between; gap: 32px; padding-top: 56px; }
.signatures span { flex: 0 1 220px; padding-top: 6px; border-top: 1px solid var(--text); font-size: 0.88rem; }

/* Finish */

body { -webkit-font-smoothing: antialiased; }
h1 { font-weight: 700; letter-spacing: -0.022em; }
h2 { font-weight: 650; letter-spacing: -0.01em; }
.screen { animation: rise 0.28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.panel, .tile, .rows, .receipt { box-shadow: var(--card-shadow); border-color: var(--line); }
.tile { transition: transform 0.15s, box-shadow 0.15s; }
a.tile:hover { transform: translateY(-2px); border-color: var(--line); box-shadow: 0 10px 28px rgb(16 24 40 / 10%); }
.tile-value { font-weight: 700; letter-spacing: -0.025em; }
.panel > header { padding-top: 16px; }
.panel > header small { display: block; }
.btn { transition: background 0.15s, transform 0.1s; }
.btn:active { transform: translateY(1px); }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 26px 28px;
  border-radius: 18px;
  color: #f3f5f9;
  background:
    radial-gradient(90% 160% at 100% 0%, rgb(42 120 214 / 42%), transparent 62%),
    linear-gradient(135deg, #0c1320, #14233f);
  box-shadow: 0 14px 34px rgb(12 19 32 / 24%);
}
.hero h1 { margin: 2px 0 4px; font-size: 3.1rem; font-variant-numeric: tabular-nums; }
.hero-kicker { font-weight: 550; color: #c5d3ea; }
.hero-note { font-size: 0.92rem; color: #b6c2d6; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.ghost { color: #f3f5f9; background: rgb(255 255 255 / 9%); border-color: rgb(255 255 255 / 16%); }
.btn.ghost:hover { background: rgb(255 255 255 / 17%); }
.btn.light { color: #0c1320; background: #fff; border-color: #fff; }
.btn.light:hover { background: #e7edf7; }

.with-art { display: flex; align-items: center; gap: 12px; }
.car-thumb { display: grid; place-items: center; flex: none; width: 72px; height: 46px; padding: 4px 6px; border-radius: 10px; background: #d5dbe4; }
.car-art { display: block; width: 100%; height: auto; }
.car-hero {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  padding: 22px 28px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.car-hero .car-art { padding: 14px 20px; border-radius: 12px; background: #d5dbe4; }
.car-hero > div { display: grid; gap: 2px; }
.car-hero .tile-value { font-size: 2.1rem; }

.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.report-grid .wide { grid-column: 1 / -1; }

.area-svg { position: absolute; top: 0; left: 0; width: 100%; height: 190px; overflow: visible; pointer-events: none; }
.area-line { fill: none; stroke: var(--series); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.area-fill { fill: var(--series); fill-opacity: 0.1; }
.area-dot { position: absolute; left: 50%; width: 10px; height: 10px; margin: 0 0 -5px -5px; border-radius: 50%; background: var(--series); box-shadow: 0 0 0 2px var(--surface); opacity: 0; }
.area-dot.last, .area-col:hover .area-dot, .area-col:focus .area-dot { opacity: 1; }
.area-col:hover .chart-track::before, .area-col:focus .chart-track::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); }
.chart-value.end { left: auto; right: 0; transform: translateY(-10px); }
.chart-bar { min-height: 0; }

.ranked { display: grid; gap: 11px; padding: 14px 16px 18px; }
.ranked li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 0.92rem; }
.ranked-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranked-track { grid-column: 1 / -1; height: 8px; }
.ranked-bar { height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--series); }

.segments { display: flex; gap: 2px; height: 44px; margin: 16px 16px 0; border-radius: 8px; overflow: hidden; }
.segment { display: grid; place-items: center; flex: 1 1 0; min-width: 0; font-size: 0.8rem; font-weight: 650; color: #0c1320; }
.slot-1 { background: #2a78d6; }
.slot-2 { background: #eb6834; }
.slot-3 { background: #1baf7a; }
.slot-4 { background: #eda100; }
.slot-5 { background: #e87ba4; }
.segment.slot-1 { color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 12px 16px 16px; font-size: 0.86rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend b { color: var(--text); font-weight: 600; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

.role-buttons { display: grid; gap: 10px; }

.login-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 36px 44px;
  color: #f3f5f9;
  background:
    radial-gradient(80% 90% at 90% 10%, rgb(42 120 214 / 45%), transparent 62%),
    linear-gradient(150deg, #0c1320, #14233f);
}
.login-side .brand { padding: 0; color: inherit; }
.login-side h2 { max-width: 13em; font-size: 2.3rem; line-height: 1.12; letter-spacing: -0.025em; }
.login-side p { max-width: 30em; margin-top: 12px; color: #b6c2d6; }
.login-side .car-art { max-width: 520px; }

.phone-only, #nav .phone-tab { display: none; }

.more-list li + li { border-top: 1px solid var(--line); }
.more-list a { display: grid; gap: 1px; padding: 13px 16px; color: var(--text); }
.more-list a:hover { background: var(--surface-2); text-decoration: none; }
.more-list b { font-weight: 600; }

@media (prefers-color-scheme: dark) {
  .slot-1 { background: #3987e5; }
  .slot-2 { background: #d95926; }
  .slot-3 { background: #199e70; }
  .slot-4 { background: #c98500; }
  .slot-5 { background: #d55181; }
}

@media print {
  :root {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #fff; --line: #bbb; --text: #000; --muted: #333;
    --warn: #000; --warn-bg: #fff;
  }
  .side, .no-print, #toasts { display: none !important; }
  .screen { animation: none; }
  .receipt { box-shadow: none; }
  .shell { display: block; }
  .screen { padding: 0; max-width: none; }
  .receipt { max-width: none; padding: 0; border: 0; }
}

/* Phones: the side bar becomes a bottom bar, and each table row becomes a card. */

@media (max-width: 1000px) {
  .columns.thirds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell { display: block; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .side {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    height: auto;
    padding: 0 0 env(safe-area-inset-bottom);
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .brand { display: none; }
  #nav .wide-only { display: none; }
  #nav .phone-tab { display: flex; }
  #nav { flex-direction: row; gap: 0; }
  #nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 2px; padding: 8px 0 6px; border-radius: 0; font-size: clamp(0.64rem, 2.9vw, 0.72rem); white-space: nowrap; overflow-wrap: normal; }
  #nav a:hover { background: none; }
  #nav a[aria-current] { background: none; }
  #nav svg { width: 22px; height: 22px; }
  .account-link, .btn.wide-only { display: none; }

  .screen { padding: 16px 16px 28px; gap: 14px; }
  .board, .columns, .columns.thirds { grid-template-columns: minmax(0, 1fr); }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; padding-inline: 10px; }
  .toolbar select { flex: 1 1 130px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 11px 12px; }
  .tile-value { font-size: 1.35rem; }

  /* Each row becomes a compact card: the title across the top, then two columns of label over value. */
  .rows, .rows tbody { display: block; width: 100%; }
  .rows { background: none; border: 0; box-shadow: none; overflow: visible; }
  .rows thead { display: none; }
  .rows tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin-bottom: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
  }
  .rows.tri tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rows td { display: block; min-width: 0; padding: 0; border: 0; text-align: left; }
  .rows td.num { white-space: normal; font-weight: 600; }
  .rows td::before { content: attr(data-label); display: block; margin-bottom: 1px; color: var(--muted); font-size: 0.76rem; }
  .rows td.title, .rows td.row-end { grid-column: 1 / -1; }
  .rows td.title::before, .rows td.row-end::before { content: none; }
  .rows td.row-end { display: flex; justify-content: flex-end; gap: 8px; }
  .rows td.row-end:empty, .rows td.row-end:has([data-act=remove]) { display: none; }
  .rows td.title .with-art { text-align: left; }

  .form-grid, .receipt-parties { grid-template-columns: minmax(0, 1fr); }
  .form-grid .field { grid-column: 1 / -1; }
  .modal { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .modal form { height: 100%; max-height: 100dvh; }
  .modal-body { flex: 1; }
  .receipt { padding: 18px; }
  .chart-axis { width: 44px; }
  .chart-value { display: none; }
  .columns-12 .thin-label .chart-month { visibility: hidden; }
  .chart-month { white-space: nowrap; }
  .columns-12 .chart-bar { width: 72%; }
  .chart { padding-inline: 12px; }
  .chart-table { padding-inline: 12px; }

  /* Touch: comfortable targets, and 16px inputs so iPhones don't zoom the page when one is tapped. */
  input, select, textarea { min-height: 44px; font-size: 16px; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }
  .tabs button { padding: 10px 12px; }
  .todo li { padding-block: 10px; }
  .tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .hero-actions { flex-wrap: nowrap; }
  .hero-actions .btn { flex: 1 1 0; }
  .modal footer .btn { flex: 1 1 0; }
  .modal footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .page-head .badge { margin-top: 2px; }
  .report-grid { grid-template-columns: minmax(0, 1fr); }
  .report-grid .wide { grid-column: auto; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 2.5rem; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { padding-inline: 8px; }
  .car-hero { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); align-content: center; }
  .login-side { display: none; }
  #toasts { bottom: 76px; }
}
