/* Self-hosted Manrope 800 — plates only; preload in HTML avoids FOUT */
@font-face {
	font-family: Manrope;
	src: url("/fonts/manrope-800-latin.woff2") format("woff2");
	font-weight: 800;
	font-style: normal;
	font-display: block;
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
	--brand-950: #00152d;
	--brand-900: #002957;
	--brand-800: #063c73;
	--brand-700: #0a4f8f;
	--brand-600: #1468b3;
	--brand-100: #dcecff;
	--brand-50: #f1f7ff;
	--success: #087f5b;
	--success-bg: #e6f6ef;
	--warning: #a85d00;
	--warning-bg: #fff3d6;
	--danger: #c62828;
	--danger-bg: #fdebea;
	--info: #1769aa;
	--info-bg: #e8f2fb;
	--canvas: #f4f6f8;
	--surface: #ffffff;
	--surface-raised: #ffffff;
	--surface-muted: #f7f8fa;
	--surface-strong: #eef1f4;
	--text: #18212c;
	--text-soft: #4e5d6c;
	--text-muted: #718092;
	--line: #d9dee5;
	--line-strong: #c4ccd5;
	--focus: #2b7ccc;
	--scrim: rgba(8, 18, 31, 0.58);
	--shadow-1: 0 1px 2px rgba(21, 36, 53, 0.06);
	--shadow-2: 0 12px 32px rgba(18, 35, 54, 0.15);
	--header-height: 64px;
	--content-max: 1680px;
	--radius: 2px;
	--btn-h: 38px; /* chrome: icon, toolbar, pager, map controls */
	--control-h: 44px; /* form fields + matching apply */
	--font: Inter, "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
	--brand-950: #071527;
	--brand-900: #0a345e;
	--brand-800: #0d467c;
	--brand-700: #1d63a0;
	--brand-600: #4c8dca;
	--brand-100: #153b60;
	--brand-50: #102942;
	--success: #64d8a6;
	--success-bg: #123b2e;
	--warning: #f2bd5b;
	--warning-bg: #453313;
	--danger: #ff8989;
	--danger-bg: #481f24;
	--info: #75b9f1;
	--info-bg: #16354f;
	--canvas: #0d141c;
	--surface: #131d28;
	--surface-raised: #182431;
	--surface-muted: #111a24;
	--surface-strong: #202d3b;
	--text: #edf2f7;
	--text-soft: #bac5d0;
	--text-muted: #8d9aaa;
	--line: #2b3948;
	--line-strong: #3b4b5d;
	--focus: #6db4f4;
	--scrim: rgba(0, 5, 12, 0.78);
	--shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
	--shadow-2: 0 14px 40px rgba(0, 0, 0, 0.38);
}

* {
	box-sizing: border-box;
}

html {
	min-width: 320px;
	background: var(--canvas);
	color-scheme: light;
}

html[data-theme="dark"] {
	color-scheme: dark;
}

body {
	min-height: 100vh;
	margin: 0;
	background: var(--canvas);
	color: var(--text);
	font-family: var(--font);
	font-size: 14px;
	line-height: 1.45;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

button,
input,
select {
	font: inherit;
}

button,
select {
	cursor: pointer;
}

/* Native <select> / <option> must carry theme colors (esp. dark mode popups) */
select {
	background-color: var(--surface);
	color: var(--text);
	color-scheme: inherit;
}

select option,
select optgroup {
	background-color: var(--surface);
	color: var(--text);
}

html[data-theme="dark"] select,
html[data-theme="dark"] select option,
html[data-theme="dark"] select optgroup {
	background-color: var(--surface-raised);
	color: var(--text);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 2px;
}

button:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.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;
}

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

.icon {
	width: 18px;
	height: 18px;
	flex: 0 0 auto;
}

.icon-sm {
	width: 16px;
	height: 16px;
}

/* Shared controls */
.btn,
.icon-btn,
.toolbar-control-btn,
.map-control-btn {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: var(--btn-h);
	min-height: var(--btn-h);
	border: 1px solid transparent;
	border-radius: var(--radius);
	font-weight: 650;
	letter-spacing: 0.005em;
	line-height: 1;
	transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn {
	padding: 0 14px;
	background: var(--brand-900);
	color: #fff;
}

.btn:hover {
	background: var(--brand-800);
}

.btn.secondary {
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--text);
}

.btn.secondary:hover,
.icon-btn:hover {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
}

.btn.ghost {
	background: transparent;
	color: var(--text-soft);
}

.btn.ghost:hover {
	background: var(--surface-strong);
	color: var(--text);
}

.btn.block {
	width: 100%;
}

.icon-btn {
	width: var(--btn-h);
	min-width: var(--btn-h);
	padding: 0;
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--text-soft);
}

.control {
	display: flex;
	box-sizing: border-box;
	height: var(--control-h);
	min-height: var(--control-h);
	align-items: center;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.control:hover {
	border-color: color-mix(in srgb, var(--brand-600) 45%, var(--line-strong));
}

.control:focus-within {
	border-color: var(--focus);
	background: var(--surface);
	box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 18%, transparent);
}

.control > .icon {
	margin-left: 12px;
	color: var(--text-muted);
	pointer-events: none;
}

.control input,
.control select {
	width: 100%;
	min-width: 0;
	padding: 10px 12px;
	border: 0;
	outline: 0;
	background: transparent;
	color: var(--text);
	caret-color: var(--brand-700);
}

.control select {
	padding-right: 28px;
	/* Keep closed field transparent over .control, but options use themed colors above */
	background-color: transparent;
	color: var(--text);
}

html[data-theme="dark"] .control select {
	/* Avoid light OS chrome + light text in the closed/open field */
	background-color: var(--surface);
	color: var(--text);
	color-scheme: dark;
}

html[data-theme="dark"] .control {
	background: var(--surface);
}

.control input:-webkit-autofill,
.control input:-webkit-autofill:hover,
.control input:-webkit-autofill:focus,
.control input:-webkit-autofill:active {
	-webkit-text-fill-color: var(--text) !important;
	caret-color: var(--brand-700);
	box-shadow: 0 0 0 1000px var(--surface) inset !important;
	transition: background-color 99999s ease-out;
}

.field {
	display: grid;
	gap: 6px;
	min-width: 0;
}

.field-label {
	color: var(--text-soft);
	font-size: 12px;
	font-weight: 650;
	letter-spacing: 0.025em;
}

