/* PIAF Election CRM — field application stylesheet.
 *
 * Hand-written and dependency-free on purpose: field agents open this on cheap
 * Android handsets over patchy 3G, so the whole UI ships as one small file with
 * no framework runtime behind it.
 *
 * Everything is driven by the tokens in :root. Change the palette there and the
 * entire app follows.
 */

/* ========================================================================
   Tokens
   ======================================================================== */

:root {
	--navy-950: #071d2a;
	--navy-900: #0b2a3c;
	--navy-800: #11394f;
	--navy-700: #1a4c64;
	--navy-600: #24627e;
	--navy-200: #b9d2de;
	--navy-100: #deebf0;
	--navy-50:  #f1f7f9;

	--emerald-800: #075c4a;
	--emerald-700: #08745c;
	--emerald-600: #0d8a6d;
	--emerald-100: #dff4ed;
	--emerald-50:  #eff9f6;

	--gold-700:  #8a5c06;
	--gold-600:  #a46f08;
	--gold-500:  #c58a19;
	--gold-100:  #f7e9bf;
	--gold-50:   #fff9e8;

	--red-700:   #a8323e;
	--red-600:   #c23c4a;
	--red-100:   #f9dfe2;
	--red-50:    #fff4f5;

	--orange-700: #a24c0e;
	--orange-100: #fbe6d6;

	--slate-900: #16212b;
	--slate-700: #3d4d5c;
	--slate-500: #64798a;
	--slate-400: #8798a6;
	--slate-300: #c2ced7;
	--slate-200: #dde5ea;
	--slate-100: #eef3f6;
	--white: #ffffff;

	/* Semantic roles */
	--bg: var(--navy-50);
	--bg-raised: var(--white);
	--bg-sunken: #e7eef2;
	--bg-inverse: var(--navy-900);
	--text: var(--slate-900);
	--text-muted: var(--slate-500);
	--text-inverse: #eaf3f7;
	--border: var(--slate-200);
	--border-strong: var(--slate-300);
	--accent: var(--navy-900);
	--accent-text: #ffffff;
	--positive: var(--emerald-700);
	--positive-bg: var(--emerald-50);
	--caution: var(--gold-600);
	--caution-bg: var(--gold-50);
	--negative: var(--red-700);
	--negative-bg: var(--red-50);

	--radius-sm: 6px;
	--radius: 10px;
	--radius-lg: 16px;
	--shadow-sm: 0 1px 2px rgba(7, 29, 42, 0.08);
	--shadow: 0 2px 10px rgba(7, 29, 42, 0.09);
	--shadow-lg: 0 18px 44px rgba(7, 29, 42, 0.20);

	--space-1: 4px;
	--space-2: 8px;
	--space-3: 12px;
	--space-4: 16px;
	--space-5: 24px;
	--space-6: 32px;
	--space-7: 48px;

	--font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

	--topbar-h: 60px;
	--sidenav-w: 232px;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #0a1720;
		--bg-raised: #10222e;
		--bg-sunken: #071219;
		--bg-inverse: #061620;
		--text: #e6eef3;
		--text-muted: #92a7b5;
		--text-inverse: #e6eef3;
		--border: #1e3746;
		--border-strong: #2b4b5e;
		--accent: var(--emerald-600);
		--accent-text: #04211a;
		--positive: #3fbe9b;
		--positive-bg: #0d2a25;
		--caution: #d9a63c;
		--caution-bg: #2b2313;
		--negative: #e2707c;
		--negative-bg: #2c1519;
		--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
		--shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
		--shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
	}
}

/* ========================================================================
   Base
   ======================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* The `hidden` attribute must beat the layout `display` values set on .boot,
   .auth and .shell below. Those are class selectors, and a class selector wins
   over the user-agent `[hidden] { display: none }` rule — without this, hiding
   a screen has no visual effect and all three render stacked on top of one
   another. */
[hidden] { display: none !important; }

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0 0 var(--space-3); line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: 0.92rem; }
p { margin: 0 0 var(--space-3); }

a { color: var(--navy-700); }
@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) a { color: var(--positive); }
}

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
	text-transform: uppercase;
	letter-spacing: 0.09em;
	font-size: 0.72rem;
	font-weight: 700;
	color: var(--text-muted);
	margin: 0 0 var(--space-2);
}

