/*
  DocMX user app styles. Tokens match docs/docmx-style-guide.md §11 so this app and
  DocMX Management resolve to the same values. Light mode only, per the style guide.
*/

:root {
    /* Brand */
    --color-brand: #074684;
    --color-brand-hover: #05376A;
    --color-brand-teal: #0EA5C6;
    --color-brand-accent: #A0EDF7;
    --color-brand-tint: #EAF1F8;
    --color-teal-tint: #E7F6FA;

    /* Surfaces */
    --color-surface: #FFFFFF;
    --color-surface-raised: #F8FAFC;
    --color-border: #E2E8F0;

    /* Text */
    --color-text-primary: #0F172A;
    --color-text-secondary: #64748B;
    --color-text-muted: #94A3B8;
    --color-text-soft: #475569;

    /* Paired status palettes (§3.4): background / foreground / border */
    --success-bg: #F0FDF4; --success-fg: #166534; --success-border: #86EFAC;
    --warning-bg: #FFFBEB; --warning-fg: #78350F; --warning-border: #FDE68A;
    --error-bg: #FEF2F2; --error-fg: #991B1B; --error-border: #FCA5A5;
    --info-bg: #EFF6FF; --info-fg: #1E40AF; --info-border: #BFDBFE;
    --neutral-bg: #F1F5F9; --neutral-fg: #475569; --neutral-border: #E2E8F0;
    --color-danger: #DC2626;
    --color-danger-hover: #B91C1C;

    /* Shape and elevation */
    --radius: 0.5rem;
    --radius-small: calc(var(--radius) * 0.75);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 4px 12px rgba(7, 70, 132, 0.10);
    --focus-ring: 0 0 0 3px rgba(14, 165, 198, 0.25);
    --radius-large: 0.875rem; /* v2 cards (forms) */

    /* Fields, v2: softly filled, with a bottom edge at 3:1 against white */
    --field-fill: #F8FAFC;
    --field-fill-hover: #F1F5F9;
    --field-edge: #7C8BA1;

    /* Motion: short and purposeful; switched off under prefers-reduced-motion */
    --motion-fast: 150ms;
    --motion: 200ms;

    /* Typography */
    --font-title: 'Roboto', system-ui, sans-serif;
    --font-subtitle: 'Hind', system-ui, sans-serif;
    --font-body: 'Open Sans', system-ui, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

    --top-bar-height: 56px;
    --nav-width: 232px;
    --rail-width: 68px;
}

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

/* One screen, never a scrolling page: the window doesn't scroll; regions inside the page do. */
html, body { height: 100%; overflow: hidden; }

body {
    margin: 0;
    background: var(--color-surface-raised);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-title); line-height: 1.2; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.125rem; font-weight: 600; }

a { color: var(--color-brand); }
a:hover { color: var(--color-brand-hover); }

:focus-visible { outline: 2px solid var(--color-brand-teal); outline-offset: 2px; }
/* FocusOnNavigate moves focus to each page's h1 for screen readers; no ring needed there. */
h1:focus, h1:focus-visible, .app-main:focus { outline: none; }

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

.skip-link { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--color-surface); padding: 8px 12px; border-radius: var(--radius); }
.skip-link:focus { left: 8px; }

/* Text roles */
.micro-label {
    font-family: var(--font-subtitle); font-size: 0.6875rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-secondary); margin: 0;
}
.hint { color: var(--color-text-secondary); font-size: 0.8125rem; }
.number { font-variant-numeric: tabular-nums; }
.shell-message { padding: 2rem; color: var(--color-text-secondary); }
.empty { padding: 1.25rem 1.125rem; color: var(--color-text-secondary); margin: 0; }

/* ---------- Shell ---------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: var(--top-bar-height) minmax(0, 1fr);
    grid-template-areas: "top top" "nav main";
    height: 100vh; height: 100dvh; overflow: hidden;
}
.app-shell.is-rail { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
.app-main { grid-area: main; min-width: 0; min-height: 0; overflow: auto; outline: none; }

.top-bar {
    grid-area: top; display: flex; align-items: center; gap: 0.75rem; padding: 0 1.5rem;
    background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.top-bar-logo { display: flex; align-items: center; }
.top-bar-logo img { height: 28px; width: auto; }
.top-bar-search { position: relative; display: flex; align-items: center; flex: 0 1 520px; margin-left: 1rem; }
.top-bar-search .icon { position: absolute; left: 12px; color: var(--color-text-secondary); }
.top-bar-search input[type="search"] {
    width: 100%; height: 38px; padding: 0 12px 0 40px; border: 1px solid var(--color-border);
    border-radius: var(--radius-small); background: var(--color-surface-raised); font: inherit; font-size: 0.875rem;
}
.top-bar-spacer { flex: 1 1 auto; }
.env-chip { font-size: 0.75rem; color: var(--color-text-soft); border: 1px dashed var(--color-border); border-radius: 100px; padding: 2px 10px; white-space: nowrap; }

.site-picker {
    display: flex; align-items: center; gap: 0.5rem; height: 38px; padding: 0 0.75rem;
    border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface);
    font: inherit; font-size: 0.875rem; color: var(--color-text-primary); cursor: pointer;
}
.site-picker:hover { border-color: var(--color-brand-teal); }
.site-picker-name { font-weight: 600; white-space: nowrap; }

.icon-button {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: var(--radius); background: transparent; color: var(--color-text-primary); cursor: pointer;
}
.icon-button:hover { background: var(--color-surface-raised); }

.avatar {
    width: 34px; height: 34px; flex: 0 0 34px; border-radius: 100px; background: var(--color-brand); color: #FFFFFF;
    font-family: var(--font-title); font-weight: 700; font-size: 0.8125rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.avatar-soft { width: 30px; height: 30px; flex-basis: 30px; background: var(--color-teal-tint); color: var(--color-brand); font-size: 0.75rem; }

.side-nav {
    grid-area: nav; display: flex; flex-direction: column; min-height: 0;
    background: var(--color-surface); border-right: 1px solid var(--color-border);
}
.side-nav-body { flex: 1; min-height: 0; overflow-y: auto; padding: 1rem 0.75rem; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.side-nav-link {
    display: flex; align-items: center; gap: 0.75rem; height: 40px; padding: 0 0.75rem; border-radius: var(--radius);
    color: var(--color-text-primary); font-size: 0.875rem; text-decoration: none; white-space: nowrap;
}
.side-nav-link:hover { background: var(--color-surface-raised); color: var(--color-text-primary); }
.side-nav-link.active { background: var(--color-brand-tint); color: var(--color-brand); font-weight: 600; }
.side-nav-divider { border: 0; border-top: 1px solid var(--color-border); margin: 0.75rem 0.25rem; width: auto; }
.side-nav-toggle {
    margin: 0.5rem 0.75rem 0.75rem; height: 36px; border: 1px solid var(--color-border); border-radius: var(--radius);
    background: var(--color-surface); color: var(--color-text-soft); cursor: pointer;
}
.is-rail .side-nav-body { padding: 0.75rem 0.625rem; align-items: center; }
.is-rail .side-nav-link { width: 44px; height: 44px; padding: 0; justify-content: center; }
.is-rail .side-nav-label { display: none; }
.is-rail .side-nav-toggle { margin: 0.5rem 0.625rem 0.75rem; }

/* Notification centre (NotificationCentre.razor) */
.notify { position: relative; }
.notify-button { position: relative; }
.notify-count {
    position: absolute; top: 4px; left: 24px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 100px;
    background: var(--color-danger); color: #FFFFFF; font-size: 0.625rem; font-weight: 700; line-height: 16px; text-align: center;
    border: 2px solid var(--color-surface); box-sizing: content-box;
}
.notify-backdrop { position: fixed; inset: 0; z-index: 19; }
.notify-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: min(400px, calc(100vw - 2rem));
    max-height: min(70vh, 560px); display: flex; flex-direction: column; box-shadow: var(--shadow-card-hover);
}
.notify-filters { padding: 0.625rem 1.125rem; border-bottom: 1px solid var(--color-border); }
.notify-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.notify-item { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.75rem 1.125rem 0.75rem 1rem; border-left: 3px solid transparent; }
.notify-item + .notify-item { border-top: 1px solid var(--color-border); }
.notify-item.is-unread { border-left-color: var(--color-brand-teal); background: var(--color-teal-tint); }
.notify-link { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; color: var(--color-text-primary); text-decoration: none; font-size: 0.875rem; line-height: 1.4; }
a.notify-link:hover .notify-text { text-decoration: underline; }
.notify-link .hint { font-size: 0.75rem; }
.notify-toggle { flex: 0 0 auto; font-size: 0.75rem; white-space: nowrap; }
.notify-panel .empty { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.notify-panel .empty p { margin: 0; }

/* ---------- Page structure ---------- */

.page { padding: 1.75rem 2rem 2.5rem; display: flex; flex-direction: column; gap: 1.5rem; }
.page-wide { max-width: none; padding: 1.25rem 1.5rem 1.75rem; gap: 1rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.page-header h1 + .hint, .page-header .micro-label + h1 { margin-top: 0.25rem; }
.page-header p { margin: 0.375rem 0 0; }
.page-wide .page-header { align-items: flex-start; }
.page-wide h1 { font-size: 1.5rem; margin-top: 0.25rem; }
.breadcrumb { font-size: 0.8125rem; color: var(--color-text-secondary); }
.breadcrumb a { text-decoration: none; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem; }
.badge-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }

.split { display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-start; }
.split-main { flex: 999 1 560px; min-width: 0; }
.split-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 1.5rem; }

