/* Admin — shell and shared components. Uses tokens.css only; no colour literals here (one exception: the QR code ground). */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 1.0625rem; line-height: 1.5; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.acc { color: var(--accent); }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 20; background: var(--bg); padding: var(--s3) var(--s4); border: 1px solid var(--ink); }
.skip:focus { left: var(--s4); }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; flex: none; }

/* ---------- shell: phone first (bottom tabs), sidebar from 1024px ---------- */
.side { display: none; }
.main { padding: 0 var(--s4) calc(96px + env(safe-area-inset-bottom)); min-width: 0; }
.main:focus { outline: 0; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5); padding: var(--s3) 0 var(--s5); }
.head-t { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head h1 { font-size: 1.375rem; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.head .sub { color: var(--muted); font-size: .9375rem; margin-top: 2px; }
.head .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.logo { width: 36px; height: 36px; color: var(--ink); flex: none; }
.logo-sm { width: 28px; height: 28px; color: var(--ink); flex: none; }
.head-t:has(.back) .logo-sm { display: none; }
.back { display: inline-flex; align-items: center; min-height: 44px; margin-left: -6px; gap: 2px; color: var(--muted); text-decoration: none; font-size: .9375rem; }
.back::before { content: "‹"; font-size: 1.75rem; line-height: 1; color: var(--ink); padding-right: 4px; }

.tabbar { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--rule); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; text-decoration: none; font-size: .8125rem; color: var(--muted); border-top: 2px solid transparent; margin-top: -1px; }
.tabbar a[aria-current] { color: var(--accent); font-weight: 600; border-top-color: var(--accent); }

@media (min-width: 1024px) {
  body { font-size: 1rem; }
  .app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--rule); padding: 28px 0 24px; }
  .tabbar, .logo-sm, .only-phone { display: none; }
  .main { padding: 32px 40px 64px; max-width: 1280px; }
  .head { padding: 0 0 20px; }
  .head h1 { font-size: 2rem; line-height: 1.15; letter-spacing: -.015em; }
  .head .sub { font-size: 1rem; margin-top: 6px; }
  .back { margin: 0 0 6px; }
  .back::before { content: none; }
  .back::after { content: " /"; }
  .head-t { flex-direction: column; align-items: flex-start; gap: 0; }
}
@media (max-width: 1023px) { .only-desk { display: none; } }

