:root {
  --canvas: oklch(94.9% 0.008 90);
  --surface: oklch(99.1% 0.003 90);
  --paper: oklch(96.7% 0.006 90);
  --text: oklch(21.6% 0.008 248);
  --text-hover: oklch(32.2% 0.012 248);
  --muted: oklch(47.4% 0.015 244);
  --neutral: oklch(54% 0.019 245);
  --border: oklch(88.4% 0.006 248);
  --border-dark: oklch(27.5% 0.01 248);
  --primary: oklch(46% 0.12 240);
  --primary-hover: oklch(40% 0.11 240);
  --primary-pale: oklch(95% 0.012 232);
  --danger: oklch(50.5% 0.146 28);
  --danger-pale: oklch(95.3% 0.019 26);
  --info: oklch(40% 0.11 240);
  --warning: oklch(50.8% 0.108 73);
  --success: oklch(47% 0.105 250);
  --success-pale: oklch(95.3% 0.012 252);
  --radius: 2px;
  --font-body: "Segoe UI Variable", "Inter", Arial, sans-serif;
  --font-display: "Arial Narrow", "Roboto Condensed", "Segoe UI Variable", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--text); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); font-family: var(--font-body); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { touch-action: manipulation; }
a { color: var(--primary-hover); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .ca-table-scroll:focus-visible { outline: 3px solid oklch(56% 0.18 240); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; min-height: 44px; padding: 10px 14px; color: var(--surface); background: var(--text); transform: translateY(-180%); }
.skip-link:focus { transform: none; }
.blueprint-grid { background-image: linear-gradient(oklch(46% 0.12 240 / .055) 1px, transparent 1px), linear-gradient(90deg, oklch(46% 0.12 240 / .055) 1px, transparent 1px); background-size: 32px 32px; }

.site-header { min-height: 76px; background: color-mix(in oklch, var(--surface) 94%, transparent); border-bottom: 1px solid var(--border); }
.site-header__inner { width: min(1240px, calc(100% - 64px)); min-height: 76px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 720; letter-spacing: 0; text-decoration: none; }
.brand__name { font-size: 20px; }
.brand__mark { width: 30px; height: 30px; display: grid; flex: 0 0 30px; grid-template-columns: 1fr 1fr; gap: 3px; transform: rotate(-2deg); }
.brand__mark span { display: block; background: var(--primary); }
.brand__mark span:first-child { grid-row: span 2; }
.brand__mark span:nth-child(2) { background: var(--text); }
.brand__mark span:nth-child(3) { background: transparent; border: 2px solid var(--primary); }
.header-actions { display: flex; align-items: center; gap: 20px; }
.header-action { flex: none; }

.page-shell { width: min(1120px, calc(100% - 64px)); margin: 0 auto; padding: 56px 0 80px; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { text-wrap: balance; }
h1 { max-width: 760px; margin-bottom: 18px; font-family: var(--font-display); font-size: clamp(40px, 5vw, 60px); font-weight: 700; letter-spacing: 0; line-height: 1.02; }
h2 { font-family: var(--font-display); font-size: 26px; letter-spacing: 0; line-height: 1.15; }
h3 { font-size: 19px; letter-spacing: 0; line-height: 1.3; }
.eyebrow { margin-bottom: 12px; color: var(--primary); font-family: var(--font-mono); font-size: 11px; font-weight: 750; letter-spacing: 0; text-transform: uppercase; }

.auth-visual { display: none; }
body[data-auth-flow] { background: var(--surface); }
body[data-auth-flow] .site-header { position: fixed; z-index: 20; inset: 0 0 auto; }
body[data-auth-flow] .auth-visual { position: fixed; inset: 76px 46% 0 0; padding: clamp(54px, 7vw, 100px) clamp(32px, 6vw, 90px); display: flex; flex-direction: column; justify-content: center; background-color: var(--paper); border-right: 1px solid var(--border); }
.auth-visual > p { color: var(--primary); font-family: var(--font-mono); font-size: 11px; font-weight: 750; letter-spacing: 0; text-transform: uppercase; }
.auth-visual > strong { max-width: 680px; font-family: var(--font-display); font-size: clamp(38px, 4vw, 64px); letter-spacing: 0; line-height: 1.04; }
.auth-visual ol { max-width: 620px; margin: 48px 0 0; padding: 0; border-top: 1px solid var(--border); list-style: none; counter-reset: auth-step; }
.auth-visual li { padding: 14px 0; display: flex; gap: 20px; border-bottom: 1px solid var(--border); font-weight: 650; counter-increment: auth-step; }
.auth-visual li::before { color: var(--primary); content: "0" counter(auth-step); font-family: var(--font-mono); }
body[data-auth-flow] .page-shell { min-height: 100vh; width: 54%; margin: 0 0 0 46%; padding: 156px clamp(32px, 8vw, 110px) 70px; display: flex; align-items: center; background: var(--surface); }
body[data-auth-flow] .legal-footer { width: 54%; margin-left: 46%; padding-right: clamp(32px, 8vw, 110px); padding-left: clamp(32px, 8vw, 110px); background: var(--surface); }
.auth-flow { width: 100%; max-width: 520px; }
.auth-flow__intro { max-width: 500px; margin-bottom: 34px; color: var(--muted); font-size: 18px; text-wrap: pretty; }
.auth-form { max-width: 480px; }
.auth-flow__switch { margin-top: 24px; color: var(--muted); }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 700; }
.field__hint { margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.field input, .ca-field-grid input, .ca-field-grid select, .ca-workspace > .field input { width: 100%; min-height: 52px; padding: 10px 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border-dark); border-radius: var(--radius); }
.field input[aria-invalid="true"] { border: 2px solid var(--danger); }
.field input[readonly] { color: var(--muted); background: var(--paper); }
.field--code { max-width: 240px; }
.field--code input { font-family: var(--font-mono); font-size: 24px; font-variant-numeric: tabular-nums; }
.form-error { min-height: 24px; margin: 0 0 16px; color: var(--danger); font-weight: 650; }
.form-status { min-height: 24px; margin: 8px 0 0; color: var(--muted); font-weight: 650; }
.form-status--error, .logout-status { color: var(--danger); }
.logout-status { min-height: 24px; margin: 0 0 -24px; font-weight: 650; }
.destination { margin: -18px 0 28px; color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.resend { margin-top: 24px; display: flex; align-items: center; gap: 8px 16px; color: var(--muted); }
.back-link { min-height: 44px; margin-bottom: 18px; padding-top: 8px; display: inline-block; }

.button { min-height: 48px; padding: 12px 18px; border: 1px solid transparent; border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 650; transition: background .18s ease, color .18s ease, border .18s ease, transform .18s ease; }
.button:hover { transform: translateY(-1px); }
.button--primary { color: var(--surface); background: var(--primary); }
.button--primary:hover { background: var(--primary-hover); }
.button--secondary { color: var(--text); background: transparent; border-color: var(--border-dark); }
.button--secondary:hover { background: var(--surface); }
.button:disabled, .button-link:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button-link { min-height: 44px; padding: 8px 0; color: var(--primary-hover); background: transparent; border: 0; text-decoration: underline; cursor: pointer; }

/* Authenticated cabinet: the existing header becomes the prototype's compact rail. */
body[data-page="dashboard"], body[data-page="profile"] { background: var(--canvas); }
body[data-page="dashboard"] .site-header, body[data-page="profile"] .site-header { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 240px; border-right: 1px solid var(--border); border-bottom: 0; }
body[data-page="dashboard"] .site-header__inner, body[data-page="profile"] .site-header__inner { width: 100%; height: 100%; padding: 30px 22px 22px; flex-direction: column; align-items: stretch; }
body[data-page="dashboard"] .header-actions, body[data-page="profile"] .header-actions { margin-top: auto; padding-top: 16px; align-items: stretch; flex-direction: column; border-top: 1px solid var(--border); }
body[data-page="dashboard"] .header-action, body[data-page="profile"] .header-action { width: 100%; justify-content: flex-start; text-align: left; }
body[data-page="dashboard"] .page-shell, body[data-page="profile"] .page-shell { width: auto; margin-left: 240px; padding: 44px clamp(26px, 4vw, 56px) 80px; }
body[data-page="dashboard"] .legal-footer, body[data-page="profile"] .legal-footer { width: auto; margin-left: 240px; padding-right: clamp(26px, 4vw, 56px); padding-left: clamp(26px, 4vw, 56px); }

.dashboard { display: grid; gap: 46px; }
.dashboard__heading { min-height: 150px; margin: -44px clamp(-56px, -4vw, -26px) 0; padding: 34px clamp(26px, 4vw, 56px); display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); align-items: end; gap: 40px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dashboard__heading h1 { margin-bottom: 0; }
.dashboard__heading > p { max-width: 440px; margin-bottom: 4px; color: var(--muted); text-wrap: pretty; }
.dashboard-section { min-width: 0; }
.section-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--text); }
.section-heading h2 { margin-bottom: 10px; }
.section-heading span { color: var(--muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.row-list { background: var(--surface); border-right: 1px solid var(--border); border-left: 1px solid var(--border); }
.access-notice { padding: 22px; background: var(--primary-pale); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); border-left: 4px solid var(--primary); }
.access-notice h3 { margin-bottom: 5px; }
.access-notice p { max-width: 760px; margin-bottom: 0; color: var(--muted); text-wrap: pretty; }
.module-row, .request-row { min-width: 0; min-height: 104px; padding: 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--border); }
.row-main { min-width: 0; }
.row-main h3 { margin-bottom: 5px; overflow-wrap: anywhere; }
.row-main p { margin-bottom: 0; color: var(--muted); overflow-wrap: anywhere; text-wrap: pretty; }
.module-row__actions { flex: none; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; }
.module-row--primary { border-left: 4px solid var(--primary); }
.module-row--secondary { background: var(--paper); }
.file-types { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.file-types span { padding: 4px 7px; color: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-mono); font-size: 12px; }
.status { flex: none; max-width: 210px; padding: 6px 9px; border-radius: var(--radius); font-size: 12px; font-weight: 700; text-align: center; }
.status--draft, .status--action_required, .status--payment_required { color: var(--warning); background: oklch(96.9% 0.036 88); }
.status--under_review, .status--in_progress { color: var(--info); background: var(--primary-pale); }
.status--failed { color: var(--danger); background: var(--danger-pale); }
.status--ready, .status--completed { color: var(--success); background: var(--success-pale); }
.status--closed { color: var(--muted); background: var(--paper); }
.request-meta { font-size: 13px; }

