/* RebarAutomation portal — "drafting ledger" design system.
   Brand hues from itech.kairosaitech.com (teal / navy / cream) kept intact;
   voice: engineering title-block precision + editorial typography.
   Type scale: perfect fourth (1.333) — 0.72 / 0.875 / 1 / 1.333 / 1.777 / 2.369rem.
   Fonts are self-hosted (strict CSP: default-src 'self', no font-src override). */

/* ---------- Self-hosted fonts (OFL) ---------- */

@font-face {
    font-family: "Archivo";
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url("/fonts/archivo-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Archivo";
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url("/fonts/archivo-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/plexmono-400-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/plexmono-400-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Cyrillic subset: bg-eurocode style-guide profiles surface Cyrillic element IDs
   and regexes in the config viewer's mono code chips. */
@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/plexmono-400-cyrillic.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/plexmono-500-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/plexmono-500-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("/fonts/plexmono-500-cyrillic.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- Tokens ---------- */

:root {
    --teal: #0EA5A0;
    --teal-deep: #0A7C78;
    --teal-soft: rgba(14, 165, 160, 0.09);

    --ink: #0B1A2D;
    --ink-mid: #15293F;
    --ink-soft: rgba(11, 26, 45, 0.05);

    --accent-red: #B91C1C;
    --accent-red-soft: rgba(185, 28, 28, 0.08);

    --paper: #F7F4EE;      /* warm cream paper — the sheet everything is drawn on */
    --surface: #FFFFFF;
    --cream: #EFEAE0;      /* deeper cream, for chips + tinted panels */
    --text: #0B1A2D;
    --hairline: rgba(11, 26, 45, 0.12);
    --hairline-strong: rgba(11, 26, 45, 0.22);
    /* Fable-audit finding: --hairline-strong measures ~1.6:1 on --surface/
       --paper — under WCAG 1.4.11's 3:1 floor for input-boundary contrast.
       A dedicated, stronger token for form-field borders specifically
       (~3.4:1 on white) rather than raising --hairline-strong itself, which
       backs plenty of decorative rules that don't need to clear that bar. */
    --hairline-input: rgba(11, 26, 45, 0.5);

    /* neutrals tinted toward the navy brand hue, never pure gray */
    --text-muted: #4E5C6E;
    /* #5A6678: darkened from an earlier #6B7789 (round-review finding) — that
       shade cleared AA only against pure white, but this redesign puts most
       micro-label/table-header text directly on --paper/--cream instead. */
    --text-subtle: #5A6678;

    /* drafting radius language: near-square */
    --r-xs: 2px;
    --r-sm: 4px;

    /* type scale — perfect fourth */
    --fs-micro: 0.72rem;
    --fs-small: 0.875rem;
    --fs-base: 1rem;
    --fs-h2: 1.333rem;
    --fs-h1: 1.777rem;
    --fs-display: 2.369rem;

    --font-display: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI",
                    "PingFang TC", "Microsoft JhengHei", sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI",
                 "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
                 "PingFang TC", "Microsoft JhengHei", monospace;
}

/* ---------- Reset + base ---------- */

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

html { height: 100%; color-scheme: light; }

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-display);
    color: var(--ink);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.15;
    margin: 0 0 0.75rem;
}

h1 { font-size: var(--fs-display); font-weight: 750; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-base); font-weight: 700; }

/* CJK never gets negative tracking */
:lang(zh-TW) h1, :lang(zh-TW) h2, :lang(zh-TW) h3 { letter-spacing: 0; }

p { margin: 0 0 1rem; }

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--hairline-strong); text-underline-offset: 3px; }
a:hover { color: var(--teal-deep); text-decoration-color: var(--teal); }

small { color: var(--text-muted); }

/* ---------- Mono micro-label (drafting title-block voice) ---------- */

.section-label {
    display: inline-flex;
    align-items: baseline;
    gap: 0.65rem;
    font-family: var(--font-mono);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: var(--fs-micro);
    color: var(--text-subtle);
    margin-bottom: 0.75rem;
}

