:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #5d6675;
  --border: #d9dde4;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --accent-soft: #e8f0fc;
  --error: #b42318;
  --error-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff5db;
  --ok: #1e7a3c;
  --ok-soft: #e6f4ea;
  --info-soft: #eef1f5;
  --row-alt: #fafbfc;
  --focus: #1f5fbf55;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e6e9ef;
    --muted: #9aa3b2;
    --border: #323846;
    --accent: #6ea2ff;
    --accent-text: #0d1320;
    --accent-soft: #1d2b45;
    --error: #ff8a80;
    --error-soft: #3a1d1c;
    --warn: #f0c060;
    --warn-soft: #362a12;
    --ok: #74d39a;
    --ok-soft: #173024;
    --info-soft: #232833;
    --row-alt: #1f242d;
    --focus: #6ea2ff66;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top .wrap { padding-top: 20px; padding-bottom: 16px; }
h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -0.01em; }
.privacy { margin: 0; color: var(--ok); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.privacy a { margin-left: 4px; }

main { padding-top: 16px; padding-bottom: 48px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
h2 { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.step {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.85rem; font-weight: 700;
}
.optional { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 8px 0 0; font-weight: 400; }

.status { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; background: var(--info-soft); }
.status.loading::before { content: "⏳ "; }
.status.ready { background: var(--ok-soft); color: var(--ok); }
.status.failed { background: var(--error-soft); color: var(--error); }

.grid { display: grid; gap: 14px; }
.settings { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.files { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.875rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; padding-bottom: 8px; }

input[type="text"], input[type="number"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 38px;
}
input:focus-visible, select:focus-visible, button:focus-visible, [contenteditable]:focus {
  outline: 3px solid var(--focus); outline-offset: 1px;
}
input.invalid { border-color: var(--error); }
.field-error { color: var(--error); font-weight: 500; }

.drop {
  position: relative;
  border: 2px dashed var(--border); border-radius: 10px;
  padding: 18px; cursor: pointer; font-weight: 400; gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.dragover { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-file { border-style: solid; border-color: var(--ok); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop strong { font-size: 0.95rem; }
.file-name { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.drop.has-file .file-name { color: var(--ok); }

.banner { padding: 10px 14px; border-radius: 8px; margin: 10px 0 0; }
.banner.error { background: var(--error-soft); color: var(--error); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
#review-banners .banner:first-child { margin-top: 0; }

.sections { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.sections label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.sections .meta { color: var(--muted); font-weight: 400; }

.table-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; }
.table-scroll.short { max-height: 320px; }
.table-scroll.tall { max-height: 70vh; }

table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.875rem; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
tbody tr:nth-child(even) td { background: var(--row-alt); }
tbody tr:last-child td { border-bottom: 0; }

.issues tbody tr { cursor: pointer; }
.issues tbody tr:hover td { background: var(--accent-soft); }
.issues td:last-child { white-space: normal; min-width: 320px; }
.sev { font-weight: 600; border-radius: 4px; padding: 1px 6px; }
.sev-error { color: var(--error); background: var(--error-soft); }
.sev-warning { color: var(--warn); background: var(--warn-soft); }
.sev-info { color: var(--muted); background: var(--info-soft); }

.data td, .data th { border-right: 1px solid var(--border); }
.data td[contenteditable] { cursor: text; min-width: 60px; }
.data td.bad { box-shadow: inset 0 0 0 2px var(--error); background: var(--error-soft) !important; }
.data th.rownum, .data td.rownum {
  position: sticky; left: 0; z-index: 1;
  background: var(--surface); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums;
}
.data thead th.rownum { z-index: 3; }
.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data tr.flash td { background: var(--accent-soft) !important; }
.data tr.deleted td:not(.rownum):not(.act) { text-decoration: line-through; color: var(--muted); }
.data td.act { padding: 2px 6px; }
.data td.act button { font-size: 0.8rem; padding: 2px 8px; min-height: 0; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.metrics div { background: var(--bg); border-radius: 8px; padding: 10px 14px; }
.metrics .label { display: block; color: var(--muted); font-size: 0.8rem; }
.metrics .value { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }

.recon { max-width: 640px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.recon td:nth-child(2), .recon td:nth-child(3) { font-variant-numeric: tabular-nums; }
.match-yes { color: var(--ok); font-weight: 600; }
.match-no { color: var(--error); font-weight: 600; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
button {
  font: inherit; cursor: pointer; border-radius: 6px; min-height: 38px; padding: 7px 16px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.verify ul { padding-left: 20px; margin: 0 0 10px; }
.verify li { margin-bottom: 4px; }
.verify p { margin: 0; }

@media (max-width: 600px) {
  .card { padding: 14px; }
  h1 { font-size: 1.3rem; }
  .metrics .value { font-size: 1.2rem; }
}
