:root {
  /* Surfaces */
  --paper: #f4f6f9; --panel: #ffffff; --control-inset: #f7f8fa; --row-hover: #f8fafc;
  --ink: #0f1b2d; --ink-muted: #5b6676; --ink-subtle: #8a94a3;
  --rule: #e3e7ed; --rule-strong: #cfd6df;
  /* Brand */
  --ledger-accent: #1f4fd1; --accent-strong: #173da6; --accent-soft: #eaf0ff; --accent-ring: rgba(31, 79, 209, .18);
  --sidebar: #0d1726; --sidebar-raised: #172338; --sidebar-ink: #c4ccd8; --sidebar-muted: #7d8899;
  /* Status */
  --status-ready: #15803d; --ready-paper: #ecfdf3; --ready-rule: #bbf0cf;
  --status-warning: #a15c07; --warning-paper: #fff8eb; --warning-rule: #fbe0ac;
  --stamp-danger: #c0262d; --danger-paper: #fef2f2; --danger-rule: #fbcaca;
  --focus: #1f4fd1;
  /* Scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --control-radius: 8px; --panel-radius: 12px; --control-height: 40px;
  --text-small: 12.5px; --text-body: 14px; --text-section: 15.5px; --text-title: 26px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .05);
  --shadow-md: 0 1px 2px rgba(15, 27, 45, .04), 0 4px 16px -4px rgba(15, 27, 45, .08);
  --shadow-lg: 0 24px 48px -16px rgba(15, 27, 45, .22);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: var(--text-body)/1.55 var(--font); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
a { color: var(--ledger-accent); text-decoration: none; font-weight: 550; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
::selection { background: var(--accent-soft); }

/* Buttons */
button, .button { min-height: var(--control-height); padding: var(--s2) var(--s4); border: 1px solid var(--rule-strong); border-radius: var(--control-radius); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13.5px; gap: var(--s2); box-shadow: var(--shadow-sm); transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; white-space: nowrap; }
button:hover, .button:hover { background: var(--control-inset); border-color: var(--ink-subtle); color: var(--ink); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); }
.primary, .button.primary { color: #fff; background: var(--ledger-accent); border-color: var(--ledger-accent); box-shadow: 0 1px 2px rgba(31, 79, 209, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.primary:hover, .button.primary:hover { color: #fff; background: var(--accent-strong); border-color: var(--accent-strong); }
.danger, .button.danger { color: #fff; background: var(--stamp-danger); border-color: var(--stamp-danger); }
.danger:hover, .button.danger:hover { color: #fff; background: #a11f25; border-color: #a11f25; }
.danger-outline { color: var(--stamp-danger); border-color: var(--danger-rule); }
.danger-outline:hover, .button.danger-outline:hover { color: var(--stamp-danger); background: var(--danger-paper); border-color: var(--stamp-danger); }
a.danger-outline:not(.button):not(.row-action) { font-weight: 600; }
.quiet, .button.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-muted); }
.quiet:hover, .button.quiet:hover { background: rgba(15, 27, 45, .05); border-color: transparent; color: var(--ink); }
form[data-upload-form][aria-busy="true"] { cursor: progress; }
form[data-upload-form] :disabled { cursor: not-allowed; opacity: .65; }
.upload-spinner { width: 1em; height: 1em; flex-shrink: 0; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: upload-spin .8s linear infinite; }
@keyframes upload-spin { to { transform: rotate(360deg); } }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: fixed; left: var(--s4); top: -100px; z-index: 30; padding: var(--s2) var(--s4); background: var(--panel); border-radius: var(--control-radius); box-shadow: var(--shadow-lg); }
.skip-link:focus { top: var(--s4); }