.section-index {
    color: var(--teal-deep);
    font-weight: 500;
}

/* ---------- Layout shell ---------- */

.site-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--ink);
    border-bottom: 2px solid var(--teal);
}

.site-nav-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-right: auto;
    text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--r-xs);
    background: var(--teal);
    color: var(--ink);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
}

.brand-wordmark {
    font-family: var(--font-display);
    font-weight: 650;
    letter-spacing: 0.01em;
    color: var(--paper);
    font-size: 1rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.35rem;
    flex-wrap: wrap;
}

.nav-link {
    color: rgba(247, 244, 238, 0.72);
    font-weight: 500;
    font-size: var(--fs-small);
    text-decoration: none;
}

.nav-link:hover { color: #FFFFFF; text-decoration: none; }

.nav-user {
    font-family: var(--font-mono);
    color: rgba(247, 244, 238, 0.5);
    font-size: var(--fs-micro);
    padding-left: 1.35rem;
    border-left: 1px solid rgba(247, 244, 238, 0.18);
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding-left: 1.35rem;
    border-left: 1px solid rgba(247, 244, 238, 0.18);
}

.lang-switch-select {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    /* Explicit height, not line-height: Chrome ignores author line-height
       when sizing a native <select>'s closed box, so line-height alone
       can't be used to match this control's height to .lang-switch-submit's
       — height is the property that's actually respected here. */
    height: 1.65rem;
    color: rgba(247, 244, 238, 0.95);
    background: transparent;
    border: 1px solid rgba(247, 244, 238, 0.3);
    border-radius: var(--r-xs);
    padding: 0.15rem 0.35rem;
}

.lang-switch-select:hover { border-color: rgba(247, 244, 238, 0.6); }

.lang-switch-select option { color: var(--ink); }

.lang-switch-submit {
    /* Fable-audit finding: a borderless, unpadded glyph read as a stray
       character rather than a button. Bordered + padded so it reads as
       the necessary no-JS submit control it is, with a real hit area
       instead of a bare 16px glyph. Explicit height (not padding or
       line-height) matches this control to .lang-switch-select's height —
       see that rule's comment for why. inline-flex centering keeps the
       glyph centered regardless of font metrics. */
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(247, 244, 238, 0.72);
    background: transparent;
    border: 1px solid rgba(247, 244, 238, 0.4);
    border-radius: var(--r-xs);
    cursor: pointer;
    padding: 0 0.6rem;
}

.lang-switch-submit:hover {
    color: #FFFFFF;
    border-color: rgba(247, 244, 238, 0.6);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nav-form { display: inline-flex; margin: 0; }

.site-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2.75rem 1.25rem 5rem;
}

.page-narrow { max-width: 620px; }

/* ---------- Page header: title block ---------- */

.page-header {
    margin-bottom: 2.25rem;
    padding-bottom: 1.1rem;
    border-bottom: 2px solid var(--ink);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 0.25rem 2rem;
}

.page-header > * { grid-column: 1; }

.page-header h1 { margin-bottom: 0; }

.page-header .page-subtitle {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    margin: 0 0 0.3rem;
    max-width: 26rem;
    text-align: right;
    overflow-wrap: break-word;
}

@media (max-width: 640px) {
    .page-header { grid-template-columns: 1fr; }
    .page-header .page-subtitle { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 0.4rem; }
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1.4rem;
    border: 1px solid transparent;
    border-radius: var(--r-xs);
    font-family: var(--font-body);
    font-size: var(--fs-small);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms ease, color 140ms ease,
                border-color 140ms ease, transform 140ms ease;
}

.btn:hover { text-decoration: none; }

/* Primary action = ink stamp; teal stays scarce */
.btn-primary {
    background: var(--ink);
    color: var(--paper);
}

.btn-primary:hover {
    background: var(--teal-deep);
    color: #FFFFFF;
}

/* The single teal button: reserved for the hero call-to-action on ink panels */
.btn-accent {
    background: var(--teal);
    color: var(--ink);
    font-weight: 700;
}

.btn-accent:hover {
    background: #14B8A6;
    color: var(--ink);
}

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--hairline-strong);
}

