/* Snowgrow portal: desktop-only admin UI. Tokens first; light and dark follow the system. */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafc; --sunken: #eef1f5;
  --border: #dfe4ea; --border-strong: #c8d0da;
  --text: #17202b; --muted: #5d6b7a; --faint: #8794a3;
  --accent: #0b7a6f; --accent-hover: #09655c; --accent-soft: #e2f3f0; --accent-ink: #ffffff;
  --ok: #178a4c; --ok-soft: #e1f4e8; --warn: #a86500; --warn-soft: #fcefd3;
  --error: #c0322b; --error-soft: #fbe4e2; --info: #2b61c7; --info-soft: #e3ebfb;
  --pending: #6a7686; --pending-soft: #e9edf2;
  --side-bg: #101923; --side-text: #b9c4d0; --side-active: #ffffff; --side-active-bg: #1d2b3a; --side-border: #1f2c3a;
  --shadow: 0 1px 2px rgba(16,25,35,.06), 0 4px 14px rgba(16,25,35,.06);
  --radius: 8px; --radius-sm: 5px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --topbar: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141c; --surface: #141d28; --surface-2: #182332; --sunken: #0f1822;
    --border: #243244; --border-strong: #33455b;
    --text: #e4eaf1; --muted: #9aa8b8; --faint: #6f7e90;
    --accent: #3cbfae; --accent-hover: #5fd0c1; --accent-soft: #123a37; --accent-ink: #06201d;
    --ok: #4cc283; --ok-soft: #12301f; --warn: #e7a73c; --warn-soft: #382a0d;
    --error: #ef6b62; --error-soft: #3a1815; --info: #7ba4f2; --info-soft: #172a4d;
    --pending: #93a1b3; --pending-soft: #1d2937;
    --side-bg: #0a1017; --side-active-bg: #16222f; --side-border: #18232f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
