/* ==========================================================================
   Project O — global stylesheet (single file, fixed sections; TASK-08)

   Section map (search for the "== SECTION" banners):
     1. TOKENS        design tokens, light + dark (semantic names canonical)
     2. BASE          reset, typography, topbar, container, page heading
     3. LAYOUT        panels, records, tables, toolbar, module nav, dialogs
     4. COMPONENTS    buttons, forms, badges, notices, status badges, combo
     5. MODULES       per-plugin business styles, namespaced by feature:
                      .project-* / .admin-* / .settings-* (project home, admin)
                      .kpi-* / .work-queue-* / .doc-home-* (document home)
                      .issue-* / .share-* / .thumb* / .image-* (documents, crew)
                      .entry-* / .ledger-* / .estimate-* (estimates)
                      .material-* / .rail-* (materials catalogue)
     6. RESPONSIVE    media queries kept next to their section

   Rules for new styles:
     - Colors/spacing/radii come from tokens; never hardcode a theme color.
     - Dark theme = token flip in body.theme-dark; add an override ONLY when
       the dark value is intentionally different (e.g. input surface).
     - Plugin styles must stay inside their feature namespace; do not restyle
       bare .button / table / label from a module section.
     - No !important without a comment explaining why.
     - The file is loaded once via views/layout.php with a content fingerprint
       (?v=sha1(mtime:size)); splitting into multiple files would require
       updating that loader, so keep the single-file organization for now.

   Design tokens (UI Design System V2) — single source of truth for both themes.
   Semantic names are canonical; the legacy names (--surface, --text-muted,
   --accent, …) stay as aliases because plugin assets (issue-location.css)
   and page-level styles still reference them. Do not fork per-module colors.
   ========================================================================== */

/* == SECTION 1: TOKENS ==================================================== */
:root {
    color-scheme: light;
    font-family: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;

    /* layout — V2.1 prototype: 58px top bar, 248px project sidebar */
    --topbar-h: 58px;
    --content-max: 1700px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --control-h: 35px;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 64px;

    /* surfaces & borders — V2.1 Linear-inspired light palette */
    --page: #f7f8fa;
    --page-glow: #f7f8fa;
    --surface-0: #fff;
    --surface-1: #fbfcfd;
    --surface-2: #f0f2f5;
    --border-subtle: #e8ebef;
    --border-strong: #d9dee6;
    --overlay-strong: rgb(255 255 255 / 92%);
    --overlay-soft: rgb(255 255 255 / 86%);

    /* text — all ≥4.5:1 on page/surface-0/1/2 (WCAG AA) */
    --text-primary: #20242b;
    --text-secondary: #424955;
    --text-tertiary: #5f6774;
    --text-placeholder: #6b7280;

    /* brand — prototype indigo */
    --brand: #5267d8;
    --brand-hover: #4559c6;
    --brand-soft: #eef0ff;
    --brand-soft-strong: #ecefff;
    --brand-border-soft: #d9defc;
    --on-brand: #fff;
    --brand-strong: #3d50c3;
    --accent-text: #3d50c3;

    /* interaction */
    --focus-ring: #5267d8;
    --input-focus-border: #8796eb;
    --input-focus-outline: rgb(82 103 216 / 14%);
    --row-hover: #fafbfc;
    --scrollbar-thumb: #c9cfd8;
    --scrollbar-thumb-hover: #aab2bf;
    --backdrop: rgb(26 31 42 / 48%);
    --card-hover-border: #c9d0f0;
    --card-current-border: #9aa6e8;
    --secondary-hover-border: #b9c0cc;
    --panel-border-strong: #d9dee6;
    --chip-border: #d9defc;
    --warning-emphasis-border: #d9a94c;
    --on-brand-soft: #e6e9ff;

    /* status semantics — always paired with a text label, never color-only */
    --status-success-bg: #e9f7f0;
    --status-success-text: #16845b;
    --status-info-bg: #edf4ff;
    --status-info-text: #3869bb;
    --status-warning-bg: #fff5df;
    --status-warning-text: #a66b12;
    --status-orange-bg: #ffe9d6;
    --status-orange-text: #9a4d12;
    --status-purple-bg: #f3efff;
    --status-purple-text: #7956bd;
    --status-danger-bg: #fff0f0;
    --status-danger-text: #c24c4c;
    --status-neutral-bg: #f0f2f5;
    --status-neutral-text: #5f6774;

    /* feedback surfaces (notice / entry status) */
    --success-surface: #e9f7f0;
    --success-border: #cdeeda;
    --success-text: #14684a;
    --error-surface: #fff0f0;
    --error-border: #f2d7d7;
    --error-text: #a83e3e;
    --info-surface: #edf4ff;
    --info-border: #d7e4f8;
    --info-text: #31599d;
    --warning-surface: #fff5df;
    --warning-border: #f0e2bd;
    --warning-text: #8a5a0e;

    /* destructive action */
    --danger: #b94a4a;
    --danger-hover: #a83e3e;
    --on-danger: #fff;

    --shadow: 0 1px 2px rgb(18 25 38 / 4%), 0 8px 28px rgb(18 25 38 / 3.5%);
    --shadow-raised: 0 20px 70px rgb(0 0 0 / 20%);

    /* legacy aliases — keep until every consumer uses semantic names */
    --surface: var(--surface-0);
    --surface-muted: var(--surface-1);
    --border: var(--border-subtle);
    --text: var(--text-primary);
    --text-muted: var(--text-tertiary);
    --accent: var(--brand);
    --accent-hover: var(--brand-hover);
    --accent-soft: var(--brand-soft);

    color: var(--text-primary);
    background: var(--page);
}

/* == SECTION 2: BASE — reset, typography, topbar, container ================ */
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--page); font-size: 14px; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 1.4375rem; font-weight: 720; letter-spacing: -.03em; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 1.05rem; line-height: 1.35; }
h3 { font-size: 1rem; }
h4 { margin: 0 0 10px; font-size: .92rem; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    padding: 0 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface-0);
    border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; color: var(--text); font-size: .95rem; font-weight: 750; letter-spacing: -.01em; text-decoration: none; }