/* ---------- Components ---------- */

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.625rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--color-border); }
.card-header h2 { margin-right: 0.5rem; }
.card-section-header { display: flex; align-items: center; justify-content: space-between; padding: 0.625rem 1.125rem; background: var(--color-surface-raised); border-bottom: 1px solid var(--color-border); }
.card-footer { padding: 0.75rem 1.125rem; border-top: 1px solid var(--color-border); background: var(--color-surface-raised); font-size: 0.8125rem; }
.card-footer a { font-weight: 600; text-decoration: none; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card { padding: 1rem 1.125rem; }
.stat-card-value { font-family: var(--font-title); font-size: 1.875rem; font-weight: 700; margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.stat-card-value.is-alert { color: var(--error-fg); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; height: 40px; padding: 0 1.125rem;
    border: 1px solid transparent; border-radius: var(--radius); font: inherit; font-size: 0.875rem; font-weight: 600;
    text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--color-brand); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--color-brand-hover); color: #FFFFFF; }
.btn-secondary { background: var(--color-surface); color: var(--color-brand); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--color-brand-teal); background: var(--color-surface-raised); }
.btn-danger { background: var(--color-danger); color: #FFFFFF; }
.btn-danger:hover:not(:disabled) { background: var(--color-danger-hover); }
.btn-small { height: 34px; padding: 0 0.75rem; font-size: 0.8125rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.link-button { border: 0; background: transparent; padding: 4px 0; color: var(--color-brand); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }

.badge {
    display: inline-block; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    padding: 2px 9px; border-radius: 100px; border: 1px solid; white-space: nowrap;
}
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-border); }
.badge-success { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }
.badge-error { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }
.badge-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-border); }

.tag-chip { font-size: 0.75rem; padding: 2px 10px; border-radius: 100px; border: 1px solid; }
.tag-chip-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-border); }
.tag-chip-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }

.chip {
    display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border-radius: 100px;
    background: var(--neutral-bg); border: 1px solid var(--neutral-border); color: var(--neutral-fg); font-size: 0.8125rem;
}
.chip button { width: 24px; height: 24px; border: 0; border-radius: 100px; background: transparent; color: inherit; cursor: pointer; font-size: 0.9375rem; line-height: 1; }
.chip button:hover { background: var(--color-border); }

