/* ============================================================
   mea-web page styles — modeled on design-system/reference/
   02-layout.css (@layer layout: structure only, not one color)
   and 03-design.css (@layer design: paint only, every value a
   token). Zero hardcoded hex (D10) — a test gates this file.
   ============================================================ */

/* Global [hidden] guard (UNLAYERED + !important on purpose).
   Progressive-enhancement JS across the app hides elements by SETTING
   the `hidden` attribute (static map, voice fallback, the no-JS
   "Estimate from photo" button, etc.), but component `display` rules
   (e.g. `.btn { display: inline-flex }`, `.citation-map { display: grid }`)
   OVERRIDE the UA `[hidden] { display: none }` in the cascade, leaving
   the "hidden" element visible. Per-component `.x[hidden]` guards only
   fix the components they name; this single unlayered `!important` rule
   makes the `hidden` attribute authoritative EVERYWHERE — the standard
   normalize/reset posture. Showing an element still just removes the
   attribute (JS never relies on overriding this rule). */
[hidden] {
	display: none !important;
}

/* ──────────────────────────────────────────────────────────────
   Citizen (participant) dark identity at BODY scope.
   The production theme (frontend/app/theme.css) scopes the dark
   --t-* rebind to `body.citizen-theme .app-screen` so the SPA's
   desk shell stays light. mea-web renders one role per request, so
   the WHOLE participant page — shell included — is dark; we promote
   the same dark token palette to body scope (covering the shell
   tokens .app-screen omits, e.g. --t-topbar-bg). Token-only (D10).
   ────────────────────────────────────────────────────────────── */
@layer theme {
	body.citizen-theme {
		--t-hero-bg: radial-gradient(120% 90% at 50% 15%, var(--mea-navy-light), var(--mea-navy) 70%);
		--t-hero--fg: var(--mea-white);
		/* Links on that dark hero card. The card palette's --t-accent is
		   dark-on-light and was barely readable here. Other skins fall back
		   to it. */
		--t-hero--link: var(--mea-baby-blue);
	}

	/* Desk pages paint the dark root page behind .app-screen, but
	   frontend/app/theme.css binds .app-screen's page-text tokens for a
	   light page, so any text that inherits .app-screen's colour (a page
	   title with no rule of its own, an unstyled form) was dark on dark.
	   Give the page-text tokens back their root values, which are made for
	   the dark page. Cards keep the card palette: the white-card rule in
	   theme.css paints them with --t-text. */
	body.desk-portal .app-screen {
		--t-bg-text: var(--mea-white);
		--t-bg-text-secondary: var(--mea-cg-3);
		--t-bg-text-muted: var(--mea-cg-4);
	}
}

/* ──────────────────────────────────────────────────────────────
   @layer layout — STRUCTURE ONLY.
   ────────────────────────────────────────────────────────────── */
