:root {
  --bg: #fbfbfc;
  --surface: #ffffff;
  --text: #0b1226;
  --muted: #48516a;
  --border: #dcdfe8;
  --track: #eceef3;
  --accent: #8a4b06;
  --accent-contrast: #ffffff;
  --focus: #1a5fd0;
  --good: #1d6b3a;
  --mid: #8a5a00;
  --low: #a3262e;
  --good-bar: #2e8b57;
  --mid-bar: #d08a1c;
  --low-bar: #c8453c;
  --warn-bg: #fdf3e2;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1226;
    --surface: #131b33;
    --text: #ebeef5;
    --muted: #a6aec3;
    --border: #28314d;
    --track: #232c47;
    --accent: #f2a33a;
    --accent-contrast: #0b1226;
    --focus: #8ab4ff;
    --good: #8fe0aa;
    --mid: #f5c56b;
    --low: #ffaaa4;
    --good-bar: #3fae6c;
    --mid-bar: #e6a23c;
    --low-bar: #e0665d;
    --warn-bg: #2d2412;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 1rem; line-height: 1.5; }
.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--text); padding: 0.5rem 1rem; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; }
h1 { font-size: 1.75rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.375rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.125rem; margin: 0 0 0.75rem; }
.lede { color: var(--muted); margin: 0 0 1rem; max-width: 42rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.375rem 0 0.75rem; }
.error { color: var(--low); font-weight: 600; margin: 0.5rem 0; }
.status { min-height: 1.5rem; font-weight: 600; margin: 0.5rem 0; }
.empty { color: var(--muted); }

.top { border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.top-inner { display: flex; justify-content: space-between; align-items: center; min-height: 3.5rem; gap: 1rem; }
.brand { font-family: var(--font-display); font-weight: 700; margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.mark { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 6px; background: var(--accent); color: var(--accent-contrast); font-size: 0.9375rem; }
.powered { margin: 0; color: var(--muted); font-size: 0.875rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; margin-bottom: 1rem; }
.gate { max-width: 26rem; margin: 3rem auto; }

label, legend { display: block; font-weight: 600; margin-bottom: 0.25rem; padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 8px; padding: 0.5rem 0.75rem; min-height: 44px;
}
textarea { font-size: 0.9375rem; }
select { width: auto; }

input[type="email"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--muted); border-radius: 8px; padding: 0.5rem 0.75rem; min-height: 44px;
}
a { color: var(--focus); text-underline-offset: 2px; }

.btn { font: inherit; font-weight: 600; min-height: 44px; padding: 0.5rem 1.125rem; border-radius: 8px; border: 1px solid var(--accent); background: transparent; color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.small { padding: 0.375rem 0.875rem; font-size: 0.9375rem; margin-top: 0.5rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.25rem 0; }
.chip { display: inline-flex; align-items: center; gap: 0.375rem; font-weight: 600; border: 1px solid var(--border); border-radius: 999px; padding: 0.375rem 0.875rem; min-height: 44px; margin: 0; cursor: pointer; background: var(--bg); }
.chip input { width: 1.125rem; height: 1.125rem; margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { border-color: var(--accent); }

.controls { display: grid; gap: 1rem; }
.sender input { max-width: 20rem; }
.places .hint { margin-bottom: 0; }
.line-pick select { min-width: 16rem; max-width: 100%; }
.tabs { display: flex; gap: 0.25rem; margin: 0 0 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { font: inherit; font-weight: 600; min-height: 44px; padding: 0.5rem 1rem; border: 1px solid transparent; border-bottom: 0; border-radius: 10px 10px 0 0; background: transparent; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--text); background: var(--surface); border-color: var(--border); margin-bottom: -1px; }
.import summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.import input[type="file"] { font: inherit; min-height: 44px; }
.now { margin-top: 0.5rem; }
.signals { margin: 0; padding-left: 1.125rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; margin: 0.5rem 0 0; }
.stats div { border: 1px solid var(--border); border-radius: 10px; padding: 0.625rem 0.75rem; }
.stats dt { color: var(--muted); font-size: 0.875rem; }
.stats dd { margin: 0.125rem 0 0; font-weight: 600; font-family: var(--font-display); font-size: 1.125rem; }

.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 0.75rem; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.filters label { margin: 0; }
.leads { list-style: none; margin: 0; padding: 0; }

.lead h3 { margin: 0.25rem 0; font-size: 1.1875rem; }
.lead-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: center; }
.lead-head p { margin: 0; }
.tier { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9375rem; }
.badge { display: inline-block; font-weight: 700; border-radius: 6px; padding: 0.125rem 0.5rem; font-size: 0.875rem; border: 1px solid currentColor; }
.badge[data-tier="A"] { color: var(--good); }
.badge[data-tier="B"] { color: var(--mid); }
.badge[data-tier="C"], .badge[data-tier="X"] { color: var(--muted); }
.hazard { font-weight: 600; font-size: 0.9375rem; color: var(--accent); }
.where { color: var(--muted); margin: 0 0 0.5rem; overflow-wrap: anywhere; }

.q { border-top: 1px solid var(--border); padding-top: 0.75rem; margin-top: 0.75rem; }
.q h4 { font-family: var(--font-display); font-size: 1rem; margin: 0 0 0.375rem; text-transform: none; }
.q p { margin: 0.25rem 0; overflow-wrap: anywhere; }
.routes { margin: 0; padding-left: 1.125rem; }
.routes > li { margin-bottom: 0.75rem; }
.roles { font-size: 0.9375rem; }
.people { border-left: 3px solid var(--accent); padding-left: 0.75rem; margin-top: 0.5rem; }
.people ul { margin: 0.25rem 0; padding-left: 1.125rem; }
.draft-q label { margin-top: 0.5rem; }
.track select { margin-bottom: 0.5rem; }
.review legend { margin-top: 0.5rem; }

.method summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.method ul { padding-left: 1.125rem; }
.method li { margin-bottom: 0.375rem; }

@media (min-width: 48rem) {
  .card { padding: 1.25rem 1.5rem; }
  .controls { grid-template-columns: 1fr 1fr; align-items: start; }
  .controls fieldset { grid-column: 1 / -1; }
  .lead { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.5rem; }
  .lead-head, .lead h3, .where, .ruled-out { grid-column: 1 / -1; }
  .draft-q { grid-row: span 2; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