.pill-tabs { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.pill {
    height: 30px; padding: 0 0.75rem; border-radius: 100px; border: 1px solid var(--color-border);
    background: var(--color-surface); color: var(--color-text-soft); font: inherit; font-size: 0.8125rem; cursor: pointer;
}
.pill:hover { border-color: var(--color-brand-teal); }
.pill.is-active { border-color: var(--color-brand-teal); background: var(--color-teal-tint); color: var(--color-text-primary); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 1px solid var(--color-border); }
.tab {
    height: 40px; padding: 0 0.875rem; border: 0; border-bottom: 2px solid transparent; background: transparent;
    color: var(--color-text-secondary); font-family: var(--font-subtitle); font-size: 0.9375rem; font-weight: 500; cursor: pointer;
}
.tab:hover { color: var(--color-text-primary); }
.tab.is-active { border-bottom-color: var(--color-brand); color: var(--color-text-primary); font-weight: 600; }

.banner { display: flex; align-items: center; gap: 0.625rem; padding: 0.75rem 1rem; border-radius: var(--radius); border: 1px solid; font-size: 0.875rem; }
.banner-warning { background: var(--warning-bg); color: var(--warning-fg); border-color: var(--warning-border); }
.banner-info { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-border); }
.banner-error { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }
.banner > .icon { flex: none; }
.lock-confirm { flex-wrap: wrap; }
.action-panel { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; overflow: visible; max-width: 36rem; }
.action-panel-title { margin: 0; font-size: 1rem; }
.next-steps ul { margin: 0.25rem 0 0; padding-left: 1.25rem; font-size: 0.875rem; }
.next-steps p { margin: 0; }
.action-problems { align-items: flex-start; }
.action-problems p, .action-problems ul { margin: 0; }
.action-problems ul { padding-left: 1.25rem; }
.person-picker { display: flex; flex-direction: column; gap: 0.375rem; }
.person-options { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.person-chips { list-style: none; margin: 0 0 0.25rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.person-chip { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.125rem 0.25rem 0.125rem 0.625rem; border-radius: 999px; background: var(--info-bg); color: var(--info-fg); border: 1px solid var(--info-border); font-size: 0.8125rem; }
.person-chip-remove { border: 0; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; min-width: 24px; min-height: 24px; border-radius: 999px; }
.person-chip-remove:hover { background: var(--color-surface); }
.person-chip-remove:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nudge-panel { display: flex; flex-direction: column; gap: 1rem; padding: 1rem; overflow: visible; max-width: 36rem; }
.lock-confirm > span:first-of-type { flex: 1 1 16rem; }

/* Tables (§6.5) */
.table-scroll { overflow-x: auto; position: relative; } /* positioned, so visually hidden labels inside stay clipped */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; min-width: 640px; }
.data-table th {
    text-align: left; padding: 0.625rem 0.75rem; background: var(--color-surface-raised); border-bottom: 1px solid var(--color-border);
    font-family: var(--font-subtitle); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-secondary);
}
.data-table td { padding: 0.75rem; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.data-table th:first-child, .data-table td:first-child { padding-left: 1.125rem; }
.data-table th:last-child, .data-table td:last-child { padding-right: 1.125rem; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(7, 70, 132, 0.03); }
.data-table tr.is-selected { background: rgba(7, 70, 132, 0.05); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.data-table .col-check { width: 40px; }
.sort-button { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.sort-button:hover { color: var(--color-text-primary); text-decoration: underline; }
.sort-button:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 2px; }
.intray-split { align-items: flex-start; }
.intray-split > .intray-folders { flex: 1 1 15rem; max-width: 18rem; }
@media (max-width: 720px) { .intray-split > .intray-folders { max-width: none; } }
.intray-split > .intray-documents { flex: 1 1 28rem; min-width: 0; }
.intray-folders { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; overflow: visible; }
.intray-folders h2 { margin: 0.75rem 0.5rem 0.25rem; }
.intray-folders ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.intray-folder { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.625rem; border-radius: var(--radius); color: var(--color-text-primary); text-decoration: none; font-size: 0.875rem; }
.intray-folder:hover { background: var(--color-surface-raised); }
.intray-folder.is-current { background: var(--info-bg); color: var(--info-fg); font-weight: 600; }
.intray-folder:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.intray-count { font-variant-numeric: tabular-nums; color: var(--color-text-secondary); font-size: 0.8125rem; }
.intray-documents h2 { margin: 0; }
.intray-documents td .badge { margin-left: 0.375rem; vertical-align: middle; }
.intray-upload { padding: 1rem 1.125rem 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.upload-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 1.25rem 1rem; text-align: center; border: 2px dashed var(--color-border); border-radius: var(--radius); background: var(--color-surface-raised); color: var(--color-text-secondary); }
.upload-drop:focus-within { border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }
.upload-drop.is-dragging { border-color: var(--color-brand-teal); background: var(--info-bg); }
.upload-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-label { color: var(--color-text-primary); font-weight: 500; font-size: 0.875rem; }
.upload-drop .hint { margin: 0; }
.link-like { color: var(--color-brand); text-decoration: underline; }
.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.upload-item { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.875rem; padding: 0.375rem 0.5rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.upload-name { font-weight: 500; flex: 1 1 10rem; min-width: 0; overflow-wrap: anywhere; }
.upload-state { color: var(--color-text-secondary); }
.upload-state.is-busy { color: var(--info-fg); }
.upload-problem { color: var(--error-fg); }
.index-form .doc-panel-body { gap: 1rem; }
.index-form select { width: 100%; }
.intray-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.625rem 1.125rem; border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); background: var(--color-surface-raised); }
.intray-actions .micro-label { margin-right: 0.25rem; }
.rotate-select { width: auto; height: 32px; font-size: 0.8125rem; }
.intray-confirm { margin: 0.75rem 1.125rem 0; }
.intray-message { margin: 0.75rem 1.125rem 0; font-size: 0.875rem; color: var(--color-text-soft); }
.form-tile-name { font-weight: 600; }
.ooo-cover { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 0.875rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface-raised); }
.ooo-cover p { margin: 0; }
.ooo-cover-list { margin: 0; padding-left: 1.125rem; font-size: 0.875rem; }
.queue-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.queue { display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem 1.125rem; overflow: visible; }
.queue-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.queue-head h2 { margin: 0; font-size: 1rem; }
.queue .hint { margin: 0; }
.queue-counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.25rem 0; }
.queue-counts div { background: var(--color-surface-raised); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.375rem 0.5rem; }
.queue-counts dt { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-secondary); }
.queue-counts dd { margin: 0; font-size: 1.125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.queue-counts .is-aging { background: var(--info-bg); border-color: var(--info-border); }
.queue-counts .is-aged { background: var(--warning-bg); border-color: var(--warning-border); }
.queue-counts .is-critical { background: var(--error-bg); border-color: var(--error-border); }
.queue-counts .is-critical dd { color: var(--error-fg); }
.queue-viewing { margin: 0; font-size: 0.875rem; }
.queue-foot { margin-top: auto; padding-top: 0.25rem; }
.task-search { display: flex; gap: 0.5rem; align-items: center; }
.task-search input { width: min(18rem, 60vw); }
.data-table input[type="checkbox"], .check input { width: 16px; height: 16px; accent-color: var(--color-brand); }
.row-link { font-weight: 600; text-decoration: none; }

.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 0.625rem 1.125rem; background: var(--info-bg); border-bottom: 1px solid var(--info-border); color: var(--info-fg); font-size: 0.8125rem; }
.bulk-bar-clear { margin-left: auto; color: var(--info-fg); }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; color: var(--color-text-secondary); }

.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li + li { border-top: 1px solid var(--color-border); }
.link-list a { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem 1.125rem; color: var(--color-text-primary); text-decoration: none; font-size: 0.875rem; }
.link-list a:hover { background: var(--color-surface-raised); }
.link-list a.note-mention { justify-content: flex-start; align-items: flex-start; font-size: 0.8125rem; line-height: 1.45; }
.note-mention-text { display: block; color: var(--color-text-soft); }
.note-mention .hint { display: block; font-size: 0.75rem; }

/* Forms (§6.2) */
.filters { flex: 1 1 250px; min-width: 0; align-self: flex-start; }
.filters-body { padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.375rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.field legend { padding: 0; margin-bottom: 0.375rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.field-row input { flex: 1 1 140px; min-width: 0; }
input[type="text"], input[type="password"], input[type="date"], input[type="search"], textarea, select {
    height: 38px; padding: 0 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-small);
    font: inherit; font-size: 0.875rem; color: var(--color-text-primary); background: var(--color-surface);
}
textarea { height: auto; padding: 0.5rem 0.75rem; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }
.check { display: flex; align-items: center; gap: 0.625rem; min-height: 30px; font-size: 0.875rem; }

/* State messages: loading, empty, not found, no access, error (StateMessage.razor) */
.state { display: flex; align-items: flex-start; gap: 0.875rem; color: var(--color-text-secondary); }
.state-page { max-width: 640px; padding: 2.5rem 2rem; }
.state-inline { padding: 1.25rem 1.125rem; }
.state-icon {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border-radius: 100px; background: var(--neutral-bg); color: var(--neutral-fg);
}
.state-inline .state-icon { width: 36px; height: 36px; }
.state-error .state-icon { background: var(--error-bg); color: var(--error-fg); }
.state-accessdenied .state-icon { background: var(--warning-bg); color: var(--warning-fg); }
.state-text { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; padding-top: 0.25rem; }
.state-inline .state-text { padding-top: 0.375rem; }
.state-title { color: var(--color-text-primary); margin: 0; }
h1.state-title { font-size: 1.375rem; }
p.state-title { font-weight: 600; font-size: 0.9375rem; }
.state-detail { font-size: 0.875rem; }
.state-detail p { margin: 0; }
.state .button-row { margin-top: 0.5rem; }
.state-spinner {
    flex: 0 0 auto; width: 20px; height: 20px; margin-top: 0.3rem; border-radius: 100px;
    border: 2px solid var(--color-border); border-top-color: var(--color-brand); animation: state-spin 0.8s linear infinite;
}
.state-page .state-spinner { width: 24px; height: 24px; }
@keyframes state-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .state-spinner { animation: none; } }

