/* Lumber Inventory
 *
 * Density is deliberate. These users compare dozens of rows at once, so this
 * is built to read like a trading terminal rather than a marketing page.
 *
 * Numbers carry the interface: tabular figures so digits align down a column,
 * right alignment on every numeric cell, and three decimals on every MBF value
 * because the team reconciles these figures against a spreadsheet.
 */

:root {
    --bg: #ffffff;
    --surface: #f7f7f8;
    --surface-2: #eeeef0;
    --border: #d4d4d8;
    --border-strong: #a1a1aa;
    --text: #18181b;
    --text-dim: #52525b;
    --text-faint: #71717a;
    --accent: #1d4ed8;
    --accent-bg: #eff6ff;
    --warn: #b45309;
    --warn-bg: #fffbeb;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --short: #78716c;

    --row-h: 32px;
    --pad-x: 10px;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
    --sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0c0c0e;
        --surface: #17171a;
        --surface-2: #202024;
        --border: #2e2e34;
        --border-strong: #52525b;
        --text: #f4f4f5;
        --text-dim: #a1a1aa;
        --text-faint: #71717a;
        --accent: #60a5fa;
        --accent-bg: #172554;
        --warn: #fbbf24;
        --warn-bg: #292014;
        --danger: #f87171;
        --danger-bg: #2a1516;
        --short: #a8a29e;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.45 var(--sans);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

/* ---------- layout ---------- */

.masthead {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.masthead h1 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.masthead .spacer { flex: 1; }

.masthead .who {
    color: var(--text-dim);
    font-size: 12px;
}

main { padding: 16px; max-width: 1600px; }

/* ---------- snapshot bar ---------- */

.snapshot {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 12px;
}

.snapshot .date {
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.snapshot .meta { color: var(--text-dim); font-size: 12px; }
.snapshot .meta code { font-family: var(--mono); font-size: 11px; }

/* ---------- position strip ---------- */

.strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.tile {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
}

a.tile { text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--border-strong); background: var(--surface-2); }
a.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tile .label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.tile .value {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums lining-nums;
    font-size: 19px;
    font-weight: 600;
    margin-top: 2px;
}

.tile .unit { font-size: 11px; color: var(--text-dim); }
.tile.is-active { border-color: var(--accent); background: var(--accent-bg); }

/* ---------- filters ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 8px;
}

.field { display: flex; flex-direction: column; gap: 3px; }

.field label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
}

select, input[type="text"], input[type="password"] {
    font: 13px var(--sans);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 5px 7px;
    min-height: 30px;
}

select:focus-visible,
input:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

select[multiple] { min-height: 96px; padding: 2px; }

button, .btn {
    font: 13px var(--sans);
    padding: 6px 12px;
    min-height: 30px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

button:hover, .btn:hover { border-color: var(--text-dim); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 3px 8px;
    background: var(--accent-bg);
    border: 1px solid var(--accent);
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
}

.chip:hover { background: var(--surface-2); }
.chip .x { font-weight: 700; color: var(--text-dim); }

/* ---------- tables ---------- */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    -webkit-overflow-scrolling: touch;
}

table { border-collapse: collapse; width: 100%; font-size: 13px; }

caption {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-strong);
    padding: 6px var(--pad-x);
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

thead th.num { text-align: right; }
thead th .unit { display: block; font-size: 10px; font-weight: 400; color: var(--text-faint); }

thead th a { color: inherit; text-decoration: none; display: block; }
thead th a:hover { color: var(--accent); }
thead th .arrow { color: var(--accent); }

tbody td, tfoot td {
    padding: 0 var(--pad-x);
    height: var(--row-h);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:hover { background: var(--surface); }

/* Numbers: monospace, tabular, right-aligned. Non-negotiable for scanning. */
.num {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums lining-nums;
}

.code { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

tfoot td {
    position: sticky;
    bottom: 0;
    background: var(--surface-2);
    border-top: 2px solid var(--border-strong);
    border-bottom: none;
    font-weight: 600;
}

tfoot tr.secondary td {
    font-weight: 400;
    color: var(--text-dim);
    border-top: 1px solid var(--border);
}

/* Oversold is routine committed volume, not an error -- a third of the book.
 * Colouring it red would train people to ignore red. The meaning is carried by
 * the minus sign and the badge, never by hue alone. */
.oversold td.net {
    border-left: 3px solid var(--short);
    padding-left: calc(var(--pad-x) - 3px);
}

.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0 4px;
    border: 1px solid var(--short);
    border-radius: 2px;
    color: var(--text-dim);
}

.pieces {
    font-size: 10px;
    color: var(--text-faint);
    margin-left: 3px;
}

/* ---------- notices ---------- */

.notice {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-dim);
}

.notice.warn {
    background: var(--warn-bg);
    border-color: var(--warn);
    color: var(--text);
}

.notice.error {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--text);
}

.empty { padding: 32px 16px; text-align: center; color: var(--text-dim); }
.empty h2 { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 6px; }

/* ---------- pagination ---------- */

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 2px;
    font-size: 12px;
    color: var(--text-dim);
}

.pager .count { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */

.login {
    max-width: 340px;
    margin: 10vh auto;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.login h1 { font-size: 16px; margin: 0 0 4px; }
.login p.sub { margin: 0 0 18px; color: var(--text-dim); font-size: 12px; }
.login .field { margin-bottom: 12px; }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- small screens ----------
 * Dense tables are the hard case. Cells are NOT stacked -- that destroys the
 * column comparison the screen exists for. The table scrolls sideways with the
 * identifying column pinned, and touch targets grow. */

@media (max-width: 900px) {
    :root { --row-h: 44px; --pad-x: 8px; }
    body { font-size: 14px; }
    main { padding: 10px; }

    tbody th[scope="row"], tbody td:first-child {
        position: sticky;
        left: 0;
        background: var(--bg);
        box-shadow: 1px 0 0 var(--border);
    }

    tbody tr:hover td:first-child { background: var(--surface); }
    button, .btn { min-height: 44px; }
    select, input { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------- upload ---------- */

.page-title { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
.page-title:first-child { margin-top: 0; }

.upload-form, .review {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 16px;
    max-width: 760px;
}

.upload-form .field { margin-bottom: 14px; }
.upload-form p.faint, .review p.faint { margin: 4px 0 0; font-size: 12px; }

input[type="file"], input[type="date"] {
    font: 13px var(--sans);
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 6px 8px;
    min-height: 32px;
}

.review h3 { margin: 0 0 4px; font-size: 14px; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin: 14px 0;
}

.summary-grid > div {
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
}

.summary-grid dt {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.summary-grid dd {
    margin: 2px 0 0;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums lining-nums;
    font-size: 16px;
    font-weight: 600;
}

.notice.ok { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.notice ul { margin: 8px 0 0; padding-left: 18px; }
.notice li { font-size: 12px; margin-bottom: 2px; }
.notice code { font-family: var(--mono); font-size: 11px; }

.confirm-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 14px;
}

/* An explicit acknowledgement, not a pre-ticked convenience. */
.ack { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; max-width: 52ch; }
.ack input { margin-top: 2px; width: 16px; height: 16px; }

.masthead nav { display: flex; gap: 14px; }
.masthead nav a { font-size: 12px; text-decoration: none; }
.masthead nav a:hover { text-decoration: underline; }