/* App shell */
.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); color: var(--sidebar-ink); padding: var(--s5) var(--s3); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s5); border-bottom: 1px solid rgba(255, 255, 255, .07); color: #fff; font-size: var(--text-section); font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.brand-mark { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #3b6cf0, #1f3fae); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 12px -2px rgba(31, 79, 209, .55); }
.brand-mark svg { width: 20px; height: 20px; }
.brand div > span { display: block; color: var(--sidebar-muted); font-size: var(--text-small); font-weight: 500; letter-spacing: 0; margin-top: 2px; }
.role-label { margin: var(--s5) var(--s3) var(--s2); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-muted); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav > a, .sidebar nav > span { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); min-height: var(--control-height); color: var(--sidebar-ink); font-weight: 500; text-decoration: none; border-radius: var(--control-radius); transition: background-color .15s, color .15s; }
.sidebar nav svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.sidebar nav > a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar nav > [aria-current] { position: relative; background: var(--sidebar-raised); color: #fff; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.sidebar nav > [aria-current] svg { opacity: 1; color: #8eabff; }
.sidebar nav > [aria-current]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #6d8fff; }
.sidebar nav > span { color: var(--sidebar-muted); cursor: default; }
.sidebar nav > span > span { display: block; line-height: 1.3; }
.sidebar small { display: block; font-size: 11.5px; color: #5d6879; }
.session-info { margin-top: auto; padding: var(--s3); border-radius: var(--control-radius); background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06); display: flex; align-items: center; gap: var(--s3); overflow-wrap: anywhere; }
.session-info > span:not(.avatar) { flex: 1; min-width: 0; color: #fff; font-weight: 600; line-height: 1.3; }
.session-info small { color: var(--sidebar-muted); font-weight: 500; }
.avatar { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #34507f, #23365a); color: #dbe4ff; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.session-info form { margin: 0; }
.session-info .quiet { min-height: 34px; padding: var(--s1) var(--s2); color: var(--sidebar-ink); }
.session-info .quiet:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.session-info .quiet svg { width: 18px; height: 18px; }
main { min-width: 0; padding: var(--s6) clamp(var(--s4), 3vw, 44px) 56px; max-width: 1480px; width: 100%; }
main:focus { outline: none; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); color: var(--ink-subtle); font-size: var(--text-small); font-weight: 500; margin-bottom: var(--s4); }
.breadcrumb a { color: var(--ink-muted); font-weight: 500; }
.breadcrumb > span:last-child { color: var(--ink); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: var(--s4); margin-bottom: var(--s6); padding-bottom: var(--s5); border-bottom: 1px solid var(--rule); }
.page-header > div:first-child { min-width: 0; flex: 1 1 320px; }
h1, h2, p { margin: 0; }
h1 { font-size: var(--text-title); font-weight: 700; line-height: 1.2; letter-spacing: -.022em; }
h2 { font-size: var(--text-section); font-weight: 650; letter-spacing: -.01em; }
.page-header p { margin-top: var(--s2); color: var(--ink-muted); font-size: 14.5px; }
.page-header .actions, .page-header > .button, .page-header > button { flex-shrink: 0; }

/* Text helpers */
.metadata, .cell-meta, .field-hint { font-size: var(--text-small); color: var(--ink-muted); }
.cell-meta { display: block; margin-top: 2px; }
.code { font-weight: 650; letter-spacing: .01em; font-feature-settings: "tnum", "zero"; }
td.code a { font-weight: 650; }
.file-tab { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.file-tab .code { display: inline-block; padding: 2px var(--s2); border: 1px solid #d3defc; border-radius: 6px; background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; }

/* Panels and ledgers */
.panel, .ledger { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--panel-radius); box-shadow: var(--shadow-md); margin-bottom: var(--s6); }
.panel { padding: var(--s5) var(--s6); }
.panel > h2:first-child, .panel > .section-header:first-child { margin-bottom: var(--s2); }
fieldset.panel { box-shadow: none; background: var(--control-inset); margin: var(--s4) 0; padding: var(--s4) var(--s5) var(--s2); }
fieldset.panel legend { padding: 0 var(--s2); font-weight: 650; }
.ledger { overflow: hidden; }
.ledger-heading, .section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); }
.ledger-heading { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--rule); }
.ledger-heading > h2 { margin-right: auto; }
.ledger-heading > .metadata { order: 0; padding: 2px var(--s2); border-radius: 999px; background: var(--control-inset); border: 1px solid var(--rule); font-weight: 600; }
.ledger-heading > button, .ledger-heading > .button { min-height: 34px; padding: var(--s1) var(--s3); }
.table-scroll { overflow: auto; max-height: 68vh; }
.candidate-table { position: relative; }
.table-scroll:focus-visible { outline-offset: -2px; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: #f9fafb; color: var(--ink-muted); font-size: 11.5px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
th, td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); vertical-align: middle; }
th:first-child, td:first-child { padding-left: var(--s5); }
th:last-child, td:last-child { padding-right: var(--s5); }
td { min-width: 120px; }
td:nth-child(2) { min-width: 240px; max-width: 500px; overflow-wrap: anywhere; }
td:has(> input[type="checkbox"]:only-child), td:has(> input[type="checkbox"] + label.visually-hidden) { min-width: 0; width: 48px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:has(input[type="checkbox"]:checked) { background: #f3f6ff; }
.row-action { display: inline-flex; min-height: 32px; align-items: center; gap: var(--s1); padding: 0 var(--s2); margin-left: calc(var(--s2) * -1); border-radius: 6px; white-space: nowrap; font-weight: 600; }
.row-action:hover { background: var(--accent-soft); text-decoration: none; }
.row-action.danger-outline { border: 0; }
.row-action.danger-outline:hover { background: var(--danger-paper); }
.status + .row-action { margin-left: var(--s2); }

/* Status pills */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border: 1px solid; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; vertical-align: middle; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ready { color: var(--status-ready); background: var(--ready-paper); border-color: var(--ready-rule); }
.locked { color: var(--stamp-danger); background: var(--danger-paper); border-color: var(--danger-rule); }
.warning-text { color: var(--status-warning); font-weight: 600; }
.status.warning-text { background: var(--warning-paper); border-color: var(--warning-rule); }

/* Empty states */
.empty-state { padding: 48px var(--s6); text-align: center; }
.empty-state h2, .empty-state strong { display: block; font-size: var(--text-section); }
.empty-state p { margin: var(--s2) auto var(--s4); color: var(--ink-muted); max-width: 48ch; }
td.empty-state, td:has(> .empty-state) { background: var(--panel); }
tbody tr:hover:has(.empty-state) { background: transparent; }

/* Forms */
.search-toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 28px var(--s3); margin-bottom: var(--s5); padding: var(--s4) var(--s5); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--panel-radius); box-shadow: var(--shadow-sm); }
.search-toolbar.panel { box-shadow: var(--shadow-sm); }
.search-toolbar .field { width: min(100%, 300px); margin: 0; }
.search-toolbar .field:first-child { width: min(100%, 380px); }
.search-toolbar .field-hint { position: absolute; }
.search-toolbar .field:has(.field-hint) { position: relative; }
.search-toolbar .field:has(.field-hint) .field-hint { top: 100%; left: 0; white-space: nowrap; }
.search-toolbar .inline-check { align-self: flex-end; }
.field { margin-bottom: var(--s4); min-width: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.required { font-size: 11.5px; font-weight: 500; color: var(--ink-subtle); }
.field input, .field textarea, .field select { width: 100%; min-height: var(--control-height); border: 1px solid var(--rule-strong); border-radius: var(--control-radius); padding: var(--s2) var(--s3); background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.field textarea { resize: vertical; }
.field select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:hover, .field textarea:hover, .field select:hover { border-color: var(--ink-subtle); }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--ledger-accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.field input::placeholder { color: var(--ink-subtle); }
.field input[aria-invalid], .field select[aria-invalid], .field textarea[aria-invalid] { border-color: var(--stamp-danger); background: #fffafa; }
.field input[aria-invalid]:focus, .field select[aria-invalid]:focus, .field textarea[aria-invalid]:focus { box-shadow: 0 0 0 4px rgba(192, 38, 45, .15); }
.field input[type="file"] { padding: 6px; background: var(--control-inset); border-style: dashed; cursor: pointer; }
.field input[type="file"]::file-selector-button { margin-right: var(--s3); padding: 6px var(--s3); border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.field-hint, .field-error { margin-top: 6px; }
.field-error { color: var(--stamp-danger); font-size: var(--text-small); font-weight: 550; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ledger-accent); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s6); margin-top: var(--s4); }
.span-full { grid-column: 1 / -1; }
.section-heading { border-top: 1px solid var(--rule); padding-top: var(--s5); margin-top: var(--s2); }
.form-footer, .actions, .pagination { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2); }
.form-footer { margin-top: var(--s4); }
.pagination { justify-content: space-between; color: var(--ink-muted); font-size: 13px; margin-bottom: var(--s6); }
.pagination > div { display: flex; gap: var(--s2); }
.record-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4) var(--s6); margin: var(--s4) 0; }
.record-details > div { padding-left: var(--s3); border-left: 2px solid var(--rule); }
.record-details dt { font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-subtle); }
.record-details dd { margin: var(--s1) 0 0; font-weight: 550; overflow-wrap: anywhere; }
.access-panel p, .confirmation p { margin: var(--s3) 0; color: var(--ink-muted); }
.confirmation { max-width: 760px; }
.confirm-check { display: flex; gap: var(--s3); align-items: center; margin: var(--s4) 0; min-height: var(--control-height); padding: var(--s2) var(--s3); border: 1px solid var(--rule); border-radius: var(--control-radius); background: var(--control-inset); }
.confirm-check input { width: 18px; height: 18px; flex-shrink: 0; }
.confirm-check label { padding: var(--s1) 0; font-weight: 550; cursor: pointer; }

