:root {
	--ink: #17202f;
	--muted: #64748b;
	--line: #d9e1ef;
	--blue: #1f4f8f;
	--green: #1a7f42;
	--red: #b42318;
	--amber: #a16207;
	--surface: #ffffff;
	--page: #f3f6fb;
}

* {
	box-sizing: border-box;
}

html, body {
	margin: 0;
	min-height: 100%;
	background: var(--page);
	color: var(--ink);
	font-family: Roboto, "Segoe UI", Arial, sans-serif;
}

button, input, select {
	font: inherit;
}

.boot-shell, .security-shell {
	min-height: 100vh;
	padding: 18px;
}

.boot-shell {
	display: grid;
	place-items: center;
	min-height: 100dvh;
	background: #f4f6fb;
	padding: 24px;
}

.boot-card {
	width: min(100%, 280px);
	color: #626874;
	text-align: center;
}

.boot-logo {
	display: block;
	width: 160px;
	height: auto;
	max-width: 100%;
	margin: 0 auto 40px;
}

.security-spinner,
.btn[aria-busy="true"]::before,
.capture-actions[aria-busy="true"] > .next-action::before {
	display: block;
	width: 26px;
	height: 26px;
	margin: auto;
	border: 3px solid #dce0e6;
	border-top-color: #0b2a78;
	border-radius: 50%;
	animation: security-spin .85s linear infinite;
}

.btn[aria-busy="true"]::before,
.capture-actions[aria-busy="true"] > .next-action::before {
	content: "";
	display: inline-block;
	width: 18px;
	height: 18px;
	margin: 0 8px 0 0;
	vertical-align: -3px;
	border-color: rgba(11, 42, 120, .20);
	border-top-color: #0b2a78;
}

.boot-card p {
	margin: 16px 0 0;
	font-size: 14px;
	line-height: 1.5;
}

.boot-error {
	display: grid;
	gap: 12px;
	max-width: 340px;
	padding: 18px;
	border: 1px solid #fecaca;
	border-radius: 8px;
	background: #fff1f0;
	color: var(--red);
}

.boot-error span {
	word-break: break-word;
}

.boot-error a { color: #0b2a78; padding: 12px; }

@keyframes security-spin {
	to {
		transform: rotate(360deg);
	}
}

.security-shell {
	max-width: 760px;
	margin: 0 auto;
}

.security-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 10px;
}

@media (prefers-reduced-motion: reduce) {
	.security-spinner, .btn[aria-busy="true"]::before,
	.capture-actions[aria-busy="true"] > .next-action::before { animation: none; }
}

.security-version {
	margin-top: 16px;
	text-align: center;
	color: var(--muted);
	font-size: .78rem;
	font-weight: 700;
	letter-spacing: .02em;
}

.status-board {
	position: sticky;
	top: 0;
	z-index: 10;
	margin: 0 -8px 12px;
	padding: 8px;
	background: rgba(243, 246, 251, .97);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid rgba(217, 225, 239, .85);
}

.wizard-steps {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 5px;
	margin-bottom: 8px;
}

.wizard-step {
	border: 1px solid var(--line);
	border-radius: 5px;
	background: var(--surface);
	color: var(--muted);
	padding: 6px 4px;
	text-align: center;
	font-size: .68rem;
	font-weight: 800;
}

.wizard-step.done {
	border-color: #b8e5c6;
	background: #ecfdf3;
	color: var(--green);
}

.wizard-step.pending {
	border-color: #fde68a;
	background: #fffbeb;
	color: var(--amber);
}

.wizard-step.error {
	border-color: #fecaca;
	background: #fff1f0;
	color: var(--red);
}

.wizard-step.waiting {
	background: #fff;
}

.brand {
	display: flex;
	align-items: center;
	gap: 12px;
}

.brand img {
	width: 36px;
	height: 36px;
	border-radius: 8px;
}

.brand h1 {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
}

.brand span {
	display: block;
	color: var(--muted);
	font-size: .78rem;
}

.status-pill {
	border: 1px solid var(--line);
	border-radius: 999px;
	padding: 7px 10px;
	background: var(--surface);
	color: var(--muted);
	font-size: .78rem;
	white-space: nowrap;
}

.status-pill.ok {
	color: var(--green);
	border-color: #b8e5c6;
	background: #ecfdf3;
}

.status-pill.pending {
	color: var(--amber);
	border-color: #fde68a;
	background: #fffbeb;
}

.status-pill.error {
	color: var(--red);
	border-color: #fecaca;
	background: #fff1f0;
}

.panel, .step {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
	transition: border-color .15s ease, box-shadow .15s ease;
}

.panel.pending,
.step.pending {
	border-color: #fde68a;
	box-shadow: 0 0 0 2px rgba(253, 230, 138, .55), 0 8px 24px rgba(15, 23, 42, .06);
}