.ca-artifacts { min-width: 0; margin-top: 12px; display: grid; gap: 6px; }
.ca-order-summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.ca-result-summary { min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.ca-result-summary span { white-space: nowrap; }
.ca-order-actions { flex: none; }
.ca-resume-clarification, .ca-resume-order { display: inline-flex; align-items: center; color: var(--primary-hover); font-size: 13px; font-weight: 700; }
.ca-result-action { min-height: 36px; display: flex; align-items: center; }
.ca-result-status { min-height: 21px; margin: 0; color: var(--muted); font-size: 13px; }
.ca-result-action .ca-artifact-download { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.ca-artifact-download__icon { width: 16px; height: 16px; flex: none; }
.ca-intake { scroll-margin-top: 24px; }
.ca-intake > .form-status { margin: 18px 0 -2px; }
.ca-workspace { padding: 30px 24px; background: var(--surface); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); }
.ca-workspace__intro { max-width: 720px; margin-bottom: 24px; }
.ca-workspace__intro h3 { margin-bottom: 6px; }
.ca-workspace__intro p:last-child { margin-bottom: 0; color: var(--muted); }
.ca-field-grid { max-width: 780px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.ca-field-grid .field { min-width: 0; }
.ca-consent { max-width: 780px; margin: 4px 0 20px; padding: 16px; display: flex; align-items: flex-start; gap: 12px; color: var(--muted); background: var(--paper); font-size: 14px; line-height: 1.5; }
.ca-consent input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.ca-consent a { color: var(--primary); }
.ca-workspace__command { margin-top: 8px; padding-top: 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--border); }
.ca-recognition > p:not(.eyebrow) { max-width: 640px; color: var(--muted); }
.ca-recognition__progress { width: min(320px, 100%); height: 4px; margin-top: 24px; background: var(--border); border-left: 96px solid var(--primary); }
.ca-review-list { border-top: 2px solid var(--text); }
.ca-review-row { padding: 18px 0; border-bottom: 1px solid var(--border); }
.ca-review-row--excluded { background: var(--paper); }
.ca-review-row__meta { min-width: 0; margin-bottom: 12px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.ca-review-row__meta strong { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.ca-review-row__meta span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.ca-review-row__meta .ca-review-row__warning { width: 100%; color: var(--danger); font-weight: 650; }
.ca-review-fields { display: grid; grid-template-columns: minmax(220px, 1.7fr) minmax(120px, .55fr) minmax(150px, .65fr); gap: 14px; }
.ca-review-field { min-width: 0; margin-bottom: 0; }
.ca-review-field label { margin-bottom: 5px; color: var(--muted); font-size: 12px; }
.ca-review-field input { width: 100%; min-height: 44px; padding: 8px 10px; color: var(--text); background: var(--surface); border: 1px solid var(--border-dark); border-radius: var(--radius); }
.ca-review-field input[aria-invalid="true"] { border: 2px solid var(--danger); }
.ca-review-field input:disabled { color: var(--muted); background: var(--canvas); }
.ca-review-row__footer { min-height: 44px; margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ca-review-row__status { margin: 0; color: var(--muted); font-size: 13px; }
.ca-review-row__toggle { flex: none; font-weight: 700; }
.ca-manual-position { margin-top: 18px; padding: 18px 0; border-top: 2px solid var(--text); border-bottom: 1px solid var(--border); }
.ca-manual-position h4 { margin: 0 0 14px; }
.ca-manual-position__actions { min-height: 44px; margin-top: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.empty-state { padding: 30px 22px; color: var(--muted); border-bottom: 1px solid var(--border); }
.empty-state h3 { margin-bottom: 6px; color: var(--text); }
.empty-state p { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.legal-footer { width: min(100% - 64px, 1120px); margin: 0 auto; padding: 0 0 28px; }
.legal-footer nav { display: flex; flex-wrap: wrap; gap: 12px 24px; font-size: 13px; }
.legal-footer a { color: var(--muted); }
.legal-page { width: min(100% - 48px, 860px); margin: 0 auto; padding: 72px 0 96px; }
.legal-page header, .legal-page section { margin-bottom: 38px; }
.legal-page h2 { margin-bottom: 12px; }
.legal-page p { max-width: 76ch; }
.legal-page__version { color: var(--muted); font-size: 14px; }

@media (max-width: 820px) {
  body[data-auth-flow] .site-header { position: static; }
  body[data-auth-flow] .auth-visual { display: none; }
  body[data-auth-flow] .page-shell { min-height: calc(100vh - 76px); width: min(100% - 40px, 560px); margin: 0 auto; padding: 64px 0; }
  body[data-auth-flow] .legal-footer { width: min(100% - 40px, 560px); margin: 0 auto; padding-right: 0; padding-left: 0; }
  body[data-page="dashboard"] .site-header, body[data-page="profile"] .site-header { position: static; width: auto; min-height: 64px; border-right: 0; border-bottom: 1px solid var(--border); }
  body[data-page="dashboard"] .site-header__inner, body[data-page="profile"] .site-header__inner { width: min(100% - 32px, 1120px); min-height: 64px; height: auto; padding: 0; flex-direction: row; align-items: center; }
  body[data-page="dashboard"] .header-actions, body[data-page="profile"] .header-actions { margin-top: 0; padding-top: 0; align-items: center; flex-direction: row; border-top: 0; }
  body[data-page="dashboard"] .header-action, body[data-page="profile"] .header-action { width: auto; }
  body[data-page="dashboard"] .page-shell, body[data-page="profile"] .page-shell { width: min(100% - 32px, 1120px); margin: 0 auto; padding: 36px 0 56px; }
  body[data-page="dashboard"] .legal-footer, body[data-page="profile"] .legal-footer { width: min(100% - 32px, 1120px); margin: 0 auto; padding-right: 0; padding-left: 0; }
  .dashboard__heading { min-height: 0; margin: 0; padding: 0 0 28px; grid-template-columns: 1fr; gap: 14px; background: transparent; border-bottom: 0; }
}

@media (max-width: 700px) {
  .site-header__inner, .page-shell { width: min(100% - 32px, 1120px); }
  .legal-footer, .legal-page { width: min(100% - 32px, 860px); }
  .page-shell { padding: 36px 0 52px; }
  h1 { font-size: 36px; }
  .auth-flow__intro { font-size: 17px; }
  .dashboard { gap: 34px; }
  .module-row, .request-row { padding: 18px 16px; align-items: flex-start; flex-direction: column; gap: 14px; }
  .request-row .row-main { width: 100%; }
  .module-row__actions { width: 100%; justify-content: flex-start; }
  .file-types { justify-content: flex-start; }
  .status { max-width: 100%; }
  .ca-order-summary { align-items: flex-start; flex-direction: column; gap: 2px; }
  .ca-order-actions { width: 100%; }
  .ca-resume-clarification, .ca-resume-order { min-height: 44px; }
  .ca-result-action .ca-artifact-download { width: 100%; min-height: 44px; }
  .ca-field-grid { grid-template-columns: 1fr; }
  .ca-workspace { padding: 22px 16px; }
  .ca-review-list { border-top: 0; }
  .ca-review-row { margin-bottom: 12px; padding: 16px; border: 1px solid var(--border); }
  .ca-review-fields { grid-template-columns: 1fr; gap: 12px; }
  .ca-review-row__footer { align-items: flex-start; flex-direction: column; gap: 0; }
  .ca-review-row__toggle { min-height: 44px; }
  .ca-workspace__command .button { width: 100%; }
  .resend { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (max-width: 420px) {
  .site-header__inner { width: calc(100% - 24px); }
  .brand__name { font-size: 18px; }
  .header-actions { gap: 12px; }
  h1 { font-size: 32px; }
  .button--primary { width: 100%; }
}

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