:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --ink: #1c2330;
    --muted: #5f6b7a;
    --line: #e2e6ec;
    --accent: #0f6b5c;
    --accent-soft: #e3f3ef;
    --warn: #a4471b;
    --warn-soft: #fbece4;
    --radius: 12px;
    color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 60px; }
h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.25rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Top bar */
.topbar { background: #16202e; color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.brand { font-weight: 600; letter-spacing: .01em; }
.link-button { background: none; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; padding: 5px 12px; cursor: pointer; }
.link-button:hover { background: rgba(255,255,255,.1); }

/* Login */
.login { max-width: 420px; margin: 48px auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.login h1 { margin: 0 0 6px; font-size: 1.4rem; }
.login label { display: block; font-weight: 600; margin: 16px 0 6px; }
.pin { width: 100%; font-size: 1.6rem; letter-spacing: .6em; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.login button[type=submit] { width: 100%; margin-top: 16px; padding: 12px; font-size: 1rem; font-weight: 600; color: #fff; background: var(--accent); border: 0; border-radius: 10px; cursor: pointer; }
.login button[disabled] { opacity: .5; cursor: not-allowed; }
.camera video { width: 100%; aspect-ratio: 4 / 3; background: #0d1117; border-radius: 10px; object-fit: cover; transform: scaleX(-1); }
.alert { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; }

/* Detail page */
section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-top: 18px; }
.hero { display: flex; flex-direction: column; gap: 8px; }
.hero h1 { margin: 2px 0 12px; font-size: 1.7rem; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; margin: 0; }
.facts dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 500; }

.toc { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; background: var(--bg); padding: 10px 0; margin-top: 8px; }
.toc a { text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .88rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; background: none; border: 0; padding: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.card span { color: var(--muted); font-size: .85rem; }
.card strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.card.warn { border-left-color: var(--warn); }

.open-items { border-left: 4px solid var(--warn); }
.open-items h2 { color: var(--warn); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
table.amounts td:first-child { width: 70%; }
tfoot tr.total td { border-bottom: 0; }

.notes { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.notes li { margin: 4px 0; }
.doclinks { margin: 12px 0 0; }
a.doc { display: inline-block; font-size: .82rem; background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; margin: 2px 4px 2px 0; text-decoration: none; }
.note { border-left: 3px solid var(--line); padding: 2px 0 2px 14px; margin: 12px 0; }
.note h3 { margin: 0 0 4px; }
.note p { margin: 0; }

.doc-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px 24px; }
.doc-group h3 { margin-top: 6px; }
.doc-group ul { margin: 0; padding-left: 18px; }
.doc-group li { margin: 3px 0; }
details { margin-top: 6px; }
summary { cursor: pointer; color: var(--muted); font-size: .88rem; }

@media (max-width: 640px) {
    section { padding: 16px; }
    .hero h1 { font-size: 1.4rem; }
}

@media print {
    body { background: #fff; font-size: 11pt; }
    .topbar, .no-print, .toc { display: none !important; }
    section { border: 0; padding: 0; margin-top: 14px; break-inside: auto; }
    .cards { grid-template-columns: repeat(3, 1fr); }
    details { display: block; }
    details > * { display: block; }
    a { color: inherit; text-decoration: none; }
}