.panel.error,
.step.error {
	border-color: #fecaca;
	box-shadow: 0 0 0 2px rgba(254, 202, 202, .65), 0 8px 24px rgba(15, 23, 42, .06);
}

.panel {
	padding: 16px;
}

.step {
	padding: 14px;
	margin: 12px 0;
}

.step-title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 12px;
}

.step-title h2 {
	font-size: 1rem;
	margin: 0;
}

.step-context {
	margin: -4px 0 12px;
	color: var(--muted);
	font-size: .88rem;
	line-height: 1.35;
}

.grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

.field {
	display: grid;
	gap: 5px;
}

.field.full {
	grid-column: 1 / -1;
}

label {
	font-size: .78rem;
	color: var(--muted);
	font-weight: 700;
	text-transform: uppercase;
}

input, select {
	width: 100%;
	min-height: 44px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
	color: var(--ink);
	padding: 10px 12px;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 12px;
}

.primary-actions {
	margin-top: 0;
}

.manual-section {
	margin-top: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fbfcff;
}

.manual-section summary {
	min-height: 44px;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	color: var(--blue);
	font-weight: 800;
	cursor: pointer;
}

.manual-section summary::-webkit-details-marker {
	display: none;
}

.manual-section summary::after {
	content: "+";
	display: inline-grid;
	place-items: center;
	width: 24px;
	height: 24px;
	margin-left: auto;
	border-radius: 999px;
	background: #e8edf6;
	color: var(--blue);
	font-size: 1rem;
	line-height: 1;
}

.manual-section[open] summary::after {
	content: "-";
}

.summary-hint {
	color: var(--muted);
	font-size: .72rem;
	font-weight: 700;
}

.manual-section[open] {
	padding-bottom: 12px;
}

.manual-section[open] summary {
	margin-bottom: 12px;
	border-bottom: 1px solid var(--line);
}

.manual-section > .grid,
.manual-section > .field,
.manual-section > .actions {
	margin-inline: 12px;
}

.btn {
	border: 0;
	border-radius: 6px;
	min-height: 44px;
	padding: 10px 14px;
	font-weight: 800;
	background: var(--blue);
	color: #fff;
	cursor: pointer;
	box-shadow: 0 3px 0 rgba(15, 23, 42, .22);
	transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease, opacity .15s ease, transform .08s ease;
}

.btn.secondary {
	border: 1px solid #b7c8e4;
	background: #fff;
	color: var(--blue);
	box-shadow: 0 3px 0 rgba(31, 79, 143, .16);
}

.btn.success {
	background: var(--green);
}

.btn.danger {
	background: var(--red);
}

.camera-action {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
}

.camera-icon {
	display: inline-flex;
	width: 20px;
	height: 20px;
}

.camera-icon svg {
	display: block;
	width: 20px;
	height: 20px;
	fill: currentColor;
}

.camera-input {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	opacity: 0;
}

.btn:hover:not(:disabled),
.btn:focus-visible {
	filter: brightness(1.04);
	outline: 2px solid rgba(31, 79, 143, .28);
	outline-offset: 2px;
}

.btn:active:not(:disabled),
.btn.is-pressed:not(:disabled),
.btn[aria-busy="true"]:not(:disabled) {
	transform: translateY(2px);
	box-shadow: 0 1px 0 rgba(15, 23, 42, .22);
	filter: brightness(.96);
}

.btn:disabled {
	background: #cbd5e1;
	color: #64748b;
	cursor: not-allowed;
	filter: saturate(.75);
	opacity: .72;
	box-shadow: none;
}

.message {
	margin-top: 8px;
	border-radius: 6px;
	padding: 8px 10px;
	background: #eef4ff;
	color: var(--blue);
	font-size: .84rem;
	font-weight: 600;
}

.message.error {
	background: #fff1f0;
	color: var(--red);
}

.message.success {
	background: #ecfdf3;
	color: var(--green);
}

.message.info {
	background: #eef4ff;
	color: var(--blue);
}

.scan-output {
	margin-top: 8px;
	border: 1px solid var(--line);
	border-radius: 6px;
	background: #fff;
}

.scan-output summary {
	padding: 7px 9px;
	color: var(--blue);
	font-size: .72rem;
	font-weight: 800;
	text-transform: uppercase;
	cursor: pointer;
}

.scan-output pre {
	max-height: 96px;
	margin: 0;
	padding: 8px 9px;
	overflow: auto;
	border-top: 1px solid var(--line);
	color: #0f172a;
	font-size: .76rem;
	white-space: pre-wrap;
	word-break: break-word;
}

