/* LPL Contacts app. Light and dark themes follow the device unless the user picks one (html[data-theme]). */

:root {
	--brand: #fed106;
	--brand-strong: #e3b900;
	--brand-ink: #1b1600;
	--bg: #f5f6f8;
	--surface: #ffffff;
	--surface-2: #f0f2f5;
	--border: #e2e5ea;
	--text: #151a21;
	--muted: #5f6977;
	--accent: #8a6d00;
	--positive: #18864b;
	--negative: #c93a3a;
	--info: #2f6fde;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
	--shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
	--radius: 14px;
	--radius-sm: 9px;
	--sidebar: 248px;
	--chart-1: #e3b900;
	--chart-2: #2f6fde;
	--chart-3: #18864b;
	--chart-4: #c93a3a;
	--chart-5: #8b5cf6;
	--chart-grid: rgba(15, 23, 42, .08);
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0e1116;
		--surface: #161a21;
		--surface-2: #1d222b;
		--border: #2a303a;
		--text: #e8ebf0;
		--muted: #9aa4b2;
		--accent: #fed106;
		--positive: #3ccb7f;
		--negative: #ff6b6b;
		--info: #6ea0ff;
		--shadow: 0 1px 2px rgba(0, 0, 0, .4);
		--shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
		--chart-1: #fed106;
		--chart-2: #6ea0ff;
		--chart-3: #3ccb7f;
		--chart-4: #ff6b6b;
		--chart-5: #a78bfa;
		--chart-grid: rgba(255, 255, 255, .08);
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #0e1116;
	--surface: #161a21;
	--surface-2: #1d222b;
	--border: #2a303a;
	--text: #e8ebf0;
	--muted: #9aa4b2;
	--accent: #fed106;
	--positive: #3ccb7f;
	--negative: #ff6b6b;
	--info: #6ea0ff;
	--shadow: 0 1px 2px rgba(0, 0, 0, .4);
	--shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
	--chart-1: #fed106;
	--chart-2: #6ea0ff;
	--chart-3: #3ccb7f;
	--chart-4: #ff6b6b;
	--chart-5: #a78bfa;
	--chart-grid: rgba(255, 255, 255, .08);
	color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { margin: 0 0 .15rem; color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
input, select, textarea, button { font: inherit; color: inherit; }

/* ---------- Shell ---------- */

.app { min-height: 100vh; }
.sidebar {
	position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
	display: flex; flex-direction: column; gap: 1.25rem;
	padding: 1.25rem 1rem; background: var(--surface); border-right: 1px solid var(--border);
	z-index: 20;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem; }
.brand-mark { display: block; width: 36px; height: 36px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
	display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem; border-radius: var(--radius-sm);
	color: var(--muted); text-decoration: none; font-weight: 550;
}
.nav a .fa { width: 1.1rem; text-align: center; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--text); }
.nav a[aria-current="page"] .fa { color: var(--brand-strong); }
.sidebar-foot { margin-top: auto; display: grid; gap: .6rem; }
.who { display: grid; font-size: .85rem; margin: 0; overflow-wrap: anywhere; }
.who span { color: var(--muted); }

.topbar {
	display: none; position: sticky; top: 0; z-index: 20;
	align-items: center; justify-content: space-between;
	padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
	border-bottom: 1px solid var(--border);
}
.tabbar { display: none; }

.main { margin-left: var(--sidebar); padding: 2rem clamp(1rem, 3vw, 2.5rem) 3rem; max-width: calc(var(--sidebar) + 1280px); }
.view { animation: fade-in .18s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head p.small { margin: 0; }

@media (max-width: 959px) {
	.sidebar { display: none; }
	.topbar { display: flex; }
	.main { margin-left: 0; padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
	h1 { font-size: 1.35rem; }
	.tabbar {
		display: grid; grid-template-columns: repeat(7, 1fr);
		position: fixed; inset: auto 0 0 0; z-index: 20;
		padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
		background: color-mix(in srgb, var(--surface) 92%, transparent);
		backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
		border-top: 1px solid var(--border);
	}
	.tabbar a {
		display: grid; justify-items: center; gap: 2px; padding: .3rem 0; border-radius: var(--radius-sm);
		color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 600;
	}
	.tabbar a .fa { font-size: 1.15rem; }
	.tabbar a span { text-align: center; line-height: 1.15; }
	.tabbar a[aria-current="page"] { color: var(--text); }
	.tabbar a[aria-current="page"] .fa { color: var(--brand-strong); }
}

/* ---------- Building blocks ---------- */

.card {
	background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
	box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .9rem; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; }
.card-head .sub { color: var(--muted); font-size: .85rem; font-weight: 500; }
.card-foot { margin: .75rem 0 0; color: var(--muted); font-size: .8rem; }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
	padding: .6rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
	font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
	transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.icon-btn {
	display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
	border: 0; background: transparent; color: var(--text); font-size: 1.25rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: .25rem 0; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

.field { display: grid; gap: .35rem; font-size: .85rem; font-weight: 600; color: var(--muted); min-width: 0; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .search-input {
	width: 100%; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
	background: var(--surface); color: var(--text); font-weight: 400; font-size: 1rem;
}
.field textarea { resize: vertical; min-height: 4.5rem; }
.field input:focus, .field select:focus, .field textarea:focus, .search-input:focus { outline: none; border-color: var(--brand-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }
.search-input { margin-bottom: .75rem; }
.grow { flex: 1 1 14rem; }
.actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; font-weight: 500; color: var(--text); font-size: .95rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 42px; height: 24px; flex: none; border-radius: 999px; background: var(--border); transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand-strong); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--info); outline-offset: 2px; }

.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 1rem; }
.segmented button { border: 0; background: transparent; padding: .4rem .8rem; border-radius: 8px; font-weight: 600; font-size: .85rem; color: var(--muted); cursor: pointer; }
.segmented button[aria-selected="true"], .segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented.small { margin: 0; }
.segmented.small button { padding: .25rem .6rem; font-size: .78rem; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-brand { background: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--text); border-color: transparent; }
.badge-positive { background: color-mix(in srgb, var(--positive) 16%, transparent); color: var(--positive); border-color: transparent; }
.badge-negative { background: color-mix(in srgb, var(--negative) 14%, transparent); color: var(--negative); border-color: transparent; }
.badge-info { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); border-color: transparent; }

.notice { padding: .7rem .9rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--positive) 12%, transparent); color: var(--text); margin-bottom: 1rem; }
.notice.error { background: color-mix(in srgb, var(--negative) 12%, transparent); }
.empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; margin: 0; }