@layer layout {

	body {
		font-family: var(--mea-font-citizen-body);
		display: grid;
		grid-template-rows: auto 1fr auto;
		min-height: 100vh;
	}

	dialog {
		padding: var(--mea-space-5);
		border-radius: var(--mea-radius-3xl);
		max-block-size: 90vh;

		& .dialog-header {
			padding-block-end: var(--mea-space-4);
			border-block-end-width: var(--mea-line-hairline);

			display: flex;
			flex-direction: row;
			align-items: center;

			& > h1, & > h2, & > h3, & > h4, & > h5, & > h6 {
				flex-grow: 1;
			}
		}

		& .dialog-footer {
			display: flex;
			flex-direction: row;
			justify-content: end;
			gap: var(--mea-space-2);
		}
	}

	svg.lucide {
		inline-size: var(--mea-space-6);
		block-size: var(--mea-space-6);
	}

	/* Skip link (a11y): visually hidden until focused, then revealed at the
     top-left above all content so keyboard users can jump past the top bar
     straight to <main id="main">. Structure only here; paint in @layer design. */
	.skip-link {
		position: absolute;
		top: var(--mea-space-2);
		left: var(--mea-space-2);
		z-index: var(--mea-z-top);
		padding: var(--mea-space-2) var(--mea-space-4);
		border-radius: var(--mea-radius-md);
		text-decoration: none;
		transform: translateY(-200%);
	}

	.skip-link:focus,
	.skip-link:focus-visible {
		transform: translateY(0);
	}

	.mea-logo {
		height: var(--mea-space-6);
	}

	/* The jurisdiction's own logo/seal as the primary brand
	   (shells/brand.html); width stays auto for non-square seals. */
	.tenant-seal {
		width: auto;
		object-fit: contain;
		max-height: 96px;
		max-width: 96px;
	}

	/* Landing hero seal: the county mark leads the hero (structure only —
	   paint stays token-driven in the design layer below). */
	.tenant-landing__seal {
		height: var(--mea-space-16);
		width: auto;
		object-fit: contain;
		justify-self: start;
	}

	/* Footer: the MEA platform mark (the seal is the primary brand above). */
	.appfooter__mea-logo {
		height: var(--mea-space-5);
		width: auto;
	}

	.appfooter__powered {
		font-size: var(--mea-text-xs);
	}

	.page__title {
		font-size: var(--mea-text-2xl);
		line-height: var(--mea-lh-tight);
	}

	.sheet {
		border-radius: var(--mea-space-5);
		padding: var(--mea-space-4);
	}


	.panel {
		display: grid;
		gap: var(--mea-space-3);
	}

	.panel__title {
		font-size: var(--mea-text-lg);
	}

	.panel__hint,
	.panel__title {
		line-height: var(--mea-lh-snug);
	}

	/* Sign-in / verify forms — a narrow centered card; they must NOT stretch to
     the signed-out page's full width on desktop (tables are wide, auth forms
     are not). */
	.signin {
		padding-top: var(--mea-space-8);
		max-width: 28rem;
		margin-inline: auto;
		width: 100%;
	}

	form, .form {
		display: grid;
		gap: var(--mea-space-4);

		& main, & .main {
			display: grid;
			gap: var(--mea-space-4);
		}

		& fieldset {
			display: grid;
			gap: var(--mea-space-4);
		}
	}

	input:not([type]), input[type="text"], input[type="number"], input[type="search"] {
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border-radius: var(--mea-radius-md);
		border-width: 1px;
	}

	.form__field {
		display: grid;
		gap: var(--mea-space-1);
	}

	.form__label {
		font-size: var(--mea-text-sm);
	}

	.form__input {
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border-radius: var(--mea-radius-md);
		border: 1px solid;
		font: inherit;
		width: 100%;
	}

	.form-error {
		padding: var(--mea-space-3);
		border-radius: var(--mea-radius-md);
		border: 1px solid;
	}

	.notice {
		display: grid;
		gap: var(--mea-space-2);
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
		border: 1px solid;
	}

	.notice__title {
		font-size: var(--mea-text-md);
		line-height: var(--mea-lh-snug);
	}

	.notice__body {
		font-size: var(--mea-text-sm);
		line-height: var(--mea-lh-normal);
	}

	/* Program card */
	.deals {
		display: grid;
		gap: var(--mea-space-3);
	}

	.case {
		display: grid;
		gap: var(--mea-space-2);
		padding: var(--mea-space-5);
		border-radius: var(--mea-radius-2xl);
	}

	/* The participant's program card. Its parts (the task, its bar and the
	   link to the case) are separate, so they sit the space apart that the
	   design system puts between the parts of a card. It stays a grid when
	   it is a link. */
	.case.program-card {
		display: grid;
		gap: var(--t-space-4);
		padding: var(--t-space-5);
	}

	/* The task's icon introduces its name and hours but is a shape of its
	   own, so it sits a card part's space from them. */
	.program-card .current-task {
		display: flex;
		align-items: center;
		gap: var(--t-space-4);
	}

	/* The bar has no outline, as in the design. Its dark track is only about
	   1.5:1 against the card where the bar sits, but the hours line above
	   states the same numbers in text, so the bar is not needed to read the
	   card (WCAG 1.4.11). */
	.program-card progress {
		border-width: 0;
	}

	/* The icon is about as tall as the name and hours together: two lines
	   at the section heading's size plus the heading's gap between them, so
	   it follows the theme's type scale. It is sized from the type and not
	   stretched to the text, because browsers disagree on how a stretched
	   square sizes. The icon is a mark, so the page sizes it and the
	   hourglass inside. */
	.program-card .mission-icon {
		flex: none;
		font-size: var(--t-font-size-lg);
		inline-size: calc(2lh + var(--t-space-2));
		block-size: calc(2lh + var(--t-space-2));

		& svg {
			inline-size: 50%;
			block-size: 50%;
		}
	}

	/* Boundary + error pages */
	.boundary,
	.error-page {
		padding-top: var(--mea-space-8);
	}

	.boundary__body,
	.error-page__body {
		font-size: var(--mea-text-base);
		line-height: var(--mea-lh-normal);
	}

	.error-page__code {
		font-size: var(--mea-text-hero);
		font-weight: var(--mea-w-extrabold);
		line-height: var(--mea-lh-tight);
	}

	.dashboard--officer {
		& .actions {
			display: flex;
			flex-direction: row;
		}
	}

	@media (max-width: 48rem) {
		/* there can only be one responsive-primary-actions per page, so use id instead of class */
		/* Linked rows are positioned, so without a z-index the rows that
		   scroll under this bar paint over it. */
		#primary-actions {
			position: fixed;
			z-index: var(--mea-z-sticky);
			bottom: 0;
			left: 0;
			right: 0;
			padding: var(--mea-space-4);
		}

		body:has(#primary-actions) {
			& .appfooter {
				margin-block-end: calc(
					var(--mea-space-4) +
					var(--t-target-min) +
					var(--mea-space-4));
			}
		}
	}



	/* Buttons */
	.btn {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-3) var(--mea-space-5);
		border: 0;
		border-radius: var(--mea-radius-pill);
	}
	a.btn {
		text-decoration: none;
	}

	.btn--quiet {
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-4);
		border: 1px solid;
	}

	.appfooter {
		display: flex;
		justify-content: center;
		align-items: center;
		gap: var(--mea-space-2);
		padding: var(--mea-space-7) var(--mea-gutter-mobile);

		& > .mea-attribution {
			display: inline-flex;
			align-items: center;

			& > .mea-logo {
				block-size: 1em;
				align-self: baseline;
				margin-inline: var(--mea-space-1);
			}
		}
	}

	.lang-form {
		display: flex;
		align-items: end;
		flex-wrap: wrap;
		gap: var(--mea-space-2);

		& details summary {
			padding: var(--mea-space-2) var(--mea-space-3);
			list-style: none;
			display: flex;
			flex-direction: row;
			align-items: center;
			font-size: var(--mea-text-sm);
			margin-inline-start: 3px;

			&::after {
				content: "►";
				transition: rotate 0.2s ease-out;
				rotate: 0deg;
			}


		}
		& details[open] summary::after {
			rotate: 90deg;
		}

		& details {

			& .lang-options {
				gap: 0;
				margin-inline-start: var(--mea-space-4);

				/* justify-content: the shared button rule centers its
				   label; these read as a list, so they start-align. */
				& button[type="submit"] {
					background: none;
					border: none;
					padding: var(--mea-space-2) var(--mea-space-3);
					text-align: start;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: start;
					gap: var(--mea-space-2);

					&[selected] {

						&::after {
							content: "✓"
						}
					}
				}
			}
		}
	}

	.lang-form__label {
		display: block;
		font-size: var(--mea-text-sm);
	}

	.lang-form__select {
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border-radius: var(--mea-radius-md);
		border: 1px solid;
		font: inherit;
	}

	form.signout {
		margin: var(--mea-space-4);
		margin-block-start: var(--mea-space-8);
	}

	dialog.voice-recording {
		width: 100vw;
		max-width: 100vw;
		/* Same defect as dialog.photo-capture: 100vh is the LARGE viewport on
		   iOS Safari, so the dialog exceeds the visible area and the submit
		   control lands below the fold. A <dialog> does not scroll — the
		   founder had to rotate the phone to reach it. dvh tracks the visible
		   viewport; vh remains the fallback. */
		height: 100vh;
		height: 100dvh;
		max-height: 100dvh;
	}

	@keyframes vbar {
		0% {
			height: var(--mea-space-2);
		}
		100% {
			height: calc(var(--mea-space-10) - var(--mea-space-1));
		}
	}

	dialog.voice-recording[open] {
		display: flex;
		flex-direction: column;
		gap: var(--mea-space-2);
		/* Keep the controls clear of the iOS home indicator. */
		padding-block-end: max(var(--mea-space-3), env(safe-area-inset-bottom));

		& .indicator {
			flex-grow: 1;
			/* Without an explicit min-size a flex child will not shrink below
			   its content, so the indicator pushed the submit control off the
			   bottom. dvh alone does not fix that. */
			min-block-size: 0;
			overflow: hidden;
		}

		/* Whatever follows the indicator (the submit/stop controls) must never
		   be squeezed out by it. */
		& > :last-child {
			flex-shrink: 0;
		}
	}
	.voice-recording {

		& .title {
			font-size: var(--mea-text-2xl);
		}

		& .subtitle {
			font-size: var(--mea-text-md);
		}

		& .indicator {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}

		& .animated-bars {
			display: flex;
			gap: var(--mea-space-1);
			align-items: center;
			justify-content: center;
			height: calc(5 * var(--mea-space-5));
			width: calc(5 * var(--mea-space-5));
			border-width: var(--mea-space-1);
			border-radius: 50%;

			& .bar {
				height: var(--mea-space-2);
				width: var(--mea-space-1);
				border-radius: 2px;
				animation: vbar .8s ease-in-out infinite alternate;

				&:nth-child(2) { animation-delay: .1s; }
				&:nth-child(3) { animation-delay: .2s; }
				&:nth-child(4) { animation-delay: .3s; }
				&:nth-child(5) { animation-delay: .4s; }
				&:nth-child(6) { animation-delay: .15s; }
				&:nth-child(7) { animation-delay: .35s; }
			}
		}

		& .actions {
			display: flex;
			flex-direction: column;
			gap: var(--mea-space-2);
		}
	}

	input[type="checkbox"].check-gate:not(:checked) + .check-gated {
		display: none;
	}
	.check-gate:has(:invalid) + .check-gated {
		display: none;
	}

	dialog.photo-capture[open] {
		display: flex;
		flex-direction: column;
		gap: var(--mea-space-2);
		padding: 0;

		& .preview {
			flex-grow: 1;
			display: flex;
			/* A flex child will not shrink below its CONTENT size without an
			   explicit min-size: the video held the preview open and pushed
			   .actions (Cancel / Capture) off the bottom of the dialog. This is
			   the second half of the unreachable-controls bug — dvh alone does
			   not fix it. */
			min-block-size: 0;
			overflow: hidden;
			/* Its own compositing layer. iOS Safari can drop a live <video>
			   layer that sits under an overflow:hidden ancestor inside a
			   rounded top-layer <dialog>: the camera runs (the decoder gets
			   frames) but the officer sees a white box. Reported on demo
			   2026-10-06 (iPhone, Safari): 197 frames decoded, nothing shown. */
			transform: translateZ(0);

			& video {
				/* Explicit size, not only max-*: a percentage max-height on the
				   child of a flex item can resolve as indefinite in Safari. */
				width: 100%;
				height: 100%;
				max-width: 100%;
				max-height: 100%;
				object-fit: contain;
			}

			/* Barcode mode: the camera mirrored onto a canvas over the video
			   (photo-capture.js startPreviewMirror), for a Safari that reads
			   video frames but never paints them. Same box and fit as the
			   video. Once drawn it covers the video on every device, so the
			   script draws it at the box's device-pixel resolution. */
			& .preview-mirror {
				position: absolute;
				inset: 0;
				width: 100%;
				height: 100%;
				object-fit: contain;
				pointer-events: none;
			}
		}
	
		& .actions {
			/* Never let the controls be squeezed out by the preview. */
			flex-grow: 0;
			flex-shrink: 0;
			margin: var(--mea-space-3);
			/* Keep the buttons clear of the iOS home indicator. */
			margin-block-end: max(var(--mea-space-3), env(safe-area-inset-bottom));

			display: flex;
			gap: var(--mea-space-3);
			flex-wrap: wrap;

			& > button {
				flex-grow: 1;
				flex-basis: auto;
			}
		}

	}

	.responsive-row {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		gap: inherit;

		& .grow {
			flex: 1 0 0;
		}

	}
}