.capture-status {
	display: inline-flex;
	align-items: center;
	border-radius: 999px;
	padding: 5px 9px;
	font-size: .74rem;
	font-weight: 800;
	color: var(--amber);
	background: #fffbeb;
}

.capture-status.done {
	color: var(--green);
	background: #ecfdf3;
}

.booking-summary {
	margin-top: 12px;
	border: 1px solid #b8e5c6;
	border-radius: 6px;
	background: #ecfdf3;
	color: var(--green);
	padding: 9px 10px;
	font-size: .84rem;
	font-weight: 700;
	line-height: 1.35;
}

.release-notice {
	border: 1px solid var(--line);
	border-radius: 10px;
	background: #fff;
	margin-bottom: 10px;
	overflow: hidden;
}

.release-notice.new-release {
	border-color: #b8e5c6;
	box-shadow: 0 8px 24px rgba(25, 135, 84, .12);
}

.release-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	border: 0;
	background: transparent;
	color: var(--blue);
	padding: 10px 12px;
	font-weight: 800;
	text-align: left;
}

.release-toggle strong {
	border-radius: 999px;
	background: #ecfdf3;
	color: var(--green);
	padding: 4px 9px;
	font-size: .76rem;
}

.release-content {
	border-top: 1px solid var(--line);
	padding: 12px;
	color: #0f172a;
}

.release-content h2 {
	margin: 0 0 6px;
	font-size: 1rem;
	color: #0f172a;
}

.release-preview {
	line-height: 1.55;
	overflow-wrap: anywhere;
}

.release-preview img {
	max-width: 100%;
	height: auto;
	border-radius: 8px;
}

.release-preview ul,
.release-preview ol {
	padding-left: 1.4rem;
}

.photo-preview {
	width: 100%;
	max-height: 190px;
	border-radius: 6px;
	object-fit: cover;
	border: 1px solid var(--line);
}