.lang-wrap {
	position: relative;
	display: inline-flex;
	height: var(--btn-h);
	align-items: stretch;
}

.lang-menu {
	position: relative;
	height: 100%;
}

.lang-trigger {
	box-sizing: border-box;
	display: inline-flex;
	width: auto;
	height: var(--btn-h);
	min-height: var(--btn-h);
	min-width: 72px;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font-size: 12px;
	font-weight: 750;
	letter-spacing: 0.04em;
	line-height: 1;
	transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.lang-trigger:hover,
.lang-menu.open .lang-trigger {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
}

.lang-trigger .icon-sm {
	width: 14px;
	height: 14px;
	color: var(--text-muted);
	transition: transform 120ms ease;
}

.lang-menu.open .lang-trigger .icon-sm {
	transform: rotate(180deg);
}

.lang-popover {
	position: absolute;
	z-index: 1400;
	top: calc(100% + 6px);
	right: 0;
	display: none;
	min-width: 108px;
	padding: 4px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow-2);
}

.lang-menu.open .lang-popover {
	display: grid;
	gap: 2px;
}

.lang-option {
	display: flex;
	min-height: 34px;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 0 10px;
	border: 0;
	border-radius: var(--radius);
	background: transparent;
	color: var(--text-soft);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-align: left;
}

.lang-option:hover {
	background: var(--surface-strong);
	color: var(--text);
}

.lang-option.is-active {
	background: var(--brand-50);
	color: var(--brand-700);
}

.lang-check {
	opacity: 0;
	color: var(--brand-700);
}

.lang-option.is-active .lang-check {
	opacity: 1;
}

/* Application header */
.app-header {
	position: sticky;
	z-index: 800;
	top: 0;
	display: flex;
	height: var(--header-height);
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	padding: 0 max(20px, calc((100vw - var(--content-max)) / 2));
	border-bottom: 1px solid var(--line);
	background: color-mix(in srgb, var(--surface) 96%, transparent);
	box-shadow: var(--shadow-1);
	backdrop-filter: blur(12px);
}

.brand-lockup {
	display: inline-flex;
	align-items: center;
	gap: 11px;
	min-width: 0;
	color: inherit;
	text-decoration: none;
}

.brand-mark {
	display: grid;
	width: 34px;
	height: 34px;
	place-items: center;
	flex: 0 0 auto;
}

.brand-logo {
	display: block;
	width: 34px;
	height: 34px;
	object-fit: contain;
}

.brand-logo-white {
	display: none;
}

[data-theme="dark"] .brand-logo-blue {
	display: none;
}

[data-theme="dark"] .brand-logo-white {
	display: block;
}

.brand-mark-on-dark .brand-logo {
	display: block;
}

.brand-copy {
	display: grid;
	line-height: 1.15;
}

.brand-name {
	color: var(--brand-900);
	font-size: 16px;
	font-weight: 800;
	letter-spacing: -0.015em;
}

[data-theme="dark"] .brand-name {
	color: #e7f2ff;
}

.brand-subtitle {
	margin-top: 3px;
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.055em;
	text-transform: uppercase;
}

.header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.user-chip {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	padding: 0 10px;
	border-left: 1px solid var(--line);
	color: var(--text-soft);
}

.user-chip .icon {
	color: var(--brand-600);
}

.refresh-group {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.refresh-meta {
	max-width: 180px;
	overflow: hidden;
	color: var(--text-muted);
	font-size: 12px;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.refresh-btn.is-busy {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
	pointer-events: none;
}

.refresh-btn.is-busy .icon {
	animation: spin 700ms linear infinite;
}

html[data-theme="dark"] .refresh-btn.is-busy {
	background: color-mix(in srgb, var(--brand-600) 18%, var(--surface));
}

.stale-banner {
	position: sticky;
	z-index: 750;
	top: var(--header-height);
	display: none;
	align-items: center;
	gap: 9px;
	padding: 9px max(20px, calc((100vw - var(--content-max)) / 2));
	border-bottom: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line));
	background: var(--warning-bg);
	color: var(--warning);
	font-size: 13px;
	font-weight: 600;
}

.stale-banner.show {
	display: flex;
}

/* Dashboard layout */
.dashboard-shell {
	display: grid;
	width: min(100%, var(--content-max));
	margin: 0 auto;
	padding: 26px 24px 44px;
	gap: 18px;
}

.page-heading {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 20px;
}

.page-heading h1 {
	margin: 0;
	color: var(--text);
	font-size: clamp(22px, 2vw, 30px);
	font-weight: 760;
	letter-spacing: -0.035em;
	line-height: 1.15;
}

.cards {
	display: grid;
	grid-template-columns: repeat(7, minmax(0, 1fr));
	gap: 12px;
}

.metric-card {
	--metric-color: var(--brand-700);
	position: relative;
	display: grid;
	grid-template-rows: auto 1fr;
	min-width: 0;
	min-height: 116px;
	padding: 16px 16px 14px;
	border: 1px solid var(--line);
	border-top: 3px solid var(--metric-color);
	background: var(--surface);
	box-shadow: var(--shadow-1);
	transition: border-color 120ms ease, background-color 120ms ease;
}

.metric-card:hover {
	border-right-color: var(--line-strong);
	border-bottom-color: var(--line-strong);
	border-left-color: var(--line-strong);
	background: color-mix(in srgb, var(--surface) 96%, var(--metric-color));
}

.metric-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 8px;
}

.metric-label {
	min-width: 0;
	color: var(--text-soft);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.005em;
	line-height: 1.3;
	overflow-wrap: anywhere;
}

.metric-icon {
	display: grid;
	flex: 0 0 auto;
	width: 30px;
	height: 30px;
	place-items: center;
	background: var(--brand-50);
	color: var(--metric-color);
}

.metric-icon .icon {
	width: 16px;
	height: 16px;
}

.metric-value {
	align-self: end;
	margin-top: 12px;
	color: var(--text);
	font-size: 30px;
	font-variant-numeric: tabular-nums;
	font-weight: 780;
	letter-spacing: -0.045em;
	line-height: 1;
}

.metric-card[data-tone="success"] {
	--metric-color: var(--success);
}

.metric-card[data-tone="success"] .metric-icon {
	background: var(--success-bg);
}

.metric-card[data-tone="warning"] {
	--metric-color: var(--warning);
}