.btn-secondary:hover {
    border-color: var(--ink);
    color: var(--ink);
}

.btn-ghost {
    background: transparent;
    color: rgba(247, 244, 238, 0.72);
    border-color: rgba(247, 244, 238, 0.4);
    padding: 0.32rem 0.95rem;
    font-size: var(--fs-micro);
}

.btn-ghost:hover {
    color: #FFFFFF;
    border-color: rgba(247, 244, 238, 0.6);
}

.btn-block { width: 100%; }

/* Inline text-button (auto-refresh pause/resume toggle) — reads as a link
   inside a sentence, not a boxed button, so it sits in a .viewer-hint line
   without disrupting the mono/micro rhythm around it. */
.btn-ghost-inline {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    font-weight: 600;
    color: var(--teal-deep);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

.btn-ghost-inline:hover { color: var(--ink); }

.btn:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
.btn-ghost-inline:focus-visible {
    /* --teal is only 2.77:1 against --paper — under the 3:1 non-text minimum
       for a focus indicator (WCAG 1.4.11) on links/inputs sitting directly on
       the page background. --teal-deep clears 3:1 against paper, cream, white,
       and the ink nav alike, so one outline color works everywhere. */
    outline: 2px solid var(--teal-deep);
    outline-offset: 2px;
}

/* ---------- Panels (used sparingly — most content sits on the paper) ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--r-sm);
    padding: 1.5rem;
}

.panel-ink {
    position: relative;
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--r-sm);
    padding: 2rem;
    overflow: hidden;
}

/* rebar-grid motif: hairline drafting grid drawn in pure CSS */
.panel-ink::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, rgba(247, 244, 238, 0.06) 0, rgba(247, 244, 238, 0.06) 1px, transparent 1px, transparent 28px),
        repeating-linear-gradient(90deg, rgba(247, 244, 238, 0.06) 0, rgba(247, 244, 238, 0.06) 1px, transparent 1px, transparent 28px);
    pointer-events: none;
}

.panel-ink > * { position: relative; }

.panel-ink h1, .panel-ink h2, .panel-ink h3 { color: var(--paper); }
.panel-ink p { color: rgba(247, 244, 238, 0.72); }
.panel-ink .section-label { color: rgba(247, 244, 238, 0.55); }
.panel-ink .section-index { color: var(--teal); }

/* ---------- Dashboard composition ---------- */

.dash-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: stretch;
}

.dash-hero .panel-ink {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    min-height: 15rem;
}

.dash-hero .panel-ink h2 { font-size: var(--fs-h1); margin-bottom: 0.35rem; }
.dash-hero .panel-ink p { max-width: 26rem; margin-bottom: 1.35rem; }

.dash-index {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dash-index li { border-top: 1px solid var(--hairline-strong); }
.dash-index li:first-child { border-top: none; }

.index-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: baseline;
    gap: 1rem;
    padding: 1.15rem 0.25rem;
    text-decoration: none;
    color: var(--text);
    transition: background-color 140ms ease;
}

.index-row:hover { background: var(--ink-soft); text-decoration: none; color: var(--text); }

.index-num {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    color: var(--teal-deep);
}

.index-row h2 { font-size: var(--fs-h2); margin: 0 0 0.15rem; }
.index-row p { color: var(--text-muted); font-size: var(--fs-small); margin: 0; }

.index-arrow {
    font-family: var(--font-mono);
    color: var(--text-subtle);
    transition: transform 140ms ease, color 140ms ease;
}

.index-row:hover .index-arrow { color: var(--teal-deep); transform: translateX(3px); }

@media (max-width: 760px) {
    .dash-hero { grid-template-columns: 1fr; }
}

/* ---------- Section heading rows ---------- */