/* ---------- Dashboard ---------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { margin: 0; display: grid; gap: .2rem; align-content: start; cursor: default; }
.kpi[data-go] { cursor: pointer; }
.kpi[data-go]:hover { border-color: color-mix(in srgb, var(--brand-strong) 60%, var(--border)); }
.kpi .label { display: flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .82rem; font-weight: 600; }
.kpi .label .fa { color: var(--brand-strong); }
.kpi .value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .detail { font-size: .8rem; color: var(--muted); }
.kpi canvas { margin-top: .35rem; max-height: 38px; }
@media (max-width: 520px) { .kpi .value { font-size: 1.45rem; } .kpi { padding: .9rem; } }

.delta { font-weight: 650; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--negative); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1rem; }
.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1100px) { .grid-2, .grid-even { grid-template-columns: minmax(0, 1fr); } }
.grid-2 > .card, .grid-even > .card { margin-bottom: 0; }
.dash-row { margin-bottom: 1rem; }

.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 200px; }
.chart-box.tall { height: 300px; }
.stat-row { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: 0 0 .9rem; }
.stat-row div { display: grid; }
.stat-row strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat-row span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.area-select { max-width: 16rem; padding: .4rem .6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }

.card-tools { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Registered Libertarians by parish (dashboard map) */
.map-tools { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .9rem; }
.map-wrap { position: relative; }
#parish-map { display: block; width: 100%; height: auto; max-height: 520px; }
#parish-map .parishes path { stroke: var(--surface); stroke-width: 1.2; stroke-linejoin: round; transition: fill .25s; }
#parish-map path.in-scope { cursor: pointer; }
#parish-map path.in-scope:hover { stroke: var(--text); stroke-width: 2; }
#parish-map path.out-of-scope { fill: var(--surface-2); opacity: .45; }
#parish-map path.is-selected { stroke: var(--text); stroke-width: 3; }
#parish-map .state-outline { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; pointer-events: none; }
/* Sits in the empty corner north of the Florida parishes and east of the Mississippi. */
.map-side { position: absolute; top: 0; right: 0; width: 29%; display: grid; gap: .75rem; }
.map-info { min-height: 5.5rem; font-size: .85rem; }
.map-info p { margin: .2rem 0; }
.map-info-name { display: block; font-size: .95rem; }
.map-info-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.map-legend p { margin: .3rem 0 0; color: var(--muted); font-size: .72rem; font-weight: 600; }
.legend-bar { height: 10px; border-radius: 5px; border: 1px solid var(--border); }
.legend-marks { position: relative; height: 1rem; margin: .15rem .5rem 0; font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.legend-marks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend-marks span:first-child { transform: none; margin-left: -.5rem; }
.legend-marks span:last-child { transform: translateX(-100%); margin-left: .5rem; }
@media (max-width: 560px) {
	.map-side { position: static; width: auto; grid-template-columns: 1fr 1fr; margin-top: .5rem; }
	.map-info { min-height: 0; }
}
.map-timeline { margin-top: .75rem; }
#map-date-controls { display: flex; align-items: flex-start; gap: .6rem; }
#map-date-controls .map-slider { flex: 1; }
#map-compare-controls { display: grid; gap: .5rem; }
.map-slider { display: grid; grid-template-columns: auto minmax(0, 1fr) 6.5rem; align-items: center; gap: .25rem .6rem; }
.map-slider label { font-size: .78rem; font-weight: 600; color: var(--muted); min-width: 2.6rem; }
.map-slider input { width: 100%; accent-color: var(--brand-strong); margin: 0; }
.map-slider output { font-weight: 650; font-size: .85rem; font-variant-numeric: tabular-nums; }
.map-ticks { grid-column: 2; position: relative; height: .9rem; margin: 0 8px; font-size: .68rem; color: var(--muted); }
.map-ticks span { position: absolute; transform: translateX(-50%); }
.map-play { flex: none; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.map-play:hover { background: var(--brand-strong); }
.map-table { margin-top: .75rem; }
.map-table summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .85rem; }
.map-table div { max-height: 320px; overflow: auto; margin-top: .5rem; }
.map-table table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.map-table th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; text-align: right; padding: .4rem; border-bottom: 1px solid var(--border); }
.map-table td { text-align: right; padding: .4rem; border-top: 1px solid var(--border); }
.map-table th:first-child, .map-table td:first-child { text-align: left; }
.map-table tbody tr { cursor: pointer; }
.map-table tbody tr:hover, .map-table tbody tr.is-selected { background: var(--surface-2); }