.metric-card[data-tone="warning"] .metric-icon {
	background: var(--warning-bg);
}

.metric-card[data-tone="danger"] {
	--metric-color: var(--danger);
}

.metric-card[data-tone="danger"] .metric-icon {
	background: var(--danger-bg);
}

.panel {
	min-width: 0;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow-1);
}

.panel-header {
	display: flex;
	min-height: 52px;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	border-bottom: 1px solid var(--line);
	background: var(--surface-muted);
	box-shadow: inset 3px 0 0 var(--brand-700);
}

.panel-title {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.panel-title > .icon {
	flex: 0 0 auto;
	color: var(--brand-600);
}

.panel-title h2 {
	margin: 0;
	color: var(--text);
	font-size: 15px;
	font-weight: 730;
	letter-spacing: -0.012em;
}

.panel-meta {
	margin: 2px 0 0;
	color: var(--text-muted);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
	line-height: 1.3;
}

.panel-actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
}

.columns-picker {
	position: relative;
}

.columns-picker[hidden] {
	display: none !important;
}

.columns-picker-menu {
	position: absolute;
	z-index: 40;
	top: calc(100% + 6px);
	right: 0;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	width: min(280px, calc(100vw - 32px));
	max-height: min(360px, 50dvh);
	border: 1px solid var(--line-strong);
	background: var(--surface);
	box-shadow: var(--shadow-2);
}

.columns-picker-menu[hidden] {
	display: none !important;
}

.columns-picker-head {
	padding: 10px 12px 8px;
	border-bottom: 1px solid var(--line);
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 650;
}

.columns-picker-list {
	overflow: auto;
	padding: 6px;
}

.columns-picker-item {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	padding: 8px;
	border-radius: var(--radius);
	color: var(--text);
	font-size: 12.5px;
	font-weight: 550;
	line-height: 1.35;
	cursor: pointer;
}

.columns-picker-item:hover {
	background: var(--surface-muted);
}

.columns-picker-item input {
	margin-top: 2px;
	flex: 0 0 auto;
}

.columns-picker-item span {
	min-width: 0;
	word-break: break-word;
}

.columns-picker-foot {
	padding: 8px;
	border-top: 1px solid var(--line);
	background: var(--surface-muted);
}

.columns-picker-foot .btn {
	width: 100%;
}

.toolbar-control-btn.is-active {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-800);
}

.th-answer {
	max-width: 140px;
}

.page-size-field {
	display: grid;
	gap: 4px;
	min-width: 72px;
	align-content: end;
}

.page-size-field[hidden] {
	display: none;
}

.page-size-field .field-label {
	margin: 0;
	font-size: 10px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.page-size-field select {
	box-sizing: border-box;
	height: var(--btn-h);
	min-height: var(--btn-h);
	padding: 0 28px 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 13px;
	font-weight: 650;
	line-height: 1;
}

.toolbar-control-btn {
	gap: 6px;
	padding: 0 12px;
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 13px;
	white-space: nowrap;
	cursor: pointer;
}

.toolbar-control-btn:hover {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
}

.map-expand-field {
	min-width: 0;
}

.filters-panel {
	padding: 0;
}

.filter-grid {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px 12px;
	padding: 14px 16px;
}

.filter-grid > .field {
	flex: 1 1 0;
	min-width: 132px;
}

.filter-grid > .field:first-child {
	flex: 1.35 1 180px;
	min-width: 180px;
}

.filter-grid .field-label {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.filter-grid .control {
	width: 100%;
}

.filter-grid .control select,
.filter-grid .control input {
	width: 100%;
	min-width: 0;
}

.filter-answers-trigger-field[hidden] {
	display: none !important;
}

.filter-answers-trigger {
	width: 100%;
	justify-content: flex-start;
	gap: 8px;
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--text);
}

.filter-answers-trigger:hover {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
}

.filter-answers-trigger.is-active {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-800);
}

.filter-answers-count {
	margin-left: auto;
	min-width: 20px;
	padding: 2px 6px;
	border-radius: 999px;
	background: var(--brand-900);
	color: #fff;
	font-size: 11px;
	font-weight: 750;
	line-height: 1.2;
	text-align: center;
}

.filter-actions {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 8px;
	margin-left: auto;
}

.filter-grid .btn,
.filter-actions .btn {
	flex: 0 0 auto;
	width: auto;
	min-width: 108px;
	height: var(--control-h);
	min-height: var(--control-h);
	padding: 0 16px;
}

.modal-footer .btn {
	min-width: 108px;
	height: var(--btn-h);
	min-height: var(--btn-h);
}

.modal-footer .btn.secondary {
	margin-right: auto;
}

.workspace-grid {
	--workspace-height: clamp(560px, calc(100dvh - 292px), 900px);
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
	align-items: stretch;
	gap: 14px;
	min-height: var(--workspace-height);
}

.workspace-grid.is-map-collapsed {
	grid-template-columns: minmax(0, 1fr);
}

.workspace-grid.is-drivers-collapsed {
	grid-template-columns: minmax(0, 1fr);
}

.workspace-grid.is-drivers-collapsed .table-panel {
	display: none;
}

.map-expand-field[hidden],
.drivers-expand-field[hidden] {
	display: none;
}

.table-panel,
.map-panel {
	height: var(--workspace-height);
	min-height: var(--workspace-height);
}

.table-panel {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
}

.table-wrap {
	width: 100%;
	min-height: 0;
	overflow: auto;
	overscroll-behavior: contain;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12.5px;
}

th,
td {
	padding: 9px 12px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: middle;
}

th {
	position: sticky;
	z-index: 2;
	top: 0;
	background: var(--surface-muted);
	color: var(--text-soft);
	font-size: 11px;
	font-weight: 750;
	letter-spacing: 0.045em;
	text-transform: uppercase;
	white-space: nowrap;
}

th[data-sort] {
	cursor: pointer;
	user-select: none;
}

th[data-sort]:hover {
	color: var(--brand-700);
}

tbody tr {
	cursor: pointer;
	transition: background-color 100ms ease;
}

tbody tr:hover {
	background: color-mix(in srgb, var(--brand-50) 72%, var(--surface));
}

tbody tr:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: -2px;
}

tbody tr:last-child td {
	border-bottom: 0;
}

.cell-primary {
	color: var(--text);
	font-weight: 650;
}