.page-section { margin-top: 3.25rem; }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 0.55rem;
    margin-bottom: 0;
}

/* a section-head doubles as the ledger's opening rule */
.section-head + .table-card,
.section-head + .empty-state { border-top: none; }

/* Error.cshtml: .page-header's own border-bottom plus .empty-state's default
   border-top otherwise reads as a doubled rule when they sit directly
   adjacent (fable-audit finding) — same cancellation as the .section-head
   case above, just for the other block that can precede .empty-state. */
.page-header + .empty-state { border-top: none; }

.section-head h2 { margin: 0; }

.section-head .section-label { margin: 0; }

a.section-label { text-decoration: none; }
a.section-label:hover { color: var(--teal-deep); }

.table-footer-link {
    margin: 1rem 0 0;
    font-weight: 600;
    font-size: var(--fs-small);
}

/* ---------- Forms ---------- */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field label {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-mid);
}

.field input,
.field select {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--hairline-input);
    border-radius: var(--r-xs);
    padding: 0.55rem 0.75rem;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field input:focus,
.field select:focus {
    /* --teal-deep, not --teal (2.77:1 on --paper, under the 3:1 WCAG 1.4.11
       floor) — (.field input:focus) outranks the universal :focus-visible
       rule's specificity, so this is the color that actually reaches every
       form field's keyboard-focus state; box-shadow alone is too faint to
       stand in for it. */
    outline: none;
    border-color: var(--teal-deep);
    box-shadow: 0 0 0 3px var(--teal-soft);
}

.field input.input-validation-error,
.field select.input-validation-error {
    border-color: var(--accent-red);
}

.field input.input-validation-error:focus,
.field select.input-validation-error:focus {
    /* Round-3 review: the soft box-shadow alone (--accent-red-soft, alpha
       0.08) measures ~1.1-1.25:1 against paper/surface — nowhere near the
       3:1 WCAG 1.4.11 floor — and the sibling .input-validation-error rule's
       border-color ties this rule's specificity, winning on source order, so
       border-color never actually changed on focus either. An explicit
       outline (not shared with --accent-red-soft, which also backs
       .validation-summary-errors' panel tint) is what makes focus visible
       on an already-invalid field. --accent-red measures 5.89:1 on --paper.
    */
    outline: 2px solid var(--accent-red);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px var(--accent-red-soft);
}

.field input[type="file"] {
    padding: 0.5rem;
    background: var(--paper);
    border-style: dashed;
    cursor: pointer;
}

.field input[type="file"]::file-selector-button {
    font-family: var(--font-body);
    font-size: var(--fs-small);
    font-weight: 600;
    color: var(--paper);
    background: var(--ink);
    border: none;
    border-radius: var(--r-xs);
    padding: 0.45rem 1rem;
    margin-right: 0.85rem;
    cursor: pointer;
    transition: background-color 140ms ease;
}

.field input[type="file"]::file-selector-button:hover {
    background: var(--teal-deep);
}

.form-actions { margin-top: 0.35rem; }

.field-hint {
    margin: 0.4rem 0 0;
    font-size: var(--fs-micro);
    color: var(--text-subtle);
}

.field-hint a { color: var(--teal-deep); text-decoration-color: currentColor; }
.field-hint a:hover { color: var(--ink); }
/* Decorative arrow via CSS content, not embedded in the translatable resx
   string — same idiom as .back-link::before, keeps it out of the link's
   accessible name. */
.field-hint a::after { content: "\2192"; margin-left: 0.3em; text-decoration: none; display: inline-block; }

.form-footer {
    margin-top: 1.5rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--hairline);
    font-size: var(--fs-small);
    color: var(--text-muted);
}

/* One-shot success notice (e.g. "Uploaded — processing" after the upload redirect) */
.notice {
    background: var(--teal-soft);
    border: 1px solid rgba(10, 124, 120, 0.35);
    border-radius: var(--r-xs);
    color: var(--teal-deep);
    font-weight: 600;
    font-size: var(--fs-small);
    padding: 0.7rem 1rem;
    margin-bottom: 1.25rem;
}

