/* DM Sans, served locally so the app works offline and under the strict CSP. */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("/fonts/dm-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url("/fonts/dm-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  --bg: #f8f8f8;
  --surface: #ffffff;
  --surface-muted: #f3f3f3;
  --surface-hover: #f1f1f1;
  --ink: #222222;
  --text: #333333;
  --text-2: #555555;
  --text-3: #6b6b6b;
  --border: #cccccc;
  --border-soft: #e5e7eb;
  --button: #e5e7eb;
  --button-hover: #d1d5db;

  --success: #17603a;
  --success-bg: #eaf6ee;
  --success-border: #bfdeca;
  --warning: #6b4300;
  --warning-bg: #fff6e5;
  --warning-border: #f0d7a8;
  --danger: #8f1d17;
  --danger-bg: #fdecea;
  --danger-border: #f3c2bd;
  --info-bg: #f3f3f3;
  --info-border: #e0e0e0;

  --focus: #222222;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-pill: 9999px;
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 24px;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
dt,
ol,
ul,
figure {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

img,
svg {
  display: block;
}

::selection {
  background: #dedede;
  color: var(--ink);
}

:where(a, button, input, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

.icon {
  flex: 0 0 auto;
}

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

.skip-link {
  position: absolute;
  top: -64px;
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  background: var(--ink);
  color: #ffffff;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-1);
}

.connection-banner {
  position: fixed;
  inset: 0 0 auto;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 14px;
  line-height: 24px;
}

/* ---------- Typography ---------- */

.page-title {
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.page-subtitle {
  max-width: 720px;
  margin-top: var(--space-1);
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

.section-title {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.section-subtitle {
  margin-top: var(--space-1);
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

.page-note {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 40px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 24px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button-large {
  height: 48px;
  padding: 0 var(--space-3);
  font-size: 16px;
}

.button-full {
  width: 100%;
}

.button-primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.button-primary:hover:not(:disabled) {
  border-color: #000000;
  background: #000000;
}

.button-secondary {
  border-color: var(--button);
  background: var(--button);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--button-hover);
  background: var(--button-hover);
}

.button-quiet {
  border-color: var(--border-soft);
  background: transparent;
  color: var(--text);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-muted);
}

.button-small {
  height: 40px;
  padding: 0 var(--space-2);
}

.button:disabled {
  border-color: var(--button);
  background: var(--button);
  color: #777777;
  cursor: not-allowed;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-2);
}

.icon-button:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--ink);
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-link:hover {
  color: #000000;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field-label {
  color: var(--text);
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
}

.field-hint {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 24px;
}

.input:hover {
  border-color: #b3b3b3;
}

.input:focus {
  border-color: var(--ink);
  outline: 2px solid var(--ink);
  outline-offset: 0;
}

.input:disabled {
  background: var(--surface-muted);
  color: var(--text-3);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.form-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.form-note .icon {
  margin-top: 0;
}

.form-error-host {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-error-host:empty {
  display: none;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 1440px;
  min-height: 64px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-wordmark {
  font-size: 24px;
  line-height: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-context {
  color: var(--text-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-2);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.nav-link.is-active {
  background: var(--surface-hover);
  color: var(--ink);
  font-weight: 600;
}

.header-side {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.steps {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  list-style: none;
  color: var(--text-3);
  font-size: 14px;
  line-height: 24px;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.step-number {
  color: #9a9a9a;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.step.is-current {
  color: var(--ink);
  font-weight: 600;
}

.step.is-current .step-number {
  color: var(--ink);
}

.step.is-done .step-number {
  color: var(--text-2);
}

.step:not(:last-child)::after {
  content: "/";
  margin-left: var(--space-1);
  color: #c4c4c4;
  font-weight: 400;
}

.user-block {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-left: var(--space-2);
  border-left: 1px solid var(--border-soft);
}

.user-name {
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
}

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

.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 1440px;
  min-height: calc(100vh - 128px);
  margin: 0 auto;
  padding: var(--space-4);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.page-head-text {
  min-width: 0;
}

.page-head-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.card {
  padding: var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

/* ---------- Auth ---------- */

.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 100vh;
  padding: var(--space-4) var(--space-2);
}

.auth-brand {
  display: flex;
  justify-content: center;
}

.auth-brand .brand {
  align-items: center;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 480px;
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.auth-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ink);
}

.auth-title {
  color: var(--ink);
  font-size: 32px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.auth-help {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.auth-footer {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 24px;
}

.alert-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.alert-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.alert-info {
  border-color: var(--info-border);
  background: var(--info-bg);
  color: var(--text);
}

.alert-icon {
  flex: 0 0 auto;
}

.alert-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.alert-title {
  font-weight: 600;
}

.alert-message {
  font-size: 14px;
  line-height: 24px;
}

.status-alerts {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* ---------- Status ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-1);
  border: 1px solid;
  border-radius: var(--radius-pill);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  white-space: nowrap;
}

.status-icon {
  display: inline-flex;
}

.status-neutral {
  border-color: var(--border-soft);
  background: var(--surface-muted);
  color: var(--text);
}

.status-success {
  border-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success);
}

.status-warning {
  border-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning);
}

.status-danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.status-active[data-status="starting"] .status-icon svg,
.status-active[data-status="running"] .status-icon svg {
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-flex;
  animation: spin 1s linear infinite;
}

/* ---------- Table ---------- */

.table-card {
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
  max-height: 70vh;
}

.data-table {
  width: 100%;
  min-width: 880px;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table caption {
  text-align: left;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 48px;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.data-table tbody th,
.data-table tbody td {
  height: 64px;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid #eeeeee;
  vertical-align: middle;
  font-size: 14px;
  line-height: 24px;
  font-weight: 400;
  text-align: left;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.cell-document {
  width: 38%;
  min-width: 280px;
}

.doc-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.doc-link:hover .doc-link-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.doc-link-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-meta {
  display: block;
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.cell-date {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-outcome {
  color: var(--text-2);
}

.cell-outcome-text {
  color: var(--text);
}

.cell-muted {
  color: var(--text-3);
}

.cell-actions {
  width: 96px;
  text-align: right;
}

.data-table tbody td.cell-actions {
  text-align: right;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-2);
}

.empty-state-title {
  color: var(--ink);
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.empty-state-message {
  max-width: 480px;
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

.loading-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
}

.error-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

/* ---------- Upload ---------- */

.upload-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  align-self: flex-start;
  max-width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
}

.connection-note {
  color: var(--text-3);
}

.dropzone {
  position: relative;
  border: 1px dashed #bdbdbd;
  border-radius: var(--radius);
  background: #fafafa;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.dropzone.is-dragover {
  border-color: var(--ink);
  background: var(--surface-muted);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--border-soft);
}

.dropzone-hit {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  width: 100%;
  min-height: 240px;
  padding: var(--space-4);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  text-align: center;
}

.dropzone-hit:hover {
  background: var(--surface-muted);
}

.dropzone-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: var(--space-1);
  border-radius: var(--radius-pill);
  background: #ededed;
  color: var(--ink);
}

.dropzone-title {
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
}

.dropzone-subtitle {
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

.file-host:empty {
  display: none;
}

.file-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg);
}

.file-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
}

.file-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.file-card-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 24px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-meta {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.file-card .button {
  margin-left: auto;
}

/* ---------- Document detail ---------- */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-3);
  font-size: 14px;
  line-height: 24px;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-2);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.breadcrumb-sep {
  color: #c4c4c4;
}

.breadcrumb-current {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-title {
  max-width: 960px;
}

.document-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: var(--space-1);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

.meta-sep {
  color: #c4c4c4;
}

.processing-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.processing-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.processing-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ink);
}

.processing-elapsed {
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
  font-variant-numeric: tabular-nums;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: 0 0 0 var(--space-2);
  border-left: 1px solid var(--border-soft);
  list-style: none;
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--text-2);
  font-size: 12px;
  line-height: 16px;
}

.timeline-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
}

.timeline-success .timeline-dot {
  background: var(--success-bg);
  color: var(--success);
}

.timeline-warning .timeline-dot {
  background: var(--warning-bg);
  color: var(--warning);
}

.timeline-danger .timeline-dot {
  background: var(--danger-bg);
  color: var(--danger);
}

.timeline-label {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
}

.timeline-time {
  display: block;
  font-variant-numeric: tabular-nums;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.supplier-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-2);
}

.metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--bg);
}

.metric-label {
  color: var(--text-2);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

.metric-value {
  color: var(--ink);
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-note {
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.metric-success .metric-value {
  color: var(--success);
}

.metric-warning .metric-value {
  color: var(--warning);
}

.metric-danger .metric-value {
  color: var(--danger);
}

.summary-note {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--warning);
  font-size: 12px;
  line-height: 16px;
}

.inline-details {
  border-top: 1px solid var(--border-soft);
  padding-top: var(--space-2);
}

.inline-details summary {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text);
  font-size: 14px;
  line-height: 24px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.inline-details summary::after {
  content: "+";
  margin-left: var(--space-1);
  color: var(--text-3);
}

.inline-details[open] summary::after {
  content: "−";
}

.warning-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: 0;
  list-style: none;
}

.warning-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
}

.warning-list .icon {
  align-self: center;
  color: var(--warning);
}

.action-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.action-bar .alert {
  flex-basis: 100%;
}

.other-files {
  border-top: 1px solid var(--border-soft);
  padding-top: var(--space-2);
}

.file-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-2);
  padding: 0;
  list-style: none;
}