.sr-only {
	position: absolute;
	width: 1px; height: 1px;
	padding: 0; margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
	border: 0;
}

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var(--accent);
	color: var(--accent-text);
	padding: var(--space-3) var(--space-4);
	z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
	outline: 2px solid var(--navy-600);
	outline-offset: 2px;
	border-radius: 3px;
}

/* ========================================================================
   Brand mark
   ======================================================================== */

.mark {
	display: grid;
	place-items: center;
	width: 34px; height: 34px;
	border-radius: 9px;
	background: linear-gradient(145deg, var(--navy-800), var(--navy-950));
	color: #fff;
	font-weight: 800;
	letter-spacing: -0.02em;
	flex: none;
}
.mark--lg { width: 56px; height: 56px; border-radius: 15px; font-size: 1.5rem; }

/* ========================================================================
   Boot screen
   ======================================================================== */

.boot {
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: var(--space-5);
}
.boot__card { text-align: center; max-width: 380px; }
.boot__card .mark { margin: 0 auto var(--space-4); }
.boot__title { font-size: 1.25rem; margin-bottom: var(--space-4); }

.progress {
	height: 4px;
	border-radius: 999px;
	background: var(--bg-sunken);
	overflow: hidden;
	margin-bottom: var(--space-4);
}
.progress > span {
	display: block;
	height: 100%;
	width: 35%;
	border-radius: inherit;
	background: var(--accent);
	animation: slide 1.25s ease-in-out infinite;
}
/* Determinate variant. The animated bar above says "something is happening";
   this one says how far through it is, which is the only useful thing to show
   somebody watching twenty thousand rows import. */
.progress__fill {
	display: block;
	height: 100%;
	border-radius: inherit;
	background: var(--accent);
	transition: width 240ms ease-out;
}
@keyframes slide {
	0%   { transform: translateX(-100%); }
	100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
	.progress > span { animation: none; width: 100%; opacity: 0.5; }
	.sidenav { transition: none; }
}

/* ========================================================================
   Auth
   ======================================================================== */

.auth {
	min-height: 100dvh;
	display: grid;
	place-items: center;
	padding: var(--space-5);
	background:
		radial-gradient(900px 500px at 10% -10%, rgba(13, 138, 109, 0.14), transparent 60%),
		radial-gradient(800px 500px at 110% 10%, rgba(26, 76, 100, 0.16), transparent 55%),
		var(--bg);
}

.auth__panel {
	width: min(980px, 100%);
	display: grid;
	grid-template-columns: 1.05fr 0.95fr;
	gap: var(--space-7);
	align-items: center;
}
.auth__brand h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-bottom: var(--space-3); }
.auth__brand .mark { margin-bottom: var(--space-4); }
.auth__forms { display: grid; gap: var(--space-4); }

@media (max-width: 860px) {
	.auth__panel { grid-template-columns: 1fr; gap: var(--space-5); }
	.auth__brand h1 br { display: none; }
}

/* ========================================================================
   Shell
   ======================================================================== */