/* Validation summary: Razor renders .validation-summary-valid (empty) when clean */
.validation-summary-valid { display: none; }

.validation-summary-errors {
    background: var(--accent-red-soft);
    border: 1px solid rgba(185, 28, 28, 0.25);
    border-radius: var(--r-xs);
    color: var(--accent-red);
    font-size: var(--fs-small);
    padding: 0.7rem 1rem;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 1.1rem;
}

/* ---------- Auth pages: asymmetric split ---------- */

.auth-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: 3.5rem;
    /* Fable-audit finding: stretch forced .auth-brand to match the taller of
       the two columns — Register's form (4 fields) is noticeably taller than
       Login's (2 fields), so Register's shorter brand content (no feature
       list) got stretched into a mostly-empty box. align-items:start lets
       each panel size to its own content instead. */
    align-items: start;
    max-width: 940px;
    margin: 1.5rem auto 0;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 22rem;
}

.auth-brand .brand-title {
    font-family: var(--font-display);
    font-size: var(--fs-display);
    font-weight: 750;
    letter-spacing: -0.015em;
    line-height: 1.05;
    margin: 0 0 0.6rem;
    color: var(--paper);
}

.auth-brand p { margin: 0; }

.auth-brand .section-label { display: block; margin: 1.75rem 0 0.5rem; }

.auth-features {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-features li {
    display: flex;
    gap: 0.9rem;
    padding: 0.8rem 0;
    border-top: 1px solid rgba(247, 244, 238, 0.14);
}

.auth-features li:first-child { border-top: none; padding-top: 0; }

.auth-features .feature-num {
    flex: none;
    padding-top: 0.15rem;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--teal);
}

.auth-features .feature-title { margin: 0 0 0.15rem; font-size: var(--fs-small); font-weight: 650; color: var(--paper); }
/* Fable-audit finding: the only persuasive copy on the page was set at
   --fs-micro (11.5px) — plenty of contrast, but too small to read as sales
   copy rather than fine print. */
.auth-features p { font-size: var(--fs-small); margin: 0; }

.auth-form-col {
    padding-top: 1rem;
    /* Fable-audit finding: the ink brand panel is taller than the form on
       desktop, leaving the form stranded near the top with empty space
       below it — centering it against the panel balances the composition. */
    align-self: center;
}

.auth-form-col h1 {
    font-size: var(--fs-h1);
    margin-bottom: 1.5rem;
}

@media (max-width: 760px) {
    .auth-split { grid-template-columns: 1fr; gap: 1.75rem; margin-top: 0; }
    .auth-brand { min-height: 0; padding: 1.5rem; }
    .auth-brand .brand-title { font-size: var(--fs-h1); }
    .auth-form-col { align-self: auto; }
    /* Fable-audit finding: the feature list pushed the sign-in form (the one
       action this page exists for) below the fold on a phone. The list is
       genuinely useful to a prospect evaluating the product on desktop, but
       on mobile the form itself takes priority — the features remain one
       tap away via the page the user is actually here for. */
    .auth-brand .section-label,
    .auth-brand .auth-features {
        display: none;
    }
}

/* ---------- Upload: form + "general notes" rail (title-block sheet notes) ---------- */

.upload-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
    gap: 3rem;
    align-items: start;
}

.upload-notes .code-value + .code-value { margin-left: 0.35rem; }

/* min-width, not an override inside the existing max-width:640px .kv-grid
   rule — a two-class selector here would always beat that rule's one-class
   selector regardless of source order, so the notes rail would never
   collapse to one column on phones like every other .kv-grid does. */
@media (min-width: 641px) {
    .upload-notes .kv-grid { grid-template-columns: minmax(140px, 200px) 1fr; }
}

@media (max-width: 760px) {
    .upload-split { grid-template-columns: 1fr; gap: 1.75rem; }
}