.cell-secondary {
	margin-top: 2px;
	color: var(--text-muted);
	font-size: 11px;
	font-variant-numeric: tabular-nums;
}

.badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 7px;
	border: 1px solid var(--line);
	border-radius: var(--radius);
	background: var(--surface-strong);
	color: var(--text-soft);
	font-size: 11px;
	font-weight: 700;
	line-height: 1.25;
	white-space: nowrap;
}

.badge::before {
	width: 6px;
	height: 6px;
	background: currentColor;
	content: "";
}

.badge.warn {
	border-color: color-mix(in srgb, var(--warning) 28%, var(--line));
	background: var(--warning-bg);
	color: var(--warning);
}

.badge.danger {
	border-color: color-mix(in srgb, var(--danger) 28%, var(--line));
	background: var(--danger-bg);
	color: var(--danger);
}

.badge.ok {
	border-color: color-mix(in srgb, var(--success) 28%, var(--line));
	background: var(--success-bg);
	color: var(--success);
}

.pager {
	display: flex;
	min-height: 54px;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 8px 12px;
	border-top: 1px solid var(--line);
}

.pager-controls {
	display: flex;
	align-items: center;
	gap: 6px;
}

.pager .btn {
	padding: 0 10px;
}

.pager-size {
	box-sizing: border-box;
	min-width: 64px;
	height: var(--btn-h);
	min-height: var(--btn-h);
	padding: 0 28px 0 10px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 13px;
	font-weight: 650;
	line-height: 1;
}

.empty {
	display: grid;
	min-height: 240px;
	place-items: center;
	padding: 32px;
	color: var(--text-muted);
	text-align: center;
}

.empty[hidden] {
	display: none;
}

.map-panel {
	position: relative;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	overflow: hidden;
	transition: width 160ms ease, min-width 160ms ease;
}

.workspace-grid.is-map-collapsed .map-panel {
	display: none;
}

.map-shell {
	position: relative;
	z-index: 0;
	min-height: 0;
	isolation: isolate;
	overflow: hidden;
}

.map-controls {
	position: absolute;
	z-index: 30;
	top: 12px;
	display: flex;
	align-items: flex-start;
	gap: 8px;
	pointer-events: none;
}

.map-controls-left {
	left: 12px;
}

.map-controls-right {
	right: 12px;
}

/* Shared map marker label shell — chip (name or plate) draws itself */
.leaflet-tooltip.map-point-label {
	padding: 0 0 6px;
	border: 0;
	background: transparent;
	box-shadow: none;
	overflow: visible;
	white-space: nowrap;
	font-family: var(--font);
}

/* Kill Leaflet's default -6px top margin that floats labels away from the dot */
.leaflet-tooltip.map-point-label.leaflet-tooltip-top {
	margin-top: 0;
}

.leaflet-tooltip.map-point-label::before,
.leaflet-tooltip.map-point-label::after {
	display: none;
}

.map-point-chip {
	--chip-bg: color-mix(in srgb, var(--surface) 96%, transparent);
	--chip-fg: var(--text);
	--chip-border: var(--line-strong);
	box-sizing: border-box;
	position: relative;
	display: inline-flex;
	align-items: center;
	height: 24px;
	padding: 0 11px;
	border: 1px solid var(--chip-border);
	border-radius: 2px;
	background: var(--chip-bg);
	color: var(--chip-fg);
	box-shadow: var(--shadow-1);
	font-size: 11px;
	font-weight: 750;
	letter-spacing: 0.01em;
	line-height: 1.15;
}

html[data-theme="dark"] .map-point-chip {
	--chip-bg: color-mix(in srgb, var(--surface) 96%, #000);
}

/* Tip under name/plate — centered with margin, rotate only (no translateX) */
.map-point-chip::before,
.leaflet-tooltip.map-point-label--plate .plate::before {
	display: none;
}

.map-point-chip::after,
.leaflet-tooltip.map-point-label--plate .plate::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: auto;
	bottom: -4px;
	z-index: 0;
	width: 7px;
	height: 7px;
	margin-inline: auto;
	box-sizing: border-box;
	border-right: 1px solid var(--chip-border, var(--plate-border));
	border-bottom: 1px solid var(--chip-border, var(--plate-border));
	background: var(--chip-bg, var(--plate-bg));
	transform: rotate(45deg);
	pointer-events: none;
}

html[data-theme="dark"] .map-shell .leaflet-container {
	background: #1b1b1b;
}

.map-controls[hidden] {
	display: none;
}

.map-control-group {
	display: grid;
	border: 1px solid var(--line-strong);
	background: var(--surface);
	box-shadow: var(--shadow-2);
	pointer-events: auto;
}

.map-control-btn {
	width: var(--btn-h);
	min-width: var(--btn-h);
	padding: 0;
	border-color: var(--line-strong);
	background: var(--surface);
	color: var(--text-soft);
	font-size: 12px;
	font-weight: 700;
	box-shadow: var(--shadow-2);
	pointer-events: auto;
	cursor: pointer;
}

.map-control-group .map-control-btn {
	border: 0;
	border-radius: 0;
	box-shadow: none;
}

.map-control-group .map-control-btn + .map-control-btn {
	border-top: 1px solid var(--line);
}

.map-control-btn:hover:not(:disabled) {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700);
}

.map-control-group .map-control-btn:hover:not(:disabled) {
	border-color: transparent;
}

.map-control-btn.is-active {
	background: var(--brand-900);
	color: #fff;
}

.map-control-btn.is-active:hover:not(:disabled) {
	background: var(--brand-800);
	color: #fff;
}

.map-control-group .map-control-btn.is-active:hover:not(:disabled) {
	border-color: transparent;
}

.map-control-btn .icon {
	width: 18px;
	height: 18px;
}

.map-control-btn:disabled {
	background: var(--surface-muted);
	color: var(--text-muted);
	opacity: 0.5;
}

#map {
	position: relative;
	z-index: 0;
	width: 100%;
	height: 100%;
	min-height: 100%;
	background: var(--surface-strong);
}

.map-shell .leaflet-container,
.map-shell .leaflet-pane,
.map-shell .leaflet-control {
	font-family: var(--font);
}

.map-shell .leaflet-container {
	z-index: 0;
	background: #dce5eb;
}

.map-shell .leaflet-control-container {
	position: relative;
	z-index: 10;
}

.leaflet-popup.map-popup-frame {
	margin-bottom: 14px;
}