.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
	position: sticky;
	top: 0;
	z-index: 30;
	height: var(--topbar-h);
	display: flex;
	align-items: center;
	gap: var(--space-3);
	padding: 0 var(--space-4);
	background: var(--bg-raised);
	border-bottom: 1px solid var(--border);
	padding-top: env(safe-area-inset-top);
}
.topbar__brand { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.topbar__titles { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.topbar__titles strong { font-size: 0.98rem; }
.topbar__titles span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.scope-picker select {
	max-width: 190px;
	padding: 7px 10px;
	font: inherit;
	font-size: 0.86rem;
	color: var(--text);
	background: var(--bg);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
}

.shell__body { flex: 1; display: flex; min-height: 0; }

.sidenav {
	width: var(--sidenav-w);
	flex: none;
	transition: width 0.16s ease;
	padding: var(--space-4) var(--space-3);
	background: var(--bg-raised);
	border-right: 1px solid var(--border);
	overflow-y: auto;
}
.sidenav__group + .sidenav__group { margin-top: var(--space-5); }
.sidenav__label {
	font-size: 0.68rem;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	font-weight: 700;
	color: var(--text-muted);
	padding: 0 var(--space-3) var(--space-2);
}

.navlink {
	display: flex;
	align-items: center;
	gap: var(--space-3);
	width: 100%;
	padding: 9px var(--space-3);
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 0.9rem;
	text-align: left;
	cursor: pointer;
}
.navlink { position: relative; }
.navlink:hover { background: var(--bg-sunken); }
.navlink[aria-current="page"] {
	background: var(--bg-inverse);
	color: var(--text-inverse);
	font-weight: 600;
}
.navlink__icon {
	width: 18px;
	height: 18px;
	flex: none;
	/* Slightly recessed so the label leads and the icons read as a column of
	   markers rather than competing with the text. */
	opacity: 0.7;
}
.navlink:hover .navlink__icon { opacity: 0.9; }
.navlink[aria-current="page"] .navlink__icon { opacity: 1; }

.navlink__label {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.navlink__count {
	margin-left: auto;
	font-size: 0.74rem;
	font-weight: 700;
	padding: 1px 7px;
	border-radius: 999px;
	background: var(--caution-bg);
	color: var(--caution);
}
.navlink[aria-current="page"] .navlink__count { background: rgba(255,255,255,0.16); color: inherit; }

.main {
	flex: 1;
	min-width: 0;
	padding: var(--space-5);
	padding-bottom: calc(var(--space-7) + env(safe-area-inset-bottom));
	overflow-x: hidden;
}
.screen { max-width: 1180px; margin: 0 auto; }

@media (max-width: 900px) {
	.sidenav {
		position: fixed;
		inset: var(--topbar-h) auto 0 0;
		z-index: 25;
		transform: translateX(-100%);
		transition: transform 0.18s ease;
		box-shadow: var(--shadow-lg);
	}
	.app-root[data-nav="open"] .sidenav { transform: none; }
	.main { padding: var(--space-4); }
}
/* Collapsed rail — desktop.
 *
 * The toggle used to be hidden here with `.nav-toggle { display: none }`, which
 * never worked: `.icon-btn { display: grid }` has the same specificity and is
 * declared later, so it won. The button now has a real job on desktop instead
 * of being hidden, so the rule is gone rather than patched with !important.
 *
 * Collapsing overrides --sidenav-w on the app root, so the width change flows
 * through the same token the expanded nav uses; nothing measures the sidebar
 * twice. */
@media (min-width: 901px) {
	.app-root[data-nav="rail"] { --sidenav-w: 64px; }

	.app-root[data-nav="rail"] .sidenav { padding: var(--space-4) var(--space-2); }

	.app-root[data-nav="rail"] .navlink {
		justify-content: center;
		padding: 10px 0;
	}

	/* Hidden visually, still in the accessibility tree: each link carries an
	   aria-label, so a screen reader still announces the destination. */
	.app-root[data-nav="rail"] .navlink__label { display: none; }

	/* The group heading collapses to a rule, so the sections stay legible
	   without their words. */
	.app-root[data-nav="rail"] .sidenav__label {
		height: 0;
		padding: 0;
		margin: 0 auto var(--space-2);
		width: 24px;
		overflow: hidden;
		border-top: 1px solid var(--border);
	}
	.app-root[data-nav="rail"] .sidenav__group:first-child .sidenav__label {
		border-top: 0;
		margin-bottom: 0;
	}

	/* A count would not fit beside a centred icon, so it rides on top of it. */
	.app-root[data-nav="rail"] .navlink__count {
		position: absolute;
		top: 2px;
		right: 8px;
		margin: 0;
		min-width: 16px;
		padding: 0 4px;
		font-size: 0.66rem;
		line-height: 16px;
		text-align: center;
	}

	.app-root[data-nav="rail"] .navlink__icon { width: 20px; height: 20px; }
}

.burger, .burger::before, .burger::after {
	display: block;
	width: 17px; height: 2px;
	background: currentColor;
	border-radius: 2px;
	content: "";
}
.burger { position: relative; }
.burger::before { position: absolute; top: -5px; }
.burger::after  { position: absolute; top: 5px; }

/* ========================================================================
   Buttons & form controls
   ======================================================================== */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--space-2);
	padding: 9px 15px;
	min-height: 38px;
	border: 1px solid transparent;
	border-radius: var(--radius-sm);
	background: var(--bg-sunken);
	color: var(--text);
	font: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.btn--primary   { background: var(--accent); color: var(--accent-text); }
.btn--secondary { background: var(--bg-raised); border-color: var(--border-strong); }
.btn--ghost     { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn--positive  { background: var(--positive); color: #fff; }
.btn--danger    { background: var(--negative); color: #fff; }
.btn--sm { min-height: 30px; padding: 4px 10px; font-size: 0.82rem; }
.btn--block { width: 100%; }

.icon-btn {
	display: grid;
	place-items: center;
	width: 36px; height: 36px;
	border: 0;
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text);
	cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunken); }

.field { display: block; margin-bottom: var(--space-3); }
.field > span {
	display: block;
	margin-bottom: 5px;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
	width: 100%;
	padding: 9px 11px;
	font: inherit;
	font-size: 0.92rem;
	color: var(--text);
	background: var(--bg-raised);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius-sm);
}
.field textarea { resize: vertical; min-height: 62px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy-600); }

.check {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	padding: 7px 0;
	font-size: 0.9rem;
	cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }

.stack { display: grid; gap: var(--space-1); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: var(--space-3); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

/* ========================================================================
   Cards, tiles, tables
   ======================================================================== */

.card {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: var(--space-4);
	box-shadow: var(--shadow-sm);
}
.card--muted { background: var(--bg-sunken); box-shadow: none; }
.card + .card { margin-top: var(--space-4); }
.card > h2, .card > h3 { margin-bottom: var(--space-3); }

.card__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	margin-bottom: var(--space-3);
	flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; }

.screen__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: var(--space-3);
	margin-bottom: var(--space-4);
	flex-wrap: wrap;
}
.screen__head h1 { margin: 0; }

