:root {
  --workspace-width: 1120px;
  --workspace-wide-width: 1440px;
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #fafbfc;
  --border: #ececf1;
  --border-strong: #dcdde5;
  --text: #1c1c1c;
  --text-muted: #5c5c70;
  --orange: #fd7801;
  --orange-dark: #e76900;
  --orange-soft: #fff3e8;
  --navy: #102a43;
  --navy-dark: #0a2035;
  --navy-soft: #edf3f8;
  --success: #237a4b;
  --success-soft: #eaf7f0;
  --attention: #8a5a00;
  --attention-soft: #fff5d8;
  --mismatch-fg: var(--attention);
  --danger: #b42318;
  --danger-soft: #fef0ef;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 8px 26px rgba(16, 42, 67, 0.06);
  --shadow-raised: 0 16px 38px rgba(16, 42, 67, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 24px 56px;
}

/* Shared engineering workspace: ordinary content and wider working tables. */
.shell--workspace { width: min(var(--workspace-width), 100%); }
.shell--workspace-wide { width: min(var(--workspace-wide-width), 100%); }
.work-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.work-heading h1, .work-heading h2 { margin: 0; }
.work-heading h1 { font-size: clamp(1.7rem, 3vw, 2.1rem); }
.work-heading .btn-primary { gap: 7px; flex-shrink: 0; box-shadow: none; }
.work-switcher { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-soft); }
.work-switcher a { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 7px 12px; border-radius: 7px; color: var(--text-muted); text-decoration: none; font-size: .85rem; font-weight: 600; }
.work-switcher a:hover { color: var(--navy); background: var(--navy-soft); }
.work-switcher a[aria-current=page] { color: var(--navy); background: var(--surface); box-shadow: 0 1px 3px rgb(16 42 67 / 12%); }
.work-area { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); }
.work-toolbar { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.table-scroll { position: relative; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.icon-button { position: relative; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; min-height: 42px; padding: 9px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); cursor: pointer; text-decoration: none; }
.icon-button:hover { background: var(--surface-soft); border-color: var(--border-strong); color: var(--navy); }
.icon-button:disabled { opacity: .5; cursor: wait; }
.icon-button[data-tooltip]::after { content: attr(data-tooltip); position: absolute; z-index: 20; right: 0; bottom: calc(100% + 6px); width: max-content; max-width: min(240px, 80vw); padding: 6px 9px; border-radius: 6px; background: var(--navy); color: white; font-size: .78rem; font-weight: 500; line-height: 1.4; pointer-events: none; visibility: hidden; opacity: 0; }
.icon-button[data-tooltip]:hover::after, .icon-button[data-tooltip]:focus-visible::after { visibility: visible; opacity: 1; }
.work-dialog { width: min(540px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius); color: var(--text); background: var(--surface); box-shadow: var(--shadow-raised); }
.work-dialog::backdrop { background: rgb(16 42 67 / 40%); }
.work-drawer { position: fixed; inset: 0 0 0 auto; width: min(640px, 100%); height: 100dvh; max-height: 100dvh; max-width: 100%; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--border-strong); color: var(--text); background: var(--surface); box-shadow: var(--shadow-raised); overflow: hidden; }
.work-drawer[open] { display: flex; flex-direction: column; }
.work-drawer::backdrop { background: rgb(16 42 67 / 25%); }
.drawer-heading { display: flex; flex-shrink: 0; align-items: flex-start; gap: 12px; justify-content: space-between; padding: 22px 24px 16px; max-height: 40dvh; overflow-y: auto; }
.drawer-heading > div { min-width: 0; }
.drawer-heading h2 { font-size: 1.2rem; line-height: 1.4; margin: 3px 0 0; overflow-wrap: anywhere; }
.drawer-eyebrow { margin: 0; font-size: .78rem; color: var(--text-muted); }
.drawer-tabs { display: flex; flex-shrink: 0; gap: 6px; padding: 0 24px; border-bottom: 1px solid var(--border-strong); }
.drawer-tabs button { min-height: 44px; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--text-muted); font: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; }
.drawer-tabs button[aria-selected=true] { color: var(--navy); border-bottom-color: var(--orange); }
.drawer-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 32px; }
.btn-danger { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border: 0; border-radius: var(--radius-sm); background: var(--danger); color: white; font: inherit; font-size: .86rem; font-weight: 700; cursor: pointer; }
.btn-danger:disabled { opacity: .55; cursor: wait; }
@media (max-width: 600px) { .drawer-heading { padding: 18px 16px 14px; } .drawer-tabs { padding-inline: 16px; } .drawer-content { padding: 18px 16px 28px; } }
.work-dialog .work-area { border: 0; margin: 0; }
.dialog-heading h2 { font-size: 1.35rem; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; width: 100%; margin-top: 10px; }
.shell--workspace [hidden], .shell--workspace-wide [hidden], .work-dialog [hidden] { display: none !important; }