.leaflet-popup.map-popup-frame .leaflet-popup-content-wrapper {
	padding: 0;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius) !important;
	background: var(--surface) !important;
	color: var(--text) !important;
	box-shadow: var(--shadow-2) !important;
}

.leaflet-popup.map-popup-frame .leaflet-popup-tip {
	border: 1px solid var(--line-strong);
	border-top: 0;
	border-left: 0;
	background: var(--surface) !important;
	box-shadow: none !important;
	width: 12px;
	height: 12px;
	margin: -7px auto 0;
	transform: rotate(45deg);
}

.leaflet-popup.map-popup-frame .leaflet-popup-content {
	margin: 0 !important;
	min-width: 200px;
	line-height: 1.35 !important;
}

.leaflet-popup.map-popup-frame .leaflet-popup-close-button {
	top: 8px !important;
	right: 8px !important;
	width: 28px;
	height: 28px;
	padding: 0 !important;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius);
	background: var(--surface);
	color: var(--text-soft) !important;
	font-size: 18px !important;
	font-weight: 500 !important;
	line-height: 26px !important;
	text-align: center;
}

.leaflet-popup.map-popup-frame .leaflet-popup-close-button:hover {
	border-color: var(--brand-600);
	background: var(--brand-50);
	color: var(--brand-700) !important;
}

.map-popup {
	display: grid;
	gap: 10px;
	padding: 14px 40px 14px 14px;
}

.map-popup-head {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	min-width: 0;
}

.map-popup-title {
	min-width: 0;
	color: var(--text);
	font-size: 14px;
	font-weight: 750;
	letter-spacing: -0.01em;
	line-height: 1.25;
	word-break: break-word;
}

.map-popup-plate {
	display: flex;
}

.map-popup-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	color: var(--text-muted);
	font-size: 12px;
	font-weight: 550;
}

.map-popup-dot {
	width: 3px;
	height: 3px;
	border-radius: 50%;
	background: var(--line-strong);
}

.map-popup-btn {
	justify-self: start;
	gap: 6px;
	min-height: var(--btn-h);
	height: var(--btn-h);
	padding: 0 12px;
	font-size: 12.5px;
}

.map-popup-btn .icon-sm {
	width: 14px;
	height: 14px;
}

.map-fallback {
	padding: 32px;
	color: var(--text-muted);
	text-align: center;
}

.replies-panel {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	min-width: 0;
}

.replies-table-wrap {
	max-height: min(42dvh, 420px);
}

.replies-panel > .empty {
	min-height: 140px;
}

.replies-table tbody tr {
	cursor: pointer;
}

.is-soft-refreshing .metric-value,
.is-soft-refreshing #driverRows,
.is-soft-refreshing .map-shell,
.is-soft-refreshing #repliesRows {
	transition: opacity 160ms ease;
}

.is-soft-refreshing .metric-value,
.is-soft-refreshing #driverRows,
.is-soft-refreshing #repliesRows {
	opacity: 0.55;
}

.is-table-loading #driverRows {
	opacity: 1;
}

.skeleton {
	display: block;
	overflow: hidden;
	position: relative;
	background: color-mix(in srgb, var(--surface-muted) 78%, var(--line));
}

.skeleton::after {
	position: absolute;
	inset: 0;
	transform: translateX(-100%);
	background: linear-gradient(
		90deg,
		transparent,
		color-mix(in srgb, var(--surface) 70%, transparent),
		transparent
	);
	content: "";
	animation: shimmer 1.15s ease-in-out infinite;
}

.skeleton-card {
	gap: 18px;
	pointer-events: none;
	border-top-color: var(--line-strong);
}

.skeleton-line {
	height: 12px;
	margin-top: 4px;
}

.skeleton-value {
	width: 42%;
	height: 28px;
	margin-top: auto;
}

.skeleton-row td {
	padding: 14px 16px;
}

.skeleton-row-bar {
	height: 14px;
	width: 100%;
}

.skeleton-map {
	width: 100%;
	height: 100%;
	min-height: 100%;
}

.w-60 {
	width: 60%;
}

.map-skeleton {
	position: absolute;
	z-index: 20;
	inset: 0;
	pointer-events: none;
}

.map-skeleton[hidden] {
	display: none;
}

@keyframes shimmer {
	100% { transform: translateX(100%); }
}

@keyframes spin {
	to { transform: rotate(360deg); }
}

/* Answer filters modal */
.modal[hidden] {
	display: none !important;
}

.modal {
	position: fixed;
	z-index: 2100;
	inset: 0;
	display: grid;
	place-items: center;
	padding: 20px;
}

.modal-backdrop {
	position: absolute;
	inset: 0;
	background: var(--scrim);
}

.modal-panel {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-rows: auto minmax(0, 1fr) auto;
	width: min(520px, 100%);
	max-height: min(720px, calc(100dvh - 40px));
	border: 1px solid var(--line-strong);
	background: var(--surface);
	box-shadow: var(--shadow-2);
}

.modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 14px;
	padding: 14px 16px;
	border-bottom: 1px solid var(--line);
}

.modal-heading {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	min-width: 0;
}

.modal-heading .icon {
	margin-top: 2px;
	color: var(--brand-600);
	flex: 0 0 auto;
}

.modal-heading h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 750;
}

.modal-sub {
	margin: 4px 0 0;
	color: var(--text-muted);
	font-size: 12px;
	line-height: 1.4;
}

.modal-body {
	overflow: auto;
	padding: 14px 16px;
}

.answer-filter-list {
	display: grid;
	gap: 12px;
}

.answer-filter-row .field-label {
	white-space: normal;
	overflow: visible;
	text-overflow: unset;
	line-height: 1.35;
}

.answer-filter-row .control {
	background: var(--surface);
}

.answer-filter-row .control select {
	background-color: var(--surface);
	color: var(--text);
	color-scheme: inherit;
}

html[data-theme="dark"] .answer-filter-row .control select,
html[data-theme="dark"] .answer-filter-row .control select option {
	background-color: var(--surface-raised);
	color: var(--text);
	color-scheme: dark;
}

.modal-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid var(--line);
	background: var(--surface-muted);
}

/* Detail dialog */
.drawer {
	position: fixed;
	z-index: 2000;
	inset: 0;
	display: none;
	background: var(--scrim);
}

.drawer.open {
	display: grid;
	justify-content: end;
}