/* Feedback */
.flash, .error-summary { display: flex; flex-direction: column; padding: var(--s3) var(--s4); margin-bottom: var(--s5); border: 1px solid; border-left-width: 4px; border-radius: var(--control-radius); font-weight: 550; }
.flash { background: var(--ready-paper); border-color: var(--ready-rule); border-left-color: var(--status-ready); color: #12612f; }
.error-summary { background: var(--danger-paper); border-color: var(--danger-rule); border-left-color: var(--stamp-danger); color: #9b1c22; }
.error-summary a { color: inherit; text-decoration: underline; }
.error-summary ul { padding-left: var(--s5); margin: var(--s2) 0 0; font-weight: 500; }
.note { color: var(--ink-muted); max-width: 80ch; margin: var(--s4) 0; }
.preview-details { padding: 0 var(--s5) var(--s5); }
.preview-summary { padding: var(--s3) var(--s5); color: var(--ink-muted); background: var(--control-inset); border-bottom: 1px solid var(--rule); }
.issue-list { margin: var(--s3) 0 0; padding-left: var(--s6); }
.issue-list li + li { margin-top: var(--s1); }
details > summary { cursor: pointer; font-weight: 600; padding: var(--s2) 0; }

/* Choices */
.choice-group { border: 0; padding: 0; margin: 0; }
.choice-group legend { font-weight: 650; margin-bottom: var(--s2); }
.choice-group label { display: flex; align-items: flex-start; gap: var(--s3); min-height: var(--control-height); padding: var(--s3); border: 1px solid var(--rule); border-radius: var(--control-radius); margin-bottom: var(--s2); cursor: pointer; transition: border-color .15s, background-color .15s; }
.choice-group label:hover { border-color: var(--rule-strong); background: var(--control-inset); }
.choice-group label:has(input:checked) { border-color: var(--ledger-accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--ledger-accent); }
.choice-group input { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.choice-group small { display: block; color: var(--ink-muted); margin-top: 2px; }
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--s2); }
.class-grid label { margin: 0; align-items: center; justify-content: flex-start; font-weight: 600; }
.inline-check { display: flex; align-items: center; gap: var(--s2); min-height: var(--control-height); padding: var(--s2) 0; }
.inline-check input { width: 18px; height: 18px; }
.inline-check label { cursor: pointer; font-weight: 500; }

/* Photo editor */
.photo-status-strip { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--s4); padding: var(--s3) var(--s5); margin-bottom: var(--s5); background: var(--panel); border: 1px solid var(--rule); border-left: 4px solid var(--ledger-accent); border-radius: var(--control-radius); box-shadow: var(--shadow-sm); }
.photo-editor-grid { display: grid; grid-template-columns: minmax(360px, 1.15fr) minmax(360px, .85fr); gap: var(--s5); align-items: start; }
.portrait-workbench { min-width: 0; }
.portrait-stage { position: relative; width: min(100%, 354px); aspect-ratio: 3 / 4; margin: var(--s4) auto; overflow: hidden; border-radius: var(--control-radius); border: 1px solid var(--rule-strong); touch-action: none; background-color: #eef1f5; background-image: linear-gradient(45deg, #e3e7ed 25%, transparent 25%, transparent 75%, #e3e7ed 75%), linear-gradient(45deg, #e3e7ed 25%, transparent 25%, transparent 75%, #e3e7ed 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.portrait-stage > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.portrait-stage canvas { display: none; width: 100%; height: 100%; cursor: move; }
.portrait-stage.canvas-ready > img { display: none; }
.portrait-stage.canvas-ready canvas { display: block; }
.crop-frame { position: absolute; inset: var(--s2); border: 2px solid #fff; border-radius: 4px; box-shadow: 0 0 0 1px rgba(15, 27, 45, .6), 0 0 0 999px rgba(15, 27, 45, .12); pointer-events: none; }
.quality-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin: var(--s4) 0 0; }
.quality-metrics div { padding: var(--s3); border: 1px solid var(--rule); border-radius: var(--control-radius); background: var(--control-inset); }
.quality-metrics dt { color: var(--ink-muted); font-size: var(--text-small); }
.quality-metrics dd { margin: 2px 0 0; font-size: 16px; font-weight: 700; }
.crop-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s3); margin-top: var(--s4); }
.face-choices { margin-top: var(--s4); }
.blocker-panel { border-color: var(--danger-rule); box-shadow: inset 4px 0 0 var(--stamp-danger), var(--shadow-md); }
.ready-panel { border-color: var(--ready-rule); box-shadow: inset 4px 0 0 var(--status-ready), var(--shadow-md); }
.ledger input[type="checkbox"] { width: 18px; height: 18px; }
.field input[type="range"] { padding: 0; border: 0; box-shadow: none; background: transparent; accent-color: var(--ledger-accent); }
.field input[type="range"]:focus { box-shadow: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); margin-bottom: var(--s6); }
.module-card { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s5); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--panel-radius); box-shadow: var(--shadow-md); color: var(--ink); font-weight: 400; transition: border-color .15s, box-shadow .15s, transform .15s; }
a.module-card:hover { color: var(--ink); text-decoration: none; border-color: #c7d4f7; box-shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 12px 28px -10px rgba(31, 79, 209, .28); transform: translateY(-2px); }
.module-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--ledger-accent); }
.module-icon svg { width: 20px; height: 20px; }
.module-card strong { font-size: 15px; font-weight: 650; }
.module-card p { color: var(--ink-muted); font-size: 13px; }
.module-card .module-link { margin-top: auto; padding-top: var(--s2); color: var(--ledger-accent); font-size: 13px; font-weight: 600; }