/* ──────────────────────────────────────────────────────────────
   @layer design — PAINT ONLY. Every value a token (D10).
   ────────────────────────────────────────────────────────────── */
@layer design {

	body {
		background: var(--t-bg);
		color: var(--t-bg-text);
	}

	dialog {
		border: none;

		&:target ~ .dialog-backdrop {
			background-color: rgba(10,22,40,.5);
		}

		& .dialog-header {
			border-block-end-color: var(--t-border);
			border-block-end-style: solid;
		}
	}


	/* Skip link paint: token-styled accent pill, visible against any theme. */
	.skip-link {
		background: var(--t-accent);
		color: var(--t-accent-text);
		font-weight: var(--mea-w-bold);
	}

	.skip-link:focus,
	.skip-link:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	.page__title {
		font-family: var(--mea-font-citizen);
		font-weight: var(--mea-w-extrabold);
		letter-spacing: var(--mea-ls-tight);
	}

	body.citizen-theme .page__title {
		color: var(--t-bg-text);
	}

	/* The sheet sets its own ink beside its white background. Body text is
	   --t-bg-text, which is white, so any child without a colour rule of its
	   own (the /security intro, its status notice, the TOTP key) would
	   otherwise render white on white. */
	.sheet {
		background-color: var(--mea-white);
		color: var(--t-text);
	}

	.panel__title {
		font-family: var(--mea-font-citizen);
		font-weight: var(--mea-w-bold);
	}

	.panel__hint {
		font-size: var(--mea-text-sm);
		color: var(--t-text-secondary);
	}
	.signin .panel__hint {
		color: var(--t-bg-text-secondary);
	}

	/* The sign-in page sits on the dark page, not a card, so its
	   link (Officer sign-in) takes --t-bg-text, as the error pages' links do.
	   --t-link is the card palette's dark blue and was near invisible here. */
	.signin .link,
	.signin .link:hover {
		color: var(--t-bg-text);
	}

	.form__label {
		color: var(--t-text-secondary);
		font-weight: var(--mea-w-semibold);
	}
	.signin .form__label {
		color: var(--t-bg-text-secondary);
	}

	.form__input {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text);
	}

	.form__input:focus-visible {
		border-color: var(--t-border-focus);
	}

	.form-error {
		background: var(--t-bg-elevated);
		border-color: var(--t-warning);
		color: var(--t-text);
	}

	.notice {
		background: var(--t-bg-elevated);
		color: var(--t-text);
		border-color: var(--t-border);
	}

	.notice__title {
		color: var(--t-text);
		font-weight: var(--mea-w-bold);
	}

	.notice__body {
		color: var(--t-text-secondary);
	}

	.case {
		box-shadow: var(--mea-shadow-card);
	}

	/* The program card takes its fill from the featured surface. The sign
	   card is not on a surface yet, so it keeps the hero fill. */
	.case--sign-cta {
		background: var(--t-hero-bg);
	}

	.case__eyebrow {
		display: none;
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-caps);
		color: var(--t-text-muted);
	}

	.case__title {
		font-family: var(--mea-font-citizen);
		font-size: var(--mea-text-3xl);
		font-weight: var(--mea-w-extrabold);
		letter-spacing: var(--mea-ls-tight);
		color: var(--t-hero--fg);
	}

	.boundary__body {
		color: var(--t-text-secondary);
	}

	/* Error pages sit straight on the dark page (--t-bg), not on a
	   card, so they take the --t-bg-text* family. --t-text* is the card palette
	   and measured 1.1-2.3:1 here (MEA-123 item 10). Body text and links are
	   --t-bg-text (white, at least 8:1 on the page and its glow; --t-bg-text-
	   secondary drops to 4.4:1 in the radial glow the text crosses). The status
	   code is large display text, so --t-bg-text-secondary (4.4:1 or better)
	   clears the 3:1 large-text bar. */
	.error-page__body,
	.error-page .link,
	.error-page .link:hover {
		color: var(--t-bg-text);
	}

	.error-page__code {
		color: var(--t-bg-text-secondary);
	}

	.dashboard--officer {
		& .actions {
			background-color: alpha(from var(--t-card-bg) / 1%);
			backdrop-filter: blur(3px);
		}
	}

	/* Participant CTA: the royal-blue gradient pill (RECONCILIATION-2026-06-09
     — the accent family is the --mea-grad-cta gradient, NOT baby-blue fills). */
	.btn--primary {
		background: var(--mea-grad-cta);
		color: var(--mea-white);
		font-weight: var(--mea-w-bold);
		box-shadow: var(--mea-shadow-btn);
	}

	.btn--primary:active {
		transform: translateY(1px);
	}

	.btn--quiet {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text-secondary);
		font-weight: var(--mea-w-semibold);
	}

	.link {
		color: var(--t-link);
		font-weight: var(--mea-w-semibold);
	}

	.link:hover {
		color: var(--t-link-hover);
	}

	.appfooter__powered {
		color: var(--t-bg-text-secondary);
	}

	.lang-form__label {
		color: var(--t-text-secondary);
		font-weight: var(--mea-w-semibold);
	}

	.lang-form__select {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text);
	}

	.lang-form__select:focus-visible {
		border-color: var(--t-border-focus);
	}

	.voice-recording {

		& .animated-bars {
			border-style: solid;
			border-color: var(--mea-blue);

			& .bar {
				background-color: var(--mea-blue);
			}
		}
	}

}

/* ──────────────────────────────────────────────────────────────
   Wave 1 — desk-role dashboards. STRUCTURE ONLY in @layer layout;
   paint follows in @layer design below. The SPA's JS-sized visuals
   (donut, trend bars, caseload bars) are native <meter> elements
   plus per-bucket count text: no inline styles, no scripts.
   ────────────────────────────────────────────────────────────── */