/* Idle sign-out warning (IdleSignOut.razor), a native modal <dialog> */
.idle-dialog {
    width: min(440px, calc(100vw - 2rem)); padding: 1.5rem; border: 1px solid var(--color-border); border-radius: var(--radius);
    background: var(--color-surface); color: var(--color-text-primary); box-shadow: var(--shadow-card-hover);
}
.idle-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.idle-dialog h2 { margin-bottom: 0.5rem; }
.idle-dialog p { margin: 0 0 1.25rem; color: var(--color-text-soft); }
/* Public pages (PublicLayout.razor) */
/* Like the app shell: the window never scrolls; the page area below the bar does. */
.public-shell { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.public-bar { display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; height: var(--top-bar-height); background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.public-main { flex: 1 1 auto; min-width: 0; min-height: 0; overflow: auto; outline: none; }
.public-page .viewer-body { height: 70vh; }
.reset-page { max-width: 480px; }
.reset-form { display: flex; flex-direction: column; gap: 0.875rem; padding: 0; margin-top: 1rem; }
.field-error { margin: 0; color: var(--error-fg); font-size: 0.8125rem; }
.reset-form input[type="password"] { max-width: none; width: 100%; }
.pw-errors { margin: 0; padding-left: 1.25rem; }
input[type="password"] { height: 38px; padding: 0 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-small); font: inherit; font-size: 0.875rem; }
/* Settings */
.avatar-link { text-decoration: none; }
.avatar-link:hover { color: #FFFFFF; box-shadow: 0 0 0 3px var(--color-teal-tint); }
.settings-section { max-width: 720px; }
.settings-body { padding: 1.125rem; display: flex; flex-direction: column; gap: 0.875rem; }
.settings-body .hint { margin: -0.375rem 0 0; }
.settings-body fieldset:disabled { opacity: 0.6; }
.settings-body .field-row .field { flex: 1 1 200px; }
.settings-body .field-row .field input { flex: none; width: 100%; } /* the row rule's 140px basis is a height in a column */
input[type="datetime-local"] {
    height: 38px; padding: 0 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-small);
    font: inherit; font-size: 0.875rem; color: var(--color-text-primary); background: var(--color-surface);
}
input[aria-invalid="true"] { border-color: var(--color-danger); }
.field-error { margin: 0; color: var(--error-fg); font-size: 0.8125rem; }
.ooo-status { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-weight: 600; }
.status-dot { width: 10px; height: 10px; border-radius: 100px; background: var(--color-border); flex: 0 0 auto; }
.status-dot.is-on { background: var(--warning-fg); }
.pw-errors { margin: 0; padding-left: 1.25rem; }
.photo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.photo-preview, .photo-placeholder { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 100px; object-fit: cover; font-size: 1.5rem; }
.details-form { display: flex; flex-direction: column; gap: 0.875rem; }
input[type="email"] { height: 38px; padding: 0 0.75rem; border: 1px solid var(--color-border); border-radius: var(--radius-small); font: inherit; font-size: 0.875rem; max-width: 420px; }
.expiry-banner { margin: 1rem 2rem 0; }
.expiry-banner .btn { margin-left: auto; }
.settings-body input[type="password"] { max-width: 320px; }
.site-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1.125rem; font-size: 0.875rem; }
.site-description { display: block; }
.signin-table { min-width: 480px; }
p.card-footer { margin: 0; }

/* ---------- Document page ---------- */

/* The document page fills the main pane: the header stays put, the viewer and panel scroll on their own. */
.page-fill { height: 100%; min-height: 0; }
.page-fill .document-split { flex: 1 1 auto; min-height: 0; flex-wrap: nowrap; }
.document-split { gap: 1rem; align-items: stretch; }
.more-menu { position: relative; }
.more-menu-backdrop { position: fixed; inset: 0; z-index: 20; }
.more-menu-panel {
    position: absolute; top: calc(100% + 0.25rem); left: 0; z-index: 21; min-width: 12rem; max-width: calc(100vw - 2rem);
    display: flex; flex-direction: column; padding: 0.25rem; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-card);
}
.more-menu-item {
    display: flex; align-items: center; gap: 0.5rem; width: 100%; min-height: 36px; padding: 0.5rem 0.75rem; border: 0;
    border-radius: calc(var(--radius) - 2px); background: none; color: var(--color-text-primary); font: inherit; font-size: 0.875rem;
    text-align: left; cursor: pointer;
}
.more-menu-item:hover:not(:disabled) { background: var(--color-surface-raised); }
.more-menu-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.more-menu-item:disabled { color: var(--color-text-secondary); cursor: not-allowed; }
.task-cycler { display: flex; align-items: center; gap: 0.25rem; font-size: 0.8125rem; color: var(--color-text-secondary); margin-right: 0.375rem; }
.task-cycler span { padding: 0 0.375rem; }
.favourite-toggle.is-on { color: var(--warning-fg); border-color: var(--warning-border); background: var(--warning-bg); }

.viewer { display: flex; flex-direction: column; min-height: 0; }
.viewer-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.375rem 0.625rem 0.375rem 1rem; border-bottom: 1px solid var(--color-border); min-height: 50px; }
.viewer-body { background: var(--color-border); flex: 1 1 auto; min-height: 0; }
.viewer-frame { width: 100%; height: 100%; border: 0; display: block; }
.viewer-pins { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.625rem 1rem; border-top: 1px solid var(--color-border); }

.pin {
    width: 28px; height: 28px; border-radius: 100px 100px 100px 4px; border: 2px solid #FFFFFF; background: var(--color-brand); color: #FFFFFF;
    font: inherit; font-size: 0.75rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 6px rgba(7, 70, 132, 0.35); padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.pin.is-mine { background: var(--color-brand-teal); color: var(--color-text-primary); }
.pin.is-selected { outline: 2px solid var(--color-brand-teal); outline-offset: 2px; }
.pin-small { width: 22px; height: 22px; flex: 0 0 22px; font-size: 0.6875rem; border: 0; box-shadow: none; cursor: default; }

.doc-panel { flex: 1 1 380px; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.doc-panel-tabs { padding: 0 0.625rem; }
.doc-panel-tabs .tab { height: 44px; padding: 0 0.625rem; font-size: 0.875rem; }
.doc-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; scroll-padding-bottom: 11rem; padding: 0.875rem; display: flex; flex-direction: column; gap: 0.75rem; background: var(--color-surface-raised); }

.note { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem 0.875rem; cursor: pointer; }
.note:hover { border-color: var(--color-brand-teal); }
.note.is-selected { border-color: var(--color-brand-teal); box-shadow: var(--shadow-card-hover); }
.note-head { display: flex; align-items: center; gap: 0.625rem; }
.note-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-size: 0.8125rem; line-height: 1.35; }
.note-who .hint { font-size: 0.75rem; }
.note-text { margin: 0.625rem 0 0; font-size: 0.875rem; }
.note-actions { display: flex; align-items: center; gap: 0.875rem; margin-top: 0.5rem; }
.note-actions .hint { margin-left: auto; }
.note-composer { margin-top: auto; position: sticky; bottom: 0; box-shadow: var(--shadow-card); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem 0.875rem; display: flex; flex-direction: column; gap: 0.5rem; }