/* ---------- Step list (first-run guidance — Jobs empty state) ---------- */

.step-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
    max-width: 34rem;
}

.step-list li {
    padding: 1.1rem 0;
    border-top: 1px solid var(--hairline-strong);
}

.step-list li:first-child { border-top: none; padding-top: 0; }

.step-num {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    color: var(--teal-deep);
    margin-bottom: 0.3rem;
}

.step-list h2 { margin: 0 0 0.3rem; font-size: var(--fs-base); }
/* .empty-state p's own margin-bottom:1.1rem rule is equal specificity and
   later in the file — outranking it on source order alone, so it must be
   overridden explicitly here rather than relying on .step-list p's own
   (equal-specificity, earlier) margin:0. */
.empty-state .step-list p { margin: 0; }
.step-list p { color: var(--text-muted); font-size: var(--fs-small); }
.step-list .btn { margin-top: 0.85rem; }

/* ---------- Ledger tables (open — no card chrome) ---------- */

.table-card {
    border-top: 2px solid var(--ink);
    overflow-x: auto;
    /* Scroll affordance for narrow viewports (the material list is 9 columns):
       edge shadows that appear only when content actually overflows, and fade
       as that edge is reached — pure CSS (Lea Verou's scrolling-shadows
       pattern), invisible when the table fits. */
    background:
        linear-gradient(to right, var(--paper) 30%, rgba(247, 244, 238, 0)) left / 40px 100%,
        linear-gradient(to left, var(--paper) 30%, rgba(247, 244, 238, 0)) right / 40px 100%,
        radial-gradient(farthest-side at 0 50%, rgba(11, 26, 45, 0.22), transparent) left / 14px 100%,
        radial-gradient(farthest-side at 100% 50%, rgba(11, 26, 45, 0.22), transparent) right / 14px 100%;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-small);
}

.data-table th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-subtle);
    padding: 0.65rem 1rem 0.55rem;
    border-bottom: 1px solid var(--hairline-strong);
    white-space: nowrap;
}

/* A numeric column's header must line up over its right-aligned values —
   .data-table th's own text-align:left otherwise outranks the plain
   .cell-numeric rule below on specificity alone. */
.data-table th.cell-numeric { text-align: right; }

.data-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.75); }

.cell-muted {
    color: var(--text-muted);
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.cell-actions { white-space: nowrap; }
.cell-actions a { font-weight: 600; font-size: var(--fs-small); }

.cell-filename {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 550;
}

.cell-numeric {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Status flags (class names come from JobStatusPill.For — keep) ---------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

.status-pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status-done { color: var(--teal-deep); }
.status-working { color: var(--text-muted); }
.status-failed { color: var(--accent-red); }

/* WORKING is the one status that means "still alive, not stuck" — the dot
   pulses to carry that liveness, same job an LED does on a panel.
   WCAG 2.2.2 (Pause/Stop/Hide) note: this can run indefinitely while a job
   stays WORKING (round-2 review flagged the lack of an on-page pause
   control). Judged acceptable without one: the pulse is purely decorative
   reinforcement of information the status-pill LABEL TEXT already states in
   full ("QUEUED"/"RECOGNIZING", never gray-and-silent) — stopping the
   animation removes no information, which is 2.2.2's own essential-exception
   test. prefers-reduced-motion is the mechanism for anyone who wants it off. */
@media (prefers-reduced-motion: no-preference) {
    .status-working::before { animation: status-pulse 1.6s ease-in-out infinite; }

    @keyframes status-pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.35; }
    }
}

.auto-refresh-status {
    color: var(--accent-red);
    font-weight: 600;
}
.auto-refresh-status::before { content: "● "; font-size: 0.6em; vertical-align: 0.1em; }

/* ---------- Failure annotation row (ledger margin note under a FAILED row) ---------- */

/* the failed row and its note read as one entry: drop the hairline between them
   (:has degrades harmlessly to an extra hairline on older engines) */