@layer layout {

	.dashboard {
		display: grid;
		gap: var(--mea-space-6);
	}

	.dashboard__intro {
		display: grid;
		gap: var(--mea-space-1);
	}

	.dashboard__title {
		font-size: var(--mea-text-2xl);
		line-height: var(--mea-lh-tight);
	}

	.dashboard__subtitle {
		font-size: var(--mea-text-sm);
	}

	.panel-empty {
		padding: var(--mea-space-4) 0;
		text-align: center;
	}

	.status-badge {
		display: inline-block;
		padding: var(--mea-space-1) var(--mea-space-2);
		border-radius: var(--mea-radius-pill);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		white-space: nowrap;
	}

	/* Prosecutor: courts, outcomes, activity, drill panel */
	.court-tabs {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-2);
	}

	.court-tab {
		display: inline-flex;
		align-items: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-1) var(--mea-space-3);
		border-radius: var(--mea-radius-pill);
		border: 1px solid;
		text-decoration: none;
		font-size: var(--mea-text-sm);
	}

	.court-info {
		display: grid;
		gap: var(--mea-space-2);
		padding-top: var(--mea-space-2);
	}

	.court-info__pair {
		display: flex;
		justify-content: space-between;
		gap: var(--mea-space-3);
	}

	.court-info__value {
		font-weight: var(--mea-w-bold);
	}

	.drill-panel {
		display: grid;
		gap: var(--mea-space-3);
		padding: var(--mea-space-4);
		border-radius: var(--mea-radius-lg);
		border: 1px solid;
	}

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

	.drill-row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--mea-space-3);
		padding: var(--mea-space-2) 0;
		border-top: 1px solid;
	}

	.drill-row__main {
		display: flex;
		align-items: center;
		gap: var(--mea-space-2);
		flex-wrap: wrap;
	}

	.drill-row__name {
		font-weight: var(--mea-w-semibold);
	}

	.drill-row__meta {
		font-size: var(--mea-text-sm);
	}

	.drill-row__time {
		font-weight: var(--mea-w-bold);
		font-variant-numeric: tabular-nums;
	}

	.drill-empty {
		padding: var(--mea-space-3) 0;
		text-align: center;
	}

	.caseload-chart {
		display: grid;
		gap: var(--mea-space-2);
	}

	.caseload-bar {
		display: grid;
		grid-template-columns: minmax(6rem, auto) 1fr auto;
		align-items: center;
		gap: var(--mea-space-2);
	}

	.caseload-bar__label {
		font-size: var(--mea-text-sm);
	}

	.caseload-bar__meter {
		width: 100%;
	}

	.caseload-bar__value {
		font-weight: var(--mea-w-bold);
		font-variant-numeric: tabular-nums;
	}

	/* Shared lists (events, sessions, providers) */
	.event-list {
		display: grid;
		gap: var(--mea-space-2);
	}

	.event {
		display: grid;
		gap: var(--mea-space-1);
		padding: var(--mea-space-2) 0;
		border-top: 1px solid;
	}

	.event__time {
		font-size: var(--mea-text-xs);
	}

	.event__actor {
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
	}

	.event__action {
		font-size: var(--mea-text-sm);
	}

}

/* Wave 1 — desk dashboards: PAINT ONLY, every value a token (D10). */
@layer design {

	.dashboard__subtitle {
		color: var(--t-bg-text-secondary);
	}

	.dashboard__title {
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-extrabold);
	}

	/* The white card sets its own ink: a participant on a page with no
	   .app-screen root gets no card palette from theme.css, and text that
	   inherits would take the page's white. */
	.drill-panel {
		background: var(--t-card-bg);
		color: var(--t-text);
		border-color: var(--t-card-border);
		box-shadow: var(--mea-shadow-card);
	}

	/* Empty states sit both in cards and directly on the desk page, so they
	   take the page-text family, which a white card rebinds to dark. */
	.panel-empty,
	.drill-empty {
		color: var(--t-bg-text-secondary);
	}

	.status-badge {
		background: var(--t-bg-active);
		color: var(--t-text-secondary);
	}

	.status-badge--approved,
	.status-badge--accepted,
	.status-badge--completed {
		background: var(--mea-green-light);
		color: var(--mea-green-dark);
	}

	.status-badge--pending,
	.status-badge--new,
	.status-badge--review,
	.status-badge--referred {
		background: var(--mea-amber-light);
		color: var(--mea-amber-dark);
	}

	.status-badge--denied,
	.status-badge--rejected,
	.status-badge--staff.status-badge--expired {
		background: var(--mea-red-light);
		color: var(--mea-red-dark);
	}

	/* ── DA triage-row signal: live SLA window ──
	   Paint from design-system tokens (D10 — no hardcoded hex). */
	.sla {
		display: inline-block;
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
	}

	.sla--ok {
		color: var(--mea-green-dark);
	}

	.sla--warn {
		color: var(--mea-amber-dark);
	}

	.sla--urgent {
		color: var(--mea-red-dark);
	}

	.sla--overdue {
		color: var(--mea-red-dark);
		font-weight: var(--mea-w-bold);
	}

	.court-tab {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text-secondary);
	}

	.court-tab--active {
		background: var(--t-accent);
		border-color: var(--t-accent);
		color: var(--t-accent-text);
	}

	.court-info__label {
		color: var(--t-text-secondary);
	}

	.drill-row {
		border-top-color: var(--t-border);
	}

	.drill-row__meta {
		color: var(--t-text-secondary);
	}

	.caseload-bar__label {
		color: var(--t-text-secondary);
	}

	.event {
		border-top-color: var(--t-border);
	}

	.event__time {
		color: var(--t-text-muted);
	}

	.event__action {
		color: var(--t-text-secondary);
	}

	.event__resource {
		font-weight: var(--mea-w-semibold);
		color: var(--t-text);
	}

}

/* ──────────────────────────────────────────────────────────────
   Wave 4 — deals list + deal-detail. STRUCTURE ONLY (@layer layout);
   paint follows in @layer design below. No inline styles, no scripts:
   filter chips / sort headers / pagination are plain links, the bulk
   action bar + every detail mutation is a real <form>.
   ────────────────────────────────────────────────────────────── */
@layer layout {

	/* Accessible-but-invisible label text (no hex; structure only). */
	.visually-hidden {
		position: absolute;
		width: 1px;
		height: 1px;
		margin: -1px;
		padding: 0;
		border: 0;
		overflow: hidden;
		clip: rect(0 0 0 0);
		clip-path: inset(50%);
		white-space: nowrap;
	}

	.btn--outline {
		border: 1px solid;
	}

	.btn--block {
		display: flex;
		width: 100%;
	}

	.deals-page {
		display: grid;
		gap: var(--mea-space-5);
	}

	.deals-page__intro {
		display: grid;
		gap: var(--mea-space-1);
	}

	.deals-page__title {
		font-size: var(--mea-text-2xl);
		line-height: var(--mea-lh-tight);
	}

	.deals-page__subtitle {
		font-size: var(--mea-text-sm);
	}

	.filter-bar {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-2);
	}

	.filter-chip {
		display: inline-flex;
		align-items: center;
		gap: var(--mea-space-2);
		min-height: var(--t-target-min);
		padding: var(--mea-space-1) var(--mea-space-3);
		border-radius: var(--mea-radius-pill);
		border: 1px solid;
		text-decoration: none;
		font-size: var(--mea-text-sm);
	}

	.deals-search {
		display: flex;
		flex-wrap: wrap;
		align-items: end;
		gap: var(--mea-space-2);
	}


	.deals-sort {
		text-decoration: none;
		display: inline-flex;
		align-items: center;
		gap: var(--mea-space-1);
	}

	.deals-sort__caret {
		font-size: var(--mea-text-xs);
	}


	.gang-unit-dot {
		display: inline-block;
		width: var(--mea-space-2);
		height: var(--mea-space-2);
		border-radius: var(--mea-radius-circle);
		flex: none;
	}

	.pagination {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: var(--mea-space-3);
	}

	.pagination__link {
		text-decoration: none;
		min-height: var(--t-target-min);
		display: inline-flex;
		align-items: center;
	}

	.pagination__info {
		font-size: var(--mea-text-sm);
		font-variant-numeric: tabular-nums;
	}

}