/* Auth pages */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.1fr); background: var(--panel); }
.auth-aside { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: var(--s8); padding: 48px; color: #e6ebf5; background: radial-gradient(120% 80% at 0% 0%, #22408f 0%, transparent 55%), radial-gradient(90% 70% at 100% 100%, #133a6b 0%, transparent 60%), var(--sidebar); }
.auth-aside::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px); background-size: 40px 40px; mask-image: linear-gradient(180deg, #000 0%, transparent 85%); pointer-events: none; }
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .brand { border: 0; padding: 0; font-size: 17px; }
.auth-aside h2 { font-size: clamp(26px, 2.6vw, 36px); line-height: 1.15; font-weight: 700; letter-spacing: -.03em; color: #fff; max-width: 16ch; }
.auth-aside p { margin-top: var(--s4); color: #a9b4c7; max-width: 44ch; font-size: 15px; }
.auth-features { list-style: none; display: grid; gap: var(--s3); margin: var(--s6) 0 0; padding: 0; }
.auth-features li { display: flex; align-items: center; gap: var(--s3); color: #d2d9e6; }
.auth-features svg { width: 18px; height: 18px; flex-shrink: 0; color: #7f9cff; }
.auth-aside footer { color: #6f7b90; font-size: var(--text-small); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px var(--s6); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.auth-card h1 { font-size: 28px; }
.auth-card .lead { margin-top: var(--s2); color: var(--ink-muted); }
.auth-card form { margin-top: var(--s6); }
.auth-card .form-grid { margin-top: 0; gap: 0 var(--s4); }
.auth-card button[type="submit"] { width: 100%; min-height: 44px; margin-top: var(--s2); }
.auth-alt { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--rule); color: var(--ink-muted); text-align: center; }
.auth-success { display: flex; gap: var(--s3); align-items: flex-start; margin-top: var(--s6); padding: var(--s4); border: 1px solid var(--ready-rule); border-radius: var(--control-radius); background: var(--ready-paper); color: #12612f; font-weight: 550; }
.auth-success svg { width: 20px; height: 20px; flex-shrink: 0; }
.auth-card .error-summary { margin: var(--s5) 0 0; }

@media (max-width: 1100px) {
  .photo-editor-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: static; height: auto; padding: var(--s3) var(--s4); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s2); }
  .brand { padding: 0; border: 0; }
  .brand div > span, .role-label { display: none; }
  .sidebar nav { grid-column: 1 / -1; grid-row: 2; display: flex; overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4) var(--s1); scrollbar-width: none; }
  .sidebar nav > a, .sidebar nav > span { flex-shrink: 0; }
  .sidebar nav > span small { display: none; }
  .sidebar nav > [aria-current]::before { display: none; }
  .session-info { grid-column: 2; grid-row: 1; margin: 0; padding: var(--s1); background: transparent; border: 0; }
  .session-info > span:not(.avatar) { display: none; }
  main { padding: var(--s5) var(--s4) 48px; }
  .auth-body { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: var(--s6); gap: var(--s4); }
  .auth-aside h2, .auth-aside p, .auth-features, .auth-aside footer { display: none; }
  .auth-main { align-items: flex-start; padding: var(--s8) var(--s4); }
}
@media (max-width: 560px) {
  .page-header { align-items: flex-start; }
  .panel { padding: var(--s4); }
  .form-grid, .record-details { grid-template-columns: minmax(0, 1fr); }
  .span-full { grid-column: auto; }
  .crop-fields, .quality-metrics { grid-template-columns: minmax(0, 1fr); }
  .search-toolbar .field, .search-toolbar .field:first-child { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
@media (prefers-reduced-motion: reduce) { .upload-spinner { animation: none; } }