.tag-list { margin: 0; display: flex; flex-direction: column; gap: 0.875rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem; }
.tag-list dd { margin: 0.125rem 0 0; font-size: 0.875rem; }
.note-replies { list-style: none; margin: 0.5rem 0 0; padding: 0 0 0 0.875rem; border-left: 2px solid var(--color-border); display: flex; flex-direction: column; gap: 0.625rem; }
.note-reply .note-text { margin: 0.25rem 0 0; }
.composer-mode { margin: 0; font-size: 0.8125rem; color: var(--color-text-soft); display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.composer-extras { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.note-edit { display: flex; flex-direction: column; gap: 0.375rem; margin: 0.5rem 0; }
.note-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0; font-size: 0.875rem; }
.note-error { margin: 0 0 0.5rem; }
.tag-section { border: 0; margin: 0 0 1rem; padding: 0; min-width: 0; }
.tag-section > h3, .tag-section > legend { margin: 0 0 0.5rem; padding: 0; }
.tag-form { display: flex; flex-direction: column; gap: 0.25rem; }
.tag-form .tag-section { display: flex; flex-direction: column; gap: 0.875rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem; }
.tag-form .tag-section > legend { float: left; width: 100%; }
.tag-readonly { margin: 0; font-size: 0.875rem; }
.tag-status { margin: 0 0 0.75rem; font-size: 0.875rem; color: var(--color-text-soft); }
.tag-summary { margin-bottom: 0.75rem; align-items: flex-start; }
.tag-summary p, .tag-summary ul { margin: 0; }
.tag-summary ul { padding-left: 1.25rem; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error-border); }
.related-group { display: flex; flex-direction: column; gap: 0.5rem; }
.related-group > h3 { margin: 0; }
.related-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.related { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem 0.875rem; font-size: 0.875rem; display: flex; flex-direction: column; gap: 0.25rem; }
.related-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.related-head a { font-weight: 600; }
.related-note { margin: 0.25rem 0 0; }
.version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.version { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 0.75rem 0.875rem; font-size: 0.875rem; }
.version-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }

/* ---------- Blazor runtime ---------- */

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: 0.75rem 1.25rem;
    background: var(--error-bg); color: var(--error-fg); border-top: 1px solid var(--error-border); box-shadow: var(--shadow-card);
}
#blazor-error-ui .dismiss { position: absolute; right: 0.75rem; top: 0.5rem; border: 0; background: transparent; color: inherit; font-size: 1.25rem; cursor: pointer; }

/* ---------- Narrow screens ---------- */

@media (max-width: 760px) {
    .app-shell, .app-shell.is-rail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "nav" "main"; grid-template-rows: auto auto minmax(0, 1fr); }
    /* One row on phones: the header and nav never scroll away, so keep them short. */
    .top-bar { gap: 0.5rem; padding: 0 0.75rem; min-width: 0; }
    .top-bar-logo img { width: 28px; height: 28px; object-fit: cover; object-position: left center; } /* just the mark */
    .top-bar-search { display: none; } /* Search is in the nav strip below */
    .env-chip, .site-picker-name { display: none; }
    .site-picker { padding: 0 0.5rem; gap: 0.25rem; }
    .icon-button { width: 40px; height: 40px; }
    .side-nav { border-right: 0; border-bottom: 1px solid var(--color-border); }
    .side-nav-body, .is-rail .side-nav-body { flex-direction: row; overflow-x: auto; padding: 0.5rem; }
    .side-nav-divider, .side-nav-toggle { display: none; }
    .page, .page-wide { padding: 1.25rem 1rem 2rem; }
    /* Too little height to sit side by side: stack inside the scrolling main pane. */
    .page-fill { height: auto; }
    .page-fill .document-split { flex-wrap: wrap; }
    .viewer-body { flex: none; height: 65dvh; }
    .doc-panel-body { overflow-y: visible; }
    /* The bell may sit anywhere in the top bar, so the panel spans the screen instead of hanging off it. */
    .notify-panel { position: fixed; top: 7rem; left: 1rem; right: 1rem; width: auto; }
}

/* Bulk task actions (#22) */
.bulk-hint { flex: 1 1 100%; font-size: 0.8125rem; }
.bulk-confirm { display: flex; flex-direction: column; gap: 0.875rem; margin: 0.75rem 1.125rem; padding: 1rem; max-width: 40rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface-raised); }
.bulk-confirm > h2 { margin: 0; }
.bulk-confirm fieldset { border: 0; margin: 0; padding: 0; }
.bulk-summary p { margin: 0 0 0.375rem; font-size: 0.875rem; }
.bulk-summary ul { margin: 0; padding-left: 1.25rem; font-size: 0.8125rem; max-height: 10rem; overflow-y: auto; }
.bulk-select { width: auto; min-width: 10rem; }
.bulk-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; max-height: 14rem; overflow-y: auto; font-size: 0.8125rem; }
.bulk-results li { display: flex; align-items: flex-start; gap: 0.625rem; }
.bulk-results .badge { flex: none; }
.bulk-result-text { display: flex; flex-direction: column; min-width: 0; }

/* Sharing outside DocMX (#34) */
.share-panel { display: flex; flex-direction: column; gap: 0.875rem; padding: 1rem; max-width: 40rem; overflow: visible; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.share-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.share-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); }
.share-list li:last-child { border-bottom: 0; }
.share-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; font-size: 0.875rem; overflow-wrap: anywhere; }
.share-who .hint { font-size: 0.8125rem; }
.share-all { align-self: flex-start; }
.share-finished summary { cursor: pointer; font-size: 0.875rem; color: var(--color-text-soft); }
.share-finished .share-list { margin-top: 0.5rem; }
.share-form { display: flex; flex-direction: column; gap: 0.875rem; padding-top: 0.875rem; border-top: 1px solid var(--color-border); }
.share-select { width: auto; min-width: 10rem; }
.share-summary { margin: 0; font-size: 0.875rem; }
.intray-rename { flex: 1 1 16rem; display: flex; flex-direction: column; gap: 0.25rem; margin: 0; }