/* Wave 4 — deals list + deal-detail: PAINT ONLY, every value a token (D10). */
@layer design {

	.btn--outline {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text-secondary);
		font-weight: var(--mea-w-semibold);
	}

	.deals-page__subtitle {
		color: var(--t-bg-text-secondary);
	}

	.deals-page__title {
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-extrabold);
	}

	.filter-chip {
		background: var(--t-bg-elevated);
		border-color: var(--t-border);
		color: var(--t-text-secondary);
	}

	.filter-chip--active {
		background: var(--t-accent);
		border-color: var(--t-accent);
		color: var(--t-accent-text);
	}

	.deals-sort {
		color: var(--t-text-muted);
	}

	.deals-sort:hover {
		color: var(--t-link);
	}


	.gang-unit-dot {
		background: var(--mea-red);
	}


	.pagination__link {
		color: var(--t-link);
		font-weight: var(--mea-w-semibold);
	}

	.pagination__link:hover {
		color: var(--t-link-hover);
	}

	.pagination__info {
		color: var(--t-text-muted);
	}

}

/* ──────────────────────────────────────────────────────────────
   Per-jurisdiction landing — STRUCTURE ONLY (@layer layout); paint
   follows in @layer design below. The role grid is plain links (or,
   in demo mode, one-click POST forms); no inline styles, no scripts.
   ────────────────────────────────────────────────────────────── */
@layer layout {

	.landing {
		display: grid;
		gap: var(--mea-space-6);
	}

	.landing__head {
		display: grid;
		gap: var(--mea-space-1);
	}

	.landing__tenant {
		font-size: var(--mea-text-2xl);
		line-height: var(--mea-lh-tight);
	}

	.landing__subtitle {
		font-size: var(--mea-text-md);
	}

	.landing__demo {
		margin: 0;
	}

	.tenant-landing {
		display: grid;
		gap: var(--mea-space-8);
	}

	.tenant-landing__hero {
		display: grid;
		gap: var(--mea-space-4);
		padding-block: var(--mea-space-8);
		padding-inline-start: var(--mea-space-5);
		border-inline-start: 4px solid;
	}

	.tenant-landing__eyebrow {
		margin: 0;
		font-size: var(--mea-text-xs);
		line-height: var(--mea-lh-snug);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-caps);
	}

	.tenant-landing__title {
		max-width: 44rem;
		font-size: var(--mea-text-4xl);
		line-height: var(--mea-lh-tight);
	}

	.tenant-landing__lede {
		max-width: 48rem;
		font-size: var(--mea-text-lg);
		line-height: var(--mea-lh-relaxed);
	}

	.tenant-landing__actions {
		display: flex;
		flex-wrap: wrap;
		gap: var(--mea-space-3);
		align-items: center;
	}

	.tenant-landing__actions .btn {
		text-decoration: none;
	}

	.tenant-landing__workflow {
		display: grid;
		gap: var(--mea-space-4);
		padding-block: var(--mea-space-6);
		border-block: 1px solid;
	}

	.tenant-landing__section-title {
		font-size: var(--mea-text-xl);
		line-height: var(--mea-lh-snug);
	}

	.tenant-landing__steps {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
	}

	.tenant-landing__step {
		display: grid;
		gap: var(--mea-space-2);
		padding-block: var(--mea-space-4);
		border-top: 1px solid;
	}

	.tenant-landing__step:first-child {
		border-top: 0;
		padding-top: 0;
	}

	.tenant-landing__step:last-child {
		padding-bottom: 0;
	}

	.tenant-landing__step-index {
		font-size: var(--mea-text-xs);
		line-height: var(--mea-lh-snug);
	}

	.tenant-landing__step-title {
		font-size: var(--mea-text-lg);
		line-height: var(--mea-lh-snug);
	}

	.tenant-landing__step-body {
		font-size: var(--mea-text-sm);
		line-height: var(--mea-lh-relaxed);
	}

	.tenant-signin {
		display: grid;
		gap: var(--mea-space-4);
	}

	.tenant-signin__head {
		display: grid;
		gap: var(--mea-space-1);
	}

	.tenant-signin__body {
		font-size: var(--mea-text-sm);
		line-height: var(--mea-lh-normal);
	}

	.tenant-signin__groups {
		display: grid;
		gap: var(--mea-space-6);
	}

	.tenant-signin__group {
		display: grid;
		gap: var(--mea-space-2);
		/* Without this the shorter column's rows stretch to match the taller
		   one, leaving a gap between its heading and its first role. */
		align-content: start;
		/* A grid item's min-width defaults to its min-content width, so a wide
		   <select> pushed this column into its neighbour on narrow screens. */
		min-width: 0;
	}

	.tenant-signin__group-title {
		font-size: var(--mea-text-sm);
		line-height: var(--mea-lh-snug);
	}

	.tenant-role-list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		grid-template-columns: minmax(0, 1fr);
		border-top: 1px solid;
	}

	.tenant-role-list__link {
		display: flex;
		align-items: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) 0;
		border-bottom: 1px solid;
		text-decoration: none;
	}

	/* One-click demo sign-in (control-plane launcher): the submit button must
	   read as the same tile as the anchor sign-in links — reset the browser
	   button chrome and let the form collapse out of the layout. */
	.tenant-role-list__form {
		display: contents;
	}

	button.tenant-role-list__link {
		width: 100%;
		border: 0;
		border-bottom: 1px solid;
		background: none;
		font: inherit;
		text-align: start;
		cursor: pointer;
	}

	.tenant-role-list__title {
		font-size: var(--mea-text-sm);
	}

	@media (min-width: 48rem) {
		.tenant-landing__step {
			grid-template-columns: 4rem 10rem minmax(0, 1fr);
			align-items: baseline;
			gap: var(--mea-space-4);
		}

		.tenant-signin__groups {
			grid-template-columns: repeat(2, minmax(0, 1fr));
		}
	}

	.role-grid {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: var(--mea-space-3);
		grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
	}

	.role-tile {
		display: grid;
	}

	.role-tile__form {
		display: grid;
		margin: 0;
	}

	.role-tile__action {
		display: flex;
		align-items: center;
		justify-content: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-5) var(--mea-space-4);
		border-radius: var(--mea-radius-2xl);
		border: 1px solid;
		text-decoration: none;
		text-align: center;
		width: 100%;
		font: inherit;
		cursor: pointer;
	}

	.role-tile__title {
		font-size: var(--mea-text-md);
		font-weight: var(--mea-w-bold);
	}
}

