/*
 * Ad Pro Order Status - ported from the "v3 Sober" design.
 *
 * The design mock computed every colour inline per element. Here the same
 * values live as tokens and the stepper states are classes, so light/dark is
 * one token block rather than two parallel copies of the markup.
 */

:root {
	color-scheme: light dark;

	--font-sans: Roboto, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
	--font-display: "Roboto Slab", Georgia, "Times New Roman", serif;
	--font-mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

	--radius: 3px;
	--rule: 1px;

	/* Light palette */
	--page: #edebe7;
	--surface: #ffffff;
	--surface-head: #ffffff;
	--border: #dcd9d3;
	--hairline: #e6e3dd;

	--ink: #1a1a1a;
	--body: #4a4e51;
	--muted: #6b6b6b;
	--meta: #6e6e6e;
	--eyebrow: #6e6e6e;

	--accent: #3a5f7a;
	--accent-strong: #2d4a60;
	--accent-ink: #2d4a60;
	--accent-tint: #f1f4f6;

	--done: #3f6b37;
	--done-icon: #ffffff;
	--done-label: #355c2e;

	--todo-border: #b8b4ac;
	--todo-icon: #6f6f6f;
	--todo-label: #6b6b6b;
	--track: #dcd9d3;

	--halo-current: 0 0 0 4px rgba(58, 95, 122, 0.15);
	--halo-done: 0 0 0 4px rgba(63, 107, 55, 0.16);

	--danger-rule: #9e3c3c;
	--danger-ink: #8f3535;

	--chip: #f1f4f6;
	--btn-bg: #3a5f7a;
	--btn-bg-hover: #2d4a60;
	--btn-ink: #ffffff;

	--tip-bg: #2e353b;
	--tip-ink: #f4f4f4;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--page: #1b1f22;
		--surface: #24282c;
		--surface-head: #2e353b;
		--border: #3a4046;
		--hairline: #3a4046;

		--ink: #f4f4f4;
		--body: #c4c4c4;
		--muted: #a9a9a9;
		--meta: #a9a9a9;
		--eyebrow: #a2a2a2;

		--accent: #8fb8d4;
		--accent-strong: #bbd8ec;
		--accent-ink: #bbd8ec;
		--accent-tint: #2e353b;

		--done: #8fd08a;
		--done-icon: #152214;
		--done-label: #9fd69a;

		--todo-border: #565c62;
		--todo-icon: #9a9a9a;
		--todo-label: #a2a2a2;
		--track: #464c52;

		--halo-current: 0 0 0 4px rgba(143, 184, 212, 0.2);
		--halo-done: 0 0 0 4px rgba(143, 208, 138, 0.22);

		--danger-rule: #c05555;
		--danger-ink: #e89a9a;

		--chip: #30373d;
		--btn-bg: #f4f4f4;
		--btn-bg-hover: #ffffff;
		--btn-ink: #1a1a1a;

		--tip-bg: #434b52;
		--tip-ink: #f4f4f4;
	}
}

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--page);
	color: var(--body);
	font-family: var(--font-sans);
	font-size: 16px;
	line-height: 1.6;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

a {
	color: var(--accent);
	text-decoration: none;
}
a:hover {
	color: var(--accent-strong);
}

:where(a, button, input, select, [tabindex]):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 2px;
}

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */

.page {
	max-width: 760px;
	margin: 0 auto;
	padding: 48px 20px 80px;
	display: flex;
	flex-direction: column;
	gap: 30px;
}

.page-head .display {
	margin: 10px 0 0;
}

.eyebrow {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--eyebrow);
}

.display {
	font-family: var(--font-display);
	font-weight: 600;
	letter-spacing: -0.02em;
	color: var(--ink);
	line-height: 1.05;
	font-size: clamp(28px, 6vw, 38px);
}

/* ---------------------------------------------------------------- card */

.card {
	background: var(--surface);
	border: var(--rule) solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
}

.card-head {
	padding: 26px 32px;
	background: var(--surface-head);
	border-bottom: var(--rule) solid var(--hairline);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
}

.logo {
	width: 96px;
	height: auto;
	display: block;
}

.card-body {
	padding: 36px 32px 40px;
	display: flex;
	flex-direction: column;
	gap: 36px;
}

.block {
	border-top: var(--rule) solid var(--hairline);
	padding-top: 28px;
}

.block-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 30px;
}

