:root {
  color-scheme: light;
  --bg: #eceff2;
  --surface: #fcfcfb;
  --surface-2: #f4f6f8;
  --ink: #12202c;
  --ink-2: #4a5764;
  --ink-3: #6b7783;
  --line: #d6dce2;
  --line-soft: #e4e8ec;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #dce8f7;
  --focus: #1c5cab;
  --grid: #e6e9ec;
  --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100;
  --bar: #2a78d6;
  --shadow: 0 1px 2px rgba(18, 32, 44, .06), 0 8px 24px rgba(18, 32, 44, .08);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --ink-3: #9c9b92;
  --line: #35352f;
  --line-soft: #2a2a27;
  --accent: #6da7ec;
  --accent-ink: #0d0d0d;
  --accent-soft: #1f3550;
  --focus: #8fbcf2;
  --grid: #2a2a27;
  --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500;
  --bar: #3987e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--body); font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { top: 8px; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 14px; }
.brand h1 { margin: 0; font: 700 24px/1.1 var(--display); letter-spacing: -.01em; }
.brand p { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.gearwrap { position: relative; }
.iconbtn {
  width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; color: var(--ink);
}
.iconbtn:hover { background: var(--surface-2); }
.menu {
  position: absolute; right: 0; top: 52px; min-width: 220px; z-index: 50; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.menu a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.menu a:hover, .menu a:focus-visible { background: var(--accent-soft); }
.menu a[aria-current="page"] { font-weight: 600; background: var(--surface-2); }

main { padding-top: 18px; padding-bottom: 40px; min-height: 70vh; }
footer { border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--ink-2); font-size: 13px; }
footer p { margin: 0; }

/* search */
.search { position: relative; }
.search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input {
  width: 100%; height: 60px; padding: 0 18px 0 52px; font-size: 18px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; box-shadow: 0 1px 0 var(--line-soft);
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus-visible { border-color: var(--accent); outline-offset: 2px; }

/* filters */
.ftoggle { display: none; margin-top: 12px; }
.filters { margin-top: 14px; display: grid; gap: 8px; position: relative; }
.frow { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; }
.frow > .flabel { padding-top: 3px; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 1px 10px; line-height: 1.2; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; color: var(--ink); font-size: 14px;
}
.pill:hover { border-color: var(--ink-3); }
.pill .n { color: var(--ink-3); font-size: 12.5px; }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill[aria-pressed="true"] .n { color: inherit; opacity: .85; }
.pill[aria-pressed="true"]::before { content: ""; width: 5px; height: 9px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(40deg) translate(-1px, -1px); }
.pill.zero:not([aria-pressed="true"]) { opacity: .5; }
.pill.more { border-style: dashed; }
.chev { width: 26px; min-height: 26px; padding: 0; justify-content: center; }
.catgroup { display: inline-flex; gap: 2px; align-items: center; }
.catgroup .pill:first-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }
.catgroup .chev { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.chev svg { transition: transform .15s; }
.chev[aria-expanded="true"] svg { transform: rotate(180deg); }
.typerow { margin: 2px 0 4px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 10px; }
.typerow .t { color: var(--ink-2); font-size: 12.5px; margin-bottom: 6px; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.popover {
  position: absolute; z-index: 40; left: 106px; right: 0; max-width: 460px; top: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 10px;
}
.popover input { width: 100%; height: 40px; padding: 0 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.poplist { max-height: 300px; overflow: auto; margin-top: 8px; display: grid; }
.poplist button {
  display: flex; justify-content: space-between; gap: 12px; text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.poplist button:hover { background: var(--surface-2); }
.poplist button[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
.poplist .n { color: var(--ink-3); }

.bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 16px 0 10px; }
.bar .count { font-size: 16px; }
.bar .count strong { font: 700 22px var(--display); }
.btn {
  min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.spacer { flex: 1; }
.sortsel { display: none; }

/* list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
@media (max-width: 1599px) { .c-phone, .thead button.c-phone { display: none; } }
.thead {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: var(--cols); gap: 12px; padding: 0 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0;
}
.thead button {
  text-align: left; background: none; border: 0; padding: 12px 0; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2);
  display: inline-flex; gap: 6px; align-items: center;
}
.thead button:hover { color: var(--ink); }
.thead button[aria-sort] { color: var(--ink); }
.thead .arr { font-size: 11px; }
.vp { position: relative; }
.row {
  position: absolute; left: 0; right: 0; display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center;
  padding: 0 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.row:hover { background: var(--surface-2); }
.row:focus-visible { outline-offset: -2px; }
.cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.dim { color: var(--ink-2); }
.cell .l2 { display: block; font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; }
.cell .l1 { display: block; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.sub-type { display: none; }
.plate {
  display: inline-block; max-width: 100%; padding: 3px 9px 4px; border-radius: 7px; background: var(--surface);
  border: 1.5px solid var(--ink); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px var(--line);
  font: 700 15px/1.2 var(--display); letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: 13.5px; }
.badge svg { flex: none; }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.card-only { display: none; }

@media (max-width: 1099px) {
  .c-type, .c-first, .c-phone, .c-chg, .thead button.c-type, .thead button.c-first, .thead button.c-phone, .thead button.c-chg { display: none; }
  .sub-type { display: block; }
  .hide-md { display: none; }
}
@media (max-width: 759px) {
  .wrap { padding: 0 14px; }
  .brand h1 { font-size: 20px; }
  .search input { height: 54px; font-size: 16px; }
  .ftoggle { display: inline-flex; }
  .filters.collapsed { display: none; }
  .frow { grid-template-columns: 1fr; gap: 4px; }
  .frow > .flabel { padding-top: 0; }
  .popover { left: 0; }
  .thead { display: none; }
  .list { background: transparent; border: 0; }
  .row {
    display: block; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: none;
  }
  .row .cell { white-space: normal; }
  .card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .card-name { font-weight: 600; margin-top: 8px; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
  .card-meta { color: var(--ink-2); font-size: 13px; margin-top: 2px; white-space: nowrap !important; overflow: hidden; text-overflow: ellipsis; }
  .row > .cell:not(.card-only) { display: none; }
  .card-only { display: block; }
  .sortsel { display: inline-block; height: 38px; padding: 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
}

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(8, 14, 20, .45); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100vw); z-index: 61; overflow: auto;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); padding: 0 0 40px;
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } .chev svg { transition: none; } }
.dhead { position: sticky; top: 0; background: var(--surface); padding: 18px 20px 14px; border-bottom: 1px solid var(--line); z-index: 2; }
.dhead .x { position: absolute; right: 12px; top: 12px; }
.dhead h2 { margin: 12px 48px 6px 0; font: 700 22px/1.2 var(--display); }
.dhead .type { color: var(--ink-2); margin-top: 8px; }
.dbody { padding: 4px 20px; }
.dbody h3 { font: 700 15px var(--display); margin: 22px 0 8px; }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--ink-2); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.block { border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface-2); }
.block .dl { grid-template-columns: 120px 1fr; font-size: 14px; }
.others { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.others a { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: 10px; text-decoration: none; color: var(--ink); }
.others a:hover { background: var(--surface-2); }
.note { color: var(--ink-2); font-size: 13.5px; }

/* analytics */
.filtline { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin: 0 0 14px; color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tile .v { font: 700 32px/1.1 var(--display); letter-spacing: -.02em; }
.tile .k { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px 14px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h2 { margin: 0; font: 700 18px/1.2 var(--display); }
.card .cap { margin: 4px 0 10px; color: var(--ink-2); font-size: 13.5px; max-width: 80ch; }
.cardhead { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; flex: none; }
.seg button { background: none; border: 0; padding: 5px 11px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.chartbox { width: 100%; min-width: 0; }
.chartbox svg { display: block; max-width: 100%; }
.chartbox text { fill: var(--ink-2); font: 12px var(--body); font-variant-numeric: tabular-nums; }
.chartbox text.val { fill: var(--ink); }
.chartbox .grid { stroke: var(--grid); stroke-width: 1; }
.chartbox .hit { fill: transparent; }
.chartbox .mark { transition: opacity .1s; }
.chartbox .hot .mark { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 8px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.dtable th, .dtable td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; }
.dtable th:first-child, .dtable td:first-child { text-align: left; }
.dtable th { color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.tablewrap { max-height: 360px; overflow: auto; }
.tip {
  position: fixed; z-index: 90; pointer-events: none; padding: 8px 10px; border-radius: 9px; font-size: 13px; max-width: 260px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tip .tv { font: 700 16px var(--display); }
.tip .tr { display: flex; align-items: center; gap: 8px; margin-top: 3px; color: var(--ink-2); }
.tip .tr i { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tip .tr b { color: var(--ink); margin-left: auto; padding-left: 12px; }

/* about */
.prose { max-width: 74ch; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 28px 28px; }
.prose h2 { font: 700 20px var(--display); margin: 28px 0 8px; }
.prose p, .prose li { color: var(--ink); }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13.5px; }
.loading { padding: 80px 0; text-align: center; color: var(--ink-2); }

@media (max-width: 959px) {
  .charts { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 759px) {
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dt { margin-top: 8px; font-size: 13px; }
  .block .dl { grid-template-columns: 1fr; }
  .prose { padding: 4px 18px 22px; }
  .card { padding: 14px 12px; }
  .tile .v { font-size: 26px; }
}

/* city picker header, status tip */
.pophead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.popsort { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.popsort button { border: 0; background: none; padding: 5px 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.popsort button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.stip { position: fixed; z-index: 80; max-width: 280px; display: grid; gap: 3px; padding: 9px 11px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px; pointer-events: none; }
.stip[hidden] { display: none; }
.stip small { color: var(--ink-3); font-size: 11.5px; }

/* movable columns */
.thead { position: sticky; }
.thead button { user-select: none; touch-action: none; position: relative; }
.thead button:hover::before {
  content: ''; position: absolute; left: -9px; top: 50%; width: 5px; height: 13px; transform: translateY(-50%); cursor: grab;
  background-image: radial-gradient(currentColor 1px, transparent 1.2px); background-size: 5px 4.4px; opacity: .55;
}
.thead button.dragging { opacity: .45; }
.coldrag, .coldrag * { cursor: grabbing !important; }
.coldrop { position: absolute; top: 6px; bottom: 6px; width: 3px; margin-left: -1px; border-radius: 2px; background: var(--focus, #3b6fd4); pointer-events: none; }
.coldrag .stip { display: none !important; }

/* analytics city selector: the same picker as Licenses, anchored to its own button */
.acity { position: relative; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.acitychips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.acity .popover { left: 0; right: auto; width: min(460px, 100%); }

/* map */
.mapel { width: 100%; height: 560px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.mapel > .note { padding: 16px; }
.maptable { max-height: 560px; overflow: auto; }
.mappop { font: 13px var(--body); color: #1a1a19; }
@media (max-width: 760px) { .mapel, .maptable { height: 380px; max-height: 380px; } }

/* issue-date scrubber */
.scrub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.scrubhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; font-size: 13.5px; color: var(--ink-2); }
.scrubhead strong { color: var(--ink); width: 100%; }
.scrubhead input { height: 34px; padding: 0 8px; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.scrubtrack { position: relative; height: 54px; touch-action: none; cursor: pointer; user-select: none; margin: 0 8px; }
.scrubtrack svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.scrubtrack rect { fill: var(--bar); }
.scrubshade { position: absolute; top: 0; bottom: 0; left: 0; background: var(--surface); opacity: .72; pointer-events: none; }
.scrubband { position: absolute; top: 0; bottom: 0; cursor: grab; border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.scrubh { position: absolute; top: -2px; bottom: -2px; width: 16px; transform: translateX(-50%); padding: 0; background: var(--accent); border: 2px solid var(--surface); border-radius: 6px; cursor: ew-resize; touch-action: none; z-index: 1; }
.scrubh:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.scrubaxis { position: relative; height: 20px; margin: 4px 8px 0; font-size: 12px; color: var(--ink-2); }
.scrubaxis span { position: absolute; transform: translateX(-50%); }

/* map style toggle */
.mapmode { background: var(--surface); box-shadow: var(--shadow); }

/* header buttons, theme icon */
.topacts { display: flex; align-items: center; gap: 6px; }
:root[data-theme="dark"] .ic-moon, :root[data-theme="light"] .ic-sun { display: none; }

/* Status pills above the Analytics charts */
.astatus { margin: 0 0 8px; }

/* a touch screen keeps a bigger target */
@media (pointer: coarse) { .pill { min-height: 32px; } .chev { min-height: 32px; } }

/* the rows sit in #frows, so the gap on .filters never reached them */
#frows { display: grid; gap: 6px; }

/* heat map color key */
.mapheatkey { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; color: var(--ink-2); font-size: 11.5px; line-height: 1.3; }
.mapheatkey[hidden] { display: none; }
.mapheatrow { display: flex; align-items: center; gap: 6px; }
.mapheatbar { display: block; width: 92px; height: 8px; border-radius: 4px; }
.mapheatnote { margin-top: 2px; color: var(--ink-3); }

/* desktop header: the pages are three buttons; phones keep the gear */
@media (min-width: 761px) {
  #gear { display: none; }
  .gearwrap { order: -1; }
  .menu, .menu[hidden] { position: static; display: flex !important; gap: 6px; min-width: 0; padding: 0; background: none; border: 0; box-shadow: none; }
  .menu a { display: flex; align-items: center; height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap; }
  .menu a:hover, .menu a:focus-visible { background: var(--surface-2); }
  .menu a[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
  .topacts { gap: 8px; flex-shrink: 0; }
}