h3 { font-size: 13px; margin: 0; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .nowrap { white-space: nowrap; }
.right { text-align: right; } .grow { flex: 1; } [x-cloak] { display: none !important; }

/* ── shell ─────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-width: 1100px; }
.sidebar { background: var(--side-bg); color: var(--side-text); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; border-right: 1px solid var(--side-border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: #fff; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #3cbfae, #0b7a6f); display: grid; place-items: center; color: #06201d; font-weight: 800; font-size: 14px; }
.nav-section { margin: 14px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6c7c8e; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0; border-radius: 6px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-active-bg); color: var(--side-active); text-decoration: none; }
.nav a.active { background: var(--side-active-bg); color: var(--side-active); box-shadow: inset 2px 0 0 #3cbfae; }
.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; font-size: 11px; background: #2a3a4c; color: #d6dee8; border-radius: 99px; padding: 0 7px; }
.nav .count.bad { background: var(--error); color: #fff; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--side-border); display: flex; align-items: center; gap: 8px; font-size: 13px; }
.side-foot button { margin-left: auto; background: none; border: 1px solid #2c3d50; color: var(--side-text); border-radius: 6px; padding: 3px 9px; cursor: pointer; font: inherit; font-size: 12px; }
.side-foot button:hover { color: #fff; border-color: #4a6078; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 10px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.search { position: relative; width: 420px; }
.search input[type=search] { width: 100%; padding: 8px 40px 8px 34px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
.search input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search .icon { position: absolute; left: 10px; top: 9px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.search .icon svg { width: 16px; height: 16px; display: block; }
.search kbd { position: absolute; right: 9px; top: 7px; font: 11px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 6px; color: var(--muted); background: var(--surface-2); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.search-results a { display: flex; gap: 10px; align-items: baseline; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--border); }
.search-results a:last-child { border: 0; }
.search-results a:hover, .search-results a.sel { background: var(--accent-soft); text-decoration: none; }
.search-results .tk { font-weight: 650; min-width: 64px; }
.search-empty { padding: 12px; color: var(--muted); }
.content { padding: 24px 28px 64px; max-width: 1680px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── building blocks ───────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head .meta { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; } .cols-2 { grid-template-columns: 1fr 1fr; } .cols-3 { grid-template-columns: repeat(3, 1fr); } .cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-main { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); }
.stack > * + * { margin-top: 16px; }
.stat { padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .foot { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--error); } .btn.danger:hover { background: var(--error-soft); border-color: var(--error); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; border-radius: 6px; } .btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--text); } .btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  padding: 6px 9px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input.invalid, select.invalid { border-color: var(--error); }
label.field { display: grid; gap: 3px; font-size: 12.5px; color: var(--muted); } .field-error { color: var(--error); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border-strong); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg a, .seg button { padding: 5px 12px; color: var(--muted); border: 0; background: none; font: inherit; font-weight: 550; cursor: pointer; border-right: 1px solid var(--border); }
.seg > :last-child { border-right: 0; } .seg a:hover { background: var(--sunken); text-decoration: none; color: var(--text); }
.seg .on { background: var(--accent-soft); color: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; background: var(--pending-soft); color: var(--pending); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok, .badge.success { background: var(--ok-soft); color: var(--ok); } .badge.warn, .badge.partial, .badge.skipped, .badge.drift { background: var(--warn-soft); color: var(--warn); }
.badge.error, .badge.failed, .badge.abandoned { background: var(--error-soft); color: var(--error); } .badge.running, .badge.info { background: var(--info-soft); color: var(--info); }
.badge.running::before { animation: pulse 1.4s infinite; } @keyframes pulse { 50% { opacity: .25; } }
.badge.plain::before { display: none; }
.filter-slot { display: inline-flex; gap: 4px; align-items: center; }
.chip { display: inline-block; padding: 0 7px; border-radius: 5px; background: var(--sunken); font: 12px var(--mono); color: var(--muted); }

table { border-collapse: collapse; width: 100%; }
.data th, .data td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; position: sticky; top: var(--topbar); z-index: 5; }
.data th.num, .data td.num { text-align: right; }
.data tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.data tr.clickable { cursor: pointer; }
.data th a { color: inherit; } .data th a:hover { color: var(--text); text-decoration: none; } .data th .arrow { color: var(--accent); }
.table-card { overflow: clip; } /* clip, not hidden: sticky table headers must keep scrolling with the page */
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager .grow { flex: 1; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.notice { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 14px; }
.notice.info { background: var(--info-soft); border-color: transparent; } .notice.warn { background: var(--warn-soft); border-color: transparent; }
.notice.error { background: var(--error-soft); border-color: transparent; color: var(--error); } .notice.ok { background: var(--ok-soft); border-color: transparent; }
#toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; width: 360px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; } .tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .spacer { flex: 1; }
.spark { width: 120px; height: 28px; } .spark path { fill: none; stroke: var(--accent); stroke-width: 1.6; } .spark circle { fill: var(--accent); }
.bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; min-width: 80px; } .bar > i { display: block; height: 100%; background: var(--accent); }
pre.json { margin: 0; padding: 8px 10px; background: var(--sunken); border-radius: 6px; font: 12px/1.45 var(--mono); max-width: 560px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
details > summary { cursor: pointer; color: var(--accent); } details[open] > summary { margin-bottom: 6px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; } .htmx-indicator { opacity: 0; transition: opacity .15s; }
.loading { opacity: .55; transition: opacity .15s; }

/* ── login ─────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 380px; padding: 30px; } .login-card h1 { margin: 14px 0 4px; } .login-card form { display: grid; gap: 14px; margin-top: 20px; }
.login-card .brand { padding: 0; color: var(--text); }

/* ── company header ────────────────────────────────── */
.co-head { display: flex; align-items: center; gap: 18px; }
.co-head .tk { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.co-head .nm { font-size: 15px; color: var(--muted); }
.co-head .facts { margin-left: auto; display: flex; gap: 24px; }
.co-head .facts div { text-align: right; } .co-head .facts .l { color: var(--muted); font-size: 12px; } .co-head .facts .v { font-weight: 600; }

/* ── statement explorer ────────────────────────────── */
.explorer-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.explorer-controls label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.explorer-controls select { color: var(--text); }
.stmt-wrap { overflow: auto; max-height: calc(100vh - 250px); }
table.stmt { width: max-content; min-width: 100%; font-variant-numeric: tabular-nums; }
.stmt th, .stmt td { padding: 6px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.stmt thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); text-align: right; font-weight: 650; font-size: 13px; }
.stmt thead th small { display: block; font-weight: 450; color: var(--muted); font-size: 11.5px; }
.stmt thead th.fail { box-shadow: inset 0 -3px 0 var(--error); }
.stmt th.label, .stmt td.label { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; min-width: 280px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--border); }
.stmt thead th.label { z-index: 4; background: var(--surface-2); }
.stmt td.v { text-align: right; cursor: pointer; }
.stmt td.v:hover { background: var(--accent-soft); }
.stmt td.v .d { display: block; font-size: 11.5px; color: var(--faint); line-height: 1.15; }
.stmt td.v .d.up { color: var(--ok); } .stmt td.v .d.down { color: var(--error); }
.stmt td.empty { color: var(--faint); text-align: right; }
.stmt tr.total td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.stmt tr.total td.label { background: var(--surface-2); }
.stmt tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface)); }
.stmt tr.total:hover td { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface-2)); }
.mark { font-size: 9px; vertical-align: super; margin-left: 3px; color: var(--info); } .mark.restated { color: var(--warn); }
.legend { display: flex; gap: 16px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; }
.drawer { position: fixed; right: 20px; bottom: 20px; width: 380px; z-index: 60; padding: 16px; }
.drawer .kv dd { overflow-wrap: anywhere; }
.drawer h2 { margin-bottom: 8px; } .drawer .x { position: absolute; right: 10px; top: 8px; }

