:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232d;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #93a1b0;
  --accent: #f97316;
  --accent-2: #38bdf8;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #eab308;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1b2330 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.topbar { border-bottom: 1px solid var(--line); background: rgba(13,17,23,.7); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.badge { background: var(--accent); color: #1a1207; font-weight: 700; font-size: 11px; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .5px; }
.meta { color: var(--muted); font-size: 13px; text-align: right; }

/* Tab navigation */
.tabs { border-bottom: 1px solid var(--line); background: rgba(13,17,23,.55); position: sticky; top: 51px; z-index: 9; backdrop-filter: blur(8px); }
.tabs-inner { display: flex; gap: 4px; flex-wrap: wrap; }
.tab-btn { appearance: none; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; padding: 13px 14px; cursor: pointer; white-space: nowrap; transition: color .12s, border-color .12s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; flex-direction: column; gap: 22px; }
.tab-panel.active { display: flex; }

main { padding: 26px 0 60px; display: flex; flex-direction: column; gap: 22px; }

.card { background: linear-gradient(180deg, var(--panel) 0%, #131820 100%); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

/* Date-coverage line — states the start/end window every figure is derived from. */
.period-line { margin: 10px 0 2px; padding: 8px 12px; font-size: 13px; line-height: 1.45;
  background: rgba(56,189,248,.07); border: 1px solid rgba(56,189,248,.22); border-radius: 8px; color: #cfe6f4; }
.period-line strong { color: var(--accent-2); }
.period-line .muted { display: inline; font-size: 12.5px; }
.period-inline { font-size: 13px; }
.period-inline strong { color: var(--accent-2); }
.cal { opacity: .85; }

/* Recently-updated datasets section */
.portal-row { display: flex; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.portal-row:last-child { border-bottom: none; }
.portal-row .muted { flex: 1; min-width: 200px; }
#recentTable td .muted { white-space: normal; max-width: 460px; font-size: 12px; margin-top: 2px; }
#recentTable .pill { margin-left: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* Emphasised "exposure" panel + a prominent stat callout */
.card.emphasis { border-color: #5a2330; background: linear-gradient(135deg, #241016 0%, #161b22 60%); }
.callout { margin: 14px 0 4px; padding: 14px 16px; border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 0 10px 10px 0; font-size: 14.5px; line-height: 1.5; }
.callout strong { color: var(--accent); }

/* Headline answer */
.answer { background: linear-gradient(135deg, #20160c 0%, #161b22 60%); border-color: #3a2a18; }
.answer-lead h2 { margin: 0; font-size: 22px; }
.answer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 18px; }
@media (max-width: 760px) { .answer-grid { grid-template-columns: repeat(2,1fr);} }
.answer-num { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.answer-num .big { font-size: 38px; font-weight: 750; line-height: 1; letter-spacing: -.5px; }
.answer-num .big.accent { color: var(--accent); }
.answer-num .lbl { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.kpis.inset { grid-template-columns: repeat(4, 1fr); margin: 6px 0 4px; }
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(3,1fr);} }
@media (max-width: 620px) { .kpis, .kpis.inset { grid-template-columns: repeat(2,1fr);} }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.kpi .k { color: var(--muted); font-size: 12px; margin-top: 5px; }
.kpi .sub { font-size: 11.5px; color: var(--accent-2); margin-top: 3px; }

.chart-box { position: relative; height: 300px; margin-top: 10px; }
.chart-box.short { height: 180px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
.table-scroll.tall { max-height: 460px; overflow-y: auto; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.bonded { background: rgba(34,197,94,.15); color: #6ee7a8; }
.pill.pending { background: rgba(234,179,8,.15); color: #f2d36b; }
.pill.felony { background: rgba(239,68,68,.15); color: #fca5a5; }
.pill.misd { background: rgba(56,189,248,.13); color: #8fd6f5; }

.methodology ul { margin: 8px 0 0; padding-left: 18px; }
.methodology li { margin: 7px 0; color: #c7d2dc; font-size: 13.5px; }
code { background: #0b0f14; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; color: #cbd5e1; }

.foot { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; padding-top: 4px; }
.banner-warn { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; padding: 10px 14px; border-radius: 10px; font-size: 13px; }

/* Source citations */
.cite-slot { margin-top: 12px; }
.cite { display: flex; gap: 7px; align-items: baseline; color: var(--muted); font-size: 11.5px; border-top: 1px dashed var(--line); padding-top: 9px; }
.cite .cite-tag { color: var(--accent-2); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: 10px; flex: none; }
.cite .cite-body { color: #9fb0bf; }
.cite .cite-body code { font-size: 11px; padding: 0 4px; }

/* County detail — dossier definition list (Texas Counties tab) */
.dossier { display: grid; grid-template-columns: 180px 1fr; gap: 2px 16px; margin-top: 6px; }
.dossier dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dossier dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.dossier dd.strong { font-weight: 700; }
@media (max-width: 620px) { .dossier { grid-template-columns: 1fr; } .dossier dt { border-bottom: none; padding-bottom: 0; } }
.notice { background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.25); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #bfe3f5; margin-top: 10px; }
.notice.warn-notice { background: rgba(234,179,8,.08); border-color: rgba(234,179,8,.3); color: #f2e0a6; margin-top: 16px; }
.notice.warn-notice code { font-size: 11px; padding: 0 4px; }

/* Data Downloads tab */
.dl-btn { display: inline-block; background: var(--accent); color: #1a1207; font-weight: 700; font-size: 12px; padding: 5px 12px; border-radius: 7px; text-decoration: none; white-space: nowrap; }
.dl-btn:hover { filter: brightness(1.08); }
.dl-copy { appearance: none; background: transparent; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px; cursor: pointer; margin-left: 6px; }
.dl-copy:hover { color: var(--text); border-color: var(--accent-2); }
.src-link { color: var(--accent-2); font-size: 12px; text-decoration: none; white-space: nowrap; }
.src-link:hover { text-decoration: underline; }

/* Texas counties map */
.tx-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.tx-select { color: var(--muted); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tx-select select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; }
.tx-map { height: 540px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #0b0f14; }
@media (max-width: 620px) { .tx-map { height: 400px; } }
.tx-legend { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.legend-bar { display: inline-flex; height: 12px; width: 160px; border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.legend-bar span { flex: 1; }
.legend-cap { font-variant-numeric: tabular-nums; }
.tx-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tx-detail-head h4 { margin: 0; font-size: 17px; }
.leaflet-tooltip.tx-tip { background: #0b0f14; border: 1px solid var(--line); color: var(--text); font-size: 12px; box-shadow: var(--shadow); }
.leaflet-tooltip.tx-tip::before { display: none; }
.leaflet-container { background: #0b0f14; font: inherit; }
.leaflet-control-attribution { background: rgba(13,17,23,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--accent-2) !important; }
.leaflet-bar a { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel); }