.brand { display: flex; align-items: center; gap: 12px; padding: 0 24px 24px; text-decoration: none; }
.brand b { display: block; font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.brand span { font-size: .875rem; color: var(--muted); }
.nav h2 { font-size: .8125rem; font-weight: 500; color: var(--muted); padding: 20px 24px 6px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 24px 0 21px; text-decoration: none; font-size: .9375rem; border-left: 3px solid transparent; }
.nav a:hover { background: var(--raised); }
.nav a[aria-current] { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }
.nav .c { font-size: .8125rem; color: var(--muted); font-weight: 400; }
.me { margin-top: auto; padding: 16px 24px 0; border-top: 1px solid var(--rule); font-size: .875rem; }
.me b { display: block; font-size: .9375rem; font-weight: 600; }
.me form { display: inline; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit; }

/* ---------- sections, layout ---------- */
.sec { border-top: 1px solid var(--rule-strong); padding-top: var(--s3); }
.sec + .sec, .stack > * + * { margin-top: 28px; }
.sec > header { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); margin-bottom: var(--s3); }
.sec h2 { font-size: 1.0625rem; font-weight: 600; }
.sec > header a, .sec > header span { font-size: .875rem; color: var(--muted); }
.grid2 { display: grid; gap: 32px; }
@media (min-width: 1024px) {
  .sec + .sec, .stack > * + * { margin-top: 40px; }
  .grid2 { grid-template-columns: minmax(0, 1fr) 360px; gap: 48px; align-items: start; }
}
.lead .date { font-size: 1.75rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
@media (min-width: 1024px) { .lead .date { font-size: 2.25rem; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--bg); color: var(--ink); font-weight: 500; font-size: 1rem; text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .12s; }
.btn:hover { background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(.92); }
.btn.text { border-color: transparent; background: none; padding: 0 8px; text-decoration: underline; text-underline-offset: 3px; }
.btn.danger { color: var(--accent); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .9375rem; }
.btn.full { width: 100%; min-height: 48px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule-strong); }
.kpis > a, .kpis > div { padding: 12px 0 14px; text-decoration: none; border-bottom: 1px solid var(--rule); min-height: 44px; }
.kpis > :nth-child(even) { padding-left: 16px; border-left: 1px solid var(--rule); }
.kpis .l, .kpis .s { font-size: .875rem; color: var(--muted); }
.kpis .v { font-size: 1.75rem; font-weight: 400; letter-spacing: -.02em; line-height: 1.2; margin: 2px 0; }
.kpis a:hover .v { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
@media (min-width: 1024px) {
  .kpis { grid-template-columns: repeat(var(--n, 4), 1fr); }
  .kpis > a, .kpis > div { padding: 14px 20px 16px; border-left: 1px solid var(--rule); }
  .kpis > :first-child { border-left: 0; padding-left: 0; }
  .kpis > :nth-child(even) { padding-left: 20px; }
  .kpis .v { font-size: 2rem; }
}
.kpis.n2 { --n: 2; } .kpis.n3 { --n: 3; } .kpis.n5 { --n: 5; }

/* ---------- tables and lists ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th { font-size: .8125rem; font-weight: 500; color: var(--muted); text-align: left; padding: 0 12px 8px 0; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
td { padding: 10px 12px 10px 0; min-height: 44px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th.num, td.num { text-align: right; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:hover { background: var(--raised); }
tr.sel { background: var(--raised); box-shadow: inset 3px 0 0 var(--ink); }
td a { text-decoration: none; font-weight: 500; }
td a:hover { text-decoration: underline; }
.list { list-style: none; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.list .t { flex: 1; min-width: 0; }
.list .m, .list .d { font-size: .9375rem; color: var(--muted); }
.list .d { white-space: nowrap; }
.list a.t { text-decoration: none; }
.kv { display: grid; grid-template-columns: minmax(96px, auto) 1fr; gap: 6px 16px; font-size: .9375rem; }
.kv dt { color: var(--muted); }
.kv + * { margin-top: 16px; }

/* ---------- status words, ledger, step track ---------- */
.st { white-space: nowrap; }
.st-acc { color: var(--accent); font-weight: 600; }
.st-ink { color: var(--ink); font-weight: 500; }
.st-muted { color: var(--muted); }
.months { display: inline-grid; grid-template-columns: repeat(12, 10px); gap: 3px; vertical-align: middle; }
.months i { width: 10px; height: 10px; border: 1px solid var(--future); }
.months i.p { background: var(--ink); border-color: var(--ink); }
.months i.d { border: 1.5px solid var(--ink); }
.track { display: inline-grid; grid-template-columns: repeat(6, 1fr); gap: 3px; width: 132px; list-style: none; }
.track li { height: 8px; border: 1px solid var(--future); }
.track li.done { background: var(--ink); border-color: var(--ink); }
.track li.current { border: 2px solid var(--ink); }

/* ---------- toolbar / filters, tabs, segmented ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.filters .count { margin-left: auto; color: var(--muted); font-size: .9375rem; }
.input, .filters select, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea { min-height: 48px; width: 100%; border: 1px solid var(--control); border-radius: var(--radius); background: var(--bg); color: var(--ink); padding: 0 12px; font-size: 1rem; }
.field textarea { padding: 10px 12px; min-height: 96px; resize: vertical; }
.filters .input { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }
@media (min-width: 1024px) { .input, .filters select { min-height: 40px; } .filters .input { flex: 0 1 280px; } }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: .9375rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.tabs { display: flex; gap: 20px; overflow-x: auto; box-shadow: inset 0 -1px 0 var(--rule); /* not a border: the active underline must cover it without overflowing (no stray scrollbar) */ margin-bottom: 16px; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; text-decoration: none; font-size: .9375rem; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a[aria-current] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }
.tabs .n { margin-left: 5px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--ink); }
.seg legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.seg label { position: relative; min-height: 46px; display: grid; place-items: center; padding: 0 12px; font-size: .9375rem; cursor: pointer; }
.seg label + label { border-left: 1px solid var(--ink); }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- forms ---------- */
.form { max-width: 640px; }
.field { margin-top: 18px; }
.field > label, .field > .lbl, .field legend { display: block; font-size: .9375rem; font-weight: 500; margin-bottom: 6px; }
.field .req { color: var(--muted); font-weight: 400; }
.field .hint { font-size: .875rem; color: var(--muted); margin-top: 6px; }
.field .err { font-size: .9375rem; color: var(--accent); font-weight: 600; margin-top: 6px; }
.field [aria-invalid="true"] { border-color: var(--accent); }
.field.check-field { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.field.check-field input { width: 22px; height: 22px; accent-color: var(--ink); }
.field.check-field label { margin: 0; font-weight: 400; }
.field ul { list-style: none; }
.errsum { border-top: 1px solid var(--accent); padding-top: 10px; margin-bottom: 16px; color: var(--accent); font-weight: 600; }
.errsum a { color: inherit; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
@media (max-width: 1023px) { .form-actions .btn { flex: 1 1 100%; min-height: 48px; } }

/* ---------- empty / error, pagination ---------- */
.empty { padding: 16px 0; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: .9375rem; }
.pager nav { display: flex; gap: 8px; }

/* ---------- bottom sheet (<dialog>), toast ---------- */
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 560px; max-height: 90vh; border: 0; padding: 8px 16px 20px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); }
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet[open] { animation: up .18s ease-out; }
@media (min-width: 1024px) { dialog.sheet { margin: auto; padding: 16px 24px 24px; } }
.sheet-h { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.sheet-h h2 { flex: 1; font-size: 1.25rem; font-weight: 600; }
.x { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; margin-right: -12px; }
.toasts { position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 16px; min-height: 48px; max-width: 560px; width: 100%; padding: 6px 8px 6px 16px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); animation: up .18s ease-out; }
.toast p { flex: 1; }
.toast form { display: contents; }
.toast .btn { min-height: 40px; color: var(--bg); border-color: transparent; background: none; text-decoration: underline; text-underline-offset: 3px; }
.toast.error { outline: 2px solid var(--accent); }
@media (min-width: 1024px) { .toasts { left: calc(var(--side) + 40px); right: 40px; bottom: 24px; justify-items: start; } }
@keyframes up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- entrance (login, codes) ---------- */
.entrance { max-width: 440px; margin: 0 auto; padding: 48px 16px 64px; }
.entrance .brand { padding: 0 0 40px; }
.entrance h1 { font-size: 1.75rem; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; margin-bottom: 12px; }
.entrance p { margin-top: 10px; }
.entrance .or { margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--rule); }
.prose > * + * { margin-top: 12px; }
.prose h2 { font-size: 1.0625rem; font-weight: 600; margin-top: 28px; border-top: 1px solid var(--rule-strong); padding-top: 12px; }
.prose ul { list-style: none; display: flex; flex-wrap: wrap; gap: 10px; }
.qr { width: 200px; height: 200px; background: #fff; /* QR stays black on white in dark mode */ padding: 8px; margin-top: 12px; }
.codes { font-size: 1.125rem; letter-spacing: .05em; columns: 2; }

@media print {
  .side, .tabbar, .toasts, .head .actions, .skip { display: none !important; }
  .main { padding: 0; }
  body { font-size: 11pt; }
}
.h1 { font-size: 1.375rem; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; margin: 12px 0 16px; }
@media (min-width: 1024px) { .h1 { font-size: 2rem; letter-spacing: -.015em; margin-top: 0; } }
.form-actions .form-actions { margin-top: 0; }