/* Per-jurisdiction landing: PAINT ONLY, every value a token (D10). */
@layer design {

	.landing__tenant {
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-extrabold);
	}

	.landing__subtitle {
		color: var(--t-bg-text-secondary);
	}

	.tenant-landing__hero {
		border-inline-start-color: var(--t-accent);
	}

	.tenant-landing__eyebrow {
		color: var(--t-accent);
		font-family: var(--mea-font-body);
		font-weight: var(--mea-w-bold);
	}

	.tenant-landing__title {
		color: var(--t-bg-text);
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-extrabold);
	}

	.tenant-landing__lede {
		color: var(--t-bg-text-secondary);
	}

	.tenant-landing__workflow {
		border-block-color: var(--t-border);
	}

	.tenant-landing__section-title {
		color: var(--t-bg-text);
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-bold);
	}

	.tenant-landing__step {
		border-top-color: var(--t-border);
	}

	.tenant-landing__step-index {
		color: var(--t-accent);
		font-family: var(--mea-font-mono);
		font-weight: var(--mea-w-bold);
	}

	.tenant-landing__step-title {
		color: var(--t-bg-text);
		font-family: var(--mea-font-heading);
		font-weight: var(--mea-w-bold);
	}

	.tenant-landing__step-body,
	.tenant-signin__body {
		color: var(--t-bg-text-secondary);
	}

	.tenant-signin__group-title {
		color: var(--t-bg-text-muted);
		font-weight: var(--mea-w-bold);
		text-transform: uppercase;
		letter-spacing: var(--mea-ls-caps);
	}

	.tenant-role-list {
		border-top-color: var(--t-border);
	}

	.tenant-role-list__link {
		border-bottom-color: var(--t-border);
		color: var(--t-bg-text);
		font-weight: var(--mea-w-semibold);
	}

	.tenant-role-list__link:hover {
		padding-inline-start: var(--mea-space-2);
	}

	.tenant-role-list__link:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	.role-tile__action {
		background: var(--t-card-bg);
		border-color: var(--t-card-border);
		color: var(--t-text);
		box-shadow: var(--mea-shadow-card);
	}

	.role-tile__action:hover {
		border-color: var(--t-border-focus);
	}

	.role-tile__action:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	.role-tile__action--demo {
		background: var(--t-bg-elevated);
		color: var(--t-text);
	}

	.role-tile__title {
		color: var(--t-bg-text);
	}
}

/* ──────────────────────────────────────────────────────────────
   Jurisdiction nav — per-role, server-rendered (no JS), drawn by
   nav/jurisdiction.html inside the signed-in shell, which lays it out
   (design-system/pages.css). Token-only paint (D10). STRUCTURE in @layer
   layout, PAINT in @layer design.
   ────────────────────────────────────────────────────────────── */
@layer layout {
	.desk-nav {
		flex: 0 0 auto;
		min-inline-size: 0;
		width: 14rem;
		top: var(--mea-space-4);
		display: grid;
		gap: var(--mea-space-5);
		padding-block: var(--mea-space-4);
	}

	.desk-nav__section {
		display: grid;
		gap: var(--mea-space-1);
	}

	.desk-nav__label {
		margin: 0 0 var(--mea-space-1);
		padding-inline: var(--mea-space-3);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		text-transform: uppercase;
		letter-spacing: 0.06em;
	}

	.desk-nav__list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 2px;
	}

	.desk-nav__item {
		display: flex;
		align-items: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border-radius: 6px;
		border-left: 3px solid transparent;
		font-size: var(--mea-text-sm);
		text-decoration: none;
	}

	.desk-nav__item.is-active {
		font-weight: var(--mea-w-semibold);
	}

	@media (min-width: 48rem) {
		.dashboard--officer {
			padding-inline-end: var(--mea-gutter-mobile);
		}
	}

	@media (max-width: 48rem) {
		.dashboard--officer {

			& .officer-profile,
			& .stat-tiles {
				margin-inline: var(--mea-gutter-mobile);
			}
		}
	}

	/* Multi-role union menu (role switcher): a compact set of plain links to
	   each dashboard the signed-in user holds, in the left rail below the
	   primary nav. STRUCTURE ONLY here (paint in @layer design); modeled on
	   .desk-nav so the two groups read as one system. */
	.role-switcher {
		display: grid;
		gap: var(--mea-space-1);
		margin-block-start: var(--mea-space-3);
		padding-block-start: var(--mea-space-4);
		border-block-start: 1px solid transparent;
	}

	.role-switcher__label {
		margin: 0 0 var(--mea-space-1);
		padding-inline: var(--mea-space-3);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		text-transform: uppercase;
		letter-spacing: 0.06em;
	}

	.role-switcher__list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 2px;
	}

	/* Start-aligned: the shared button rule centers its label. */
	.role-switcher__item {
		display: flex;
		align-items: center;
		justify-content: start;
		inline-size: 100%;
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border: 0;
		border-left: 3px solid transparent;
		border-radius: 6px;
		background: none;
		font: inherit;
		font-size: var(--mea-text-sm);
		text-align: start;
		text-decoration: none;
		cursor: pointer;
	}

	.role-switcher__item.is-active {
		font-weight: var(--mea-w-semibold);
	}

	/* Indented under the label to the same column as the language options;
	   the 3px left border sits inside the indent. Three classes, because the
	   shared button padding outranks two: components.css nests
	   `&:not(.ghost)` under `button, a.button, …`, and a nested `&` is
	   `:is()` of that list, so it counts as a.button: 0-2-1. */
	.role-switcher .role-switcher__list .role-switcher__item {
		padding-inline-start: calc(var(--mea-space-3) + var(--mea-space-4) - 3px);
	}
}

@layer design {
	/*
	   The desk shell now uses the dark root page. Keep shell text on
	   dark surfaces readable without changing card-local light-theme text.
	*/
	.desk-nav__label,
	.lang-form__label {
		color: var(--mea-cg-3);
	}

	/* Page-level titles, subtitles and labels that sit directly on the dark
	   desk page. Their pages paint them with the light palette's dark text,
	   which read ~1.3:1 on the dark background. White cards keep dark text
	   (frontend/app/theme.css white-card rule). */
	body.desk-portal :is(
		.user-management__title
	) {
		color: var(--mea-white);
	}

	body.desk-portal :is(
		.user-management__subtitle,
		.case-field__label, .filter-bar .field__label
	) {
		color: var(--mea-cg-3);
	}

	/* Pagination sits on the dark page only on these pages; elsewhere it is
	   inside a white card and keeps the card's dark text. */
	body.desk-portal :is(.deals-page, .caseload-search-page, .active-cases) > * .pagination__info {
		color: var(--mea-cg-3);
	}

	.lang-form {
		& button {
			color: inherit;
		}
	}

	.desk-nav__item[aria-current] {
		color: var(--t-accent);
		background: var(--t-bg-elevated);
		border-left-color: var(--t-accent);
	}

	.desk-nav__item:hover {
		color: var(--t-text);
		background: var(--t-bg-elevated);
	}

	.desk-nav__item:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	.desk-nav__label {
		color: var(--mea-cg-3);
	}

	@media (max-width: 48rem) {
		.desk-nav__item.is-active {
			border-left-color: transparent;
			border-bottom-color: var(--t-accent);
		}
	}

	/* Role-switcher PAINT — token-only (D10), mirroring the desk-nav palette.
	   Its text inks come from the nav's surface (design-system pages.css). */
	.role-switcher {
		border-block-start-color: var(--t-border);
	}

	.role-switcher__label {
		color: var(--t-bg-text-muted);
	}

	.role-switcher__item {
		color: var(--t-text-inverse);
	}

	.role-switcher__item:hover,
	.role-switcher__item[aria-current="true"] {
		color: var(--t-accent);
		background: var(--t-bg-elevated);
	}

	.role-switcher__item[aria-current="true"] {
		border-left-color: var(--t-accent);
	}

	.role-switcher__item:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

}

/* ──────────────────────────────────────────────────────────────
   Participant (citizen) navigation — mobile-first (D11), trauma-informed
   (D12), server-rendered (no JS). The drawer menu (.citizen-nav) lists every
   participant-reachable page; the bottom tab bar (.citizen-tabbar) surfaces the
   <=3 PRIMARY actions. Rendered by base.html only for the participant view
   (participant_nav / participant_primary). Token-only paint (D10); reads on the
   dark citizen theme (D1, no surveillance aesthetics). STRUCTURE in @layer
   layout, PAINT in @layer design.
   ────────────────────────────────────────────────────────────── */