/* Linking documents (#33) */
.related-remove { align-self: flex-start; font-size: 0.8125rem; }
.related-confirm { margin-top: 0.375rem; font-size: 0.8125rem; }
.link-start { align-self: flex-start; }
.link-document { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.875rem; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.link-document > h3 { margin: 0; }
.link-find { margin: 0; }
.link-find-row { display: flex; align-items: center; gap: 0.5rem; }
.link-find-row input { flex: 1 1 auto; min-width: 0; }
.link-find .hint { margin-bottom: 0; }
.link-confirm { display: flex; flex-direction: column; gap: 0.625rem; }
.link-found { margin: 0; font-size: 0.875rem; display: flex; flex-direction: column; }
.link-problem { margin: 0; color: var(--color-text-primary); }

/* Spreadsheet and audio previews (#35) */
.sheet-preview { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.5rem; padding: 0.75rem; }
.sheet-tabs { flex: none; overflow-x: auto; }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-small); background: var(--color-surface); }
.sheet-scroll:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sheet-table { border-collapse: collapse; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.sheet-table th, .sheet-table td { border: 1px solid var(--color-border); padding: 0.25rem 0.5rem; white-space: nowrap; text-align: left; }
.sheet-table thead th, .sheet-table tbody th { background: var(--color-surface-raised); color: var(--color-text-soft); font-weight: 500; position: sticky; }
.sheet-table thead th { top: 0; z-index: 1; text-align: center; }
.sheet-table tbody th { left: 0; text-align: right; }
.sheet-note { flex: none; margin: 0; }
.audio-preview { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding: 2rem 1rem; color: var(--color-text-soft); }
.audio-preview audio { width: 100%; max-width: 28rem; }
.audio-title { margin: 0; color: var(--color-text-primary); font-weight: 500; text-align: center; overflow-wrap: anywhere; }

/* Full-height grids (My tasks): the page fills the main pane, the card fills the page, and only the rows scroll,
   under a header that stays put, with the pager pinned at the bottom. */
.page-fill { height: 100%; min-height: 0; }
.card-fill { flex: 1 1 auto; min-height: 18rem; display: flex; flex-direction: column; }
.card-fill > .table-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.card-fill > .card-section-header, .card-fill > .card-footer, .card-fill > .intray-actions, .card-fill > .bulk-confirm { flex: none; }
.card-fill .data-table thead th { position: sticky; top: 0; z-index: 1; }

/* Forms v2 (#159): the form scrolls inside the page and the action bar stays put. One section is open at a time;
   the others collapse to a summary. Fields are softly filled; choices are option cards over real radio inputs. */
.form-v2 { padding: 0; gap: 0; display: flex; flex-direction: column; }
.fv-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.fv-layout { max-width: 64rem; margin: 0 auto; padding: 2.25rem 2rem 2.5rem; display: flex; gap: 3rem; align-items: flex-start; }
.fv-main { flex: 1 1 auto; min-width: 0; max-width: 40rem; display: flex; flex-direction: column; gap: 1rem; }

.fv-rail { flex: 0 0 13.75rem; position: sticky; top: 0; display: flex; flex-direction: column; gap: 1.25rem; padding-top: 0.25rem; }
.fv-rail-label { margin: 0 0 0.5rem; font-family: var(--font-subtitle); font-size: 0.8125rem; font-weight: 600; color: var(--color-text-soft); }
.fv-progress-track { height: 6px; border-radius: 99px; background: var(--color-border); overflow: hidden; }
.fv-progress-fill { height: 100%; border-radius: 99px; background: var(--color-brand-teal); transition: width 300ms ease; }
.fv-progress-text { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--color-text-secondary); }
.fv-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.fv-step {
    width: 100%; min-height: 44px; display: flex; align-items: center; gap: 0.75rem; padding: 0.375rem 0.75rem; border: 0; border-radius: 0.625rem;
    background: transparent; color: var(--color-text-primary); font: inherit; font-size: 0.9375rem; text-align: left; cursor: pointer;
    transition: background var(--motion-fast) ease, color var(--motion-fast) ease;
}
.fv-step:hover { background: var(--neutral-bg); }
.fv-step.is-current { background: var(--color-brand-tint); color: var(--color-brand); font-weight: 600; }