.data-table tr:has(+ .row-note) td { border-bottom: none; }

.row-note td {
    padding: 0 1rem 0.85rem;
    font-size: var(--fs-small);
    color: var(--accent-red);
    overflow-wrap: anywhere;
}

.row-note-label {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-right: 0.5rem;
}

/* ---------- Empty state: annotation note ---------- */

.empty-state {
    border-top: 2px solid var(--ink);
    background: var(--cream);
    border-radius: 0 0 var(--r-sm) var(--r-sm);
    padding: 2.25rem 1.75rem;
    color: var(--text-muted);
    max-width: 44rem;
}

.empty-state p { margin-bottom: 1.1rem; max-width: 34rem; }
.empty-state p:last-child { margin-bottom: 0; }

/* ---------- CAD viewer chrome ---------- */

.viewer-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.viewer-toolbar .field { min-width: 200px; }

.legend {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--text-muted);
    margin: 0;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    flex: none;
}

/* Swatch colors mirror the SVG scene markup — do not retheme */
.legend-beam { background: steelblue; border-radius: 2px; }
.legend-column { background: darkorange; border-radius: 50%; }
.legend-issue { border: 2px solid red; border-radius: 50%; }

.viewer-frame {
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-xs);
    padding: 0.4rem;
}

.viewer-hint {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--text-subtle);
    margin: 0.5rem 0 0;
    text-align: right;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1.75rem;
    font-weight: 600;
    font-size: var(--fs-small);
}

.back-link::before { content: "\2190"; }

/* ---------- Result tabs: drafting underline, not capsules ---------- */

.view-tabs {
    display: flex;
    gap: 1.75rem;
    border-bottom: 1px solid var(--hairline-strong);
    margin-bottom: 1.5rem;
}

.view-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.1rem 0.55rem;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-subtle);
    text-decoration: none;
}

a.view-tab:hover {
    color: var(--ink);
    text-decoration: none;
}

.view-tab-active {
    color: var(--ink);
    border-bottom-color: var(--teal);
}

/* ---------- Style guide viewer ---------- */

.kv-grid {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 0.6rem 1.5rem;
    align-items: baseline;
    margin: 0;
    padding: 1.25rem 0 0.25rem;
}

@media (max-width: 640px) {
    .kv-grid { grid-template-columns: 1fr; gap: 0.15rem; }
    .kv-grid .kv-value { margin-bottom: 0.7rem; }
}

.kv-key {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ink-mid);
}

.kv-value { margin: 0; }

.code-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--cream);
    border: 1px solid var(--hairline);
    border-radius: var(--r-xs);
    padding: 0.12rem 0.45rem;
    word-break: break-all;
}

.muted-note {
    color: var(--text-muted);
    font-size: var(--fs-small);
}

.guide-table { margin-top: 1.5rem; }
.guide-table > h3 { margin-bottom: 0.6rem; }
.guide-table .muted-note { max-width: 34rem; }

/* section rail: number + rule anchors each style-guide block */
.rail-section {
    display: grid;
    grid-template-columns: 3.5rem minmax(0, 1fr);
    gap: 0 1.5rem;
    margin-top: 3.25rem;
}

.rail-section > .rail {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    font-weight: 500;
    color: var(--teal-deep);
    padding-top: 0.35rem;
    border-top: 2px solid var(--ink);
}

.rail-section > .rail-body { min-width: 0; border-top: 2px solid var(--ink); padding-top: 0.75rem; }

.rail-section .rail-body > h2 { margin-bottom: 0.25rem; }

@media (max-width: 640px) {
    .rail-section { grid-template-columns: 1fr; }
    .rail-section > .rail { border-top: none; padding-top: 0; }
}

/* ---------- The one motion moment: staggered ledger reveal (dashboard, auth pages) ---------- */

@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(7px);
        animation: reveal-in 480ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
        animation-delay: calc(var(--i, 0) * 45ms);
    }

    @keyframes reveal-in {
        to { opacity: 1; transform: none; }
    }
}