.block-title {
	margin: 0 0 20px;
}

.counter {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.06em;
	color: var(--accent-ink);
}

/* ---------------------------------------------------------------- intro */

.orderref {
	margin: 0;
	font-family: var(--font-mono);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0.08em;
	color: var(--muted);
}

.client {
	margin: 10px 0 0;
	font-size: clamp(24px, 5vw, 30px);
	line-height: 1.15;
}

.status-band {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 14px;
	margin-top: 18px;
	padding: 14px 18px;
	background: var(--accent-tint);
	border-left: 3px solid var(--accent);
	border-radius: 0 var(--radius) var(--radius) 0;
}

.status-label {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: var(--accent-ink);
}

.status-updated {
	font-size: 13.5px;
	color: var(--muted);
}

.blurb {
	margin: 18px 0 0;
	font-size: 16px;
	line-height: 1.6;
	color: var(--body);
	max-width: 58ch;
	text-wrap: pretty;
}

/* ---------------------------------------------------------------- stepper */

.stepper {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(7, 1fr);
}

.step {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	text-align: center;
}

/* Connectors sit behind the dot and stop at the first and last step. */
.step::before,
.step::after {
	content: "";
	position: absolute;
	top: 13px;
	height: 2px;
	background: var(--track);
}
.step::before {
	left: 0;
	width: 50%;
}
.step::after {
	left: 50%;
	right: 0;
}
.step:first-child::before,
.step:last-child::after {
	background: transparent;
}
.step.is-done::before,
.step.is-done::after,
.step.is-current::before,
.step.is-final::before {
	background: var(--done);
}

.step-dot {
	position: relative;
	z-index: 1;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	border: 1px solid var(--todo-border);
	background: var(--surface);
}
.step-dot svg {
	display: block;
	stroke: var(--todo-icon);
}

.step.is-done .step-dot,
.step.is-final .step-dot {
	border: 2px solid var(--done);
	background: var(--done);
}
.step.is-done .step-dot svg,
.step.is-final .step-dot svg {
	stroke: var(--done-icon);
}

.step.is-current .step-dot {
	border: 2px solid var(--accent);
	box-shadow: var(--halo-current);
}
.step.is-current .step-dot svg {
	stroke: var(--accent-ink);
}

/* The last step, once reached, reads as complete rather than in-progress. */
.step.is-final .step-dot {
	box-shadow: var(--halo-done);
}

.step-label {
	font-size: 11.5px;
	line-height: 1.4;
	padding: 0 4px;
	color: var(--todo-label);
}
.step.is-done .step-label,
.step.is-final .step-label {
	color: var(--done-label);
}
.step.is-current .step-label {
	font-weight: 600;
	color: var(--accent-ink);
}
.step.is-final .step-label {
	font-weight: 600;
}

.step-body {
	display: flex;
	flex-direction: column;
	align-items: center;
}

/*
 * Per-step description. Reachable three ways - hover, keyboard focus and tap -
 * because a hover-only tooltip is invisible on a phone and to a keyboard user.
 * The text is also wired up with aria-describedby, so a screen reader reads it
 * without needing any of the three.
 */
.step-tip {
	position: absolute;
	bottom: calc(100% + 12px);
	left: 50%;
	transform: translateX(-50%);
	z-index: 5;
	width: max-content;
	max-width: 200px;
	padding: 10px 12px;
	background: var(--tip-bg);
	color: var(--tip-ink);
	border-radius: var(--radius);
	font-size: 12.5px;
	line-height: 1.45;
	font-weight: 400;
	text-align: left;
	text-wrap: pretty;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 120ms ease;
}

/*
 * A centred tooltip on a step near either end overflows the card, so the two
 * steps at each end anchor to their own edge instead. Only the middle three
 * stay centred.
 */
.step:nth-child(-n + 2) .step-tip {
	left: 0;
	transform: none;
}
.step:nth-last-child(-n + 2) .step-tip {
	left: auto;
	right: 0;
	transform: none;
}

.step:hover .step-tip,
.step:focus .step-tip,
.step:focus-within .step-tip {
	opacity: 1;
	visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
	.step-tip {
		transition: none;
	}
}

/*
 * Seven columns do not fit a phone. The design did not cover this; below 720px
 * the bar becomes a vertical list with the connector running down the left.
 */