.file-links li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 14px;
  line-height: 24px;
}

.preview-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.document-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: var(--space-3);
  align-items: start;
}

.document-panel {
  min-width: 0;
}

.pdf-frame,
.result-frame {
  width: 100%;
  height: clamp(480px, 70vh, 800px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.frame-note {
  margin-top: var(--space-1);
  color: var(--text-3);
  font-size: 12px;
  line-height: 16px;
}

.tabs {
  display: none;
  gap: var(--space-1);
}

.tab-button {
  height: 40px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  line-height: 24px;
  font-weight: 600;
}

.tab-button[aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.preview-card {
  display: flex;
  flex-direction: column;
}

.message-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.noscript {
  max-width: 480px;
  margin: var(--space-8) auto;
  padding: var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
}

.noscript h1 {
  margin-bottom: var(--space-1);
  color: var(--ink);
  font-size: 24px;
  line-height: 32px;
}

.noscript p {
  color: var(--text-2);
  font-size: 16px;
  line-height: 24px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1023px) {
  .steps {
    display: none;
  }
}

@media (max-width: 1199px) {
  .document-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tabs {
    display: flex;
  }

  .document-grid .document-panel {
    display: none;
  }

  .document-grid[data-active-tab="pdf"] [data-panel="pdf-panel"],
  .document-grid[data-active-tab="report"] [data-panel="report-panel"] {
    display: block;
  }
}

@media (max-width: 719px) {
  .header-inner {
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
    min-height: 64px;
    padding: var(--space-1) var(--space-2);
  }

  .brand {
    order: 1;
  }

  .brand-context {
    display: none;
  }

  .header-side {
    order: 2;
    margin-left: auto;
  }

  .main-nav {
    order: 3;
    gap: var(--space-1);
    width: 100%;
    margin-left: 0;
  }

  .nav-link {
    padding: 0 var(--space-1);
    font-size: 14px;
  }

  .steps {
    display: none !important;
  }

  .user-name {
    display: none;
  }

  .user-block {
    padding-left: 0;
    border-left: 0;
  }

  .page {
    gap: var(--space-3);
    padding: var(--space-2);
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-2);
  }

  .page-title {
    font-size: 32px;
    line-height: 40px;
  }

  .document-meta {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-1);
  }

  .document-meta .meta-sep {
    display: none;
  }

  .card {
    padding: var(--space-2);
  }

  .upload-card {
    padding: var(--space-2);
  }

  .auth-page {
    padding: var(--space-2);
  }

  .auth-card {
    padding: var(--space-3) var(--space-2);
  }

  .dropzone-hit {
    min-height: 200px;
    padding: var(--space-3) var(--space-2);
  }

  .dropzone-title {
    font-size: 24px;
  }

  .empty-state {
    padding: var(--space-4) var(--space-2);
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    padding: var(--space-1) var(--space-2);
  }

  .action-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .action-bar .button {
    width: 100%;
  }

  .pdf-frame,
  .result-frame {
    height: 60vh;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-2);
  }

  .data-table {
    min-width: 760px;
  }
}

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

@media print {
  .site-header,
  .site-footer,
  .tabs,
  .action-card,
  .skip-link,
  .connection-banner {
    display: none !important;
  }

  .page {
    padding: 0;
  }

  .card {
    box-shadow: none;
    border-color: #cccccc;
  }

  .document-grid {
    display: block;
  }

  .document-panel {
    break-inside: avoid;
    margin-bottom: var(--space-2);
  }
}