.fv-marker {
    flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--field-edge); color: var(--color-text-soft); font-size: 0.75rem; font-weight: 600; line-height: 1;
}
.fv-marker.is-done { border: 0; background: var(--color-brand-teal); color: #FFFFFF; animation: fv-pop var(--motion) ease both; }
.fv-marker.is-done .icon { stroke-width: 3; }

.fv-header { margin-bottom: 0.75rem; }
.fv-header .breadcrumb { margin-bottom: 0.625rem; }
.form-v2 h1 { font-size: 1.875rem; line-height: 1.15; }
.fv-lead { margin: 0.5rem 0 0; font-size: 1rem; color: var(--color-text-soft); }

.fv-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06); }
.fv-sections { display: flex; flex-direction: column; gap: 1rem; }
.fv-section-body { padding: 1.5rem 1.75rem; display: flex; flex-direction: column; gap: 1.375rem; animation: fv-in var(--motion) ease both; }
.fv-section-title { font-size: 1.1875rem; font-weight: 500; }
.fv-section-heading { margin: 0; font-size: inherit; font-weight: inherit; }
.fv-section-head {
    width: 100%; display: flex; align-items: center; gap: 0.875rem; padding: 1.125rem 1.75rem; border: 0; border-radius: var(--radius-large);
    background: transparent; font: inherit; text-align: left; color: var(--color-text-primary); cursor: pointer;
    transition: background var(--motion-fast) ease;
}
.fv-section-head:hover { background: var(--color-surface-raised); }
.fv-section-head .fv-marker { flex-basis: 24px; width: 24px; height: 24px; }
.fv-section-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.fv-section-name { font-family: var(--font-title); font-size: 1rem; font-weight: 500; }
.fv-section-summary { font-size: 0.875rem; color: var(--color-text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fv-section-summary.has-problems { color: var(--warning-fg); font-weight: 600; }
.fv-section-action { flex: none; font-size: 0.875rem; font-weight: 600; color: var(--color-brand); }

/* Fields */
.ff-field { display: flex; flex-direction: column; gap: 0.375rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.ff-label { padding: 0; font-size: 0.9375rem; font-weight: 600; color: var(--color-text-primary); }
legend.ff-label { margin-bottom: 0.375rem; }
.ff-optional { font-weight: 400; color: var(--color-text-secondary); }
.ff-help { margin: 0; font-size: 0.875rem; color: var(--color-text-secondary); }
.ff-heading { margin: 0.25rem 0 -0.5rem; font-family: var(--font-title); font-size: 1rem; font-weight: 600; }
.ff-description { margin: 0; font-size: 0.9375rem; color: var(--color-text-soft); }
.ff-line { border: 0; border-top: 1px solid var(--color-border); margin: 0; width: 100%; }
.ff-short { max-width: 18rem; }
.form-v2 .ff-input {
    width: 100%; height: 44px; padding: 0 0.875rem; font: inherit; font-size: 1rem; color: var(--color-text-primary);
    background: var(--field-fill); border: 1px solid var(--color-border); border-bottom-color: var(--field-edge); border-radius: 0.625rem;
    transition: background var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.form-v2 textarea.ff-input { height: auto; min-height: 6.5rem; padding: 0.75rem 0.875rem; line-height: 1.5; resize: vertical; }
.form-v2 .ff-input:hover { background: var(--field-fill-hover); }
.form-v2 .ff-input:focus { outline: none; background: var(--color-surface); border-color: var(--color-brand-teal); box-shadow: var(--focus-ring); }
.form-v2 .ff-input[aria-invalid="true"] { border-color: var(--error-border); border-bottom-color: var(--color-danger); }
.form-v2 .ff-input[readonly], .form-v2 .ff-input:disabled { background: var(--neutral-bg); color: var(--color-text-soft); }
.ff-amount { position: relative; }
.ff-amount-sign { position: absolute; left: 0.875rem; top: 50%; transform: translateY(-50%); color: var(--color-text-secondary); pointer-events: none; }
.form-v2 .ff-amount .ff-input { padding-left: 1.75rem; text-align: right; }
.ff-error { font-size: 0.875rem; }

.ff-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.625rem; }
.ff-choices.is-pair { grid-template-columns: repeat(2, minmax(0, 7.5rem)); }
.ff-choice {
    position: relative; min-height: 48px; display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.875rem;
    border: 1px solid var(--color-border); border-radius: 0.625rem; background: var(--color-surface); font-size: 0.9375rem; cursor: pointer;
    transition: background var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.ff-choice:hover { border-color: var(--color-text-muted); }
.ff-choice input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--color-brand); }
.ff-choice:has(input:checked) { border-color: var(--color-brand); box-shadow: inset 0 0 0 1px var(--color-brand); background: var(--color-brand-tint); color: var(--color-brand); font-weight: 600; }
.ff-choice:has(input:focus-visible) { box-shadow: var(--focus-ring); border-color: var(--color-brand-teal); }
.ff-choice:has(input:disabled) { cursor: default; opacity: 0.7; }
.ff-check { align-self: flex-start; }

/* Review */
.fv-review { display: flex; flex-direction: column; gap: 1rem; animation: fv-in var(--motion) ease both; }
.fv-review > h2 { font-size: 1.375rem; }
.fv-review > h2:focus { outline: none; }
.fv-review > .fv-lead { margin-top: -0.75rem; }
.fv-missing { padding: 1rem 1.125rem; border-radius: 0.75rem; background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-fg); }
.fv-missing-title { margin: 0 0 0.5rem; font-weight: 600; }
.fv-missing ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; font-size: 0.875rem; }
.fv-missing li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.625rem; }
.fv-missing .link-button { font-size: 0.875rem; text-decoration: underline; }
.fv-missing-q { font-weight: 600; }
.fv-missing-why::before { content: "· "; }
.fv-review-section { overflow: hidden; }
.fv-review-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.875rem 1.375rem; border-bottom: 1px solid var(--color-border); }
.fv-review-head h3 { margin: 0; font-family: var(--font-title); font-size: 1rem; font-weight: 500; }
.fv-review-head .link-button { margin-left: auto; font-size: 0.875rem; }
.fv-answers { margin: 0; padding: 0.375rem 1.375rem 0.625rem; }
.fv-answers > div { display: flex; gap: 1rem; padding: 0.5625rem 0; border-bottom: 1px solid var(--neutral-bg); font-size: 0.9375rem; }
.fv-answers > div:last-child { border-bottom: 0; }
.fv-answers dt { flex: 0 0 13rem; color: var(--color-text-secondary); }
.fv-answers dd { flex: 1 1 auto; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.fv-answers dd.is-empty { color: var(--warning-fg); font-style: italic; }

/* Submitted */
.fv-done { padding: 2rem; display: flex; flex-direction: column; gap: 1.25rem; box-shadow: var(--shadow-card-hover); animation: fv-in var(--motion) ease both; }
.fv-done h2 { font-size: 1.5rem; font-weight: 700; }
.fv-done p { margin: 0.375rem 0 0; color: var(--color-text-soft); font-size: 1rem; }
.fv-done-mark { width: 48px; height: 48px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success-fg); }
.fv-done .fv-reference { display: flex; align-items: center; gap: 0.75rem; margin: 0; padding: 0.75rem 1rem; border-radius: 0.625rem; background: var(--color-surface-raised); border: 1px solid var(--color-border); font-size: 0.8125rem; }
.fv-reference-number { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; color: var(--color-text-primary); }