.tile {
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: var(--space-4);
	box-shadow: var(--shadow-sm);
}
.tile__label {
	font-size: 0.76rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--text-muted);
	margin-bottom: 6px;
}
.tile__value {
	font-size: 1.85rem;
	font-weight: 700;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
}
.tile__hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; }
.tile--positive .tile__value { color: var(--positive); }
.tile--caution  .tile__value { color: var(--caution); }
.tile--negative .tile__value { color: var(--negative); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.88rem;
}
table.data th, table.data td {
	padding: 9px var(--space-3);
	text-align: left;
	border-bottom: 1px solid var(--border);
	white-space: nowrap;
}
table.data th {
	font-size: 0.74rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-muted);
	background: var(--bg-sunken);
	position: sticky;
	top: 0;
}
table.data tbody tr:hover { background: var(--bg-sunken); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.wrap { white-space: normal; min-width: 200px; }

/* ========================================================================
   Badges, pills, bars
   ======================================================================== */

.badge {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	padding: 2px 9px;
	border-radius: 999px;
	font-size: 0.75rem;
	font-weight: 700;
	background: var(--bg-sunken);
	color: var(--text-muted);
	white-space: nowrap;
}
.badge--positive { background: var(--positive-bg); color: var(--positive); }
.badge--caution  { background: var(--caution-bg);  color: var(--caution); }
.badge--negative { background: var(--negative-bg); color: var(--negative); }
.badge--info     { background: var(--navy-100);    color: var(--navy-800); }

.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
/* Sits inside a card heading rather than above a screen, so it needs to stay
   out of the heading's way. */
.chips--tight { gap: 4px; }

/* Committed search terms. Each is removable, and they OR together. */
.facets {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	align-items: center;
	margin-top: var(--space-3);
}
.facet {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 6px 4px 10px;
	border-radius: 999px;
	background: var(--bg-sunken);
	border: 1px solid var(--border-strong);
	font-size: 0.82rem;
	max-width: 100%;
}
.facet__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.facet__x {
	border: 0;
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	font-size: 0.75rem;
	line-height: 1;
	padding: 3px;
	border-radius: 50%;
}
.facet__x:hover { color: var(--negative); background: var(--bg-raised); }

/* Who rates this voter, and how. Sits on the card so a coordinator scanning a
   list can see two of their agents disagreeing without opening anything. */
.claim-ribbon {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 10px;
	margin-top: 6px;
	font-size: 0.76rem;
}
.claim-ribbon--split { padding-left: 6px; border-left: 2px solid var(--caution); }
.claim-ribbon__flag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 15px;
	height: 15px;
	border-radius: 50%;
	background: var(--caution);
	color: #12212b;
	font-weight: 700;
	font-size: 0.66rem;
}
.claim-ribbon__item { display: inline-flex; align-items: center; gap: 4px; }
.claim-ribbon__who { color: var(--text-muted); }
.claim-ribbon__level { font-weight: 600; }

/* --- hierarchy tree ------------------------------------------------------ */