.drawer-panel {
	display: grid;
	width: min(620px, 100vw);
	height: 100dvh;
	grid-template-rows: auto minmax(0, 1fr);
	border-left: 1px solid var(--line-strong);
	background: var(--surface);
	box-shadow: var(--shadow-2);
	animation: slide-in 180ms ease-out;
}

@keyframes slide-in {
	from { transform: translateX(18px); opacity: 0.7; }
	to { transform: translateX(0); opacity: 1; }
}

.drawer-header {
	display: flex;
	min-height: 64px;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 12px 18px;
	border-bottom: 1px solid var(--line);
}

.drawer-heading {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
}

.drawer-heading .icon {
	color: var(--brand-600);
}

.drawer-heading h2 {
	margin: 0;
	overflow: hidden;
	font-size: 16px;
	font-weight: 750;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.drawer-content {
	overflow-y: auto;
	padding: 16px 18px 28px;
}

.detail-summary {
	display: grid;
	gap: 14px;
	margin-bottom: 20px;
	padding: 14px;
	border: 1px solid var(--line);
	background: var(--surface-muted);
}

.detail-summary-main {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.detail-vehicle-name {
	color: var(--text-soft);
	font-size: 13px;
	font-weight: 600;
}

.detail-muted {
	color: var(--text-muted);
	font-size: 13px;
	font-weight: 600;
}

.detail-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.detail-facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
	gap: 1px;
	border: 1px solid var(--line);
	background: var(--line);
	overflow: hidden;
}

.answers-cell {
	display: grid;
	gap: 4px;
}

.answers-cell-row {
	display: grid;
	gap: 1px;
	min-width: 0;
}

.answers-cell-label {
	color: var(--text-muted);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.answers-cell-value {
	color: var(--text);
	font-size: 12.5px;
	font-weight: 650;
	word-break: break-word;
}

.answers-cell-more {
	margin-top: 2px;
	color: var(--brand-700);
	font-size: 11px;
	font-weight: 700;
}

.detail-fact {
	display: grid;
	align-content: start;
	align-items: start;
	gap: 4px;
	padding: 10px 12px;
	background: var(--surface);
	min-width: 0;
}

.detail-fact-label {
	color: var(--text-muted);
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.05em;
	line-height: 1.2;
	text-transform: uppercase;
}

.detail-fact-value {
	color: var(--text);
	font-size: 12.5px;
	font-weight: 650;
	line-height: 1.35;
	word-break: break-word;
}

.detail-fact-tg {
	display: inline-flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

.detail-id {
	color: var(--text-muted);
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

.detail-fact-inline {
	color: var(--text-muted);
	font-size: 11px;
	font-weight: 550;
	white-space: nowrap;
}

.detail-section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 10px;
}

.detail-section-meta {
	color: var(--text-muted);
	font-size: 12px;
	font-weight: 650;
}

.section-label {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	color: var(--text);
	font-size: 14px;
	font-weight: 750;
}

.section-label .icon {
	color: var(--brand-600);
}

.detail-map-block,
.detail-history-block,
.detail-answers-block {
	margin: 0 0 22px;
}

.detail-answers-list {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
	border: 1px solid var(--line);
	background: var(--surface);
	max-height: min(280px, 36dvh);
	overflow: auto;
}

.detail-answers-list li {
	display: grid;
	grid-template-columns: minmax(100px, 0.42fr) minmax(0, 1fr);
	align-items: start;
	gap: 12px;
	padding: 9px 12px;
	border-bottom: 1px solid var(--line);
	font-size: 12px;
}

.detail-answers-list li:last-child {
	border-bottom: 0;
}

.detail-map-shell {
	position: relative;
	z-index: 0;
	height: 260px;
	min-height: 220px;
	border: 1px solid var(--line);
	isolation: isolate;
	overflow: hidden;
	background: var(--surface-muted);
}

.detail-map-shell .leaflet-container {
	width: 100%;
	height: 100%;
	background: #dce5eb;
	font-family: var(--font);
}

.detail-map-empty,
.detail-empty {
	display: grid;
	place-items: center;
	padding: 20px;
	color: var(--text-muted);
	font-size: 13px;
	text-align: center;
}

.detail-map-empty {
	height: 100%;
}

.detail-map-empty[hidden] {
	display: none;
}

.detail-path-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 10px 14px;
	margin: 8px 0 0;
	color: var(--text-muted);
	font-size: 11px;
}

.detail-path-legend span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.detail-path-dot {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--success);
}

.detail-path-dot.is-stale {
	background: var(--warning);
}

.detail-path-line {
	width: 18px;
	height: 2px;
	background: color-mix(in srgb, var(--brand-600) 70%, transparent);
}

.history-list {
	display: grid;
	gap: 10px;
}

.history-item {
	border: 1px solid var(--line);
	background: var(--surface);
}

.history-head {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 14px;
	background: var(--surface-muted);
	border-bottom: 1px solid var(--line);
}

.history-head-main {
	min-width: 0;
}

.history-title {
	color: var(--text);
	font-size: 13px;
	font-weight: 700;
}

.history-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 4px;
	color: var(--text-muted);
	font-size: 11px;
}

.history-meta-extras {
	margin-top: 6px;
}

.history-answers {
	display: grid;
	margin: 0;
	padding: 0;
	list-style: none;
}

.history-answers li {
	display: grid;
	grid-template-columns: minmax(88px, 0.4fr) minmax(0, 1fr);
	align-items: start;
	gap: 12px;
	padding: 9px 14px;
	border-bottom: 1px solid var(--line);
	font-size: 12px;
}

.history-answers .answer-key,
.history-answers .answer-value {
	line-height: 1.35;
}

.history-answers li:last-child {
	border-bottom: 0;
}

.answer-key {
	color: var(--text-muted);
	font-weight: 650;
}

.answer-value {
	color: var(--text);
	font-weight: 550;
	word-break: break-word;
}

.map-popup--compact {
	padding: 10px 12px;
	gap: 6px;
}

.map-popup--compact .map-popup-title {
	font-size: 12.5px;
}

/* Login */
.login-page {
	display: grid;
	min-height: 100dvh;
	grid-template-columns: minmax(320px, 0.9fr) minmax(460px, 1.1fr);
	background: var(--surface);
}