.brand-mark { display: grid; width: 25px; height: 25px; flex: 0 0 auto; place-items: center; color: #fff; background: linear-gradient(145deg, #6479ed, #3d50c3); border-radius: 7px; font-size: .8rem; font-weight: 800; }
.brand-word { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-divider { height: 22px; border-left: 1px solid var(--border); }
.topbar-menu { display: none; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; padding: 0; color: var(--text-tertiary); background: transparent; border: 0; border-radius: 7px; font-size: 1rem; cursor: pointer; }
.topbar-menu:hover { background: var(--surface-2); color: var(--text); }
.project-switcher { position: relative; }
.project-switcher > summary { list-style: none; cursor: pointer; }
.project-switcher > summary::-webkit-details-marker { display: none; }
.project-switch { display: inline-flex; align-items: center; gap: 8px; max-width: min(420px, 38vw); padding: 7px 9px; color: var(--text-secondary); border-radius: 7px; font-size: .86rem; font-weight: 600; text-decoration: none; }
.project-switch:hover { background: var(--surface-2); color: var(--text); }
.project-switcher[open] .project-switch { background: var(--surface-2); color: var(--text); }
.project-menu { position: absolute; z-index: 45; top: calc(100% + 6px); left: 0; width: min(320px, 86vw); max-height: 340px; overflow-y: auto; padding: 5px; background: var(--surface-0); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-raised); }
.project-menu form { margin: 0; }
.project-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; color: var(--text-secondary); background: transparent; border: 0; border-radius: 7px; font-size: .8125rem; font-weight: 600; text-align: left; cursor: pointer; }
.project-menu-item:hover { background: var(--surface-2); color: var(--text); }
.project-menu-item.is-current { color: var(--accent-text); background: var(--brand-soft); }
.project-menu-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-menu-check { margin-left: auto; color: var(--accent-text); }
.project-menu-foot { display: block; margin-top: 4px; padding: 8px 10px; border-top: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: .75rem; text-decoration: none; }
.project-menu-foot:hover { color: var(--accent-text); }
.project-switch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch-caret { color: var(--text-tertiary); font-size: .8rem; }
.project-switch-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #9aa1ac; }
.project-switch-dot.status-ongoing { background: #36a779; }
.project-switch-dot.status-planning { background: #8a93a3; }
.project-switch-dot.status-completed { background: #6083bc; }
.project-switch-dot.status-on-hold { background: #c28a39; }
.project-switch.is-empty .project-switch-name { color: var(--text-tertiary); font-weight: 500; }
.account { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.account form { display: flex; align-items: center; margin: 0; }
.account-avatar { display: grid; width: 29px; height: 29px; flex: 0 0 auto; place-items: center; color: var(--accent-text); background: var(--brand-soft); border-radius: 50%; font-size: .75rem; font-weight: 700; }
.account-name { max-width: 140px; overflow: hidden; color: var(--text-secondary); font-size: .84rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.container { width: min(var(--content-max), 100%); margin: 0 auto; padding: 26px clamp(22px, 3vw, 48px) 60px; }
.crumb { margin: 0 0 12px; color: var(--text-tertiary); font-size: .75rem; }
body.is-anonymous .container { width: min(580px, calc(100% - 32px)); padding-top: clamp(30px, 8vh, 90px); }
.page-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.page-heading h1 { margin-bottom: 6px; }
.page-heading .muted, .panel-heading .muted { margin: 4px 0 0; font-size: .8125rem; line-height: 1.5; }
.eyebrow { margin-bottom: 5px; color: var(--text-tertiary); font-size: .625rem; font-weight: 750; letter-spacing: .09em; }
.muted { color: var(--text-muted); }
/* == SECTION 2b: APP SHELL — V2.1 top bar + project sidebar ================ */
.app-shell { display: flex; align-items: stretch; min-height: calc(100vh - var(--topbar-h)); }
.app-sidebar {
    position: sticky;
    top: var(--topbar-h);
    width: var(--sidebar-w);
    height: calc(100vh - var(--topbar-h));
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 17px;
    padding: 17px 12px 14px;
    overflow-y: auto;
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 17px; }
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-label { margin: 0; padding: 0 10px 6px; color: var(--text-tertiary); font-size: .625rem; font-weight: 750; letter-spacing: .09em; }
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 34px;
    padding: 8px 10px;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    border-radius: 7px;
    font-size: .8125rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .14s ease, color .14s ease;
}
.sidebar-item:hover { color: var(--text); background: var(--surface-2); }
.sidebar-item.is-active { color: var(--accent-text); background: var(--brand-soft-strong); font-weight: 650; }
.sidebar-icon { width: 17px; flex: 0 0 auto; color: var(--text-tertiary); font-size: .875rem; text-align: center; }
.sidebar-item.is-active .sidebar-icon { color: var(--brand); }
.sidebar-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.sidebar-collapse { color: var(--text-tertiary); }
.sidebar-scrim { position: fixed; inset: var(--topbar-h) 0 0; z-index: 39; background: var(--backdrop); }
.sidebar-scrim[hidden] { display: none; }
/* Collapsed rail (desktop): icons only, state persisted by app.js. */
body.sidebar-collapsed .app-sidebar { width: var(--sidebar-w-collapsed); padding-inline: 8px; }
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-text { display: none; }
body.sidebar-collapsed .sidebar-item { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-collapse .sidebar-icon { transform: rotate(180deg); }
.app-shell > .container { flex: 1 1 auto; min-width: 0; }

@media (max-width: 1050px) {
    :root { --sidebar-w: 218px; }
}
@media (max-width: 760px) {
    .topbar-menu { display: grid; }
    .brand-word, .topbar-divider { display: none; }
    .project-switch { max-width: 46vw; padding-inline: 6px; }
    .account-name { display: none; }
    /* Drawer mode: the sidebar slides over the content; state lives in app.js.
       Without JS the drawer button does nothing, but every page stays reachable
       through the in-page module nav and the top bar links. */
    .app-sidebar {
        position: fixed;
        z-index: 40;
        top: var(--topbar-h);
        bottom: 0;
        left: calc(-1 * var(--sidebar-w) - 12px);
        height: auto;
        box-shadow: var(--shadow-raised);
        transition: left .2s ease;
    }
    body.sidebar-open .app-sidebar { left: 0; }
    body.sidebar-collapsed .app-sidebar { width: var(--sidebar-w); padding-inline: 12px; }
    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .sidebar-text { display: block; }
    body.sidebar-collapsed .sidebar-item { justify-content: flex-start; padding-inline: 10px; }
    .sidebar-collapse { display: none; }
}

/* == SECTION 3: LAYOUT — panels, records, tables, nav, dialogs ============= */
.current-project, .panel, .auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}
.current-project { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px; padding: 16px 18px; margin-bottom: 18px; }
.current-project h2 { font-size: 1.05rem; }
.current-project .eyebrow { margin-bottom: 3px; }
.panel { padding: 0; margin: 14px 0; }
.panel > :not(.panel-heading):not(.toolbar):not(.panel-body) { margin-inline: 17px; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 18px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.panel-heading p { max-width: 80ch; }
.panel-body { padding: 16px 17px; }
.record-summary { margin: 0; }
.record-summary h2 { margin-bottom: 6px; }
.record-summary p { margin-bottom: 10px; }
.record-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.record-list { display: grid; gap: 8px; }
.record-card { padding: 16px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.record-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 18px; }
.record-heading h3 { margin: 0; font-size: .98rem; line-height: 1.45; overflow-wrap: anywhere; }
.record-heading .eyebrow { margin-bottom: 3px; }
.record-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.record-meta { margin: 8px 0; color: var(--text-muted); font-size: .82rem; line-height: 1.55; overflow-wrap: anywhere; }
.record-tools { padding-top: 9px; margin-top: 9px; border-top: 1px solid var(--border); }
.record-tools > summary { color: var(--accent-text); font-size: .82rem; font-weight: 620; cursor: pointer; }
.record-form { margin-top: 10px; }
.follow-up-list, .history-list { display: grid; gap: 8px; }
.follow-up-list { padding-left: 20px; }
.follow-up-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.follow-up-list form { margin: 0; }
.history-list { padding-left: 24px; }
.history-list li { padding-left: 4px; }
.history-list span { display: block; color: var(--text-muted); font-size: .82rem; }
.history-list p { margin: 5px 0 0; overflow-wrap: anywhere; }
.is-complete { color: var(--text-muted); text-decoration: line-through; }

.table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.data-table { min-width: 760px; }
.data-table td { vertical-align: middle; }
.data-table .table-primary-cell { display: block; max-width: 48ch; font-weight: 650; overflow-wrap: anywhere; }
/* Ledger descriptions clamp to two lines; the full text stays in the detail
   dialog (and in the title attribute for a quick hover peek). */
.issue-description-clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.data-table .record-meta { display: block; margin: 3px 0 0; }
.search-field input { width: min(280px, 72vw); min-height: 38px; }
.data-table tr[hidden] { display: none; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 8px 13px; border-bottom: 1px solid var(--border); font-size: .75rem; vertical-align: middle; }
th { height: 38px; color: var(--text-tertiary); background: var(--surface-1); font-size: .625rem; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
td { height: 49px; color: var(--text-secondary); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-muted); }
.report-table { min-width: 680px; }
.report-table th { background: var(--surface-muted); }
.report-table td { overflow-wrap: anywhere; }
.project-name, .report-table .material-primary { font-weight: 650; }
.report-code, .report-table .material-secondary { color: var(--text-muted); font-size: .8rem; }
.actions form { margin: 0; }
.project-list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.project-list-actions .inline-form { align-items: center; margin-top: 0; }
.project-current-row { background: var(--accent-soft); }
.project-current-row td:first-child { box-shadow: inset 3px 0 var(--accent); }
.material-mobile-meta, .report-strip { display: none; }

/* == SECTION 5a: MODULE project-foundation — project home ==================
   Mirrors the user-supplied high-fidelity prototype (Project_O_V2.1_项目首页_
   高保真原型.html): light gradient hero for the current project, 2-column
   quick-entry cards, then a portfolio grid with status tabs + search.
   Hierarchy: hero (subject) → quick entries → portfolio list. */
.projects-heading { align-items: flex-start; margin-bottom: 26px; }
.projects-heading h1 { font-size: 1.6875rem; letter-spacing: -.045em; }
.projects-heading .muted { margin: 7px 0 0; font-size: .8125rem; }
.projects-heading .eyebrow { color: var(--text-tertiary); font-size: .625rem; letter-spacing: .12em; }

/* Portfolio report: real counts over the visible project list only.
   One compact horizontal strip — each stat is a small block, never a full row. */
.portfolio-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 22px; }
.stat { padding: 10px 13px; background: var(--surface-0); border: 1px solid var(--border-subtle); border-radius: 9px; }
.stat-label { display: block; color: var(--text-tertiary); font-size: .6875rem; }
.stat-value { display: block; margin: 3px 0 1px; font-size: 1.25rem; font-weight: 720; letter-spacing: -.03em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-foot { display: block; color: var(--text-tertiary); font-size: .625rem; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 30px; background: var(--status-neutral-bg); color: var(--status-neutral-text); font-size: .6875rem; font-weight: 650; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.status-ongoing { background: var(--status-success-bg); color: var(--status-success-text); }
.status-pill.status-planning { background: var(--status-info-bg); color: var(--status-info-text); }
.status-pill.status-on-hold { background: var(--status-warning-bg); color: var(--status-warning-text); }
.status-pill.status-completed { background: var(--status-neutral-bg); color: var(--status-neutral-text); }

/* Whole-card click enters the project (hidden POST form submitted by app.js). */
.project-card.is-clickable { cursor: pointer; }
.project-card.is-clickable:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.project-enter-form { display: none; }

.portfolio-section { margin-top: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; margin-bottom: 13px; }
.section-head h3 { margin: 0; font-size: .9375rem; font-weight: 700; letter-spacing: -.012em; }
.section-head p { margin: 4px 0 0; color: var(--text-tertiary); font-size: .6875rem; }
.section-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 8px; }
.tab { padding: 5px 10px; color: var(--text-tertiary); background: transparent; border: 0; border-radius: 6px; font-size: .6875rem; cursor: pointer; }
.tab.is-active { color: var(--text-secondary); background: var(--surface-0); box-shadow: 0 1px 3px rgb(28 42 68 / 8%); font-weight: 650; }
.portfolio-search input { width: 190px; min-height: 32px; font-size: .6875rem; }
.portfolio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.project-card { position: relative; min-width: 0; padding: 16px; background: var(--surface-0); border: 1px solid var(--border-subtle); border-radius: 12px; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.project-card:hover { border-color: var(--card-hover-border); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card.is-current { border-color: var(--card-current-border); box-shadow: inset 0 0 0 1px var(--brand-soft); }
.project-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.mini-mark { display: grid; width: 29px; height: 29px; place-items: center; color: var(--accent-text); background: var(--brand-soft); border-radius: 8px; font-size: .75rem; font-weight: 750; }
.project-card-title { margin: 0 0 6px; overflow: hidden; font-size: .8125rem; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.project-card-meta { color: var(--text-tertiary); font-size: .6875rem; }
.project-dates { display: flex; gap: 12px; margin-top: 13px; color: var(--text-tertiary); font-size: .6875rem; }
.project-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.project-footer form { margin: 0; }
.linkbtn { padding: 0; color: var(--accent-text); background: transparent; border: 0; font-size: .6875rem; font-weight: 650; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn-quiet { color: var(--text-tertiary); }
.current-project-label { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-text); font-size: .625rem; font-weight: 650; }
.portfolio-foot { display: flex; justify-content: flex-end; margin-top: 14px; }
.archive-link { color: var(--text-tertiary); font-size: .6875rem; text-decoration: none; }
.archive-link:hover { color: var(--accent-text); }
.footer-note { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--border-subtle); color: var(--text-tertiary); font-size: .625rem; }
.empty-projects { display: grid; justify-items: center; padding: 30px; background: var(--surface-1); border: 1px dashed var(--border-strong); border-radius: 12px; text-align: center; }
.empty-projects-icon { display: grid; width: 46px; height: 46px; margin-bottom: 14px; place-items: center; color: var(--accent-text); background: var(--accent-soft); border-radius: 15px; font-size: 1.4rem; }
.empty-projects h3 { margin-bottom: 6px; font-size: .8125rem; }
.empty-projects p { max-width: 42ch; margin-bottom: 16px; font-size: .75rem; }
.create-project-dialog { width: min(520px, calc(100vw - 32px)); }

/* == SECTION 4: COMPONENTS — buttons, forms, badges, notices =============== */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-size: .75rem; font-weight: 600; line-height: 1.25; text-decoration: none; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease; }
.button-primary { color: var(--on-brand); background: var(--brand); border-color: var(--brand); box-shadow: 0 2px 5px rgb(53 89 199 / 15%); }
.button-primary:hover { color: var(--on-brand); background: var(--brand-hover); border-color: var(--brand-hover); }
.button-secondary { color: var(--text-secondary); background: var(--surface-0); border-color: var(--border-strong); }
.button-secondary:hover { background: var(--surface-1); border-color: var(--secondary-hover-border); }
.button-small { min-height: 28px; padding: 4px 8px; font-size: .6875rem; }
.button-quiet { color: var(--text-tertiary); background: transparent; }
.button-quiet:hover { color: var(--text); background: var(--surface-muted); }
.button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.stack { display: grid; gap: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid > * { min-width: 0; }
label { display: grid; gap: 5px; color: var(--text-secondary); font-size: .6875rem; font-weight: 650; }
input, select, textarea {
    width: 100%;
    min-width: 0;
    min-height: var(--control-h);
    padding: 0 10px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: .75rem;
}
textarea { min-height: 75px; padding: 8px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-placeholder); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--input-focus-border); box-shadow: 0 0 0 3px var(--input-focus-outline); }
input[type="checkbox"], input[type="radio"] { width: 17px; min-height: 17px; padding: 0; accent-color: var(--accent); }
.checkbox-field { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 9px 16px; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 3px; }
.checkbox-group legend { padding: 0 5px; color: var(--text-secondary); font-size: .81rem; font-weight: 600; }
.field-wide { grid-column: 1 / -1; }
.inline-form { display: flex; align-items: flex-end; gap: 9px; margin-top: 10px; }
.inline-form label { flex: 1; }
.admin-form { margin-bottom: 16px; }
.admin-record-list { display: grid; gap: 6px; margin-top: 14px; }
.admin-record { padding: 12px 0; border-top: 1px solid var(--border); }
.admin-record:first-of-type { border-top: 0; }
.runtime-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.runtime-grid div { min-width: 0; padding: 11px 12px; background: var(--surface-muted); }
.runtime-grid dt { color: var(--text-muted); font-size: .8rem; }
.runtime-grid dd { margin: 4px 0 0; font-weight: 620; overflow-wrap: anywhere; }

.badge, .selected-label { display: inline-flex; align-items: center; padding: 3px 7px; border-radius: 5px; color: var(--accent-text); background: var(--accent-soft); font-size: .625rem; font-weight: 650; }
.selected-label { color: var(--text-secondary); background: var(--surface-2); }
.badge-neutral { color: var(--status-neutral-text); background: var(--status-neutral-bg); }
.notice { padding: 11px 14px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 3px; font-size: .85rem; }
.notice-success { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
.notice-error { color: var(--error-text); background: var(--error-surface); border-color: var(--error-border); }
.notice-info { color: var(--info-text); background: var(--info-surface); border-color: var(--info-border); }
.empty-state { margin: 0; padding: 18px 10px; color: var(--text-muted); text-align: center; }
.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; }

.module-nav { display: flex; flex-wrap: nowrap; gap: 4px; padding: 2px 0 8px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
.module-nav .button { flex: 0 0 auto; min-height: 32px; padding: 5px 10px; }
.entry-disclosure { margin: 0 0 10px; border-bottom: 1px solid var(--border); }
.entry-disclosure > summary { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 4px 0; color: var(--text-muted); font-size: .82rem; font-weight: 620; cursor: pointer; list-style: none; }
.entry-disclosure > summary::-webkit-details-marker { display: none; }
.entry-disclosure > summary::after { content: "+"; color: var(--text-tertiary); font-size: 1rem; }
.entry-disclosure[open] > summary::after { content: "−"; }
.entry-disclosure > .form-grid { padding: 10px 0 14px; }
.disclosure { border: 1px solid var(--border); border-radius: 3px; }
.disclosure > summary { padding: 11px 14px; cursor: pointer; }
.disclosure-content { padding: 12px 14px; border-top: 1px solid var(--border); }
.project-create { position: relative; }
.project-create > summary { list-style: none; }
.project-create > summary::-webkit-details-marker { display: none; }
.project-create[open] .project-create-form { position: absolute; z-index: 4; top: calc(100% + 10px); right: 0; width: min(640px, calc(100vw - 48px)); padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-raised); }
.edit-dialog { width: min(650px, calc(100vw - 32px)); max-height: 90vh; overflow-y: auto; padding: 18px 20px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.edit-dialog::backdrop { background: var(--backdrop); }
.category-editor[open] { position: relative; width: min(680px, calc(100vw - 40px)); }
.row-editor .row-editor-form { padding: 12px; background: var(--surface-muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.auth-card { width: min(440px, 100%); margin: 8vh auto; padding: 26px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .button { width: 100%; }

/* Dark theme: flip semantic tokens; component rules above resolve automatically.
   Only rules whose light values are intentionally different (input surface,
   translucent overlays) need explicit overrides below. */
body.theme-dark {
    color-scheme: dark;
    --page: #07090d;
    --page-glow: #07090d;
    --surface-0: #12151d;
    --surface-1: #0c0f15;
    --surface-2: #1a1f2b;
    --border-subtle: #2a303c;
    --border-strong: #3e4557;
    --overlay-strong: rgb(18 21 29 / 92%);
    --overlay-soft: rgb(18 21 29 / 90%);
    --text-primary: #e6e8ee;
    --text-secondary: #c3c8d4;
    --text-tertiary: #9aa1b2;
    --text-placeholder: #8b92a3;
    --brand: #5b6fd8;
    --brand-hover: #6d80e8;
    --brand-soft: #232a41;
    --brand-soft-strong: #2c3452;
    --brand-border-soft: #3e4557;
    --on-brand: #fff;
    --brand-strong: #aab6f5;
    --accent-text: #98a6f2;
    --focus-ring: #98a6f2;
    --input-focus-border: #7583c9;
    --input-focus-outline: rgb(152 166 242 / 22%);
    --row-hover: #1a1f2b;
    --scrollbar-thumb: #3e4557;
    --scrollbar-thumb-hover: #565e73;
    --backdrop: rgb(0 0 0 / 68%);
    --card-hover-border: #5b6378;
    --card-current-border: #7583c9;
    --secondary-hover-border: #5b6378;
    --panel-border-strong: #4a5164;
    --chip-border: #363c4a;
    --warning-emphasis-border: #8a6a2a;
    --on-brand-soft: #dfe3ff;
    --status-success-bg: rgb(16 113 78 / 30%);
    --status-success-text: #82e3b4;
    --status-info-bg: rgb(22 104 220 / 32%);
    --status-info-text: #93bdff;
    --status-warning-bg: rgb(148 98 5 / 34%);
    --status-warning-text: #ffd97a;
    --status-orange-bg: rgb(192 86 33 / 32%);
    --status-orange-text: #ffb184;
    --status-purple-bg: rgb(101 83 216 / 34%);
    --status-purple-text: #c9bfff;
    --status-danger-bg: rgb(192 57 43 / 34%);
    --status-danger-text: #ff9e97;
    --status-neutral-bg: rgb(255 255 255 / 8%);
    --status-neutral-text: #c1cac4;
    --success-surface: #24322c;
    --success-border: #363c4a;
    --success-text: #a9d8b8;
    --error-surface: #3a2b2e;
    --error-border: #363c4a;
    --error-text: #ff9e97;
    --info-surface: #273040;
    --info-border: #363c4a;
    --info-text: #c9d4ec;
    --warning-surface: #3a3325;
    --warning-border: #363c4a;
    --warning-text: #ffd97a;
    --danger: #7d4a44;
    --danger-hover: #8c544d;
    --on-danger: #f3e7e5;
    --shadow: none;
    --shadow-raised: none;

    /* Legacy aliases must flip here too: rules still referencing the old
       names resolve against body.theme-dark, not :root. */
    --surface: var(--surface-0);
    --surface-muted: var(--surface-1);
    --border: var(--border-subtle);
    --text: var(--text-primary);
    --text-muted: var(--text-tertiary);
    --accent: var(--brand);
    --accent-hover: var(--brand-hover);
    --accent-soft: var(--brand-soft);
}
html:has(body.theme-dark) { background: var(--page); }
/* Inputs sit darker than panels in dark mode (intentional, not a token flip). */
body.theme-dark input:not([type="checkbox"]):not([type="radio"]),
body.theme-dark select,
body.theme-dark textarea { background: #0a0d12; }

@media (max-width: 900px) {
    .container { padding: 22px 20px 48px; }
    .topbar { padding-inline: 16px; }
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .portfolio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .container { padding: 18px 14px 44px; }
    .topbar { padding-inline: 12px; gap: 8px; }
    .account { gap: 6px; }
    .account-name { max-width: 84px; font-size: .8rem; }
    .page-heading { margin-bottom: 16px; }
    .form-grid, .record-grid, .runtime-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .record-heading { flex-direction: column; }
    .record-badges { justify-content: flex-start; }
    .follow-up-list li { align-items: flex-start; flex-direction: column; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .module-nav { margin-inline: -2px; }
    .current-project { align-items: flex-start; }
    .projects-heading { display: block; }
    .projects-heading .project-list-actions { margin-top: 15px; }
    .portfolio-stats { gap: 8px; }
    .stat { padding: 9px 11px; }
    .stat-value { font-size: 1.125rem; }
    .portfolio { grid-template-columns: 1fr; }
    .section-head { align-items: flex-start; flex-direction: column; gap: 10px; }
    .section-tools { width: 100%; justify-content: space-between; }
    .portfolio-search input { width: 145px; }
    .footer-note { display: block; }
    .project-list-actions { gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Shared application surfaces */
.container > .page-heading:not(.projects-heading) { padding-bottom: 4px; }
.page-heading:not(.projects-heading) h1 { font-size: 1.4375rem; letter-spacing: -.03em; }
.page-heading .eyebrow { text-transform: none; }
.module-nav {
    position: sticky;
    top: var(--topbar-h);
    z-index: 4;
    gap: 7px;
    padding: 5px;
    margin: -4px 0 20px;
    background: var(--overlay-soft);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.module-nav .button { min-height: 36px; padding: 7px 12px; border-color: transparent; border-radius: 8px; }
.module-nav .button-primary { box-shadow: 0 2px 6px rgb(34 54 43 / 12%); }
.module-nav .button-secondary { color: var(--text-muted); background: transparent; }
.module-nav .button-secondary:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.panel-heading h2 { font-size: .8125rem; font-weight: 700; letter-spacing: 0; }
.panel-heading .muted { font-size: .6875rem; }
.record-summary { min-height: 170px; display: flex; flex-direction: column; align-items: flex-start; }
.record-summary h2 { margin-bottom: 5px; font-size: 1.25rem; }
.record-summary p { margin-bottom: 12px; }
.record-summary a { display: inline-flex; align-items: center; gap: 7px; margin-top: auto; color: var(--accent-text); font-size: .84rem; font-weight: 650; text-decoration: none; }
.record-summary a::after { content: "→"; transition: transform .16s ease; }
.record-summary a:hover::after { transform: translateX(3px); }
.record-card { border-radius: 13px; box-shadow: 0 2px 7px rgb(34 54 43 / 3%); }
.record-card + .record-card { margin-top: 11px; }
.record-tools { border-color: var(--border); border-radius: 9px; }
.record-tools > summary { padding: 8px 10px; border-radius: 7px; }
.record-tools > summary:hover { background: var(--surface-muted); }
.record-form { padding-top: 12px; }
.record-badges { align-items: center; }
.follow-up-list li { padding: 9px 10px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 8px; }
.history-list li::marker { color: var(--accent-text); font-weight: 700; }
.table-wrap { border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.table-wrap table { min-width: 620px; }
.report-table { min-width: 680px; }
th, td { padding: 8px 13px; }
th { background: var(--surface-1); letter-spacing: .02em; }
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: var(--row-hover); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar label { min-width: 0; }
.toolbar .search-field input { width: min(280px, 72vw); min-height: 33px; }
.toolbar select { width: auto; min-height: 33px; padding: 0 28px 0 9px; color: var(--text-secondary); font-size: .75rem; }
.toolbar-count { margin-left: auto; color: var(--text-tertiary); font-size: .6875rem; font-weight: 600; }
.report-empty { padding: 22px 14px; color: var(--text-muted); background: var(--surface-muted); border: 1px dashed var(--border-strong); border-radius: 10px; text-align: center; }
.report-intro { align-items: center; }
.report-intro .button-quiet { color: var(--accent-text); background: var(--accent-soft); }
.report-intro .button-quiet:hover { background: var(--brand-soft-strong); }
.report-heading { letter-spacing: -.035em; }
.material-primary { display: block; }
.material-secondary, .report-table .material-secondary { display: block; margin-top: 3px; font-size: .77rem; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.row-actions form, .actions form { display: inline-flex; }
.row-actions .button { min-height: 33px; padding: 5px 9px; }
.inline-form { align-items: flex-end; }
.inline-form + .inline-form { margin-top: 9px; }
.entry-disclosure {
    overflow: hidden;
    margin: 0 0 12px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.entry-disclosure > summary { min-height: 42px; padding: 9px 13px; color: var(--text); }
.entry-disclosure > summary::after { display: grid; width: 23px; height: 23px; place-items: center; color: var(--accent-text); background: var(--accent-soft); border-radius: 7px; }
.entry-disclosure[open] > .form-grid { padding: 13px; border-top: 1px solid var(--border); }
.disclosure { overflow: hidden; border-radius: 10px; }
.disclosure > summary { color: var(--text); font-weight: 650; }
.disclosure-content { background: var(--surface-muted); }
.checkbox-group { gap: 10px 18px; padding: 13px 15px; background: var(--surface-muted); border-radius: 9px; }
.notice { padding: 10px 12px; border-radius: 7px; font-size: .75rem; }
.notice-success { color: var(--success-text); background: var(--success-surface); border-color: var(--success-border); }
.notice-error { color: var(--error-text); background: var(--error-surface); border-color: var(--error-border); }
.notice-info { color: var(--info-text); background: var(--info-surface); border-color: var(--info-border); }
.empty-state { padding: 34px 16px; color: var(--text-tertiary); background: transparent; border: 0; border-radius: 0; font-size: .75rem; }
.auth-card { width: min(460px, 100%); padding: 34px; margin-top: clamp(30px, 8vh, 90px); border-radius: 20px; box-shadow: var(--shadow-raised); }
body:has(.auth-card) .container { width: min(580px, calc(100% - 32px)); }
.auth-card .eyebrow { color: var(--accent-text); font-weight: 700; }
.auth-card h1 { margin-bottom: 8px; letter-spacing: -.035em; }
.auth-card > .muted { margin-bottom: 22px; }
.auth-card .stack { gap: 15px; }
.auth-card .button { min-height: 45px; margin-top: 3px; }
.auth-card label { gap: 7px; }
.auth-card input { min-height: 43px; }
.edit-dialog { border-radius: 12px; box-shadow: var(--shadow-raised); }
.edit-dialog::backdrop { backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.dialog-actions { padding-top: 6px; }
.admin-record { padding: 15px 0; border-color: var(--border); }
.admin-record-list { gap: 0; }
.admin-record .form-grid { align-items: end; }
.runtime-grid div { border: 1px solid var(--border); border-radius: 9px; }
.project-create[open] .project-create-form { border-radius: 14px; }
summary { transition: color .14s ease, background-color .14s ease; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .68; }

@media (max-width: 900px) {
    .record-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .account { gap: 3px; }
    .module-nav { margin-inline: -2px; padding: 4px; }
    .module-nav .button { min-height: 34px; padding-inline: 10px; font-size: .77rem; }
    .panel-heading { align-items: flex-start; }
    .record-grid { grid-template-columns: 1fr; gap: 10px; }
    .record-summary { min-height: 145px; }
    .toolbar { padding: 11px; }
    .toolbar .search-field input { width: 100%; }
    .toolbar-count { margin-left: auto; }
    .inline-form { align-items: stretch; flex-direction: column; }
    .table-wrap { margin-inline: -2px; }
    .table-wrap th, .table-wrap td { padding: 9px 10px; }
    .row-actions { gap: 4px; }
    .row-actions .button { min-height: 35px; }
    .auth-card { padding: 25px 20px; }
    .admin-record .form-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
}

/* == SECTION 5b: MODULE document-management — home KPI + work queues ======= */
.kpi-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.kpi-item { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; align-items: center; padding: 14px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); text-decoration: none; transition: border-color .16s ease; }
.kpi-item:hover { border-color: var(--card-hover-border); }
.kpi-label { grid-column: 1; color: var(--text-tertiary); font-size: .78rem; font-weight: 650; letter-spacing: .04em; }
.kpi-value { grid-column: 1; grid-row: 2; color: var(--text); font-size: 1.7rem; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-note { grid-column: 2; grid-row: 1 / 3; justify-self: end; color: var(--text-tertiary); font-size: .82rem; text-align: right; }
.doc-home-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.doc-home-grid > .panel { margin: 0; }
.work-queue { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.work-queue-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 12px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-md); }
.work-queue-kind { flex: 0 0 auto; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.work-queue-kind.is-issue { color: var(--status-info-text); background: var(--status-info-bg); }
.work-queue-kind.is-rfi { color: var(--status-purple-text); background: var(--status-purple-bg); }
.work-queue-main { display: flex; flex: 1 1 220px; min-width: 0; align-items: baseline; gap: 8px; color: var(--text); text-decoration: none; }
.work-queue-main:hover .work-queue-summary { color: var(--accent-text); }
.work-queue-number { flex: 0 0 auto; color: var(--text-tertiary); font-size: .78rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.work-queue-summary { min-width: 0; overflow: hidden; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.work-queue-time { flex: 0 0 auto; color: var(--text-tertiary); font-size: .76rem; font-variant-numeric: tabular-nums; }
.work-queue-group-title { margin: 12px 0 8px; font-size: .88rem; }
.work-queue-group-title:first-of-type { margin-top: 0; }
.work-queue-more { margin: 12px 0 0; font-size: .8rem; }
.work-queue-more a { color: var(--accent-text); font-weight: 620; }
@media (max-width: 900px) {
    .doc-home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .kpi-strip { grid-template-columns: 1fr; }
    .work-queue-time { flex-basis: 100%; }
}

.dialog-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.dialog-section h3 { margin: 0 0 8px; font-size: .95rem; }
.dialog-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; padding: 0; list-style: none; }
.dialog-images li { display: flex; align-items: center; gap: 6px; padding: 5px 9px; font-size: .82rem; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 8px; }
.edit-dialog.wide { width: min(960px, calc(100vw - 32px)); }

/* Sample image thumbnails (samples page and edit dialogs) */
.thumb-list { display: flex; flex-wrap: wrap; gap: 6px; }
.thumb { width: 64px; height: 48px; display: block; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-muted); }
.dialog-images .thumb { width: 44px; height: 33px; }

.button-danger { color: var(--on-danger); background: var(--danger); }
.button-danger:hover { color: var(--on-danger); background: var(--danger-hover); box-shadow: 0 5px 14px rgb(120 60 50 / 18%); transform: translateY(-1px); }

/* == SECTION 5c: MODULE platform-admin — settings groups + two-column shell = */
.settings-group { min-width: 0; padding: 14px 16px 16px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-muted); }
.settings-group > legend { padding: 0 6px; color: var(--text); font-size: .9rem; font-weight: 700; }
.settings-group-note { margin: 0 0 12px; font-size: .8rem; }
.settings-group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-save-note { margin: 0 0 10px; font-size: .8rem; }
.settings-save-actions { justify-content: flex-start; }
@media (max-width: 600px) {
    .settings-group-grid { grid-template-columns: 1fr; }
}
.admin-shell { display: grid; grid-template-columns: minmax(188px, 232px) minmax(0, 1fr); gap: 20px; align-items: start; }
.admin-sidebar { position: sticky; top: 88px; padding: 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.admin-nav { display: grid; gap: 3px; }
.admin-nav a { display: flex; align-items: center; min-height: 40px; padding: 8px 12px; color: var(--text-muted); border-radius: 9px; font-size: .86rem; font-weight: 620; text-decoration: none; transition: background-color .14s ease, color .14s ease; }
.admin-nav a:hover { color: var(--text); background: var(--surface-muted); }
.admin-nav a[aria-current="page"] { color: var(--accent-text); background: var(--accent-soft); font-weight: 700; }
.admin-content > .panel { margin: 0; }
.admin-content .panel-heading .muted a { color: var(--accent-text); font-weight: 620; }

@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; gap: 12px; }
    .admin-sidebar { position: static; padding: 6px; }
    .admin-nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; }
    .admin-nav a { flex: 0 0 auto; min-height: 36px; padding: 7px 11px; font-size: .8rem; white-space: nowrap; }
}

/* Status badges: one semantic mapping for every module; text label required. */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 5px; font-size: .625rem; font-weight: 650; line-height: 1.5; white-space: nowrap; }
.status-badge.is-green { background: var(--status-success-bg); color: var(--status-success-text); }
.status-badge.is-blue { background: var(--status-info-bg); color: var(--status-info-text); }
.status-badge.is-amber { background: var(--status-warning-bg); color: var(--status-warning-text); }
.status-badge.is-orange { background: var(--status-orange-bg); color: var(--status-orange-text); }
.status-badge.is-purple { background: var(--status-purple-bg); color: var(--status-purple-text); }
.status-badge.is-red { background: var(--status-danger-bg); color: var(--status-danger-text); }
.status-badge.is-neutral { background: var(--status-neutral-bg); color: var(--status-neutral-text); }

.thumb-button { padding: 0; border: 0; background: none; border-radius: 6px; cursor: zoom-in; }
.thumb-button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.thumb-button .thumb { transition: transform .15s ease; }
.thumb-button:hover .thumb { transform: scale(1.04); }
.image-gallery { display: flex; flex-direction: column; gap: 14px; }
.image-gallery figure { margin: 0; }
.image-gallery a { display: block; }
.image-gallery img { display: block; max-width: 100%; max-height: 62vh; margin: 0 auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); }
.image-gallery figcaption { margin-top: 6px; color: var(--text-muted); font-size: .78rem; text-align: center; }
.image-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 0; }
.image-meta > div { min-width: 0; }
.image-meta dt { margin: 0 0 2px; color: var(--text-muted); font-size: .74rem; font-weight: 640; }
.image-meta dd { margin: 0; font-size: .88rem; overflow-wrap: anywhere; }
.image-meta .image-meta-wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .image-meta { grid-template-columns: 1fr; } }

/* == SECTION 5d: MODULE labor-crew — share dialog ========================== */
.share-link-field { display: grid; gap: 7px; margin: 14px 0 4px; }
.share-link-label { font-weight: 620; }
.share-link-box { padding: 11px 13px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 10px; }
.share-link-url { display: block; color: var(--accent-text); font-size: .86rem; line-height: 1.5; word-break: break-all; overflow-wrap: anywhere; text-decoration: none; user-select: all; -webkit-user-select: all; }
.share-link-url:hover { text-decoration: underline; }
.share-link-url:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; border-radius: 4px; }
.share-card-preview { display: flex; align-items: center; gap: 12px; padding: 11px 13px; margin: 12px 0 4px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 12px; }
.share-card-thumb { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); background: var(--surface); }
.share-card-text { display: grid; gap: 3px; min-width: 0; }
.share-card-text strong { font-size: .9rem; line-height: 1.4; overflow-wrap: anywhere; }
.share-card-text span { color: var(--text-muted); font-size: .78rem; line-height: 1.45; overflow-wrap: anywhere; }
.share-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.share-actions .inline-form { margin: 0; }
.share-feedback { margin: 10px 0 0; padding: 8px 12px; color: var(--success-text); background: var(--success-surface); border: 1px solid var(--success-border); border-radius: 9px; font-size: .82rem; }
.share-feedback.is-warning { color: var(--warning-text); background: var(--warning-surface); border-color: var(--warning-border); }
.share-hint { margin: 10px 0 0; font-size: .8rem; }
/* Manual-copy fallback: a real, selectable field holding the exact payload. */
.share-manual-copy { display: block; width: 100%; margin: 10px 0 0; padding: 10px 12px; color: var(--text); background: var(--surface-muted); border: 1px solid var(--accent); border-radius: 10px; font: inherit; font-size: .82rem; line-height: 1.5; resize: vertical; }
.share-manual-copy:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* Honest WeChat guidance inside the share dialog. */
.share-wechat-note { margin: 12px 0 0; padding: 11px 13px; background: var(--accent-soft); border: 1px solid var(--brand-border-soft); border-left: 3px solid var(--accent-text); border-radius: 10px; font-size: .82rem; }
.share-wechat-note strong { display: block; margin-bottom: 5px; font-size: .86rem; }
.share-wechat-note p { margin: 0 0 6px; line-height: 1.6; color: var(--text-muted); }
.share-wechat-note p:last-child { margin-bottom: 0; }
.share-wechat-note b { color: var(--text); }
.share-wechat-note code { padding: 1px 5px; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; font-size: .95em; }

/* The public share page is a standalone static file with inline styles
   (modules/labor-crew/views/share.php); it no longer uses app.css. */

/* Searchable material picker. Without JavaScript the native select stays
   visible; app.js swaps in the text input + option list (is-enhanced). */
.combo { position: relative; }
.combo-native { width: 100%; }
.combo-input { display: none; width: 100%; }
.combo.is-enhanced .combo-native { display: none; }
.combo.is-enhanced .combo-input { display: block; }
.combo-options {
    position: absolute;
    z-index: 30;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    max-height: 300px;
    margin: 0;
    padding: 5px;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--shadow-raised);
}
.combo-options[hidden] { display: none; }
.combo-options li { padding: 8px 10px; border-radius: 7px; font-size: .84rem; line-height: 1.4; cursor: pointer; overflow-wrap: anywhere; }
.combo-options li.is-active, .combo-options li:hover { background: var(--accent-soft); }
.combo-options li.combo-empty { color: var(--text-muted); cursor: default; }
.combo-options li.combo-empty:hover { background: none; }

/* == SECTION 5e: MODULE material-management — estimates workbench ========== */
.estimate-entry-panel { border-color: var(--panel-border-strong); }
.entry-counter { flex: 0 0 auto; padding: 6px 13px; color: var(--text-muted); background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; font-size: .8rem; font-weight: 620; white-space: nowrap; }
.entry-counter strong { color: var(--accent-text); font-size: .98rem; font-variant-numeric: tabular-nums; }
.quick-entry { display: grid; gap: 14px; }
.entry-location { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 10px; padding: 12px 14px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 12px; }
.entry-location-label { align-self: center; margin-right: 2px; color: var(--text-muted); font-size: .76rem; font-weight: 700; letter-spacing: .06em; }
.entry-location-field { display: grid; flex: 1 1 170px; gap: 4px; min-width: 150px; color: var(--text-secondary); font-size: .76rem; font-weight: 620; }
.entry-location-field select { min-height: 36px; font-size: .85rem; }
.entry-location-sep { align-self: center; padding-top: 16px; color: var(--text-tertiary); font-weight: 700; }
.entry-location-hint { align-self: center; margin-left: auto; padding-top: 16px; color: var(--text-muted); font-size: .74rem; white-space: nowrap; }
.entry-line { display: grid; grid-template-columns: auto minmax(0, 1.7fr) auto minmax(170px, .7fr) auto; gap: 12px; align-items: end; }
.entry-step { display: grid; width: 26px; height: 26px; margin-bottom: 9px; place-items: center; color: var(--accent-text); background: var(--accent-soft); border-radius: 50%; font-size: .8rem; font-weight: 750; }
.entry-field { display: grid; gap: 6px; min-width: 0; color: var(--text-secondary); font-size: .8rem; font-weight: 620; }
.entry-field-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.entry-field-hint { color: var(--text-muted); font-size: .72rem; font-weight: 500; }
.entry-field-material .combo-input { min-height: 46px; font-size: .95rem; }
.quantity-box { position: relative; display: block; }
.quantity-box input { min-height: 46px; padding-right: 58px; font-size: 1.18rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.quantity-box input::-webkit-outer-spin-button, .quantity-box input::-webkit-inner-spin-button { margin-left: 6px; }
.quantity-unit { position: absolute; top: 50%; right: 12px; max-width: 46px; overflow: hidden; color: var(--text-muted); font-size: .8rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; transform: translateY(-50%); pointer-events: none; }
.entry-submit { min-height: 46px; padding: 10px 18px; font-size: .9rem; white-space: nowrap; }
.entry-submit-key { margin-left: 8px; padding: 2px 7px; color: var(--on-brand-soft); background: rgb(255 255 255 / 16%); border-radius: 6px; font-size: .7rem; font-weight: 650; }
.entry-more { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.entry-remarks { display: flex; flex: 1 1 320px; align-items: center; gap: 9px; min-width: 0; color: var(--text-secondary); font-size: .78rem; font-weight: 620; }
.entry-remarks > span { flex: 0 0 auto; }
.entry-remarks input { min-height: 36px; font-size: .84rem; font-weight: 500; }
.entry-keys { margin: 0 0 0 auto; color: var(--text-muted); font-size: .74rem; }
.entry-keys kbd, .entry-submit-key { font-family: inherit; }
.entry-keys kbd { padding: 1px 6px; background: var(--surface-muted); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font-size: .72rem; }
.entry-status { margin: 0; padding: 9px 13px; border-radius: 9px; font-size: .83rem; font-weight: 600; }
.entry-status.is-success { color: var(--success-text); background: var(--success-surface); border: 1px solid var(--success-border); }
.entry-status.is-error { color: var(--error-text); background: var(--error-surface); border: 1px solid var(--error-border); }
.entry-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); }
.entry-recent[hidden] { display: none; }
.entry-recent-label { color: var(--text-muted); font-size: .76rem; font-weight: 700; letter-spacing: .05em; }
.entry-recent-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.entry-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; color: var(--text); background: var(--accent-soft); border: 1px solid var(--chip-border); border-radius: 999px; font-size: .78rem; }
.entry-chip strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.entry-chip .entry-chip-place { color: var(--text-muted); font-size: .72rem; }

/* Estimates record ledger */
.ledger { display: grid; gap: 12px; }
.ledger-toolbar { align-items: center; }
.ledger-toolbar .ledger-filter { flex: 1 1 240px; min-width: min(240px, 100%); }
.ledger-tabs { display: inline-flex; gap: 6px; }
.ledger-toolbar .inline-form { margin: 0; }
.ledger-toolbar .toolbar-count { margin: 0 0 0 auto; }
.ledger-group { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.ledger-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 15px; cursor: pointer; list-style: none; }
.ledger-group-head::-webkit-details-marker { display: none; }
.ledger-group-title { font-size: .92rem; font-weight: 700; overflow-wrap: anywhere; }
.ledger-count { flex: 0 0 auto; padding: 2px 9px; color: var(--text-muted); background: var(--surface-muted); border-radius: 999px; font-size: .73rem; font-weight: 650; white-space: nowrap; }
.ledger-group-body { display: grid; gap: 10px; padding: 4px 12px 12px; border-top: 1px solid var(--border); }
.ledger-subgroup { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 10px; }
.ledger-subgroup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 13px; cursor: pointer; list-style: none; }
.ledger-subgroup-head::-webkit-details-marker { display: none; }
.ledger-subgroup-head .ledger-group-title { font-size: .84rem; }
.ledger-subgroup-body { display: grid; gap: 8px; padding: 4px 10px 10px; }
.ledger-record { padding: 0; overflow: hidden; }
.ledger-record.is-new { animation: ledger-flash 1.5s ease; }
.ledger-record-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 14px; cursor: pointer; list-style: none; }
.ledger-record-head::-webkit-details-marker { display: none; }
.ledger-record-head:hover { background: var(--surface-muted); }
.ledger-record-title { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 8px; min-width: 0; }
.ledger-record-title strong { font-size: .9rem; overflow-wrap: anywhere; }
.ledger-record-code { color: var(--text-muted); font-size: .74rem; }
.ledger-record-place { color: var(--text-muted); font-size: .8rem; }
.ledger-record-remarks { max-width: 34ch; overflow: hidden; color: var(--text-muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.ledger-record-quantity { margin-left: auto; padding: 3px 10px; color: var(--brand-strong); background: var(--accent-soft); border-radius: 999px; font-size: .84rem; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger-record-body { padding: 12px 14px 14px; border-top: 1px solid var(--border); background: var(--surface-muted); }
.ledger-record-body .inline-form { margin-top: 8px; }
.ledger-material-field { display: grid; gap: 5px; }
.field-label { color: var(--text-secondary); font-size: .81rem; font-weight: 600; }
.ledger-record-actions { display: flex; justify-content: flex-end; }
@keyframes ledger-flash {
    0% { box-shadow: 0 0 0 3px rgb(40 98 71 / 35%); }
    100% { box-shadow: 0 0 0 0 rgb(40 98 71 / 0%); }
}

@media (max-width: 900px) {
    .entry-line { grid-template-columns: auto minmax(0, 1fr); }
    .entry-step { display: none; }
    .entry-field-material { grid-column: 1 / -1; }
    .entry-field-quantity { grid-column: 1; }
    .entry-submit { grid-column: 2; justify-self: end; }
    .entry-location-hint { display: none; }
}
@media (max-width: 600px) {
    .entry-line { grid-template-columns: 1fr; }
    .entry-field-quantity, .entry-submit { grid-column: 1; }
    .entry-submit { justify-self: stretch; }
    .entry-location-field { flex: 1 1 100%; }
    .entry-location-sep { display: none; }
    .ledger-record-quantity { margin-left: 0; }
    .ledger-record-remarks { max-width: 100%; }
}

/* == SECTION 5f: MODULE material-management — catalogue rail + entry ======= */
.material-entry-panel { border-color: var(--panel-border-strong); scroll-margin-top: calc(var(--topbar-h) + 66px); }
/* Collapsed by default: one compact summary bar; the catalogue owns the first
   screen. <details> keeps working without JS (native toggle + form POST). */
.material-entry-panel > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; cursor: pointer; list-style: none; }
.material-entry-panel > summary::-webkit-details-marker { display: none; }
.material-entry-panel > summary::after { content: "+"; display: grid; width: 23px; height: 23px; flex: 0 0 auto; place-items: center; color: var(--accent-text); background: var(--accent-soft); border-radius: 7px; font-size: 1rem; }
.material-entry-panel[open] > summary::after { content: "−"; }
.material-entry-panel[open] > summary { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.material-entry-summary-title { font-size: 1.08rem; font-weight: 650; letter-spacing: -.015em; }
.material-entry-summary-hint { min-width: 0; color: var(--text-muted); font-size: .81rem; line-height: 1.5; }
.material-entry-panel > summary .entry-counter { margin-left: auto; }
.material-entry { display: grid; gap: 13px; }
.toolbar-export { margin: 0; align-items: center; }
.entry-context { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 14px; padding: 12px 14px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 12px; }
.entry-context-field { display: grid; flex: 0 1 240px; gap: 4px; min-width: 180px; color: var(--text-secondary); font-size: .76rem; font-weight: 620; }
.entry-context-field select { min-height: var(--control-h); font-size: .87rem; font-weight: 650; }
.entry-context-stat { align-self: center; padding: 5px 12px; color: var(--brand-strong); background: var(--accent-soft); border-radius: 999px; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-context-toggle { display: flex; flex-direction: row; align-items: center; gap: 7px; align-self: center; color: var(--text-muted); font-size: .78rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.entry-context-hint { align-self: center; margin-left: auto; color: var(--text-muted); font-size: .74rem; }
.entry-grid { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1.6fr) minmax(110px, .5fr) auto; gap: 12px; align-items: end; }
.entry-grid-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.entry-field-code input { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.entry-field-name input { min-height: 46px; font-size: .95rem; font-weight: 620; }
.entry-field-unit input { min-height: 46px; font-weight: 620; }
.entry-grid-secondary textarea { min-height: 42px; }
.entry-code-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: -4px; }
.entry-code-tools[hidden], .entry-code-tools [hidden] { display: none; }
.button-mini { min-height: 30px; padding: 4px 11px; font-size: .76rem; }
.button-mini strong { color: var(--accent-text); font-variant-numeric: tabular-nums; }
.button-mini.is-warning { border-color: var(--warning-emphasis-border); }
.button-mini.is-warning strong { color: var(--warning-text); }
.entry-code-note { color: var(--text-muted); font-size: .74rem; }
.material-workspace { display: grid; grid-template-columns: minmax(196px, 236px) minmax(0, 1fr); gap: 16px; align-items: start; margin: 16px 0; }
.material-workspace:not(.has-entry) { grid-template-columns: minmax(0, 1fr); }
.material-workspace:not(.has-entry) .material-rail { display: none; }
.material-workspace > .panel { margin: 0; }
.material-rail { position: sticky; top: calc(var(--topbar-h) + 64px); max-height: calc(100vh - var(--topbar-h) - 88px); display: flex; flex-direction: column; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 8px; color: var(--text-muted); font-size: .74rem; font-weight: 700; letter-spacing: .07em; }
.rail-manage { padding: 2px 8px; color: var(--accent-text); background: none; border: 0; border-radius: 6px; font-size: .74rem; font-weight: 650; cursor: pointer; }
.rail-manage:hover { background: var(--accent-soft); }
.rail-list { display: grid; gap: 3px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
.rail-list::-webkit-scrollbar { width: 8px; }
.rail-list::-webkit-scrollbar-track { background: transparent; }
.rail-list::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 8px; }
.rail-list::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }
.rail-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: 7px 10px; color: var(--text); background: none; border: 1px solid transparent; border-radius: 9px; font-size: .84rem; font-weight: 600; text-align: left; cursor: pointer; transition: background-color .14s ease, border-color .14s ease; }
.rail-item:hover { background: var(--surface-2); }
.rail-item.is-active { color: var(--accent-text); background: var(--accent-soft); border-color: var(--brand-border-soft); font-weight: 700; }
.rail-name { min-width: 0; overflow-wrap: anywhere; }
.rail-count { flex: 0 0 auto; min-width: 26px; padding: 1px 8px; color: var(--text-muted); background: var(--surface-2); border-radius: 999px; font-size: .73rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
.rail-item.is-active .rail-count { color: var(--brand-strong); background: var(--brand-soft-strong); }
.rail-hint { margin: 9px 4px 2px; padding-top: 8px; border-top: 1px dashed var(--border); color: var(--text-muted); font-size: .72rem; line-height: 1.5; }
.material-row.is-new { animation: material-flash 1.6s ease; }
.material-row.is-new td { background: var(--accent-soft); }
@keyframes material-flash {
    0% { box-shadow: inset 3px 0 var(--accent); }
    100% { box-shadow: inset 0 0 transparent; }
}
#materials-no-match { margin-top: 10px; }
.edit-dialog .entry-submit-key { margin-left: 8px; padding: 2px 7px; color: var(--on-brand-soft); background: rgb(255 255 255 / 16%); border-radius: 6px; font-size: .7rem; font-weight: 650; }

@media (max-width: 900px) {
    .material-workspace { grid-template-columns: 1fr; gap: 12px; }
    .material-rail { position: static; max-height: none; padding: 8px; }
    .rail-list { display: flex; overflow-x: auto; overflow-y: hidden; padding-bottom: 3px; }
    .rail-item { flex: 0 0 auto; width: auto; min-height: 34px; white-space: nowrap; }
    .rail-name { overflow-wrap: normal; }
    .rail-hint { display: none; }
    .entry-grid { grid-template-columns: minmax(0, 1fr) minmax(110px, .4fr); }
    .entry-field-code { grid-column: 1; }
    .entry-field-name { grid-column: 1 / -1; grid-row: 1; }
    .entry-field-unit { grid-column: 2; grid-row: 2; }
    .entry-grid .entry-submit { grid-column: 1 / -1; justify-self: stretch; }
    .entry-context-hint { display: none; }
}
@media (max-width: 600px) {
    .entry-grid { grid-template-columns: 1fr; }
    .entry-field-code, .entry-field-name, .entry-field-unit, .entry-grid .entry-submit { grid-column: 1; grid-row: auto; }
    .entry-grid-secondary { grid-template-columns: 1fr; }
    .entry-context-field { flex: 1 1 100%; }
    .entry-context-stat { align-self: flex-start; }
    .material-entry-summary-hint { flex-basis: 100%; order: 3; }
    .material-entry-panel > summary .entry-counter { margin-left: auto; }
    .toolbar-export { flex: 1 1 100%; }
    .toolbar-export .button { width: 100%; }
}

/* Dark residuals for the materials workbench: none — all colors resolve via
   the semantic token flip in body.theme-dark above. */