main {
  display: block;
}

/* Top navigation */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 10px 12px 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: max-content;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 38px;
  padding: 0 9px;
  background: var(--orange);
  color: var(--navy-dark);
  border-radius: 11px;
  font-size: 0.96rem;
  font-weight: 850;
  letter-spacing: 0.06em;
}

.brand-name {
  font-size: 0.96rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav a {
  padding: 9px 15px;
  border-radius: 11px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease;
}

.main-nav a:hover {
  background: var(--surface-soft);
  color: var(--navy);
}

.main-nav a.active {
  background: var(--orange);
  color: var(--navy-dark);
}

/* Feedback */

.flash-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--navy-soft);
  border: 1px solid #c8d9e8;
  border-radius: var(--radius);
  color: var(--navy);
}

.flash-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  background: var(--navy);
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
}

.flashes {
  margin: 1px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.flashes li + li {
  margin-top: 4px;
}

.flash-panel--success {
  background: var(--success-soft);
  border-color: #b5dec6;
  color: #185c38;
}

.flash-panel--success .flash-icon { background: var(--success); }

.flash-panel--warning {
  background: var(--attention-soft);
  border-color: #ecd38a;
  color: var(--attention);
}

.flash-panel--warning .flash-icon { background: var(--attention); }

.flash-panel--error {
  background: var(--danger-soft);
  border-color: #f5c4c0;
  color: #7d2119;
}

.flash-panel--error .flash-icon { background: var(--danger); }

/* Shared typography and surfaces */

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1,
h2 {
  color: var(--text);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

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

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  padding: 34px 38px;
  background: var(--navy);
  border-radius: var(--radius-lg);
  color: #fff;
  box-shadow: var(--shadow-raised);
}

.hero::after {
  content: "";
  position: absolute;
  top: -54px;
  right: -38px;
  width: 176px;
  height: 176px;
  border: 30px solid rgba(253, 120, 1, 0.16);
  border-radius: 50%;
  pointer-events: none;
}

.hero--compact {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-eyebrow,
.page-kicker,
.section-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--orange);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero .hero-eyebrow {
  color: #ffad62;
}

.hero h1 {
  position: relative;
  z-index: 1;
  margin: 0 0 10px;
  color: #fff;
  font-size: clamp(2rem, 4vw, 3.1rem);
}

.hero p {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0;
  color: #d9e4ed;
  font-size: 1rem;
}

.page-head {
  margin: 0 0 24px;
}

.page-head h1 {
  margin: 0 0 7px;
  font-size: clamp(1.8rem, 4vw, 2.55rem);
}

.subtitle,
.result-date {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.page-title-row,
.page-toolbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-title-row {
  margin-bottom: 22px;
}

.page-title-row .page-head {
  margin-bottom: 0;
}

.page-toolbar {
  justify-content: flex-end;
  margin-bottom: 18px;
}

/* Buttons */

.btn-primary,
.btn-secondary,
.clear-files {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.btn-primary {
  min-height: 50px;
  padding: 13px 24px;
  background: var(--orange);
  color: var(--navy-dark);
  border-radius: 13px;
  box-shadow: 0 9px 20px rgba(253, 120, 1, 0.2);
  font-size: 0.95rem;
  font-weight: 800;
}

.btn-primary:hover:not(:disabled) {
  background: var(--orange-dark);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #dddfe5;
  color: #797b85;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-primary--compact {
  min-height: 42px;
  padding: 9px 17px;
  border-radius: 11px;
  font-size: 0.86rem;
}

.btn-secondary {
  min-height: 42px;
  padding: 9px 17px;
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  font-size: 0.86rem;
  font-weight: 750;
}

.btn-secondary:hover {
  background: var(--navy-soft);
  border-color: #c9d8e4;
}

.btn-submit.is-loading {
  cursor: wait;
}

/* Upload page */

.verification-form {
  margin-bottom: 18px;
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.upload-card {
  position: relative;
  min-width: 0;
  padding: 25px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--orange);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: box-shadow 160ms ease, border-color 160ms ease;
}

.upload-card--calculation {
  border-top-color: var(--navy);
}

.upload-card.has-files {
  box-shadow: var(--shadow-raised);
}

.upload-card--project.has-files {
  border-color: #fdc28c;
  border-top-color: var(--orange);
}

.upload-card--calculation.has-files {
  border-color: #b9ccdc;
  border-top-color: var(--navy);
}

.upload-card-heading {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  min-height: 104px;
  margin-bottom: 18px;
}

.upload-card-heading h2 {
  margin: 2px 0 7px;
  font-size: 1.15rem;
}

.upload-card-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  background: var(--orange-soft);
  color: #994500;
  border-radius: 10px;
  font-size: 0.86rem;
  font-weight: 850;
}

.upload-card--calculation .step-number {
  background: var(--navy-soft);
  color: var(--navy);
}

.dropzone {
  position: relative;
  display: flex;
  min-height: 218px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: var(--surface-soft);
  border: 2px dashed #d8d9e1;
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.dropzone:hover,
.dropzone:focus-within,
.dropzone.is-dragging {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.upload-card--calculation .dropzone:hover,
.upload-card--calculation .dropzone:focus-within,
.upload-card--calculation .dropzone.is-dragging {
  border-color: var(--navy);
  background: var(--navy-soft);
}

.dropzone.is-dragging {
  transform: scale(1.01);
  border-style: solid;
}

.dropzone:focus-within {
  outline: 3px solid var(--orange);
  outline-offset: 3px;
}

.upload-card--calculation .dropzone:focus-within {
  outline-color: var(--navy);
}

.dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  background: var(--orange);
  color: var(--navy-dark);
  border-radius: 13px;
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
}

.upload-card--calculation .dropzone-icon {
  background: var(--navy);
  color: #fff;
}

.dropzone-title {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 800;
}

.dropzone-action {
  margin-top: 2px;
  color: #8f4506;
  font-size: 0.85rem;
  font-weight: 650;
}

.upload-card--calculation .dropzone-action {
  color: var(--navy);
}

.dropzone-hint {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-selection {
  margin-top: 17px;
}

.file-selection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 27px;
}

.file-count {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.has-files .file-count {
  color: var(--text);
}

.clear-files {
  padding: 3px 0;
  background: transparent;
  color: #8b3d00;
  font-size: 0.78rem;
  font-weight: 750;
}

.upload-card--calculation .clear-files {
  color: var(--navy);
}

.clear-files:hover {
  text-decoration: underline;
}

.clear-files[hidden],
.file-list[hidden] {
  display: none;
}

.file-list {
  display: grid;
  gap: 8px;
  max-height: 228px;
  margin: 11px 0 0;
  padding: 0 3px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-meta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.file-extension {
  padding: 3px 6px;
  background: var(--orange-soft);
  color: #8a3d00;
  border-radius: 6px;
  font-size: 0.64rem;
  font-weight: 850;
  letter-spacing: 0.03em;
}

.upload-card--calculation .file-extension {
  background: var(--navy-soft);
  color: var(--navy);
}

.file-size {
  color: var(--text-muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 4px;
  text-align: center;
}

.btn-submit {
  min-width: 230px;
}

.form-requirement {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.verification-form.is-ready .form-requirement {
  color: var(--success);
}

.process-note {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.process-note-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  background: var(--navy-soft);
  color: var(--navy);
  border-radius: 50%;
  font-weight: 850;
}

.process-note p {
  margin: 0;
  font-size: 0.83rem;
}

.process-note strong {
  color: var(--text);
}

/* Result page */

.page-head--result {
  padding: 26px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.document-pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 14px;
}

.document-pair {
  min-width: 0;
  padding: 12px 14px;
  background: var(--orange-soft);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius-sm);
}

.document-pair--calculation {
  background: var(--navy-soft);
  border-left-color: var(--navy);
}

.document-pair-label {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.document-pair strong {
  display: block;
  overflow: hidden;
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-date {
  display: block;
  font-size: 0.78rem;
}

.processing-card,
.state-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 30px;
}

.processing-card {
  border-left: 5px solid var(--orange);
}

.processing-card h2,
.state-card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.processing-text,
.state-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 4px solid var(--orange-soft);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.state-card--error {
  background: var(--danger-soft);
  border-color: #f5c4c0;
}

.state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  background: var(--danger);
  color: #fff;
  border-radius: 50%;
  font-size: 1.05rem;
  font-weight: 850;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-match {
  background: var(--success-soft);
  color: #17623b;
}

.status-attention {
  background: var(--attention-soft);
  color: #795000;
}

.status-error {
  background: #fbd5d2;
  color: #8e1e16;
}

.status-neutral {
  background: var(--navy-soft);
  color: var(--navy);
}

.result-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.85fr);
  gap: 24px;
  margin-bottom: 30px;
  padding: 27px;
}

.result-summary h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.summary {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.stat {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 18px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.stat--danger {
  background: var(--danger-soft);
  border-color: #f6d4d1;
}

.stat--attention {
  background: var(--attention-soft);
  border-color: #f1dfa9;
}

.stat-value {
  color: var(--navy);
  font-size: 1.55rem;
  font-weight: 850;
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.66rem;
  font-weight: 650;
}

.result-section + .result-section {
  margin-top: 30px;
}

.section-heading {
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.section-kicker {
  margin-bottom: 4px;
}

.section-kicker--attention {
  color: var(--attention);
}

.section-kicker--success {
  color: var(--success);
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 850;
}

.section-empty {
  padding: 22px;
  color: var(--text-muted);
  text-align: center;
}

.section-empty p {
  margin: 0;
}

.section-empty--success {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--success);
}

/* Tables */

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background-color 120ms ease;
}

tbody tr:hover {
  background: #fffaf5;
}

td.notes,
.history-files {
  color: var(--text-muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  padding: 5px 9px;
  background: var(--navy-soft);
  color: var(--navy);
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1.25;
}

.pill-match {
  background: var(--success-soft);
  color: #17623b;
}

.pill-quantity_mismatch,
.pill-mismatch,
.pill-processing {
  background: var(--attention-soft);
  color: #795000;
}

.pill-missing_from_report,
.pill-extra_in_report,
.pill-error {
  background: var(--danger-soft);
  color: #922219;
}

.row-link {
  color: #9a4500;
  font-weight: 850;
  text-decoration: none;
}

.row-link:hover {
  text-decoration: underline;
}

.history-table {
  min-width: 880px;
}

.history-table th:first-child,
.history-table td:first-child {
  width: 90px;
}

.history-table td:nth-child(2) {
  min-width: 180px;
  color: var(--text-muted);
  white-space: nowrap;
}

.history-files {
  max-width: 260px;
  overflow-wrap: anywhere;
}

/* Empty states */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 52px 24px;
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  background: var(--navy-soft);
  color: var(--navy);
  border-radius: 17px;
  font-size: 1.55rem;
  font-weight: 800;
}

.empty-icon--orange {
  background: var(--orange-soft);
  color: #914100;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.empty-state p {
  max-width: 530px;
  margin: 0 0 21px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.price-placeholder .status-badge {
  margin-bottom: 12px;
}

/* Tablet */

@media (max-width: 920px) {
  .shell {
    padding-inline: 18px;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  .upload-card-heading {
    min-height: 0;
  }

  .result-overview {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    padding: 13px;
  }

  .brand {
    padding: 0 3px;
  }

  .main-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
  }

  .main-nav a {
    padding: 9px 8px;
    text-align: center;
  }

  .hero {
    padding: 30px;
  }

  .document-pairs {
    grid-template-columns: 1fr;
  }

  .page-title-row {
    align-items: flex-start;
  }
}

/* Mobile */

@media (max-width: 640px) {
  .shell {
    padding: 12px 12px 38px;
  }

  .topbar {
    margin-bottom: 16px;
    border-radius: 15px;
  }

  .brand-mark {
    min-width: 48px;
    min-height: 35px;
  }

  .brand-name {
    font-size: 0.88rem;
  }

  .main-nav a {
    font-size: 0.75rem;
  }

  .hero {
    padding: 27px 23px;
    border-radius: 18px;
  }

  .hero--compact {
    min-height: 184px;
  }

  .hero p {
    font-size: 0.9rem;
  }

  .upload-grid {
    gap: 14px;
  }

  .upload-card {
    padding: 19px;
    border-radius: 18px;
  }

  .upload-card-heading {
    gap: 10px;
    margin-bottom: 15px;
  }

  .upload-card-heading h2 {
    font-size: 1.02rem;
  }

  .dropzone {
    min-height: 195px;
    padding: 18px 13px;
  }

  .file-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .file-name {
    width: 100%;
  }

  .form-actions {
    padding-inline: 0;
  }

  .btn-submit {
    width: 100%;
  }

  .process-note {
    align-items: flex-start;
  }

  .page-title-row {
    flex-direction: column;
  }

  .page-title-row .btn-primary {
    width: 100%;
  }

  .page-toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .page-toolbar a {
    width: 100%;
  }

  .page-head--result {
    padding: 21px;
  }

  .processing-card,
  .state-card {
    align-items: flex-start;
    padding: 23px;
  }

  .result-overview {
    padding: 21px;
  }

  .stat-row {
    grid-template-columns: 1fr;
  }

  .stat {
    display: grid;
    grid-template-columns: 45px 1fr;
    align-items: center;
    gap: 9px;
  }

  .stat-label {
    margin: 0;
  }

  .table-card {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  table,
  .history-table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    padding: 7px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  tbody tr:hover {
    background: var(--surface);
  }

  td,
  .history-table td:nth-child(2) {
    display: grid;
    grid-template-columns: minmax(115px, 40%) minmax(0, 1fr);
    gap: 10px;
    min-width: 0;
    max-width: none;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  tbody tr td:last-child {
    border-bottom: 0;
  }

  .history-files {
    max-width: none;
  }

  .empty-state {
    padding: 40px 20px;
  }
}

@media (max-width: 390px) {
  .brand-name {
    max-width: 145px;
    line-height: 1.15;
  }

  .main-nav a {
    padding-inline: 4px;
    font-size: 0.7rem;
  }

  .page-toolbar {
    grid-template-columns: 1fr;
  }

  td,
  .history-table td:nth-child(2) {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Шаг 4: сборка состава ------------------------------------------------ */

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.inline-form input,
.inline-form select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  font-size: 0.9rem;
}

.inline-form input:focus,
.inline-form select:focus {
  border-color: var(--orange);
  outline: none;
  box-shadow: 0 0 0 3px var(--orange-soft);
}

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

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-link-danger {
  padding: 0;
  background: none;
  border: 0;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
}

.btn-link-danger:hover {
  text-decoration: underline;
}

.notice {
  margin-bottom: 18px;
  border-left: 3px solid var(--border-strong);
}

.notice-attention {
  border-left-color: var(--attention);
  background: var(--attention-soft);
}

.assembly-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.assembly-actions > div {
  flex: 1 1 340px;
  min-width: 0;
}

.assembly-total {
  margin: 4px 0 8px;
  font-size: 1.7rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.assembly-total span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.review-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

/* Несколько кнопок в правой части панели — держатся вместе и переносятся
   целиком, а не расходятся по краям при узком экране. */
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Пояснение под шапкой: почему на экране видно не всё. */
.hint {
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--orange);
}

.review-area {
  margin-bottom: 18px;
}

.area-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  font-weight: 850;
}

.review-table .col-check {
  width: 44px;
  padding-right: 0;
}

.review-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--orange);
  cursor: pointer;
}

.review-table .area-row td {
  padding-top: 17px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.review-table .subtotal-row td,
.review-table .total-row td {
  background: var(--surface-soft);
  font-weight: 800;
}

.review-table .total-row td {
  background: var(--navy-soft);
  font-size: 0.92rem;
}

.review-table tbody tr.is-selectable {
  background: #fffdf9;
}

/* Широкие таблицы проверки/расчёта не превращаются в карточки на узком экране:
   у них 5-7 колонок и своя разметка по участкам — прокрутка читается лучше.
   Правило должно идти после медиазапроса карточной раскладки, чтобы его
   перебить. */
@media (max-width: 640px) {
  .review-table thead {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
  }

  .review-table tbody {
    display: table-row-group;
    gap: 0;
  }

  .review-table tbody tr {
    display: table-row;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .review-table td {
    display: table-cell;
    padding: 12px 14px;
    white-space: nowrap;
  }

  .review-table td::before {
    content: none;
  }
}

/* --- Шаг 5: прогресс разбора документов ------------------------------------ */

.progress-head {
  display: flex;
  align-items: flex-start;
  gap: 15px;
}

.progress-head > div {
  min-width: 0;
}

.progress-files {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.progress-files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 0.86rem;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.progress-files li.has-hits {
  background: var(--orange-soft);
  border-color: #f6d5b4;
}

.progress-file-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.progress-file-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.progress-files li.has-hits .progress-file-count {
  color: #9a4500;
}

.progress-bar {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  background: var(--border);
  border-radius: 999px;
}

.progress-bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--orange-dark));
  border-radius: 999px;
  transition: width 900ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar-fill {
    transition: none;
  }
}

.progress-head-text {
  flex: 1 1 auto;
  min-width: 0;
}

.progress-pct {
  flex: 0 0 auto;
  color: var(--navy);
  font-size: 1.5rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.template-pick {
  width: 100%;
  min-width: 15rem;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-size: 0.84rem;
}

.template-pick:focus {
  border-color: var(--orange);
  outline: none;
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.template-pick::placeholder {
  color: #9a9aa8;
}

.notice-danger {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

/* --- база цен ------------------------------------------------------------ */

/* Поле поиска занимает всю свободную ширину строки, остальные — по контенту:
   искать тут длинными фразами («чем красят корпус»), и обрезать их незачем. */
.field--grow {
  flex: 1 1 22rem;
}

.field-choices {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
}

/* Второстепенная кнопка в тулбаре — той же высоты, что и компактная главная,
   иначе они не встают на одну линию. */
.btn-secondary--compact {
  min-height: 38px;
  padding: 9px 16px;
  font-size: 0.82rem;
}

/* Дата рядом с ценой — подпись, а не второе число: с новой строки и мельче,
   иначе колонка читается как две цены. */
.price-date {
  display: block;
  font-size: 0.68rem;
  font-weight: 650;
}

/* В тулбаре заголовок секции стоит в одну строку с кнопкой, и собственный
   нижний отступ ему там не нужен — иначе строка съезжает вниз. */
.review-toolbar .section-heading {
  margin-bottom: 0;
}

/* --- Техлист изделия (Шаг 6) ------------------------------------ */
/* Строк здесь под сотню, и глазами их читают по статусу, а не по порядку:
   цветная полоса слева — единственное, что отличает «конфликт» от «задано»
   на экране такой длины. */
.spec-table td { vertical-align: top; }
.spec-table input[type="text"],
.spec-table select {
  width: 100%;
  min-width: 8rem;
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--line, #d7d5d0);
  border-radius: 4px;
  background: #fff;
}
.spec-row { border-left: 3px solid transparent; }
.spec-row--extracted { border-left-color: #4c9a5a; }
.spec-row--derived { border-left-color: #5b7f96; }
.spec-row--assumed { border-left-color: #c99a2e; }
.spec-row--conflict { border-left-color: #a8452f; background: #fdf5f3; }
.spec-row--not_applicable,
.spec-row--unknown { border-left-color: #ddd; }
/* Keep the questionnaire inside its scroll area after the generic mobile
   table-to-card rules. Its inputs and source citations still need columns. */
.spec-table-scroll:focus-visible { outline-offset: -3px; }
@media (max-width: 640px) {
  .spec-table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
  .spec-table { display: table; min-width: 760px; }
  .spec-table thead { display: table-header-group; }
  .spec-table tbody { display: table-row-group; }
  .spec-table tr { display: table-row; }
  .spec-table th, .spec-table td { display: table-cell; width: auto; white-space: normal; overflow-wrap: anywhere; }
  .spec-table th { white-space: nowrap; }
  .spec-table td:first-child { min-width: 160px; }
}
.spec-quote {
  margin-top: 4px;
  padding-left: 8px;
  border-left: 2px solid #ddd;
  font-style: italic;
}

/* --- воздух вокруг текста внутри блоков ---------------------------------- */

/* .subtitle объявлен с margin: 0 — он задуман под шапку страницы, где отступ
   даёт .page-head. Внутри карточки текст от этого прилипал к тому, что под
   ним. Отступ снизу — и только когда за текстом что-то есть. */
.card > p,
.card > .subtitle {
  margin: 0 0 16px;
}

.card > p:last-child,
.card > .subtitle:last-child {
  margin-bottom: 0;
}

/* Заголовок внутри карточки: сверху воздуха не нужно, снизу нужен. */
.card > h2 {
  margin: 0 0 10px;
}

/* Уведомление — короткий абзац в рамке, и 28px карточки для него много;
   но и прижимать текст к цветной полосе слева нельзя. */
.notice {
  padding: 18px 22px;
}

/* Заголовок участка стоит на границе карточки, у него своя внутренняя рамка. */
.area-heading {
  padding: 18px 22px;
}

/* Текст под заголовком участка идёт внутри карточки-таблицы, где своих
   отступов нет вовсе. */
.table-card > .subtitle {
  padding: 0 22px 16px;
}

/* У .table-card padding: 0 — таблица должна доходить до краёв. Всё, что стоит
   в ней НАД таблицей (тулбар, заголовок секции), своих отступов от этого не
   имеет и липнет к рамке: даём их явно. */
.table-card > .review-toolbar,
.table-card > .section-heading {
  padding: 20px 22px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

/* --- BOM от техлиста (Шаг 7) ----------------------------------- */
/* Происхождение строки видно слева, как статус в листе: зелёное посчитано
   от листа, серое — медиана архива, жёлтое — правка инженера. */
.bom-row { border-left: 3px solid transparent; }
.bom-row--формула, .bom-row--номинал { border-left-color: #4c9a5a; }
.bom-row--медиана { border-left-color: #ddd; }
.bom-row--инженер { border-left-color: #c99a2e; }

/* --- Вход и учётная запись (SPEC.md, RBAC) ---------------------------------- */
.auth-card { max-width: 420px; margin: 48px auto; }
.auth-form { display: grid; gap: 14px; margin-top: 12px; }
.auth-form input[type="text"], .auth-form input[type="password"] { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); font: inherit; }
.auth-remember { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.topbar-user { display: flex; align-items: center; gap: 12px; margin-left: auto; font-size: 0.9rem; }
.topbar-user form { margin: 0; }
.project-owner-form select { font: inherit; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); background: var(--surface); }
.project-owner-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.project-owner { color: var(--text-muted); }
.users-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; align-items: end; }
.users-form .form-actions { margin: 0; }
.users-form input, .users-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); font: inherit; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.users-table select, .users-table input { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); font: inherit; }
.users-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.users-actions form { margin: 0; display: flex; gap: 6px; }
.users-row--inactive td { color: var(--text-muted); }
.dashboard-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.dashboard-period { display: inline-flex; align-items: center; gap: 6px; }
.dashboard-days { width: 90px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); font: inherit; }
.dashboard-filters select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm, 6px); font: inherit; }
.dashboard-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dashboard-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.dashboard-tile .n { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.dashboard-tile .l { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }
.dashboard-stages { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.dashboard-table { width: 100%; border-collapse: collapse; }
.dashboard-table th, .dashboard-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.dashboard-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