.tree { display: grid; gap: 2px; }
.tree__row {
	display: flex;
	align-items: stretch;
	/* One indent step per level. A CSS variable rather than nested markup so
	   the server can keep sending a flat list with a depth on each row. */
	padding-left: calc(var(--depth, 0) * 22px);
}
.tree__spine {
	width: 3px;
	flex: 0 0 3px;
	margin-right: 10px;
	border-radius: 2px;
	background: var(--border-strong);
}
.tree__row[style*="--depth:0"] .tree__spine { background: var(--accent); }
.tree__body {
	flex: 1;
	min-width: 0;
	padding: 8px 0;
	border-bottom: 1px solid var(--border);
}
.tree__row:last-child .tree__body { border-bottom: 0; }
.tree__name { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.chips--tight .chip { padding: 3px 10px; font-size: 0.78rem; }
.chip {
	padding: 5px 11px;
	border: 1px solid var(--border-strong);
	border-radius: 999px;
	background: var(--bg-raised);
	color: var(--text);
	font: inherit;
	font-size: 0.82rem;
	font-weight: 600;
	cursor: pointer;
}
/* The selected filter, and it has to *look* selected.
   This used to paint the pressed chip with --bg-inverse / --text-inverse. In
   the light theme that is a navy pill with white text and reads correctly. In
   the dark theme --bg-inverse (#061620) is darker than the chip's own
   background and --text-inverse is the same colour as --text, so the chosen
   chip lost its border and sank into the card while every unchosen chip kept a
   visible outline - the selection read as the exact opposite of itself.
   --accent is the colour this app already uses for "this one": it is navy in
   the light theme, so nothing changes there, and green in the dark one. */
.chip[aria-pressed="true"] {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--accent-text);
}

.bar {
	height: 8px;
	border-radius: 999px;
	background: var(--bg-sunken);
	overflow: hidden;
}
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar--positive > span { background: var(--positive); }
.bar--caution  > span { background: var(--caution); }
.bar--negative > span { background: var(--negative); }
/* "Uncontacted" is the absence of an answer, not a good one - it must not read
   as green next to the stages that were actually earned. */
.bar--neutral  > span { background: var(--slate-400); }

.meter { display: grid; gap: 5px; margin-bottom: var(--space-3); }
.meter__top { display: flex; justify-content: space-between; font-size: 0.84rem; gap: var(--space-3); }
.meter__top b { font-variant-numeric: tabular-nums; }

/* Support-level colour coding, used everywhere a level is shown. */
.support { font-weight: 650; }
.support--100-confirmed-voter { color: var(--emerald-700); }
.support--positive            { color: var(--emerald-600); }
.support--maybe               { color: var(--gold-600); }
.support--not-supporting      { color: var(--red-700); }
.support--uncontacted         { color: var(--text-muted); }

/* ========================================================================
   Voter list & profile
   ======================================================================== */

.voter-list { display: grid; gap: var(--space-2); }

.voter-card {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: var(--space-3);
	align-items: center;
	width: 100%;
	padding: var(--space-3) var(--space-4);
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-left: 3px solid var(--border-strong);
	border-radius: var(--radius-sm);
	font: inherit;
	text-align: left;
	color: inherit;
	cursor: pointer;
}
.voter-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.voter-card__name { font-weight: 650; }
.voter-card__meta {
	display: flex;
	gap: var(--space-3);
	flex-wrap: wrap;
	font-size: 0.8rem;
	color: var(--text-muted);
	margin-top: 2px;
}
.voter-card__right { display: flex; align-items: center; gap: var(--space-2); }

.voter-card[data-support="100% Confirmed Voter"] { border-left-color: var(--emerald-700); }
.voter-card[data-support="Positive"]             { border-left-color: var(--emerald-600); }
.voter-card[data-support="Maybe"]                { border-left-color: var(--gold-500); }
.voter-card[data-support="Not Supporting"]       { border-left-color: var(--red-700); }
.voter-card[data-voted="1"] { background: var(--positive-bg); }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px var(--space-4); font-size: 0.9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 550; }

.timeline { display: grid; gap: var(--space-3); }
.timeline__item {
	display: grid;
	grid-template-columns: 8px 1fr;
	gap: var(--space-3);
	padding-bottom: var(--space-3);
	border-bottom: 1px solid var(--border);
}
.timeline__dot {
	width: 8px; height: 8px;
	margin-top: 6px;
	border-radius: 50%;
	background: var(--border-strong);
}
.timeline__item:last-child { border-bottom: 0; padding-bottom: 0; }

