/* Theme tokens. Placeholder values until the Racing Telemetry design system
   tokens are dropped in here; nothing below this block names a color. */
:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #5d6168;
  --line: #dcdde0;
  --accent: #0b6e4f;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141518;
    --surface: #1d1f23;
    --text: #ecedef;
    --muted: #a3a7ae;
    --line: #34373d;
    --accent: #3fb68b;
    --accent-text: #0d0e10;
    --danger: #f2b8b5;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  min-height: 100vh;
}
main { max-width: 560px; margin: 0 auto; padding: 32px 16px 64px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 24px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin: 16px 0;
}
label { display: block; font-weight: 600; margin: 0 0 6px; }
input {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
input.code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
button, .button {
  display: inline-block;
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
button.link {
  background: none;
  color: var(--accent);
  width: auto;
  padding: 8px 0;
}
button[disabled] { opacity: .6; cursor: default; }
.error { color: var(--danger); min-height: 1.5em; margin-top: 8px; }
.notice {
  border-left: 4px solid var(--accent);
  padding: 8px 12px;
  background: var(--surface);
}
dl { display: grid; grid-template-columns: fit-content(55%) 1fr; gap: 4px 16px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
[hidden] { display: none !important; }

/* ---- Phase 2 additions ------------------------------------------------- */
main.wide { max-width: 960px; }
h3 { font-size: 1rem; margin: 16px 0 8px; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label + input, label + select, label + textarea { margin-bottom: 12px; }
select, textarea {
  width: 100%;
  font: inherit;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}
fieldset.choice { border: 0; padding: 0; margin: 0 0 12px; display: flex; gap: 16px; flex-wrap: wrap; }
fieldset.choice legend { font-weight: 600; margin-bottom: 6px; }
fieldset.choice label, label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 6px 0; }
fieldset.choice input, label.check input { width: auto; }
.checks { display: grid; gap: 2px; }

nav.top {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
}
nav.top a { color: var(--text); text-decoration: none; padding: 4px 0; }
nav.top a[aria-current="page"] { font-weight: 700; border-bottom: 2px solid var(--accent); }
nav.top .right, nav.top button.link { margin-left: auto; }
/* After a right-pushed item the switcher sits next to it, not halfway between. */
nav.top .right ~ select.lang, nav.top button.link ~ select.lang { margin-left: 0; }

button.secondary, .button.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.danger { color: var(--danger) !important; }
button.link.danger { background: none; }

.rows { list-style: none; margin: 16px 0; padding: 0; }
.row {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.row.stack { flex-direction: column; align-items: stretch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions button, .actions .button { width: auto; margin-top: 0; }
.actions input, .actions select { width: auto; flex: 1 1 160px; margin: 0; }
.note { border-left: 3px solid var(--line); padding: 4px 10px; margin: 8px 0; color: var(--muted); }
ul.plain { list-style: none; padding: 0; margin: 8px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); }
.chip-x { width: auto; margin: 0; padding: 0 8px; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; }

.meter { height: 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--accent); }
#meter-text { margin-top: 8px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; }
.tile .n { font-size: 1.8rem; font-weight: 700; }

.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 16px 0; }
.filters input, .filters select, .filters button { margin: 0; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.tabs button { width: auto; margin: 0; background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.card > h2:first-child, .card > form > h2:first-child, form.card > h2:first-child { margin-top: 0; }
.actions label.check { margin: 0; flex: 0 0 auto; }
.actions label.check input { flex: none; width: auto; }

/* ---- Phase 3 additions ------------------------------------------------- */
.mapping { display: grid; gap: 8px; margin-bottom: 12px; }
.map-row { display: grid; grid-template-columns: 1fr minmax(150px, 220px); gap: 8px 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line); }
.map-row select { margin: 0; }
.map-row .muted { font-size: .85rem; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); }
.badge.create { color: var(--accent); border-color: var(--accent); }
.badge.update { color: var(--text); border-color: var(--text); }
.badge.review { color: var(--danger); border-color: var(--danger); }
.badge.error { color: var(--accent-text); background: var(--danger); border-color: var(--danger); }
.badge.duplicate { color: var(--muted); }

/* ---- Phase 4 additions ------------------------------------------------- */
.actions.spread { justify-content: space-between; }
.actions.spread h2 { margin: 0; }
label.check.inline { display: inline-flex; margin: 0; }
.row.focus { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.row .card { margin: 8px 0 0; padding: 12px; }

/* ---- v1.1 and Phase 5 additions ------------------------------------------ */
select.lang { width: auto; margin: 0 0 0 auto; padding: 4px 8px; font-size: .9rem; }
.langbar { display: flex; justify-content: flex-end; padding: 8px 16px 0; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.list thead th { font-size: .8rem; color: var(--muted); }
table.measures tr.total th, table.measures tr.total td { font-weight: 700; border-top: 2px solid var(--text); }
.badge.ok { color: var(--accent); border-color: var(--accent); }
.badge.warn { color: var(--danger); border-color: var(--danger); }
.tile.warn { border-color: var(--danger); }