@media (max-width: 719px) {
	.stepper {
		grid-template-columns: 1fr;
		gap: 0;
	}
	.step {
		flex-direction: row;
		align-items: flex-start;
		gap: 14px;
		text-align: left;
		padding: 7px 0;
	}
	.step::before,
	.step::after {
		top: auto;
		left: 13px;
		width: 2px;
		height: 50%;
	}
	.step::before {
		top: 0;
	}
	.step::after {
		bottom: 0;
		right: auto;
	}
	.step-label {
		font-size: 14px;
		padding: 3px 0 0;
	}
	.step-body {
		align-items: flex-start;
	}
	.step-tip {
		position: static;
		transform: none;
		width: auto;
		max-width: none;
		margin-top: 8px;
		display: none;
		opacity: 1;
		visibility: visible;
	}
	.step:hover .step-tip,
	.step:focus .step-tip,
	.step:focus-within .step-tip {
		display: block;
	}
}

/* ---------------------------------------------------------------- detail grids */

.facts {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 22px 28px;
}
.facts.wide {
	grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.fact-key {
	font-size: 13px;
	color: var(--meta);
}
.fact-value {
	font-size: 16px;
	font-weight: 600;
	margin-top: 5px;
	color: var(--ink);
}
.fact-value.accent {
	color: var(--accent-ink);
}
.fact-value.positive {
	color: var(--done-label);
}
.fact-value.plain {
	font-weight: 500;
}

.mono-chip {
	font-family: var(--font-mono);
	font-size: 15px;
	color: var(--ink);
	margin-top: 6px;
	padding: 6px 10px;
	background: var(--chip);
	border-radius: var(--radius);
	display: inline-block;
	word-break: break-all;
}

.btn {
	display: inline-block;
	margin-top: 26px;
	padding: 12px 22px;
	background: var(--btn-bg);
	color: var(--btn-ink);
	border: 1px solid transparent;
	border-radius: var(--radius);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.01em;
	cursor: pointer;
	font-family: inherit;
}
.btn:hover {
	background: var(--btn-bg-hover);
	color: var(--btn-ink);
}
.btn.ghost {
	background: transparent;
	color: var(--ink);
	border-color: var(--border);
	margin-top: 0;
	padding: 8px 14px;
}
.btn.ghost:hover {
	background: var(--accent-tint);
	color: var(--accent-ink);
}

/* ---------------------------------------------------------------- arriving */

/*
 * The carrier's own estimate, borrowing the design's dark surface. No
 * confidence meter: we have nothing to compute one from.
 */
.arriving {
	background: var(--tip-bg);
	color: var(--tip-ink);
	border-radius: var(--radius);
	padding: 20px 22px;
	margin-bottom: 24px;
}
.arriving-eyebrow {
	color: #a9a9a9;
}
.arriving-count {
	display: flex;
	align-items: baseline;
	gap: 8px;
	margin: 10px 0 0;
}
.arriving-number {
	font-family: var(--font-display);
	font-size: 42px;
	font-weight: 700;
	line-height: 1;
	color: #ffffff;
}
.arriving-unit {
	font-size: 16px;
	color: #c4c4c4;
}
.arriving-date {
	margin: 9px 0 0;
	font-size: 14.5px;
	font-weight: 500;
	color: #8fd08a;
}
.arriving-source {
	margin: 12px 0 0;
	font-family: var(--font-mono);
	font-size: 10.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #a9a9a9;
}

/* ---------------------------------------------------------------- scan feed */

.scans {
	list-style: none;
	margin: 0;
	padding: 0;
}

.scan {
	position: relative;
	display: grid;
	grid-template-columns: 16px 1fr auto;
	gap: 14px;
	align-items: start;
	padding-bottom: 18px;
}
.scan:last-child {
	padding-bottom: 0;
}

/* Thread running through the dots, stopping at the last scan. */
.scan:not(:last-child)::before {
	content: "";
	position: absolute;
	left: 7px;
	top: 15px;
	bottom: -3px;
	width: 1px;
	background: var(--hairline);
}

.scan-dot {
	width: 9px;
	height: 9px;
	margin: 5px auto 0;
	border-radius: 50%;
	background: var(--todo-border);
}
.scan.is-latest .scan-dot {
	background: var(--done);
	box-shadow: var(--halo-done);
}

.scan-body {
	display: flex;
	flex-direction: column;
	gap: 3px;
}
.scan-event {
	font-size: 14px;
	color: var(--muted);
}
.scan.is-latest .scan-event {
	font-weight: 600;
	color: var(--ink);
}
.scan-place {
	font-size: 12.5px;
	color: var(--eyebrow);
}
.scan-time {
	font-family: var(--font-mono);
	font-size: 11.5px;
	color: var(--eyebrow);
	text-align: right;
	white-space: nowrap;
	padding-top: 2px;
}

/* ---------------------------------------------------------------- notice */

.notice {
	border-top: var(--rule) solid var(--hairline);
	border-left: 3px solid var(--danger-rule);
	padding: 26px 0 0 18px;
}
.notice-title {
	margin: 0 0 8px;
	font-family: var(--font-display);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
	color: var(--danger-ink);
}
.notice-body {
	margin: 0;
	font-size: 14.5px;
	line-height: 1.6;
	color: var(--muted);
	max-width: 60ch;
	text-wrap: pretty;
}
.notice-body strong {
	font-weight: 600;
	color: var(--ink);
}

/* ---------------------------------------------------------------- messages */

.message {
	text-align: center;
	padding: 48px 32px;
}
.message .display {
	font-size: clamp(22px, 5vw, 28px);
	margin: 0 0 10px;
}
.message p {
	margin: 0 auto;
	max-width: 46ch;
	color: var(--muted);
	text-wrap: pretty;
}

/* ---------------------------------------------------------------- admin */

body.admin .page {
	max-width: 1180px;
}

.table-scroll {
	overflow-x: auto;
}
/* Below this the table scrolls rather than crushing the client name column. */
.table-scroll table {
	min-width: 1040px;
}

table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}
th,
td {
	text-align: left;
	padding: 14px 12px;
	border-bottom: var(--rule) solid var(--hairline);
	vertical-align: top;
}
th {
	font-family: var(--font-mono);
	font-size: 10px;
	font-weight: 500;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--eyebrow);
	white-space: nowrap;
}
tbody tr:last-child td {
	border-bottom: none;
}