/* Duplicate review: two records side by side, differences highlighted. */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 720px) { .compare { grid-template-columns: 1fr; } }
.compare__side { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); }
.compare__side[data-keep="1"] { border-color: var(--positive); background: var(--positive-bg); }
.compare__row { display: grid; grid-template-columns: 110px 1fr; gap: var(--space-2); padding: 4px 0; font-size: 0.86rem; }
.compare__row dt { color: var(--text-muted); }
.compare__row[data-differs="1"] dd { background: var(--caution-bg); color: var(--caution); border-radius: 3px; padding: 0 4px; font-weight: 650; }

/* ========================================================================
   Voter board (kanban)
   ======================================================================== */

/* The board scrolls horizontally inside itself; the page body never does.
   Columns keep a fixed width so a card is always legible rather than being
   squeezed to nothing when seven columns are on screen. */
.board {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(232px, 1fr);
	gap: var(--space-3);
	overflow-x: auto;
	overscroll-behavior-x: contain;
	padding-bottom: var(--space-3);
	scroll-snap-type: x proximity;
}

.board__column {
	display: flex;
	flex-direction: column;
	min-width: 0;
	background: var(--bg-sunken);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: var(--space-3);
	scroll-snap-align: start;
}
.board__column[data-dropping="1"] {
	border-color: var(--accent);
	box-shadow: inset 0 0 0 2px var(--accent);
}

.board__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-2);
	margin-bottom: var(--space-3);
	padding-bottom: var(--space-2);
	border-bottom: 1px solid var(--border);
}
.board__count {
	font-size: 0.78rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	padding: 1px 8px;
	border-radius: 999px;
	background: var(--bg-raised);
	color: var(--text-muted);
}

.board__cards {
	display: grid;
	gap: var(--space-2);
	align-content: start;
	min-height: 60px;
	/* Tall columns scroll independently so the headers stay comparable. */
	max-height: 62vh;
	overflow-y: auto;
}

.board__card {
	display: grid;
	gap: 6px;
	padding: var(--space-3);
	background: var(--bg-raised);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	box-shadow: var(--shadow-sm);
}
.board__card[draggable="true"] { cursor: grab; }
.board__card[data-dragging="1"] { opacity: 0.45; cursor: grabbing; }

.board__open {
	display: grid;
	gap: 2px;
	width: 100%;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-align: left;
	cursor: pointer;
}
.board__name { font-weight: 650; line-height: 1.3; }
.board__sub,
.board__meta { font-size: 0.78rem; color: var(--text-muted); }

.board__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.board__tags .badge { font-size: 0.68rem; padding: 1px 7px; }

.board__move { display: block; }
.board__select {
	width: 100%;
	padding: 4px 6px;
	font: inherit;
	font-size: 0.78rem;
	color: var(--text-muted);
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
}
.board__select:focus { color: var(--text); border-color: var(--navy-600); }

.board__loadmore {
	width: 100%;
	padding: 7px;
	border: 1px dashed var(--border-strong);
	border-radius: var(--radius-sm);
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-size: 0.76rem;
	font-weight: 600;
	cursor: pointer;
}
.board__loadmore:hover { background: var(--bg-raised); color: var(--text); }
.board__loadmore[aria-busy="true"] { opacity: 0.6; cursor: progress; }

.board__empty,
.board__more {
	margin: 0;
	padding: var(--space-2);
	font-size: 0.78rem;
	color: var(--text-muted);
	text-align: center;
}

/* Colour the column by what it means, matching the support scale used
   everywhere else in the app. */
.board__column[data-level="100% Confirmed Voter"] { border-top: 3px solid var(--emerald-700); }
.board__column[data-level="Positive"]             { border-top: 3px solid var(--emerald-600); }
.board__column[data-level="Maybe"]                { border-top: 3px solid var(--gold-500); }
.board__column[data-level="Uncontacted"]          { border-top: 3px solid var(--slate-400); }
.board__column[data-level="Not Supporting"]       { border-top: 3px solid var(--red-700); }

@media (max-width: 700px) {
	/* One column at a time on a phone, swiped between. */
	.board { grid-auto-columns: 85%; }
	.board__cards { max-height: none; }
}

/* ========================================================================
   Alerts, toasts, modal, empty states
   ======================================================================== */

