:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #5f6b7a;
  --border: #dde2e8;
  --accent: #2f6fd6;
  --notice-bg: #fff4e0;
  --notice-border: #e0a526;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel: #1b2129;
    --text: #e6e9ee;
    --muted: #98a3b1;
    --border: #2c3440;
    --accent: #6ea0ff;
    --notice-bg: #2e2614;
    --notice-border: #b8861b;
  }
}

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

select {
  font: inherit; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}

/* App */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 18px; }

.notice {
  margin: 16px 20px 0; padding: 10px 14px; border-radius: 8px; font-size: 14px;
  background: var(--notice-bg); border: 1px solid var(--notice-border);
}

.layout {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 16px; padding: 16px 20px;
}
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.map-wrap, .detail { min-width: 0; }

.map-wrap, .detail {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px;
}
.controls { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.controls label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
#map { width: 100%; height: auto; display: block; margin-top: 8px; }
.state { stroke: var(--panel); stroke-width: 1; cursor: pointer; outline: none; }
.state:hover, .state:focus { opacity: 0.8; }
.state.selected { stroke: var(--text); stroke-width: 2.5; }
.state-label {
  font-size: 10px; font-weight: 600; fill: #fff; text-anchor: middle;
  dominant-baseline: central; pointer-events: none;
}

.ban-marker { cursor: pointer; }
.ban-marker circle { fill: #b3122b; stroke: #fff; stroke-width: 1.5; }
.ban-marker text { fill: #fff; font-size: 12px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.ban-icon {
  display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border-radius: 50%;
  background: #b3122b; color: #fff; font-size: 11px; font-weight: 800;
}
.cr-marker { cursor: pointer; }
.cr-marker rect { stroke: #fff; stroke-width: 1.2; }
.cr-marker.full rect { fill: #1f5fbf; }
.cr-marker.partial rect { fill: #fff; stroke: #1f5fbf; stroke-width: 1.8; }
.cr-marker text { font-size: 8px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.cr-marker.full text { fill: #fff; }
.cr-marker.partial text { fill: #1f5fbf; }
.cr-icon {
  display: inline-grid; place-items: center; flex: none; width: 20px; height: 14px; border-radius: 3px;
  font-size: 8px; font-weight: 800;
}
.cr-icon.full { background: #1f5fbf; color: #fff; }
.cr-icon.partial { background: #fff; color: #1f5fbf; border: 1.5px solid #1f5fbf; }
.ban-alert {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px;
  border: 1px solid #b3122b; border-radius: 8px; font-size: 13px;
}
.ban-alert .ban-icon { margin-top: 2px; }

.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

.detail h2 { margin: 0 0 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  font: inherit; font-size: 14px; font-weight: 600; padding: 8px 12px; cursor: pointer;
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted);
}
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.brands { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.brand { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.brand-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.brand-meta { font-size: 12px; }
.brand-evidence { margin-top: 4px; color: var(--muted); }
.brand-source { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--accent); overflow-wrap: anywhere; }
.local-tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: #2f9e6e; color: #fff; }
.detail h3 { margin: 18px 0 6px; font-size: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; color: #fff; }
.badge.confidence { color: var(--text); border: 1px solid var(--border); }
.badge.confidence.low { border-color: #d1495b; }
.badge.confidence.medium { border-color: #e0a526; }
.badge.confidence.high { border-color: #2f9e6e; }
.summary { margin: 12px 0; }
.limits { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 4px; }
.limits th, .limits td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.limits thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.limits tbody th { font-weight: 600; min-width: 7em; }
.limits td.changed { font-weight: 600; color: var(--accent); }
.table-scroll { overflow-x: auto; }
.table-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
dl { margin: 0; }
dt { font-weight: 600; font-size: 13px; color: var(--muted); margin-top: 12px; }
dd { margin: 2px 0 0; }
.sources { margin: 0; padding-left: 18px; }
.sources a { color: var(--accent); }

.disclaimer { padding: 0 20px 24px; font-size: 12px; color: var(--muted); }

/* Phones */
@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  .layout { padding: 12px 16px; gap: 12px; }
  .map-wrap, .detail { padding: 12px; }
  .controls label { flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
  .controls select { width: 100%; }
  .state-label { font-size: 14px; }
  .legend { gap: 6px 12px; font-size: 12px; }
  .detail h2 { font-size: 20px; }
  /* Stack each limit row: label on top, then Current / Effective / Federal with their column names. */
  .limits thead { display: none; }
  .limits, .limits tbody, .limits tr, .limits th, .limits td { display: block; width: 100%; }
  .limits tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .limits th, .limits td { border: 0; padding: 2px 0; }
  .limits tbody th { white-space: normal; font-size: 14px; }
  .limits td { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; }
  .limits td::before { content: attr(data-label); color: var(--muted); font-weight: 400; font-size: 12px; }
  .sources a { overflow-wrap: anywhere; }
  .disclaimer { padding: 0 16px 20px; }
}