.login-brand {
	position: relative;
	display: grid;
	overflow: hidden;
	align-content: space-between;
	padding: clamp(32px, 5vw, 72px);
	background: url("/login-bg.jpg") center / cover no-repeat;
	color: #fff;
}

.login-brand .brand-lockup,
.login-brand-copy,
.login-brand-foot {
	position: relative;
	z-index: 1;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.login-brand .brand-mark {
	background: transparent;
}

.login-brand .brand-name {
	color: #fff;
}

.login-brand .brand-subtitle {
	color: rgba(255, 255, 255, 0.68);
}

.login-brand-copy {
	max-width: 540px;
}

.login-brand-copy h1 {
	margin: 0;
	font-size: clamp(34px, 5vw, 64px);
	font-weight: 780;
	letter-spacing: -0.05em;
	line-height: 0.98;
}

.login-brand-copy p {
	max-width: 460px;
	margin: 22px 0 0;
	color: rgba(255, 255, 255, 0.72);
	font-size: 15px;
	line-height: 1.65;
}

.login-brand-foot {
	display: flex;
	align-items: center;
	gap: 10px;
	color: rgba(255, 255, 255, 0.66);
	font-size: 12px;
}

.login-main {
	position: relative;
	display: grid;
	place-items: center;
	padding: 32px;
	background: var(--canvas);
}

.login-utilities {
	position: absolute;
	z-index: 5;
	top: 20px;
	right: 24px;
	display: flex;
	align-items: center;
	gap: 8px;
}

.login-card {
	width: min(420px, 100%);
	border: 1px solid var(--line);
	border-top: 3px solid var(--brand-900);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow-2);
}

.login-card-header {
	padding: 28px 28px 18px;
}

.login-card-logo {
	margin-bottom: 16px;
}

.login-card h2 {
	margin: 0;
	color: var(--text);
	font-size: 25px;
	font-weight: 760;
	letter-spacing: -0.03em;
}

.login-form {
	display: grid;
	gap: 16px;
	padding: 4px 28px 28px;
}

.login-form .control {
	min-height: 48px;
	border-color: var(--line-strong);
	background: var(--surface);
	box-shadow: inset 0 0 0 1px transparent;
}

.login-form .control:hover {
	border-color: color-mix(in srgb, var(--brand-700) 35%, var(--line-strong));
}

.login-form .control:focus-within {
	border-color: var(--brand-700);
	background: var(--surface);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-700) 14%, transparent);
}

.login-form .control input {
	background-color: transparent !important;
}

.login-form .control input:-webkit-autofill,
.login-form .control input:-webkit-autofill:hover,
.login-form .control input:-webkit-autofill:focus,
.login-form .control input:-webkit-autofill:active {
	-webkit-text-fill-color: var(--text) !important;
	box-shadow: 0 0 0 1000px var(--surface) inset !important;
	-webkit-box-shadow: 0 0 0 1000px var(--surface) inset !important;
	filter: none;
}

.login-form .btn {
	min-height: 48px;
	margin-top: 6px;
}

.error {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
	border-left: 3px solid var(--danger);
	background: var(--danger-bg);
	color: var(--danger);
	font-size: 12px;
	font-weight: 600;
}

.error[hidden] {
	display: none;
}

/* Responsive */
@media (max-width: 1320px) {
	.cards {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.filter-grid > .field {
		flex: 1 1 calc(33.333% - 12px);
		min-width: 140px;
	}

	.filter-grid > .field:first-child {
		flex: 1 1 calc(66.666% - 12px);
	}

	.filter-actions {
		margin-left: 0;
		width: 100%;
	}

	.filter-actions .btn {
		flex: 1 1 auto;
	}

	.workspace-grid,
	.workspace-grid.is-map-collapsed {
		--workspace-height: auto;
		grid-template-columns: minmax(0, 1fr);
		gap: 12px;
		min-height: 0;
	}

	.table-panel {
		height: auto;
		min-height: 0;
		max-height: none;
	}

	.table-wrap {
		max-height: min(62dvh, 680px);
	}

	.map-panel {
		height: auto;
		min-height: 0;
	}

	.workspace-grid:not(.is-map-collapsed) .map-shell,
	.workspace-grid:not(.is-map-collapsed) #map {
		height: min(48dvh, 420px);
		min-height: 280px;
	}

	.panel-actions {
		width: auto;
		justify-content: flex-end;
	}
}

@media (max-width: 860px) {
	:root {
		--header-height: 58px;
	}

	.app-header {
		padding-inline: 14px;
	}

	.brand-subtitle,
	.refresh-meta,
	.user-chip span {
		display: none;
	}

	.refresh-group {
		gap: 0;
	}

	.user-chip {
		padding: 0 6px;
		border-left: 0;
	}

	.dashboard-shell {
		padding: 16px 12px 28px;
		gap: 12px;
	}

	.page-heading {
		align-items: flex-start;
		flex-direction: column;
	}

	.page-heading h1 {
		font-size: 22px;
	}

	.cards {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 8px;
	}

	.metric-card {
		min-height: 92px;
		padding: 12px;
	}

	.metric-label {
		font-size: 11px;
	}

	.metric-value {
		margin-top: 8px;
		font-size: 24px;
	}

	.metric-icon {
		width: 26px;
		height: 26px;
	}

	.panel-header {
		flex-wrap: wrap;
		align-items: center;
		gap: 10px;
		padding: 12px;
	}

	.filters-panel .panel-header {
		min-height: 48px;
	}

	.filter-grid {
		gap: 12px;
		padding: 12px;
	}

	.filter-grid > .field,
	.filter-grid > .field:first-child {
		flex: 1 1 100%;
		min-width: 0;
	}

	.filter-actions {
		width: 100%;
		margin-left: 0;
	}

	.filter-actions .btn {
		flex: 1 1 auto;
		width: auto;
	}

	.table-panel .panel-actions {
		margin-left: auto;
	}

	.replies-table-wrap {
		max-height: min(48dvh, 360px);
	}

	/* Mobile card-list for drivers table */
	.table-wrap {
		max-height: none;
		overflow: visible;
	}

	.table-wrap table,
	.table-wrap thead,
	.table-wrap tbody,
	.table-wrap th,
	.table-wrap td,
	.table-wrap tr {
		display: block;
		width: 100%;
	}

	.table-wrap thead {
		display: none;
	}

	.table-wrap tbody {
		display: grid;
		gap: 8px;
		padding: 10px;
	}

	.table-wrap tbody tr {
		padding: 12px;
		border: 1px solid var(--line);
		background: var(--surface);
	}

	.table-wrap tbody tr:last-child td {
		border-bottom: 0;
	}

	.table-wrap td {
		display: grid;
		grid-template-columns: 102px minmax(0, 1fr);
		gap: 8px;
		align-items: start;
		padding: 6px 0;
		border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
	}

	.table-wrap td:last-child {
		border-bottom: 0;
		padding-bottom: 0;
	}

	.table-wrap td:first-child {
		padding-top: 0;
	}

	.table-wrap td::before {
		color: var(--text-muted);
		content: attr(data-label);
		font-size: 10px;
		font-weight: 750;
		letter-spacing: 0.04em;
		text-transform: uppercase;
		padding-top: 3px;
	}

	.table-wrap .skeleton-row td {
		display: block;
		padding: 0;
		border: 0;
	}

	.table-wrap .skeleton-row td::before {
		content: none;
	}

	.pager {
		flex-wrap: wrap;
		gap: 8px;
	}

	.workspace-grid:not(.is-map-collapsed) .map-shell,
	.workspace-grid:not(.is-map-collapsed) #map {
		height: 300px;
		min-height: 240px;
	}

	.login-page {
		grid-template-columns: 1fr;
	}

	.login-brand {
		display: none;
	}

	.login-main {
		min-height: 100dvh;
		padding: 72px 18px 24px;
	}

	.login-utilities {
		top: 16px;
		right: 18px;
	}
}