td.ref {
	font-family: var(--font-mono);
	font-size: 12px;
	letter-spacing: 0.04em;
	color: var(--accent-ink);
	white-space: nowrap;
}
td.name {
	font-weight: 600;
	color: var(--ink);
	min-width: 14ch;
}
td.meta {
	color: var(--meta);
	font-size: 13px;
}

input,
select {
	font-family: inherit;
	font-size: 13px;
	color: var(--ink);
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 8px 10px;
	max-width: 100%;
}
input::placeholder {
	color: var(--todo-label);
}

.stack {
	display: flex;
	flex-direction: column;
	gap: 8px;
	align-items: flex-start;
}
.row {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
}

.pill {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--accent-tint);
	color: var(--done-label);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	font-family: var(--font-mono);
}

.lede {
	margin: 12px 0 0;
	font-size: 14.5px;
	color: var(--muted);
	max-width: 70ch;
	text-wrap: pretty;
}

/*
 * Shipment cards - only rendered when an order ships as more than one box.
 * Collapsed by default: a ten-box drop-ship order has to stay readable on a
 * phone, and the customer is usually looking for one destination.
 */
.block-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
}

.block-note {
	font-size: 12px;
	color: var(--meta);
}

.ships {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ship {
	border: var(--rule) solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
}

.ship-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 6px 12px;
	padding: 12px 14px;
	cursor: pointer;
	list-style: none;
}

.ship-head::-webkit-details-marker {
	display: none;
}

.ship-head:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: -2px;
}

.ship-title {
	font-weight: 600;
	color: var(--ink);
	flex: 1 1 auto;
}

.ship-state {
	font-size: 12px;
	color: var(--accent-ink);
	background: var(--accent-tint);
	border-radius: 999px;
	padding: 2px 10px;
}

.ship-state.is-delivered {
	color: var(--done-label);
	background: color-mix(in srgb, var(--done) 12%, transparent);
}

.ship-when,
.ship-tail {
	font-size: 12px;
	color: var(--meta);
}

.ship-tail {
	font-family: var(--font-mono);
}

.ship-body {
	padding: 0 14px 14px;
	border-top: var(--rule) solid var(--hairline);
}

.ship-body .facts {
	margin-top: 12px;
}

/* A delivered box recedes but keeps its place: the list must not reshuffle. */
.ship.is-delivered .ship-title {
	color: var(--body);
}