/* ── mapping editor ────────────────────────────────── */
table.map { table-layout: fixed; }
.map td, .map th { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.map thead th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; position: sticky; top: var(--topbar); z-index: 5; }
.map tbody.line { border-bottom: 2px solid var(--border-strong); }
.map tr.head td { background: var(--surface-2); font-weight: 600; }
.map tbody.line:hover tr.head td { background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface-2)); }
.map tr.cand td { font-size: 13px; }
.map .handle { cursor: grab; color: var(--faint); text-align: center; user-select: none; font-size: 16px; }
.map .ord { color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.map input[type=text], .map input[type=number], .map select { width: 100%; }
.map tr.edit td { background: var(--accent-soft); }
.sortable-ghost { opacity: .35; } .sortable-chosen tr.head td { background: var(--accent-soft); }
.tag { font: 12.5px var(--mono); overflow-wrap: anywhere; }
.map td.muted { white-space: nowrap; }
.formula { font: 12.5px var(--mono); color: var(--info); }
.saved-flash { animation: flash 1.2s ease-out; } @keyframes flash { from { background: var(--ok-soft); } to { background: transparent; } }

/* filing text browser */
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: inherit; }
.chunk-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.outline { position: sticky; top: calc(var(--topbar, 56px) + 12px); max-height: calc(100vh - 120px); overflow: auto; }
.outline nav { display: flex; flex-direction: column; padding: 6px; }
.outline nav a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 8px; border-radius: 6px; color: inherit; text-decoration: none; font-size: 13px; }
.outline nav a:hover { background: var(--sunken); }
.outline nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.outline nav a.sub { padding-left: 22px; color: var(--muted); }
.outline nav .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.outline nav .part { margin: 8px 8px 2px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.chunks td.where { white-space: normal; font-size: 12.5px; color: var(--muted); max-width: 260px; }
table.chunks td.preview { white-space: normal; font-size: 13px; }
table.chunks td.detail { background: var(--sunken); white-space: normal; }
.chunk-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; margin-bottom: 6px; }
.chunk-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.55; max-height: 520px; overflow: auto; }
.chunk-text.table { font: 12.5px/1.45 var(--mono); white-space: pre; overflow-x: auto; }
#chunk-text.chunk-text { max-height: none; }