@media (max-width: 560px) {
	.app-header {
		gap: 8px;
	}

	.header-actions {
		gap: 4px;
	}

	.lang-trigger {
		min-width: 58px;
		padding-inline: 8px;
	}

	#logoutBtn span {
		display: none;
	}

	.metric-card:nth-child(7) {
		grid-column: 1 / -1;
	}

	.metric-value {
		font-size: 22px;
	}

	.page-size-field {
		min-width: 58px;
	}

	.map-expand-field span,
	.drivers-expand-field span {
		display: none;
	}

	.table-wrap td {
		grid-template-columns: 88px minmax(0, 1fr);
	}

	.drawer-panel {
		width: 100vw;
		border-left: 0;
	}

	.drawer-content {
		padding: 14px;
	}

	.detail-map-shell {
		height: 240px;
	}

	.detail-facts {
		grid-template-columns: 1fr;
	}

	.detail-summary {
		padding: 12px;
	}

	.history-answers li,
	.detail-answers-list li {
		grid-template-columns: 1fr;
		gap: 3px;
	}

	.login-main {
		padding-inline: 12px;
	}

	.login-card-header,
	.login-form {
		padding-inline: 20px;
	}
}

/* License plates — authentic chip, theme-aware chrome */
.plate {
	--plate-bg: #f4f5f2;
	--plate-fg: #111418;
	--plate-border: #8b95a1;
	--plate-sep: #c5ccd4;
	--plate-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 1px 1px rgba(16, 24, 32, 0.12);
	box-sizing: border-box;
	display: inline-flex;
	vertical-align: middle;
	align-items: stretch;
	max-width: 100%;
	overflow: hidden;
	border: 1px solid var(--plate-border);
	border-radius: 2px;
	background: var(--plate-bg);
	color: var(--plate-fg);
	box-shadow: var(--plate-shadow);
	font-family: Manrope, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-weight: 800;
	letter-spacing: 0.01em;
	line-height: 1;
	user-select: text;
	white-space: nowrap;
}

html[data-theme="dark"] .plate {
	--plate-bg: #e8e9e4;
	--plate-fg: #0d1116;
	--plate-border: #6f7b88;
	--plate-sep: #b4bbc4;
	--plate-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.plate--foreign {
	--plate-bg: #f5e34a;
	--plate-fg: #121417;
	--plate-sep: #c9b82a;
	--plate-border: #b59f1c;
}

html[data-theme="dark"] .plate--foreign {
	--plate-bg: #e6d43a;
	--plate-border: #9a8818;
	--plate-sep: #c4b028;
}

.plate-euro {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1px;
	padding: 3px 5px 2px 4px;
	border-right: 1px solid var(--plate-sep);
	background: transparent;
	color: var(--plate-fg);
}

.plate-flag {
	display: block;
	width: 12px;
	height: 9px;
	object-fit: cover;
	border-radius: 0.5px;
	box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.22);
}

.plate-cc {
	font-size: 7px;
	font-weight: 800;
	letter-spacing: 0.06em;
	line-height: 1;
	opacity: 0.72;
}

.plate-body {
	display: inline-flex;
	align-items: center;
	align-self: stretch;
	gap: 0.12em;
	padding: 0 8px;
	min-width: 0;
	line-height: 1;
}

.plate-seg {
	display: inline-block;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
}

.plate-seg--letters {
	letter-spacing: 0.01em;
	/* Extra air around the letter block (vs digit groups) */
	margin-inline: 0.18em;
}

.plate-sep {
	display: none;
}

.plate--xs {
	height: 18px;
	font-size: 10px;
}

.plate--xs .plate-euro {
	padding: 2px 4px 1px 3px;
	gap: 0;
}

.plate--xs .plate-flag {
	width: 10px;
	height: 7.5px;
}

.plate--xs .plate-cc {
	font-size: 6px;
}

.plate--xs .plate-body {
	padding: 0 6px;
}

.plate--sm {
	height: 24px;
	font-size: 11px;
}

.plate--sm .plate-body {
	padding: 0 8px;
}

.plate--md {
	height: 26px;
	font-size: 13px;
}

.plate--md .plate-body {
	padding: 0 9px;
}

.plate--md .plate-flag {
	width: 14px;
	height: 10.5px;
}

.plate--md .plate-cc {
	font-size: 8px;
}

.plate--lg {
	height: 30px;
	font-size: 14px;
}

.plate-empty {
	color: var(--text-muted);
}

.leaflet-tooltip.map-point-label--plate .plate {
	position: relative;
	overflow: visible;
	height: 24px;
	font-size: 11px;
}

.leaflet-tooltip.map-point-label--plate .plate-body {
	padding: 0 9px;
}

.leaflet-tooltip.map-point-label--plate .plate-euro {
	padding: 3px 5px 2px 5px;
}


.cell-primary .plate,
.history-meta .plate {
	margin-top: 1px;
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