/* Action bar */
.fv-bar { flex: none; background: var(--color-surface); border-top: 1px solid var(--color-border); }
.fv-bar-inner { max-width: 64rem; margin: 0 auto; padding: 0.875rem 2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.fv-bar-status { margin: 0; font-size: 0.875rem; font-weight: 600; }
.fv-bar-actions { margin-left: auto; display: flex; gap: 0.625rem; }
.fv-bar .btn { height: 44px; padding: 0 1.25rem; border-radius: 0.625rem; font-size: 0.9375rem; }

@keyframes fv-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fv-pop { from { transform: scale(0.6); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .fv-section-body, .fv-review, .fv-done, .fv-marker.is-done { animation: none; }
    .fv-progress-fill, .fv-step, .fv-section-head, .form-v2 .ff-input, .ff-choice { transition: none; }
}

@media (max-width: 760px) {
    .form-v2.page-fill { height: 100%; } /* keep the bar pinned: the form scrolls inside, as on a desktop */
    .fv-layout { flex-direction: column; gap: 1.25rem; padding: 1.25rem 1rem 1.5rem; }
    .fv-rail { display: none; } /* the bar says what's left; the steps don't fit beside the form */
    .fv-section-body { padding: 1.25rem 1rem; }
    .fv-section-head { padding: 1rem; }
    .fv-answers > div { flex-direction: column; gap: 0.125rem; }
    .fv-answers dt { flex: none; }
    .fv-bar-inner { padding: 0.75rem 1rem; }
    .fv-bar-actions { margin-left: 0; width: 100%; }
    .fv-bar-actions .btn { flex: 1 1 0; }
}

/* Form header, shared by both channels (#162): name, description, and the Classic / New layout switch. */
.form-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem; }
.form-head-text { flex: 1 1 18rem; min-width: 0; }
.form-blocked { margin-top: 1rem; }
.channel-switch { flex: none; display: inline-flex; align-items: center; gap: 0; margin: 0; padding: 3px; border: 1px solid var(--color-border); border-radius: 0.625rem; background: var(--color-surface); }
.channel-switch legend { float: left; padding: 0 0.5rem 0 0.375rem; font-size: 0.75rem; color: var(--color-text-secondary); line-height: 32px; }
.channel-switch label { position: relative; display: inline-flex; cursor: pointer; }
.channel-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.channel-switch label span { display: inline-flex; align-items: center; height: 32px; padding: 0 0.75rem; border-radius: 0.5rem; font-size: 0.8125rem; font-weight: 600; color: var(--color-text-soft); transition: background var(--motion-fast) ease, color var(--motion-fast) ease; }
.channel-switch input:checked + span { background: var(--color-brand-tint); color: var(--color-brand); }
.channel-switch input:focus-visible + span { box-shadow: var(--focus-ring); }

/* Forms, Classic channel (#162): looks and flows like the current DocMX web app. A fixed column, one section at a
   time, labels in a column beside the fields, and a footer with a step per section (red with issues, green when fine). */
.form-classic { padding: 0; gap: 0; display: flex; flex-direction: column; }
.fc-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 1.5rem; }
.fc-card { width: 50rem; max-width: 100%; margin: 0 auto; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-small); box-shadow: var(--shadow-card); }
.fc-head { display: flex; align-items: flex-start; gap: 0.875rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); }
.fc-icon { flex: 0 0 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--success-fg); color: #FFFFFF; }
.fc-head-text { flex: 1 1 auto; min-width: 0; }
.form-classic .breadcrumb { display: none; } /* the original has none; the side nav says where you are */
.form-classic h1 { font-size: 1.25rem; }
.form-classic .form-lead { margin-top: 0.125rem; font-size: 0.8125rem; color: var(--color-text-secondary); }
.fc-banner { margin: 1rem 1.25rem 0; }
.fc-banner:focus { outline: none; }
.fc-nav { display: flex; align-items: center; gap: 0.75rem; padding: 0.625rem 1.25rem; background: var(--color-surface-raised); border-bottom: 1px solid var(--color-border); }
.fc-nav-button { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--color-border); border-radius: var(--radius-small); background: var(--color-surface); color: var(--color-text-soft); cursor: pointer; }
.fc-nav-button:disabled { opacity: 0.45; cursor: default; }
.fc-nav-count { font-size: 0.8125rem; color: var(--color-text-soft); }
.fc-section-title { margin-left: 0.5rem; font-size: 1rem; font-weight: 500; }
.fc-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.875rem; }
.fc-row { display: flex; gap: 1rem; align-items: flex-start; margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.fc-row { display: block; }
.fc-label { flex: 0 0 10rem; padding: 0.4375rem 0 0; font-size: 0.8125rem; color: var(--color-text-soft); }
fieldset.fc-row > .fc-label { float: left; width: 10rem; }
fieldset.fc-row > .fc-control { margin-left: 11rem; }
.fc-star { color: var(--color-danger); }
.fc-control { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.form-classic .fc-input { width: 100%; height: 34px; padding: 0 0.625rem; border: 1px solid var(--field-edge); border-radius: 4px; background: var(--color-surface); font: inherit; font-size: 0.875rem; }
.form-classic textarea.fc-input { height: auto; padding: 0.5rem 0.625rem; }
.form-classic .fc-input[aria-invalid="true"] { border-color: var(--color-danger); }
.form-classic .fc-short { max-width: 12.5rem; }
.fc-radios { display: flex; flex-wrap: wrap; gap: 0.25rem 1.125rem; padding-top: 0.25rem; }
.fc-checkbox { width: 16px; height: 16px; margin: 0.5rem 0 0; accent-color: var(--color-brand); }
.fc-help { margin: 0; font-size: 0.75rem; color: var(--color-text-secondary); }
.fc-heading { margin: 0.25rem 0 0; font-size: 0.9375rem; }
.fc-description { margin: 0; font-size: 0.875rem; color: var(--color-text-soft); }
.fc-line { border: 0; border-top: 1px solid var(--color-border); margin: 0.25rem 0; width: 100%; }
.fc-footer { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.75rem 1.5rem; background: var(--color-surface); border-top: 1px solid var(--color-border); }
.fc-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fc-step { height: 36px; padding: 0 0.75rem; border-radius: 4px; border: 1px solid; font: inherit; font-size: 0.8125rem; cursor: pointer; }
.fc-step.is-good { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-border); }
.fc-step.is-bad { background: var(--error-bg); color: var(--error-fg); border-color: var(--error-border); }
.fc-step.is-current { border-width: 2px; font-weight: 600; }
.fc-step .number { font-weight: 700; }
.fc-actions { margin-left: auto; display: flex; gap: 0.5rem; }

@media (max-width: 760px) {
    .form-classic.page-fill { height: 100%; }
    .fc-scroll { padding: 0.75rem; }
    .fc-row { flex-direction: column; gap: 0.25rem; }
    .fc-label { flex: none; padding: 0; }
    .fc-row > .fc-control { width: 100%; }
    .fc-steps { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
    .fc-step { white-space: nowrap; }
    fieldset.fc-row > .fc-label { float: none; width: auto; display: block; margin-bottom: 0.25rem; }
    fieldset.fc-row > .fc-control { margin-left: 0; }
    .fc-actions { margin-left: 0; width: 100%; }
    .fc-actions .btn { flex: 1 1 0; }
}

/* Form list, v2 style (#164): category chips beside the search, larger tiles with an icon and what each form becomes. */
.forms-page { max-width: 72rem; gap: 1.25rem; }
.forms-head h1 { font-size: 1.875rem; line-height: 1.15; }
.forms-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; }
.forms-search { position: relative; flex: 0 1 22rem; display: flex; align-items: center; }
.forms-search .icon { position: absolute; left: 0.875rem; color: var(--color-text-secondary); pointer-events: none; }
.forms-search input[type="search"] {
    width: 100%; height: 44px; padding: 0 0.875rem 0 2.5rem; font-size: 0.9375rem; border-radius: 0.625rem;
    background: var(--field-fill); border-color: var(--color-border); border-bottom-color: var(--field-edge);
}
.forms-search input[type="search"]:focus { background: var(--color-surface); }
.forms-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.forms-chips label { position: relative; display: inline-flex; cursor: pointer; }
.forms-chips input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.forms-chips span {
    display: inline-flex; align-items: center; height: 36px; padding: 0 0.875rem; border-radius: 99px; border: 1px solid var(--color-border);
    background: var(--color-surface); font-size: 0.875rem; color: var(--color-text-soft);
    transition: background var(--motion-fast) ease, border-color var(--motion-fast) ease, color var(--motion-fast) ease;
}
.forms-chips label:hover span { border-color: var(--color-text-muted); }
.forms-chips input:checked + span { background: var(--color-brand-tint); border-color: var(--color-brand); color: var(--color-brand); font-weight: 600; }
.forms-chips input:focus-visible + span { box-shadow: var(--focus-ring); }

.form-group { display: flex; flex-direction: column; gap: 0.75rem; }
.form-group > h2 { margin: 0; display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; font-weight: 500; }
.form-group-count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.375rem; padding: 0 0.375rem; border-radius: 99px; background: var(--neutral-bg); color: var(--neutral-fg); font-size: 0.75rem; font-weight: 600; }
.form-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 0.875rem; }
.form-tile {
    height: 100%; display: flex; align-items: flex-start; gap: 0.875rem; padding: 1.125rem 1.25rem; text-decoration: none; color: var(--color-text-primary);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-large); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.form-tile:hover { border-color: var(--color-brand-teal); box-shadow: var(--shadow-card-hover); color: var(--color-text-primary); }
.form-tile:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--color-brand-teal); }
.form-tile-icon { flex: 0 0 40px; height: 40px; border-radius: 0.625rem; display: inline-flex; align-items: center; justify-content: center; background: var(--color-teal-tint); color: var(--color-brand); }
.form-tile-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.form-tile-name { font-weight: 600; font-size: 1rem; }
.form-tile-description { font-size: 0.875rem; color: var(--color-text-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.form-tile-type { margin-top: 0.25rem; font-size: 0.75rem; color: var(--color-text-secondary); }
.form-tile-go { flex: none; align-self: center; color: var(--color-text-muted); transition: transform var(--motion-fast) ease, color var(--motion-fast) ease; }
.form-tile:hover .form-tile-go { color: var(--color-brand); transform: translateX(2px); }
@media (prefers-reduced-motion: reduce) { .form-tile, .form-tile-go, .forms-chips span { transition: none; } }
@media (max-width: 760px) { .forms-search { flex-basis: 100%; } .form-tiles { grid-template-columns: minmax(0, 1fr); } }