@layer layout {
	.citizen-nav {
		display: grid;
		gap: var(--mea-space-5);
		padding-block: var(--mea-space-4);
	}

	.citizen-nav__section {
		display: grid;
		gap: var(--mea-space-1);
	}

	.citizen-nav__label {
		margin: 0 0 var(--mea-space-1);
		padding-inline: var(--mea-space-3);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		text-transform: uppercase;
		letter-spacing: 0.06em;
	}

	.citizen-nav__list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 2px;
	}

	.citizen-nav__item {
		display: flex;
		align-items: center;
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-3);
		border-radius: var(--mea-radius-md);
		font-size: var(--mea-text-sm);
		text-decoration: none;
	}

	/* Bottom tab bar: the <=3 primary actions, fixed to the viewport bottom on
	   the mobile citizen surface. On wider viewports the drawer menu is the
	   persistent rail, so the tab bar is hidden. */
	.citizen-tabbar {
		position: fixed;
		inset-inline: 0;
		bottom: 0;
		z-index: var(--mea-z-top);
		display: flex;
		align-items: stretch;
		padding-bottom: env(safe-area-inset-bottom, 0px);
	}

	.citizen-tabbar__item {
		flex: 1 1 0;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: var(--mea-space-1);
		min-height: var(--t-target-min);
		padding: var(--mea-space-2) var(--mea-space-1);
		font-size: var(--mea-text-xs);
		font-weight: var(--mea-w-semibold);
		text-decoration: none;
		text-align: center;
	}

	.citizen-tabbar__item > svg {
		inline-size: var(--mea-space-5);
		block-size: var(--mea-space-5);
	}

	.case--link {
		display: block;
		text-decoration: none;
	}

	@media (min-width: 48rem) {
		.citizen-tabbar {
			display: none;
		}
	}
}

@layer design {
	.citizen-nav__label {
		color: var(--t-text-muted);
	}

	.citizen-nav__item {
		color: var(--t-text);
	}

	.citizen-nav__item:hover {
		color: var(--t-accent);
		background: var(--t-bg-elevated);
	}

	.citizen-nav__item.is-active {
		color: var(--t-accent);
		background: var(--t-bg-elevated);
		font-weight: var(--mea-w-semibold);
	}

	.citizen-nav__item:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	.citizen-tabbar {
		background: var(--t-card-bg);
		border-block-start: 1px solid var(--t-border);
	}

	.citizen-tabbar__item {
		color: var(--t-text-secondary);
	}

	.citizen-tabbar__item:hover,
	.citizen-tabbar__item.is-active {
		color: var(--t-accent);
	}

	.citizen-tabbar__item:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: -2px;
	}

	.case--link:focus-visible {
		outline: 2px solid var(--t-border-focus);
		outline-offset: 2px;
	}

	/* The "view my case" affordance on the tappable case card. */
	.case__more {
		color: var(--t-hero--link, var(--t-accent));
		font-size: var(--mea-text-sm);
		font-weight: var(--mea-w-semibold);
	}

	.case.surface .case__more {
		color: var(--c-surface-text-color-interactive);
	}
}

/* Demo launcher: login-selectable data-state variant on persona tiles
   (admin_landing.html; founder 2026-07-21). Tokens only — no raw color. */
.tenant-role-list__variant {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	margin-block-end: 0.5rem;
}

.tenant-role-list__variant-label {
	font-size: var(--mea-text-sm);
	font-weight: var(--mea-w-semibold);
	color: var(--t-bg-text-secondary);
}

.tenant-role-list__variant-select {
	font: inherit;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	padding: 0.375rem 0.5rem;
}

/* A demo row keeps its role name, data-state picker and credentials above ONE
   divider, drawn by the row itself rather than by the sign-in button, so the
   picker always reads as belonging to the role above it. */
.tenant-role-list__item--demo {
	min-width: 0;
	padding-block-end: var(--mea-space-2);
	border-bottom: 1px solid var(--t-border);
}

.tenant-role-list__item--demo .tenant-role-list__link {
	border-bottom: 0;
}

/* Demo launcher credentials (admin_landing.html; founder 2026-07-20,
   task 3e0d381ec2e9). The PUBLISHED demo creds (non-secret — fake Suffolk demo
   jurisdiction, kindex 1deab21c0ad0) render display-only on the @mea.tech
   SSO-gated control plane so testers can capture them for a re-auth challenge
   (e.g. the session-expiry re-login, task 2d961d463827). A click-to-open
   <details> disclosure: no JS, keyboard operable, and nothing moves until the
   tester asks for it. The text sits on the page background, so it takes the
   --t-bg-* text tokens (the card --t-text token is dark-on-light and was
   unreadable here). Tokens only (D10); never rendered on the public demo host
   (task #9). */
.demo-tile__creds {
	margin: 0;
	color: var(--t-bg-text);
}

.demo-tile__creds-toggle {
	cursor: pointer;
	padding-block: var(--mea-space-1);
	font-size: var(--mea-text-xs);
	font-weight: var(--mea-w-semibold);
	color: var(--t-bg-text-secondary);
}

.demo-tile__creds-toggle:hover {
	color: var(--t-bg-text);
}

.demo-tile__creds-toggle:focus-visible {
	outline: 2px solid var(--t-border-focus);
	outline-offset: 2px;
}

.demo-tile__cred-line {
	margin: 0;
	padding: var(--mea-space-1) 0;
	font-size: var(--mea-text-xs);
	line-height: var(--mea-lh-normal);
	color: var(--t-bg-text);
	overflow-wrap: anywhere;
	display: flex;
	flex-wrap: wrap;
	gap: var(--mea-space-1) var(--mea-space-2);
}

.demo-tile__cred-state {
	font-weight: var(--mea-w-semibold);
}

.demo-tile__cred-user,
.demo-tile__cred-pass {
	font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}


/* ──────────────────────────────────────────────────────────────
   Wizard submit in-flight status (Story 3 D3/D5/D7).

   The status region is server-rendered EMPTY beside the advance
   control; the optional aid (static/js/submit-inflight.js) fills it
   with the localized busy sentence and flips [data-submit-status].
   With JS off nothing here paints anything — an empty region takes no
   space, which is exactly why the busy state can never claim to know
   about a request the server-rendered page cannot see.

   D7: the busy state lives ON THE CONTROL, in normal page flow. No
   overlay, no fixed positioning, nothing that covers the page or blocks
   reading while a submit is in flight.
   STRUCTURE in @layer layout; PAINT in @layer design (token-only, D10).
   ────────────────────────────────────────────────────────────── */
@layer layout {
	/* The nav is a row; the status takes its own line under the button. */
	.wizard-nav {
		flex-wrap: wrap;
	}

	.citation-step__submit-status {
		flex-basis: 100%;
		margin: 0;
		text-align: center;
	}

	/* Idle (and no-JS) is genuinely nothing: no reserved strip, no
	   placeholder that could read as a state. */
	.citation-step__submit-status:empty {
		display: none;
	}
}

@layer design {
	.citation-step__submit-status[data-submit-status="busy"] {
		margin-block-start: var(--mea-space-2);
		color: var(--t-text-secondary);
		font-size: 0.9em;
	}
}

/* ──────────────────────────────────────────────────────────────
   mea-web's own components (web/templates/components/). Each is selected by
   its own class and styled the way design-system components are: box and type
   in @layer layout, colour in @layer design, colours only from the surface
   the part sits on (--c-surface-*), never a fill of its own.
   ────────────────────────────────────────────────────────────── */