.alert {
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-sm);
	border: 1px solid var(--border);
	background: var(--bg-sunken);
	font-size: 0.88rem;
	margin-bottom: var(--space-3);
}
.alert--error    { background: var(--negative-bg); border-color: var(--negative); color: var(--negative); }
.alert--success  { background: var(--positive-bg); border-color: var(--positive); color: var(--positive); }
.alert--warning  { background: var(--caution-bg);  border-color: var(--caution);  color: var(--caution); }

.toasts {
	position: fixed;
	left: 50%;
	bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
	transform: translateX(-50%);
	z-index: 90;
	display: grid;
	gap: var(--space-2);
	width: min(440px, calc(100vw - 32px));
}
.toast {
	padding: var(--space-3) var(--space-4);
	border-radius: var(--radius-sm);
	background: var(--bg-inverse);
	color: var(--text-inverse);
	box-shadow: var(--shadow-lg);
	font-size: 0.88rem;
	animation: rise 0.16s ease-out;
}
.toast--error    { background: var(--red-700); color: #fff; }
.toast--success  { background: var(--emerald-700); color: #fff; }
@keyframes rise {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

.modal {
	position: fixed;
	inset: 0;
	z-index: 80;
	display: grid;
	place-items: center;
	padding: var(--space-4);
	background: rgba(7, 29, 42, 0.55);
	backdrop-filter: blur(2px);
}
.modal__panel {
	width: min(620px, 100%);
	max-height: calc(100dvh - 48px);
	overflow-y: auto;
	background: var(--bg-raised);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-lg);
	padding: var(--space-5);
}
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.modal__head h2 { margin: 0; }
.modal__foot { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-5); flex-wrap: wrap; }
.modal__body { font-size: 0.92rem; }
.modal__body p { margin: 0 0 var(--space-2); }

/* A choice dialog raised from inside another modal sits above it rather than
   replacing it, so the form underneath survives if the agent backs out. */
.modal--stacked { z-index: 90; background: rgba(7, 29, 42, 0.65); }

/* --- supporter claims --------------------------------------------------- */

.claim-panel {
	border: 1px solid var(--border);
	border-left: 3px solid var(--caution);
	border-radius: var(--radius);
	background: var(--bg-raised);
	padding: var(--space-3) var(--space-4);
	margin-bottom: var(--space-4);
	display: grid;
	gap: var(--space-2);
}
.claim-panel--empty {
	border-left-color: var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3);
	flex-wrap: wrap;
}
.claim-panel__head h3 { margin: 0 0 2px; font-size: 0.95rem; }

.claim-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.claim-row {
	display: flex;
	align-items: center;
	gap: var(--space-2);
	flex-wrap: wrap;
	font-size: 0.9rem;
	padding: 4px 0;
	border-bottom: 1px solid var(--border);
}
.claim-row:last-child { border-bottom: 0; }
.claim-row__who { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.claim-row__stage { margin-left: auto; }

.tile--clickable { cursor: pointer; }
.tile--clickable:hover { border-color: var(--caution); }

.empty {
	text-align: center;
	padding: var(--space-7) var(--space-4);
	color: var(--text-muted);
}
.empty h3 { color: var(--text); }

.skeleton {
	background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 37%, var(--bg-sunken) 63%);
	background-size: 400% 100%;
	border-radius: var(--radius-sm);
	animation: shimmer 1.3s ease infinite;
	height: 58px;
}
.skeleton + .skeleton { margin-top: var(--space-2); }
@keyframes shimmer {
	0%   { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ========================================================================
   Polling-day mode
   ======================================================================== */

/* On polling day the interface has one job: find a name, tap once, move on.
   Controls get bigger, chrome gets quieter, and the search box owns the screen. */
.app-root[data-mode="election"] {
	--accent: var(--emerald-700);
	--accent-text: #ffffff;
}
.app-root[data-mode="election"] .voter-card { padding: var(--space-4); }
.app-root[data-mode="election"] .voter-card__name { font-size: 1.05rem; }
.app-root[data-mode="election"] .btn { min-height: 46px; font-size: 0.98rem; }

.turnout-search input {
	width: 100%;
	padding: var(--space-4);
	font-size: 1.15rem;
	font-family: var(--font-mono);
	text-align: center;
	border: 2px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--bg-raised);
	color: var(--text);
}
.turnout-search input:focus { border-color: var(--positive); }

@media print {
	.topbar, .sidenav, .toasts, .btn { display: none !important; }
	.main { padding: 0; }
	body { background: #fff; color: #000; }
}