@media (max-width: 640px) {
	.security-shell {
		padding: 12px;
	}

	.status-board {
		margin: 0 -6px 10px;
		padding: 6px;
	}

	.wizard-steps {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.grid {
		grid-template-columns: 1fr;
	}

	.security-header {
		align-items: flex-start;
	}

	.btn {
		width: 100%;
	}
}

/* Keep the current capture and its next action together on a handheld screen. */
.capture-wizard {
	display: flex;
	flex-direction: column;
	height: 100vh;
	height: 100dvh;
	min-height: 0;
	padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
	gap: 10px;
}
.capture-wizard .security-header { margin: 0; align-items: center; gap: 10px; flex-shrink: 0; }
.capture-wizard .brand { min-width: 0; gap: 8px; }
.capture-wizard .brand img { width: 30px; height: 30px; }
.capture-wizard .brand h1 { font-size: 15px; overflow-wrap: anywhere; }
.capture-wizard .brand span { font-size: 12px; }
.settings-toggle { min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--blue); font-size: 13px; cursor: pointer; }
.capture-progress { flex-shrink: 0; }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; flex-shrink: 0; }
.progress-heading > span { color: var(--muted); white-space: nowrap; font-size: 12px; }
.capture-milestones { display: flex; list-style: none; margin: 12px 0 8px; padding: 0; }
.capture-milestones li { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); text-align: center; }
.capture-milestones li:not(:first-child)::before { content: ""; position: absolute; top: 13px; right: calc(50% + 17px); width: calc(100% - 34px); height: 2px; background: var(--line); }
.milestone-marker { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; font-size: 12px; font-weight: 700; background: var(--page); }
.milestone-label { font-size: 12px; font-weight: 600; line-height: 1.3; }
.capture-milestones small { font-size: 10px; line-height: 1.2; }
.capture-milestones .current { color: var(--blue); }
.capture-milestones .current .milestone-marker { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 0 0 3px #e1e9f4; }
.capture-milestones .done .milestone-marker { color: var(--blue); background: #e1e9f4; border-color: #c9d7eb; }
.capture-milestones .skipped .milestone-marker { border-style: dashed; }
.capture-milestones .attention { color: #922b35; }
.capture-milestones .attention .milestone-marker { color: #922b35; background: #fff2f2; border-color: #efb8b8; }
.progress-next { font-size: 12px; line-height: 1.4; color: var(--muted); margin: 0; }
.capture-wizard .message { margin: 0; line-height: 1.4; font-weight: 500; flex-shrink: 0; max-height: 84px; overflow: auto; }
.capture-content { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.capture-wizard .step { margin: 0; padding: 16px; box-shadow: none; border-color: var(--line); }
.capture-wizard .step.error { border-color: #efb3ad; }
.capture-wizard h2 { font-size: 18px; line-height: 1.35; margin: 0 0 14px; }
.capture-wizard .step-title { margin-bottom: 14px; }
.capture-wizard .step-title h2 { margin: 0; }
.capture-wizard .step-context { margin: 0 0 14px; line-height: 1.45; font-size: 14px; }
.capture-wizard .field { margin: 14px 0; }
.capture-wizard label { text-transform: none; font-size: 14px; color: var(--ink); font-weight: 600; }
.capture-wizard input, .capture-wizard select { font-size: 16px; min-height: 46px; }
.capture-wizard input[type=file] { font-size: 13px; }
.capture-wizard .btn { min-height: 46px; box-shadow: none; font-size: 15px; font-weight: 600; line-height: 1.3; }
.capture-wizard .step > .btn, .capture-options .btn { width: 100%; }
.capture-options { display: grid; gap: 12px; }
.capture-methods { display: flex; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; overflow: hidden; }
.capture-methods button { flex: 1; min-height: 44px; border: 0; background: #f3f6fb; color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; }
.capture-methods button.selected { background: var(--blue); color: #fff; }
.capture-methods button:disabled { opacity: .65; }
.capture-summary { background: #f3f6fb; border-radius: 6px; padding: 10px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.capture-wizard .photo-preview { display: block; width: auto; max-width: 100%; max-height: 100px; margin: 12px auto 0; object-fit: contain; }
.field-error { color: var(--red); font-size: 14px; line-height: 1.4; }
.capture-wizard .question-label { font-size: 18px; line-height: 1.4; }
.capture-wizard .field .step-context { margin: 0; font-size: 13px; }
.review-summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; line-height: 1.4; }
.review-summary dt { color: var(--muted); }
.review-summary dd { margin: 0; overflow-wrap: anywhere; }
.gate-note { font-size: 14px; line-height: 1.45; color: var(--muted); margin: 14px 0 0; }
.capture-wizard .step.saved-visit { overflow: hidden; padding: 0; }
.saved-hero { padding: 16px 16px 14px; text-align: center; background: linear-gradient(160deg, #eef4ff, #fff 80%); }
.saved-mark { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%; background: #e3f3eb; color: var(--green); font-size: 26px; }
.saved-hero h2 { font-size: 22px; margin: 0 0 4px; }
.saved-site { color: var(--muted); font-size: 14px; margin: 0 0 12px; overflow-wrap: anywhere; }
.saved-direction { display: inline-block; color: var(--blue); background: #eaf0fa; border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 600; }
.vehicle-summary-detail { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.saved-summary { margin: 0; padding: 0 16px; font-size: 13px; line-height: 1.4; }
.saved-summary > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 12px; padding: 10px 0; border-top: 1px solid #edf0f5; }
.saved-summary dt { color: var(--muted); }
.saved-summary dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.saved-summary small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.saved-gate-status { margin: 16px; padding: 12px; border-radius: 8px; background: #f0f4fa; font-size: 13px; color: var(--blue); line-height: 1.4; }
.saved-gate-status p { color: var(--muted); margin: 4px 0 0; }
.saved-gate-status.gate-failed { background: #fff2f2; border: 1px solid #efb8b8; color: #922b35; }
.saved-gate-status.gate-failed p { color: #70343a; }
.blocked-result { padding: 8px 0; text-align: center; }
.blocked-mark { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: #fff2f2; color: var(--red); }
.blocked-result h2 { color: var(--red); }
.blocked-result p { font-size: 14px; line-height: 1.5; margin: 0 0 16px; overflow-wrap: anywhere; }
.home-countdown { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 16px; color: var(--muted); font-size: 13px; }
.capture-actions { display: flex; flex-shrink: 0; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; background: var(--page); }
.capture-actions .btn { width: auto; flex: 0 1 auto; }
.capture-actions .next-action { flex: 1; }
.capture-actions .back-action { padding-left: 12px; padding-right: 12px; }
.settings-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, .45); display: grid; align-items: start; justify-items: center; padding: 16px; overflow-y: auto; }
.settings-panel { width: min(100%, 480px); padding: 18px; background: var(--surface); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, .2); }
.settings-panel > .btn { width: 100%; margin-top: 12px; }
.settings-panel .step-title .btn { width: auto; }
.settings-serial { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-serial > .btn { width: 100%; margin-top: 12px; }
.capture-wizard .settings-serial .message { max-height: none; margin-top: 12px; }
.capture-wizard button:focus-visible, .capture-wizard input:focus-visible, .capture-wizard select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (max-height: 580px) {
	.capture-wizard { gap: 6px; padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
	.capture-wizard .step { padding: 12px; }
	.capture-wizard .message { max-height: 60px; }
	.capture-milestones { margin-top: 8px; margin-bottom: 6px; }
	.saved-hero { padding-top: 14px; padding-bottom: 12px; }
	.saved-mark { width: 40px; height: 40px; margin-bottom: 8px; font-size: 26px; }
}