@layer layout {

	/* The evidence photo field (components/photo.html). The group itself has
	   no box; each state is a panel with its own surface and edge, so it pads
	   itself. */
	/* Both classes the field's fieldset carries: the page-wide
	   `form fieldset` rule nests under `form, .form`, which gives it a class's
	   weight, and would otherwise make this a grid. */
	.field.photo-field {
		/* A column rather than a grid: an empty region below can then cancel
		   its own gap (a grid track cannot shrink below zero). */
		display: flex;
		flex-direction: column;
		gap: var(--t-space-3);
		min-inline-size: 0;
		margin: 0;
		padding: 0;
		border: 0;

		/* The empty file drop centres what it asks for, with more room above
		   and below than the panels that follow it. */
		& .prompt {
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: var(--t-space-3);
			padding-block: var(--t-space-5);
			text-align: center;

			& .button {
				inline-size: min(100%, 24rem);
				justify-content: center;
				gap: var(--t-space-2);
			}
		}

		/* The marks: the prompt's camera, and the check or warning on a
		   thumbnail. The mark component centres them; their sizes are here. */
		& .prompt .mark {
			inline-size: 3rem;
			block-size: 3rem;

			& svg {
				inline-size: 1.5rem;
				block-size: 1.5rem;
			}
		}

		& :is(.prompt, .text) {
			& .title {
				margin: 0;
				font-size: var(--t-font-size-md);
				font-weight: var(--t-font-weight-bold);
			}

			& .hint {
				margin: 0;
				font-size: var(--t-font-size-sm);
			}
		}

		& .prompt .title {
			font-size: var(--t-font-size-lg);
		}

		/* Reading and result callouts: the photo beside what happened to it,
		   and the actions across the bottom. Without a painted photo the text
		   takes the whole width. The callout pads and rounds itself. */
		& :is(.progress, .result) {
			display: grid;
			grid-template-columns: minmax(0, 1fr);
			grid-template-areas: "text" "actions";
			align-items: center;
			gap: var(--t-space-3);

			&:has(.thumbnail:not([hidden])) {
				grid-template-columns: 5rem minmax(0, 1fr);
				grid-template-areas: "thumbnail text" "actions actions";
			}

			& .thumbnail {
				grid-area: thumbnail;
			}

			& .text {
				grid-area: text;
				display: grid;
				gap: var(--t-space-1);
			}

			& :is(.actions, .cancel) {
				grid-area: actions;
			}
		}

		/* A panel's actions stack, the one that moves on last. */
		& .actions {
			display: flex;
			flex-direction: column;
			gap: var(--t-space-2);

			& > * {
				justify-content: center;
				gap: var(--t-space-2);
			}
		}

		& .cancel {
			justify-self: center;
		}

		& .thumbnail {
			position: relative;
			margin: 0;
			inline-size: 5rem;
			aspect-ratio: 1;

			& img {
				inline-size: 100%;
				block-size: 100%;
				object-fit: cover;
				border-radius: var(--t-radius-md);
			}

			/* The badge is the same surface as the panel it sits in, so its
			   own edge is what sets it apart from the panel. */
			& .mark {
				position: absolute;
				inset-inline-end: calc(var(--t-space-2) * -1);
				inset-block-end: calc(var(--t-space-2) * -1);
				inline-size: 1.5rem;
				block-size: 1.5rem;
				border-width: var(--t-border-width-interactive);

				& svg {
					inline-size: 1rem;
					block-size: 1rem;
				}
			}
		}

		& .progress .title {
			display: flex;
			align-items: center;
			gap: var(--t-space-2);
		}

		/* The camera input is what the keyboard reaches; its focus is drawn on
		   the control that opens it, whichever panel that control is in (the
		   others are not shown). */
		&:has(.file-input:focus-visible) label.button[for] {
			outline-width: var(--t-border-width-focus);
			outline-style: solid;
			outline-offset: var(--t-border-width-focus);
		}

		/* A part the script hides stays hidden, whatever display it has. */
		& [hidden] {
			display: none;
		}

		/* The reading region stays in the page so it can announce; while all
		   it holds is hidden it takes no room and cancels its gap. */
		& > .progress-region:not(:has(> :not([hidden]))) {
			margin-block-start: calc(var(--t-space-3) * -1);
		}

		/* Inside the centred prompt, a refusal reads as a paragraph. */
		& .prompt .refusal {
			align-self: stretch;
			text-align: start;
		}

		/* A photo waiting in the input: the note that offers to read it. It
		   sits where the prompt was, on the same surface but no longer dashed,
		   because it is no longer empty, with a check beside its title. */
		& .ready {
			display: flex;
			flex-direction: column;
			gap: var(--t-space-3);

			& .title {
				display: flex;
				align-items: center;
				gap: var(--t-space-2);
				margin: 0;
				font-size: var(--t-font-size-md);
				font-weight: var(--t-font-weight-bold);

				& svg {
					inline-size: 1.25em;
					block-size: 1.25em;
					flex: none;
				}
			}
		}

		/* The ready panel reads the photo with "Fill in from photo" the first
		   time, and with "Try again" once a send from it has failed. */
		& .ready:not(:has(.refusal:not([hidden]))) .retry,
		& .ready:has(.refusal:not([hidden])) .autofill {
			display: none;
		}

		/* Which panel shows follows the input itself (it is `required`, so
		   CSS can tell whether it holds a photo): the prompt, the offer of
		   another photo or the last result while it is empty, the ready panel
		   once it holds one. */
		&:has(input[type="file"]:invalid) .ready {
			display: none;
		}

		&:has(input[type="file"]:valid) :is(.prompt, .another, .result) {
			display: none;
		}

		/* While the photo is read, the reading panel is the whole field: the
		   prompt, the last result and the offer to read are the same request
		   or are about to be replaced by it. */
		&.busy :is(.prompt, .another, .result, .ready) {
			display: none;
		}
	}

	/* The shoplifting evidence form (components/
	   shoplifting-evidence-photo-form.html). */
	.evidence-form {
		display: grid;
		gap: var(--t-space-4);

		& .labeled-hr {
			position: relative;
			text-align: center;

			& span {
				position: relative;
				z-index: 1;
				padding-inline: var(--t-space-2);
			}

			& hr {
				position: absolute;
				inset-block-start: 0.5lh;
				inline-size: 100%;
				margin: 0;
			}
		}

		/* Name across the top; quantity and price share the row below. */
		& .fields {
			display: grid;
			grid-template-columns: repeat(2, minmax(0, 1fr));
			gap: var(--t-space-3);
			align-items: start;

			& .name {
				grid-column: 1 / -1;
			}
		}

		/* A label with a badge beside it: "Item name   [From photo]". */
		& .label-row {
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			justify-content: space-between;
			gap: var(--t-space-2);

			& .badge {
				display: inline-flex;
				align-items: center;
				gap: var(--t-space-1);

				& svg {
					inline-size: 1em;
					block-size: 1em;
				}
			}
		}
	}
}

@layer design {
	.photo-field {
		& :is(.prompt, .text) .hint {
			color: var(--c-surface-text-color-muted);
		}

		& .result.success .title,
		& .ready .title svg {
			color: var(--c-surface-text-color-success);
		}

		& .result.warning .title {
			color: var(--c-surface-text-color-warning);
		}

		&:has(.file-input:focus-visible) label.button[for] {
			outline-color: var(--t-border-focus);
		}

		& .thumbnail .mark {
			border-style: var(--t-border-style-interactive);
			border-color: var(--c-surface-border-color-interactive);
		}

		/* Scripting is live and a file is over the field: dropping it here
		   is the same as taking it. */
		&.dragging .prompt {
			border-color: var(--c-surface-text-color-interactive);
		}
	}

	.evidence-form .labeled-hr span {
		background-color: var(--c-surface-background-color);
	}
}