.map-info-actions { display: flex; flex-wrap: wrap; gap: 0 .9rem; }

/* Voter search results on a map */
#voter-results .card-head .segmented { margin: 0; }
.voter-map-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .75rem; }
.voter-map-bar p { margin: 0; }
.voter-map-search { display: flex; align-items: center; gap: .4rem; flex: 0 1 18rem; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.voter-map-search input { border: 0; background: transparent; color: var(--text); width: 100%; font: inherit; outline: none; }
.voter-map-search:focus-within { border-color: var(--brand-strong); }
.voter-map { height: min(68vh, 640px); min-height: 360px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); z-index: 0; }
.voter-map .leaflet-control-attribution { font-size: .65rem; }
.voter-map .leaflet-tile-pane { filter: saturate(.55) brightness(1.04); }
.voter-map.is-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.4); }
.voter-parish { cursor: zoom-in; transition: stroke-opacity .3s, fill-opacity .3s; }
.voter-map.is-close .voter-parish { stroke-opacity: 0; fill-opacity: 0; pointer-events: none; }
.voter-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); vertical-align: -2px; }
.voter-dot > span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.voter-dot.dot-dues { background: var(--chart-3); }
.voter-dot.dot-member { background: var(--chart-2); }
.voter-dot.dot-other { background: var(--chart-1); }
.leaflet-marker-icon.voter-dot { cursor: pointer; }
.leaflet-marker-icon.voter-dot:focus-visible { outline: 3px solid var(--text); outline-offset: 1px; }
.voter-cluster { display: grid; place-items: center; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .78rem; border: 3px solid rgba(255, 255, 255, .85); box-shadow: 0 1px 6px rgba(0, 0, 0, .35); font-variant-numeric: tabular-nums; }
.voter-map-tip { font-size: .8rem; }
.voter-map-fit { width: 34px; height: 34px; border: 2px solid rgba(0, 0, 0, .2); border-radius: 4px; background: #fff; color: #333; cursor: pointer; font-size: 1rem; }
.voter-map-fit:hover { background: #f4f4f4; }
.voter-map-legend { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.legend-toggle { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .8rem; font-weight: 600; cursor: pointer; }
.legend-toggle[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
#voter-unmapped .list-item { cursor: pointer; }
#voter-unmapped .list-item:hover { background: var(--surface-2); }

.movers { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 520px) { .movers { grid-template-columns: 1fr; } }
.movers h3 { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .4rem; }
.mover { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .2rem; border-bottom: 1px solid var(--border); font-size: .9rem; cursor: pointer; }
.mover:last-child { border-bottom: 0; }
.mover:hover { background: var(--surface-2); }

.bars { display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 4.5rem 1fr 3.5rem; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-row .track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; background: var(--chart-1); }
.bar-row .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.list { display: grid; }
.list-item { display: flex; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .date-chip { flex: none; width: 3.1rem; text-align: center; border-radius: var(--radius-sm); background: var(--surface-2); padding: .25rem 0; line-height: 1.1; }
.date-chip b { display: block; font-size: 1.1rem; }
.date-chip span { font-size: .68rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.list-item .body { min-width: 0; }
.list-item .body p { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; }
details.inquiry summary { cursor: pointer; list-style: none; }
details.inquiry summary::-webkit-details-marker { display: none; }
details.inquiry .message { white-space: pre-wrap; margin: .5rem 0 0; font-size: .9rem; color: var(--text); }

.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.skeleton-grid div { height: 110px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border: 1px solid var(--border); }
@media (max-width: 1100px) { .skeleton-grid { grid-template-columns: repeat(2, 1fr); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Voters & members ---------- */

.filter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 700px) { .filter-row { grid-template-columns: 1fr; } }
.filter-toggles { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin-top: 1rem; }
#sms-field { margin-top: 1rem; }
.picker-btn {
	display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; min-height: 44px;
	padding: .4rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-align: left;
}
.picker-btn:hover { border-color: var(--brand-strong); }
.picker-btn .fa { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; font-weight: 400; color: var(--muted); }
.chip { padding: .12rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .8rem; font-weight: 550; border: 1px solid var(--border); }

.table-card { padding: .9rem; overflow: hidden; }
table.dataTable { border-collapse: collapse !important; font-size: .9rem; }
table.dataTable thead th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border) !important; padding: .6rem .6rem !important; text-align: left; }
table.dataTable tbody td { border-top: 1px solid var(--border) !important; padding: .6rem !important; }
table.dataTable tbody tr { background: transparent !important; cursor: pointer; }
table.dataTable tbody tr:hover { background: var(--surface-2) !important; }
table.dataTable.no-footer { border-bottom: 0 !important; }
.dataTables_wrapper { color: var(--text) !important; }
.dataTables_wrapper .dataTables_filter input, .dataTables_wrapper .dataTables_length select {
	border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; background: var(--surface) !important; color: var(--text) !important; padding: .35rem .5rem !important;
}
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_length, .dataTables_wrapper .dataTables_filter { color: var(--muted) !important; font-size: .85rem; margin-bottom: .6rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: var(--text) !important; border-radius: 8px !important; border: 1px solid transparent !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current, .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { background: var(--brand) !important; color: var(--brand-ink) !important; border-color: transparent !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled { color: var(--muted) !important; opacity: .5; }
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before { background-color: var(--brand-strong) !important; box-shadow: none !important; border: 0 !important; }
.dataTables_wrapper .dataTables_paginate { padding-top: .75rem; }
.dataTables_filter { float: none !important; text-align: left !important; }
.dataTables_filter label { display: flex; align-items: center; gap: .5rem; }
.dataTables_filter input { margin-left: 0 !important; flex: 1; max-width: 18rem; }
td .badge { margin-left: .35rem; }
td .badge.member-type { float: right; margin-left: .5rem; }

/* ---------- Drawer (voter / member detail) ---------- */

.drawer-backdrop, .sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 40; animation: fade-in .15s ease; }
.drawer {
	position: fixed; inset: 0 0 0 auto; width: min(560px, 100vw); z-index: 41;
	display: flex; flex-direction: column; background: var(--bg); box-shadow: var(--shadow-lg);
	animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-body { overflow-y: auto; padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom)); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.drawer .card { margin-bottom: .85rem; }
.profile-head { display: flex; gap: .9rem; align-items: center; margin-bottom: .9rem; }
.avatar { display: grid; place-items: center; flex: none; width: 52px; height: 52px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 35%, transparent); font-weight: 750; font-size: 1.1rem; }
.profile-head .badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .3rem; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .85rem; }
.quick-actions .btn { flex-direction: column; gap: .2rem; padding: .65rem .3rem; font-size: .8rem; }
.quick-actions .btn .fa { font-size: 1.1rem; color: var(--brand-strong); }
.quick-actions .btn.is-disabled { opacity: .45; pointer-events: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.map-frame { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); margin-top: .85rem; }
.map-frame iframe { display: block; width: 100%; height: 220px; border: 0; }
.timeline { display: grid; gap: .65rem; }
.note { padding: .65rem .8rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.note .meta { font-size: .75rem; color: var(--muted); font-weight: 600; margin-bottom: .2rem; }
.note .text { white-space: pre-wrap; font-size: .9rem; }
.vote-chips { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ---------- Sheets (pickers, settings) ---------- */

.sheet {
	position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
	width: min(520px, calc(100vw - 2rem)); max-height: min(80vh, 720px);
	display: flex; flex-direction: column; padding: 1rem; border-radius: var(--radius);
	background: var(--surface); box-shadow: var(--shadow-lg); animation: fade-in .15s ease;
}
@media (max-width: 600px) {
	.sheet { left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%; max-height: 88vh; border-radius: var(--radius) var(--radius) 0 0; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; }
.picker-tools { display: flex; gap: 1rem; margin: -.25rem 0 .4rem; font-size: .85rem; }
.picker-list { overflow-y: auto; overscroll-behavior: contain; margin: 0 -1rem; padding: 0 1rem; }
.picker-group { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .8rem 0 .25rem; }
.picker-option { display: flex; align-items: center; gap: .7rem; padding: .55rem .4rem; border-radius: var(--radius-sm); cursor: pointer; }
.picker-option:hover { background: var(--surface-2); }
.picker-option input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand-strong); flex: none; }
/* Collapsible sections (wards, precincts and districts) */
.picker-section { border-bottom: 1px solid var(--border); }
.picker-section > summary { display: flex; align-items: center; gap: .5rem; padding: .7rem .4rem; cursor: pointer; font-weight: 650; list-style: none; border-radius: var(--radius-sm); }
.picker-section > summary::-webkit-details-marker { display: none; }
.picker-section > summary::before { content: '\f105'; font-family: FontAwesome; width: .8rem; color: var(--muted); transition: transform .15s; }
.picker-section[open] > summary::before { transform: rotate(90deg); }
.picker-section > summary:hover { background: var(--surface-2); }
.picker-count { margin-left: auto; color: var(--muted); font-size: .78rem; font-weight: 600; }
.picker-section.has-picks > summary .picker-count { color: var(--accent); }
.picker-section > .picker-option, .picker-section > .picker-sub { margin-left: 1.2rem; }
.picker-sub { border-bottom: 0; }
.picker-sub > summary { font-weight: 600; font-size: .9rem; padding: .5rem .4rem; }
.settings-body { display: grid; gap: 1.1rem; }
.settings-body .segmented { margin: 0; }

/* ---------- Events ---------- */

.events-layout { display: grid; gap: 1rem; }
.event-card-list { display: grid; gap: .75rem; }
.event-card-record { padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.event-card-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .4rem; }
.event-card-header > div { display: flex; gap: .35rem; flex-wrap: wrap; }
.event-type-badge, .event-status-badge { display: inline-flex; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 650; background: var(--surface-2); color: var(--muted); }
.event-status-active { background: color-mix(in srgb, var(--positive) 15%, transparent); color: var(--positive); }
.event-status-inactive { background: color-mix(in srgb, var(--negative) 12%, transparent); color: var(--negative); }
.event-card-date { font-weight: 650; font-size: .9rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.event-card-date span { color: var(--muted); font-weight: 500; }
.event-date-missing { color: var(--negative); }
.event-card-record h3 { margin: .3rem 0; font-size: 1.05rem; }
.event-card-location { display: grid; gap: .1rem; font-size: .88rem; }
.event-card-location span { color: var(--muted); }
.event-card-description { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }
.event-results-summary { color: var(--muted); font-size: .82rem; margin-bottom: .6rem; }
.event-empty-state { display: grid; gap: .25rem; text-align: center; color: var(--muted); padding: 1.5rem; margin: 0; }
.event-error { color: var(--negative); }
.event-button { display: inline-flex; padding: .35rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: .82rem; cursor: pointer; }
.event-button:hover { background: var(--surface-2); }
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin-top: 1rem; }
.event-page-button { min-width: 2.2rem; padding: .35rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: .85rem; }
.event-page-button[aria-current="page"] { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.event-page-button:disabled { opacity: .45; cursor: default; }
.event-page-gap { padding: .35rem .2rem; color: var(--muted); }
#event_form_message { font-size: .88rem; color: var(--muted); }
#event_form_message.error { color: var(--negative); }
#event_form_message.success { color: var(--positive); }

/* ---------- Audio ---------- */

.audio-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.audio-item:last-child { border-bottom: 0; }
.audio-item audio { grid-column: 1 / -1; width: 100%; height: 36px; }
.audio-item .meta { color: var(--muted); font-size: .8rem; }

/* ---------- Toasts & loading ---------- */

.toasts { position: fixed; z-index: 60; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: .5rem; width: min(420px, calc(100vw - 2rem)); pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 1.5rem; } }
.toast { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: .9rem; animation: fade-in .15s ease; pointer-events: auto; }
.toast.error { background: var(--negative); color: #fff; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Donors ---------- */

.head-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
.head-actions p { margin: 0; }
#donor-kpis { margin-bottom: 1rem; }
#donor-kpis .skeleton-grid { grid-column: 1 / -1; }
@media (max-width: 400px) { .tabbar a { font-size: .62rem; } }
#campaign-filter, #campaign-status { display: flex; width: fit-content; max-width: 100%; }
#campaign-filter { margin-bottom: .6rem; }
.campaign-area-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .campaign-area-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .campaign-area-row { grid-template-columns: 1fr; } }
#campaign-area-clear { margin-top: .75rem; }
.contact-icons { display: inline-flex; align-items: center; gap: .55rem; flex-wrap: wrap; color: var(--muted); }
.social-link { color: var(--muted); text-decoration: none; font-size: 1.05rem; line-height: 1; }
.social-link:hover, .social-link:focus-visible { color: var(--brand-strong); }
#campaign-table thead th.contact-filter { cursor: pointer; white-space: nowrap; }
#campaign-table thead th.contact-filter .fa-filter { color: var(--muted); margin-left: .2rem; }
#campaign-table thead th.contact-filter .fa-filter.is-on { color: var(--brand-strong); }
#campaign-table thead th.contact-filter:hover .fa-filter { color: var(--brand-strong); }
.campaign-badges { display: inline-flex; gap: .25rem; flex-wrap: wrap; vertical-align: middle; }
.donor-month-row { justify-content: space-between; cursor: pointer; border-radius: var(--radius-sm); }
.donor-month-row:hover { background: var(--surface-2); }
.donor-month-row .amount { white-space: nowrap; }

/* ---------- Events (list and editor) ---------- */

.event-filters { display: grid; gap: .25rem; margin-bottom: .5rem; }
.event-filters .segmented { margin-bottom: .5rem; }
.event-month { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.25rem 0 .6rem; }
.event-row { display: flex; gap: 1rem; align-items: flex-start; margin-bottom: .75rem; }
.event-row.is-hidden { opacity: .72; border-style: dashed; }
.date-chip.big { flex: none; width: 3.6rem; text-align: center; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--brand) 22%, var(--surface)); padding: .35rem 0; line-height: 1.15; }
.date-chip.big b { display: block; font-size: 1.45rem; }
.date-chip.big span { display: block; font-size: .68rem; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.event-body { min-width: 0; flex: 1; display: grid; gap: .3rem; }
.event-body h3 { font-size: 1.05rem; margin: 0; }
.event-body .badges { display: flex; gap: .35rem; flex-wrap: wrap; }
.event-meta { margin: 0; font-size: .88rem; color: var(--text); }
.event-meta .fa { width: 1rem; color: var(--muted); }
.event-row:not(.preview) .event-description { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.event-description { margin: 0; font-size: .88rem; color: var(--muted); white-space: pre-line; }
.event-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .35rem; }
.event-author { margin-left: auto; }
@media (max-width: 520px) { .event-author { margin-left: 0; width: 100%; } .event-row { gap: .75rem; } }

.event-editor fieldset.card { border: 1px solid var(--border); margin: 0 0 .85rem; display: grid; gap: .9rem; min-width: 0; }
.event-editor legend { float: left; width: 100%; padding: 0; margin-bottom: .1rem; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.event-editor legend + * { clear: both; }
.fb-import { margin: 0 0 .85rem; display: grid; gap: .6rem; }
.fb-import .eyebrow { margin: 0; }
.fb-import .eyebrow .fa { color: #1877f2; }
.fb-import-row { display: flex; gap: .5rem; }
.fb-import-row input { flex: 1; min-width: 0; }
.fb-import .hint { margin: 0; }
.fb-import .notice { margin: 0; }
.fb-import .notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.type-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.type-chip { cursor: pointer; }
.type-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type-chip span { display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550; font-size: .85rem; }
.type-chip input:checked + span { background: color-mix(in srgb, var(--brand) 35%, var(--surface)); border-color: var(--brand-strong); }
.type-chip input:focus-visible + span { outline: 2px solid var(--info); outline-offset: 2px; }
.counter, .hint { font-size: .78rem; font-weight: 500; color: var(--muted); }
.hint.warn { color: var(--negative); }
.quick-durations { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.event-preview-card { background: var(--surface-2); }
.event-preview-card .event-row { margin: .4rem 0 0; }
.drawer-footer {
	position: sticky; bottom: calc(-2rem - env(safe-area-inset-bottom)); z-index: 2;
	display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
	margin: 0 -1rem calc(-2rem - env(safe-area-inset-bottom)); padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
	background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
	border-top: 1px solid var(--border);
}
.drawer-footer .spacer { flex: 1; }
.btn.danger { color: var(--negative); }
.btn.danger:hover { background: color-mix(in srgb, var(--negative) 10%, var(--surface)); }

/* ---------- Dashboard: "Who they are" ---------- */

.profile-stats em { display: block; font-style: normal; font-weight: 500; color: var(--muted); font-size: .72rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.25rem 2rem; margin-top: .5rem; }
.profile-panel h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .55rem; }
.profile-panel .bar-row { grid-template-columns: 7.5rem 1fr 2.75rem; }
.bar-row .track { position: relative; overflow: visible; }
.bar-row .marker { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--muted); opacity: .8; }
