:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --warn-bg: #fff6e0;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --muted: #a9a79f;
  --ink-series: #52514e;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --raised: #222220;
    --ink: #ffffff; --ink-2: #c3c2b7; --ink-3: #9a988f;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --warn-bg: #3a2f12;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --muted: #6c6a64; --ink-series: #c3c2b7;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --raised: #222220;
  --ink: #ffffff; --ink-2: #c3c2b7; --ink-3: #9a988f;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --warn-bg: #3a2f12;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --muted: #6c6a64; --ink-series: #c3c2b7;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); line-height: 1.45; font-size: 15px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
.sub { color: var(--ink-2); font-size: 14px; }
.muted { color: var(--ink-3); }
.italic, i { font-style: italic; }
a { color: var(--accent); }

header.top { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
button, .button {
  font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--raised); color: var(--ink);
}
button.primary, .button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button:hover, .button:hover { filter: brightness(0.96); }
input[type=file] { display: none; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card > .sub { margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
section { margin-bottom: 16px; }

.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.controls label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.controls label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
select, input[type=number], input[type=text], input[type=email], input[type=password], input[type=date], input:not([type]) {
  font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--raised); color: var(--ink); min-width: 110px;
}
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; margin-top: 12px; }
.mapping { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--ink-2); }
.tile .value { font-size: 28px; font-weight: 600; margin-top: 2px; }
.tile .note { font-size: 12px; color: var(--ink-3); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.desc { color: var(--ink-3); font-size: 12.5px; min-width: 220px; }
.table-scroll { max-height: 520px; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; background: var(--surface); }
.row-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

.notice { background: var(--warn-bg); border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.empty { text-align: center; padding: 64px 16px; color: var(--ink-2); }

.map { height: 460px; border-radius: 8px; border: 1px solid var(--border); z-index: 0; }
.leaflet-tooltip { font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
@media (max-width: 600px) { .map { height: 340px; } }

/* Status badges: icon + label, never colour alone. */
.badge { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: rgba(12, 163, 12, .14); color: var(--ink); }
.badge.warning { background: rgba(250, 178, 25, .25); color: var(--ink); }
.badge.error { background: rgba(208, 59, 59, .18); color: var(--ink); }
.badge.skipped, .badge.info { background: var(--grid); color: var(--ink-2); }
th.mapped { color: var(--accent); }
pre.code { background: var(--raised); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre; margin: 6px 0; }
code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
button:disabled { opacity: .55; cursor: default; }

/* Charts */
.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart text { font-family: inherit; }
.tick-label { font-size: 11.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.value-label { font-size: 11.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.axis-title { font-size: 12px; fill: var(--ink-2); }
.grid { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.bar.s1 { fill: var(--s1); }
.hit:hover .bar { filter: brightness(1.1); }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.s1 { stroke: var(--s1); } .line.s2 { stroke: var(--s2); } .line.s3 { stroke: var(--s3); }
.line.muted { stroke: var(--muted); } .line.ink-series { stroke: var(--ink-series); }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.s1 { fill: var(--s1); } .dot.s2 { fill: var(--s2); } .dot.s3 { fill: var(--s3); }
.dot.muted { fill: var(--muted); } .dot.ink-series { fill: var(--ink-series); }
circle.dot:hover { r: 6; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tooltip {
  position: fixed; z-index: 10; display: none; pointer-events: none; max-width: 300px;
  background: var(--raised); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

@media (max-width: 600px) {
  h1 { font-size: 22px; }
  .tile .value { font-size: 22px; }
}

/* Photos */
img.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; margin-top: 12px; }
.photo-grid figure { margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; background: var(--raised); }
.photo-grid figcaption { font-size: 0.85rem; margin-top: 6px; line-height: 1.35; display: flex; flex-direction: column; }
