:root {
  color-scheme: light;
  --page: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #626d80;
  --quiet: #8a94a6;
  --line: #dce2ea;
  --line-strong: #c5ceda;
  --blue: #2463eb;
  --blue-dark: #1d4fc4;
  --blue-soft: #eef4ff;
  --green: #16805d;
  --green-soft: #e9f7f1;
  --amber: #a66012;
  --amber-soft: #fff7e8;
  --red: #c23c49;
  --red-soft: #fff0f1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .04);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; overflow-x: hidden; color: var(--text); background: var(--page); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, label:focus-within, [tabindex]:focus-visible { outline: 3px solid rgba(36, 99, 235, .28); outline-offset: 2px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 50; padding: 9px 13px; border-radius: 6px; color: #fff; background: var(--blue-dark); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 16px; font-weight: 720; letter-spacing: -.02em; }
.brand-mark { width: 32px; height: 32px; padding: 7px 6px; display: grid; gap: 3px; border-radius: 8px; background: var(--blue); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.brand-mark i { display: block; height: 3px; border-radius: 4px; background: #fff; }
.brand-mark i:nth-child(2) { width: 68%; opacity: .72; }
.topbar-meta { display: flex; align-items: center; gap: 14px; }
.project-links { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.project-links a { min-height: 32px; padding: 6px 9px; display: inline-flex; align-items: center; gap: 4px; border-right: 1px solid var(--line); color: var(--blue-dark); background: var(--surface); text-decoration: none; font-size: 11px; font-weight: 650; }
.project-links a:last-child { border-right: 0; }
.project-links a:hover { background: var(--blue-soft); }
.workspace-context { display: grid; gap: 1px; padding-right: 14px; border-right: 1px solid var(--line); text-align: right; }
.workspace-context small { color: var(--muted); font-size: 11px; }
.workspace-context strong { font-size: 12px; font-weight: 650; }
.privacy-chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border-radius: 999px; color: #315247; background: var(--green-soft); font-size: 11px; font-weight: 650; }
.privacy-chip span { color: var(--green); font-size: 9px; }

.app-shell { display: grid; grid-template-columns: 208px minmax(0,1fr); min-height: calc(100vh - 64px); }
.nav-rail { position: sticky; top: 64px; height: calc(100vh - 64px); padding: 20px 14px 16px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fbfcfe; }
.nav-rail nav { display: grid; gap: 4px; }
.nav-item { min-height: 40px; padding: 9px 10px; display: flex; align-items: center; gap: 10px; border-radius: 7px; color: #526076; text-decoration: none; font-size: 13px; font-weight: 550; }
.nav-item:hover { color: var(--text); background: #f0f3f8; }
.nav-item.is-active { color: var(--blue-dark); background: var(--blue-soft); font-weight: 650; }
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; color: currentColor; font-size: 13px; }
.rail-card { margin-top: 24px; padding: 14px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.rail-card strong, .rail-card small { display: block; }
.rail-card strong { margin: 6px 0 3px; font-size: 12px; }
.rail-card small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.rail-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }

.workspace { min-width: 0; width: 100%; max-width: 1480px; margin: 0 auto; padding: 30px clamp(18px,2.8vw,42px) 56px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 650; }
h1 { max-width: 760px; margin: 3px 0 5px; font-size: clamp(24px,2.2vw,32px); line-height: 1.15; letter-spacing: -.03em; }
.page-heading p { max-width: 700px; margin: 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; gap: 9px; }
.button { min-height: 40px; padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 7px; cursor: pointer; color: #344054; background: var(--surface); font-size: 12px; font-weight: 650; box-shadow: 0 1px 1px rgba(16,24,40,.03); }
.button:hover { border-color: #9ba8ba; background: #fbfcfe; }
.button-primary { border-color: var(--blue); color: #fff; background: var(--blue); }
.button-primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.file-picker { position: relative; display: inline-flex; min-width: 166px; cursor: pointer; border-radius: 7px; }
.file-picker .button { width: 100%; pointer-events: none; }
.file-picker-input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.file-picker:hover .button, .file-picker:focus-within .button { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }

.source-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 82px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); }
.file-identity { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.file-icon { width: 42px; height: 46px; display: grid; place-items: center; border: 1px solid #a9bbd8; border-radius: 7px; color: var(--blue-dark); background: var(--blue-soft); font-size: 10px; font-weight: 750; }
.file-identity strong, .file-identity small { display: block; }
.file-identity strong { margin: 2px 0; font-size: 13px; }
.file-identity small { color: var(--muted); font-size: 11px; }
.progress-steps { flex: 1; max-width: 700px; display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.progress-steps li { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px 10px; border-radius: 7px; color: var(--quiet); }
.progress-steps li > span { flex: 0 0 24px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 10px; font-weight: 700; }
.progress-steps strong, .progress-steps small { display: block; white-space: nowrap; }
.progress-steps strong { color: #344054; font-size: 11px; }
.progress-steps small { margin-top: 1px; color: var(--muted); font-size: 10px; white-space: normal; overflow-wrap: anywhere; }
.progress-steps .is-done > span { color: #fff; border-color: var(--green); background: var(--green); }
.progress-steps .is-active { color: var(--blue-dark); background: var(--blue-soft); }
.progress-steps .is-active > span { border-color: var(--blue); color: #fff; background: var(--blue); }

.metrics { min-height: 44px; margin: 12px 0; padding: 0 12px; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow-x: auto; }
.metric-card { flex: 0 0 auto; padding: 0 14px; border-right: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.metric-card:first-child { padding-left: 3px; }
.metric-card b { margin-right: 4px; color: var(--text); font-size: 13px; }
.metric-ready b { color: var(--green); }
.metric-review b { color: var(--amber); }
.metric-rejected b { color: var(--red); }
.status-note { margin-left: auto; padding-left: 12px; color: var(--muted); font-size: 10px; white-space: nowrap; }

.mapping-card, .records-card, .inspection-card, .audit-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.mapping-card { margin-bottom: 12px; padding: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
h2 { margin: 2px 0 0; font-size: 16px; line-height: 1.3; letter-spacing: -.015em; }
.mapping-state { padding: 5px 8px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 700; }
.mapping-state.is-incomplete { color: var(--amber); background: var(--amber-soft); }
.mapping-state.has-conflict { color: var(--red); background: var(--red-soft); }
.mapping-state.has-optional-skips { color: var(--blue-dark); background: var(--blue-soft); }
.mapping-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 10px; margin-top: 14px; }
.mapping-field { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.mapping-field label { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; color: var(--muted); font-size: 10px; font-weight: 650; }
.mapping-field label small, .mapping-target small { font-size: 9px; color: var(--muted); }
.mapping-field.is-optional-skipped { background: var(--blue-soft); }
.mapping-field.is-conflict { background: var(--red-soft); }
.mapping-field.is-conflict select { border-color: var(--red); }
.mapping-field select { width: 100%; min-height: 34px; padding: 6px 28px 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text); background: var(--surface); font-size: 11px; font-weight: 550; }
.mapping-target { display: flex; align-items: center; gap: 5px; margin-top: 7px; color: var(--blue-dark); font-size: 10px; font-weight: 650; }
.mapping-target small { margin-left: auto; }
.mapping-warning { margin: 10px 0 0; padding: 10px 12px; border: 1px solid #d4a4a6; border-radius: 7px; color: var(--red); background: var(--red-soft); font-size: 12px; }

.review-layout { display: grid; grid-template-columns: minmax(0,1.9fr) minmax(290px,.58fr); gap: 12px; align-items: stretch; }
.records-card { min-width: 0; overflow: hidden; }
.records-heading { padding: 15px 16px 12px; }
.filter-tabs { display: flex; gap: 3px; padding: 3px; border-radius: 7px; background: #f0f3f7; }
.filter-tab { min-height: 30px; padding: 5px 9px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 650; }
.filter-tab span { margin-left: 2px; color: var(--quiet); }
.filter-tab.is-active { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(16,24,40,.12); }
.filter-tab.is-active span { color: var(--blue); }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.table-scroll-hint { display: none; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { height: 38px; padding: 8px 10px; color: var(--muted); background: var(--surface-muted); text-align: left; font-size: 10px; font-weight: 650; white-space: nowrap; }
td { height: 45px; padding: 8px 10px; border-top: 1px solid #e8ecf1; color: #3d485b; vertical-align: middle; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fafcff; }
tbody tr.is-selected { background: var(--blue-soft); }
tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 var(--blue); }
.company-cell { color: var(--text); font-weight: 650; }
.status-badge { display: inline-flex; min-height: 22px; align-items: center; padding: 3px 7px; border-radius: 999px; font-size: 9px; font-weight: 700; text-transform: capitalize; }
.status-ready { color: var(--green); background: var(--green-soft); }
.status-review { color: var(--amber); background: var(--amber-soft); }
.status-rejected { color: var(--red); background: var(--red-soft); }
.reason { max-width: 190px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
.empty-state { padding: 38px 18px; text-align: center; color: var(--muted); }
.empty-state strong, .empty-state span { display: block; }
.empty-state strong { margin-bottom: 4px; color: var(--text); }

.inspection-card { padding: 15px; }
.inspection-top { display: flex; align-items: center; justify-content: space-between; }
.row-pill { padding: 4px 7px; border-radius: 999px; color: #435169; background: #eef1f5; font-size: 10px; font-weight: 650; }
.compare-block { margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.compare-block.is-clean { border-color: #b9ddce; background: var(--green-soft); }
.compare-label { color: var(--muted); font-size: 10px; font-weight: 650; }
.compare-block dl { display: grid; grid-template-columns: 58px 1fr; gap: 6px 8px; margin: 9px 0 0; font-size: 10px; }
.compare-block dt { color: var(--muted); }
.compare-block dd { margin: 0; overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }
.compare-arrow { width: 26px; height: 26px; display: grid; place-items: center; margin: -4px auto -9px; position: relative; z-index: 1; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--blue); background: var(--surface); font-weight: 700; }
.rule-callout { margin-top: 11px; padding: 10px; border-radius: 7px; color: #315247; background: var(--green-soft); font-size: 10px; line-height: 1.45; }

.audit-card { margin-top: 12px; padding: 15px 16px; }
.text-button { min-height: 32px; padding: 5px 0; border: 0; color: var(--blue); background: transparent; cursor: pointer; font-size: 11px; font-weight: 650; }
.audit-list { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin: 13px 0 0; padding: 0; list-style: none; }
.audit-list li { position: relative; min-height: 60px; padding: 10px 10px 10px 35px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); }
.audit-list li::before { content: "✓"; position: absolute; left: 11px; top: 11px; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 9px; font-weight: 800; }
.audit-list li.is-pending::before { content: "!"; background: var(--amber); }
.audit-list li.has-conflict::before { content: "!"; background: var(--red); }
.audit-list strong, .audit-list small { display: block; }
.audit-list strong { font-size: 10px; text-transform: capitalize; }
.audit-list small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 30; max-width: 340px; padding: 11px 14px; border-radius: 8px; color: #fff; background: #253044; box-shadow: 0 12px 30px rgba(16,24,40,.18); font-size: 12px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 64px minmax(0,1fr); }
  .nav-rail { padding-inline: 9px; }
  .nav-item { justify-content: center; }
  .nav-item span:last-child, .rail-card, .rail-foot span:last-child { display: none; }
  .source-card { align-items: flex-start; flex-direction: column; }
  .progress-steps { width: 100%; max-width: none; }
  .mapping-grid { grid-template-columns: repeat(3,1fr); }
  .review-layout { grid-template-columns: 1fr; }
  .inspection-card { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px 12px; }
  .inspection-top, .inspection-card h2, .rule-callout { grid-column: 1 / -1; }
  .compare-block { margin-top: 0; }
  .compare-arrow { display: none; }
}

@media (max-width: 760px) {
  .topbar { min-height: 56px; padding: 8px 12px; }
  .brand { flex: 1 1 auto; }
  .workspace-context { display: none; }
  .privacy-chip { padding: 5px 7px; font-size: 9px; }
  .app-shell { display: block; }
  .nav-rail { position: sticky; top: 56px; z-index: 15; width: 100%; height: auto; padding: 5px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-rail nav { grid-template-columns: repeat(4,1fr); }
  .nav-item { min-height: 34px; padding: 5px; }
  .rail-foot { display: none; }
  .workspace { padding: 20px 10px 42px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 14px; margin-bottom: 16px; }
  h1 { font-size: 26px; }
  .heading-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .file-picker { width: 100%; min-width: 0; }
  .button { text-align: center; padding-inline: 8px; font-size: 11px; }
  .source-card { padding: 12px; }
  .file-identity { min-width: 0; }
  .progress-steps { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .progress-steps li { padding: 7px 6px; }
  .metrics { padding: 0 8px; }
  .metric-card { padding-inline: 9px; }
  .status-note { display: none; }
  .mapping-card, .audit-card { padding: 12px; }
  .mapping-grid { grid-template-columns: 1fr 1fr; }
  .records-heading { align-items: stretch; flex-direction: column; padding: 12px; }
  .filter-tabs { overflow-x: auto; }
  .filter-tab { flex: 1 0 auto; }
  .table-scroll-hint { margin: 0; padding: 8px 12px; display: flex; align-items: center; gap: 7px; color: var(--blue-dark); background: var(--blue-soft); font-size: 11px; }
  th, td { padding: 8px; }
  .inspection-card { display: block; padding: 12px; }
  .compare-block { margin-top: 10px; }
  .compare-arrow { display: grid; }
  .audit-list { grid-template-columns: 1fr 1fr; }
  .toast { right: 10px; bottom: 10px; left: 10px; max-width: none; }
}

@media (max-width: 420px) {
  .privacy-chip { display: none; }
  .mapping-grid, .audit-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
