/* Large, high-contrast UI: used outdoors, in the cold, possibly with gloves. */
:root {
	--red: #c0161c;
	--red-dark: #8f0f13;
	/* delivery numbers (slip + app): dark red on white, little toner */
	--slip: #8f0f13;
	/* tour numbers: filled blue pill, clearly different from delivery numbers */
	--tour: #1b3e8c;
	--green: #1d6b3a;
	--green-light: #e3f1e7;
	--amber: #b65c00;
	--amber-light: #fff1dc;
	--ink: #16191d;
	--muted: #5b636d;
	--line: #d5d9de;
	--bg: #f4f5f7;
	--card: #fff;
	--radius: 12px;
	--tap: 56px;
	font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	font-size: 18px;
	color: var(--ink);
	background: var(--bg);
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	min-height: 100dvh;
}

header.bar {
	position: sticky;
	top: 0;
	z-index: 1000;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 16px;
	background: var(--red);
	color: #fff;
}

header.bar h1 {
	flex: 1;
	margin: 0;
	font-size: 1.25rem;
}

header.bar a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	color: #fff;
	text-decoration: none;
	font-size: 1.6rem;
	line-height: 1;
	padding: 4px 8px;
}

#connection {
	font-size: 0.8rem;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgb(255 255 255 / 0.2);
}

#connection.offline {
	background: #ffd400;
	color: var(--ink);
	font-weight: 700;
}

/* narrow phones: only a coloured dot (green online, yellow offline), the label stays in aria-label */
@media (max-width: 400px) {
	#connection {
		font-size: 0;
		width: 12px;
		height: 12px;
		padding: 0;
		flex: 0 0 auto;
	}

	#connection.online {
		background: #6fdc8c;
	}
}

/* login page after a login ran out or all devices were logged out */
.signed-out {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--amber-light);
	border: 1px solid var(--amber);
}

main {
	max-width: 1100px;
	margin: 0 auto;
	padding: 16px;
}

h2 {
	font-size: 1.15rem;
	margin: 20px 0 10px;
}

.card {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px;
	margin-bottom: 16px;
}

/* ---------- forms ---------- */

label {
	display: block;
	font-weight: 600;
	margin: 14px 0 6px;
}

label small {
	font-weight: 400;
	color: var(--muted);
}

input,
select,
textarea {
	width: 100%;
	min-height: var(--tap);
	padding: 10px 14px;
	font: inherit;
	border: 2px solid var(--line);
	border-radius: var(--radius);
	background: #fff;
	color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
	outline: none;
	border-color: var(--green);
}

input.tag-input {
	font-size: 2.2rem;
	font-weight: 800;
	text-align: center;
	letter-spacing: 0.05em;
	color: var(--slip);
	border-color: var(--slip);
}

.row {
	display: flex;
	gap: 12px;
}

.row > * {
	flex: 1;
}

.row > .narrow {
	flex: 0 0 30%;
}

.check {
	display: flex;
	align-items: center;
	gap: 12px;
	font-weight: 400;
}

.check input {
	width: 28px;
	min-height: 28px;
	height: 28px;
}

.hint-text {
	color: var(--muted);
	font-size: 0.9rem;
	margin: 6px 0 0;
}

.warn {
	color: var(--amber);
	font-weight: 600;
}

/* a warning that must not be overlooked (e.g. number already taken at the till) */
.warn-box {
	margin: 8px 0 0;
	padding: 10px 12px;
	border: 2px solid var(--amber);
	border-radius: 8px;
	background: #fff6e0;
	color: var(--ink);
	font-weight: 600;
}

/* the hidden attribute always wins, also over display: flex of buttons */
[hidden] {
	display: none !important;
}

/* ---------- buttons ---------- */

button,
.button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: var(--tap);
	padding: 10px 20px;
	font: inherit;
	font-weight: 700;
	border: 2px solid var(--ink);
	border-radius: var(--radius);
	background: #fff;
	color: var(--ink);
	cursor: pointer;
	text-decoration: none;
	user-select: none;
}

button.primary,
.button.primary {
	background: var(--green);
	border-color: var(--green);
	color: #fff;
}

/* till: "Eingaben leeren" small and apart from "Speichern" */
.actions.clear-actions {
	margin-top: 20px;
	justify-content: flex-end;
}

.actions.clear-actions > * {
	flex: 0 0 auto;
}

/* dangerous action apart from the everyday buttons */
.actions.danger-zone {
	margin-top: 24px;
	padding-top: 16px;
	border-top: 1px dashed var(--line);
}

button.danger {
	background: var(--red);
	border-color: var(--red);
	color: #fff;
}

button.warning {
	background: var(--amber-light);
	border-color: var(--amber);
	color: var(--amber);
}

button.small {
	min-height: 44px;
	padding: 6px 12px;
	font-size: 0.9rem;
}

button.wide,
.button.wide {
	width: 100%;
}

button:disabled {
	opacity: 0.5;
	cursor: wait;
}

.actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	margin-top: 16px;
}

.actions > * {
	flex: 1 1 200px;
}

/* ---------- start page ---------- */

.roles {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 16px;
}

.roles a {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	grid-template-rows: auto 1fr;
	column-gap: 16px;
	align-items: start;
	padding: 24px;
	min-height: 140px;
	border-radius: var(--radius);
	background: var(--card);
	border: 2px solid var(--line);
	color: var(--ink);
	text-decoration: none;
}

.roles a:hover,
.roles a:focus {
	border-color: var(--green);
}

.roles strong {
	display: block;
	font-size: 1.5rem;
	margin-bottom: 6px;
}

.roles span {
	color: var(--muted);
}

/* emoji left of title and description */
.roles .role-icon {
	grid-row: 1 / span 2;
	font-style: normal;
	font-size: 2.4rem;
	line-height: 1;
}

.roles strong,
.roles span {
	grid-column: 2;
}

.admin-link {
	margin-top: 32px;
	text-align: center;
}

.admin-link a {
	display: inline-block;
	padding: 12px 20px; /* a target for a thumb, not just a line of text */
	color: var(--muted);
}

/* Übersicht: one wide tile above the stations */
.roles.overview {
	grid-template-columns: 1fr;
	margin-top: 16px;
}

.roles.overview a {
	min-height: 0;
	padding: 16px 24px;
	align-items: center;
}

.roles.overview .role-icon {
	font-size: 2rem;
}

/* ---------- lists ---------- */

.list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.list li {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 4px;
	border-bottom: 1px solid var(--line);
}

.list li:last-child {
	border-bottom: none;
}

/* tour badge above the trailer name (loading view: card heading, delivery: tour choice) */
.tour-head {
	margin-bottom: 8px;
}

/* tour badge with the tour's status right next to it */
.tour-badges {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
}

.tour-head h2 {
	margin: 8px 0 0;
}

.tour-choice .tour-line {
	display: block;
	margin-top: 8px;
}

/* a list that is also a card keeps the card's inner spacing (.list above resets the padding) */
.list.card {
	padding: 4px 16px;
}

.list li > * {
	flex-shrink: 0;
}

.list .grow {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: break-word; /* whole words; very long ones still break */
	hyphens: auto;
}

.list .sub {
	display: block;
	color: var(--muted);
	font-size: 0.9rem;
}

/* delivery number – same look as on the laminated slip */
.tag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 52px;
	height: 44px;
	padding: 0 8px;
	border: 2px solid var(--slip);
	border-radius: 10px;
	background: #fff;
	color: var(--slip);
	font-weight: 800;
	font-size: 1.3rem;
}

/* tour number – filled pill with the word "Tour", as high as the status badges */
.tour-tag {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	padding: 3px 10px;
	border-radius: 999px;
	background: var(--tour);
	color: #fff;
	font-size: 0.8rem;
	font-weight: 800;
	white-space: nowrap;
	vertical-align: middle;
}

.badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 700;
	background: var(--line);
}

.status-erfasst {
	background: #e6e9ee;
}

.status-verladen,
.status-beladen {
	background: #dce8ff;
	color: #1b3e8c;
}

.status-unterwegs {
	background: var(--amber-light);
	color: var(--amber);
}

.status-geliefert,
.status-fertig {
	background: var(--green-light);
	color: var(--green);
}

.status-problem {
	background: var(--red);
	color: #fff;
}

.zones {
	display: grid;
	grid-template-columns: repeat(3, 1fr); /* 6 zones: 3 + 3 on tablets, 2 + 2 + 2 on phones */
	gap: 10px;
}

@media (max-width: 600px) {
	.zones {
		grid-template-columns: repeat(2, 1fr);
	}
}

.zone {
	display: block;
	width: 100%;
	padding: 12px;
	border-radius: var(--radius);
	background: var(--card);
	border: 2px solid var(--line);
	color: var(--ink);
	font-weight: 400;
	text-align: left;
}

.zone[aria-pressed='true'] {
	border-color: var(--green);
	background: var(--green-light);
}

.waiting {
	margin-top: 10px;
}

.waiting h3 {
	margin: 0 0 6px;
}

.waiting li.chosen {
	background: var(--green-light);
}

.draft-list .position {
	width: 2em;
	text-align: right;
	color: var(--muted);
	font-weight: 700;
}

/* on phones the buttons wrap into a second line instead of squeezing the address */
.draft-list li {
	flex-wrap: wrap;
}

.draft-list .grow {
	flex: 1 1 140px;
}

.draft-list .move {
	display: flex;
	gap: 4px;
	margin-left: auto;
}

.draft-list .move button {
	min-width: 44px;
	padding: 0;
}

/* ✕ – take a tree out of the planned tour */
button.remove {
	min-width: 44px;
	padding: 0;
	font-size: 1.2rem;
	color: var(--red);
	border-color: var(--red);
}

.zone b {
	font-size: 2rem;
	display: block;
}

/* ---------- loading list: what goes on the trailer first ---------- */

/* Versand: loading list, one row per tree (same layout as the planning list) */
.loading-list li {
	flex-wrap: wrap;
}

.loading-list .position {
	width: 2em;
	text-align: right;
	color: var(--muted);
	font-weight: 700;
}

.loading-list .grow {
	flex: 1 1 140px;
}

/* same width for "2" and "913", so the ticks stand in one column */
.loading-list .tag {
	min-width: 72px;
}

/* phones: tick, number and ✕ in the first line, name and address below */
@media (max-width: 600px) {
	.loading-list .grow {
		order: 1;
		flex-basis: 100%;
		padding-left: calc(2em + 12px);
	}
}

/* All lists on phones: number, status and buttons in the first line, name and address below in
   full width instead of a squeezed column (tour choice, stops, waiting trees, problems, till). */
@media (max-width: 600px) {
	.list li {
		flex-wrap: wrap;
	}

	.list li > .grow {
		order: 1;
		flex-basis: 100%;
	}

	/* status and buttons to the right edge */
	.list li > .grow + * {
		margin-left: auto;
	}

	.stop-list .grow {
		padding-left: 34px; /* under the number: stop badge (22px) + gap */
	}

	/* tour choice: tour, trailer and status first, the start button below in its own line */
	.tour-choice li > .grow {
		order: 0;
	}

	.tour-choice li > button {
		flex: 1 1 100%;
		margin-left: 0;
	}
}

/* tick box for the loader: tree is on the trailer */
button.load-check {
	min-width: 48px;
	min-height: 48px;
	padding: 0;
	border: 2px solid var(--ink);
	border-radius: 8px;
	background: #fff;
	color: transparent;
	font-size: 1.5rem;
	font-weight: 900;
}

button.load-check[aria-pressed='true'] {
	border-color: var(--green);
	background: var(--green);
	color: #fff;
}

.loading-list li.loaded {
	background: #eef7f0;
}

.loading-list li.loaded .grow {
	color: var(--muted);
	text-decoration: line-through;
}

.loading-list .load-remove {
	margin-left: auto;
}

.load-progress {
	font-weight: 700;
}

.add-tree {
	margin-top: 12px;
}

/* ---------- driver ---------- */

/* stop list in Auslieferung: a tap shows the stop on the map */
.list li.tappable {
	cursor: pointer;
}

.list li.focused {
	background: var(--amber-light);
}

/* the stop shown in the card at the top */
.list li.current:not(.focused) {
	background: var(--green-light);
}

.badge-current {
	background: var(--green);
	color: #fff;
}

.stop-card {
	border: 3px solid var(--green);
}

.stop-card {
	padding: 12px;
	margin-bottom: 10px;
}

/* number, name/address and progress side by side */
.stop-head {
	display: flex;
	align-items: flex-start;
	gap: 12px;
}

.stop-card .tag {
	flex-shrink: 0;
	font-size: 2rem;
	height: 56px;
	min-width: 80px;
}

.stop-text {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: break-word;
	hyphens: auto;
}

.stop-card .name {
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.2;
}

.stop-card .address {
	font-size: 1.15rem;
	font-weight: 600;
}

.stop-card .ort {
	color: var(--muted);
}

.stop-card .progress {
	flex-shrink: 0;
	margin: 0;
	font-size: 0.85rem;
	white-space: nowrap;
}

.stop-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 14px; /* "Problem" and "✓ Geliefert" must not be hit by mistake */
	margin-top: 10px;
}

.stop-actions > * {
	flex: 1 1 80px;
	min-height: 48px;
	padding: 6px 10px;
}

.stop-actions .delivered {
	flex-grow: 2;
}

.stop-card .hint {
	margin-top: 10px;
	padding: 8px 12px;
	border-radius: 10px;
	background: var(--amber-light);
	color: #5a2f00;
	font-weight: 600;
}

.progress {
	color: var(--muted);
	margin-bottom: 8px;
}

/* ---------- map ---------- */

.map {
	height: 360px;
	border-radius: var(--radius);
	border: 1px solid var(--line);
	z-index: 0;
}

.map.small {
	height: 260px;
}

/* base map switch (Karte / Luftbild / OpenStreetMap), top right in every map */
/* Auslieferung: map right under the current stop */
.drive-map {
	height: 320px;
	margin-bottom: 16px;
}

/* "Tour" (whole tour) below the zoom buttons */
.map-tour {
	min-height: 44px;
	padding: 4px 10px;
	border: 0;
	border-radius: 4px;
	background: #fff;
	color: var(--ink);
	font-size: 0.85rem;
	font-weight: 600;
}

.map-switch {
	display: flex;
	background: #fff;
}

.map-switch button {
	min-height: 44px;
	padding: 4px 10px;
	border: 0;
	border-radius: 0;
	border-left: 1px solid #ccc;
	background: #fff;
	color: var(--ink);
	font-size: 0.85rem;
	font-weight: 600;
}

.map-switch button:first-child {
	border-left: 0;
}

.map-switch button[aria-pressed='true'] {
	background: var(--ink);
	color: #fff;
}

/* zoom buttons big enough for a thumb (Leaflet: 30 px) */
.map .leaflet-bar a,
.map .leaflet-touch .leaflet-bar a,
.leaflet-touch .map .leaflet-bar a {
	width: 44px;
	height: 44px;
	line-height: 44px;
	font-size: 22px;
}

/* attributions are required but must not cover the small map at the till */
.map .leaflet-control-attribution {
	font-size: 9px;
	line-height: 1.3;
	max-width: 100%;
}

/* delivery numbers on the map: same look as .tag; the state shows as a coloured ring.
   The marker is a 44 px touch target with the 30 px circle in the middle. */
.num-marker {
	display: flex;
	align-items: center;
	justify-content: center;
}

.num-marker span {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	box-sizing: border-box;
	border-radius: 50%;
	background: #fff;
	color: var(--slip);
	font-weight: 800;
	font-size: 13px;
	border: 2px solid var(--slip);
	box-shadow: 0 1px 4px rgb(0 0 0 / 0.4);
}

.num-marker.selected span {
	box-shadow: 0 0 0 4px var(--green);
}

.num-marker.done span {
	opacity: 0.55;
}

/* position of the stop in the tour: small dark badge (map marker corner, stop list, stop card) */
.stop-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.6em;
	height: 1.6em;
	padding: 0 0.35em;
	border-radius: 999px;
	background: var(--ink);
	color: #fff;
	font-size: 0.8rem;
	font-weight: 700;
	flex-shrink: 0;
}

/* at the top right corner of the circle (circle at 7–37 px in the 44 px marker) */
.num-marker .stop-badge {
	position: absolute;
	top: -1px;
	right: -3px;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	font-size: 10px;
	border: 1.5px solid #fff;
	box-sizing: border-box;
}

.num-marker.next span {
	box-shadow: 0 0 0 4px var(--amber);
}

/* the sale site is not a delivery: filled */
.num-marker.depot span {
	background: var(--red);
	color: #fff;
	border-color: #fff;
	font-size: 12px;
	width: 34px;
	height: 34px;
}

/* ---------- table (overview) ---------- */

table {
	width: 100%;
	border-collapse: collapse;
	background: var(--card);
}

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

th {
	font-size: 0.85rem;
	color: var(--muted);
}

table.stack .time {
	display: block;
}

/* narrow phones: each row becomes a small card – number on the left, everything else below each other */
@media (max-width: 600px) {
	table.stack thead {
		display: none;
	}

	table.stack tr {
		display: grid;
		grid-template-columns: auto minmax(0, 1fr);
		column-gap: 12px;
		row-gap: 4px;
		padding: 10px 12px;
		border-bottom: 1px solid var(--line);
	}

	table.stack td {
		grid-column: 2;
		padding: 0;
		border: 0;
		overflow-wrap: break-word;
		hyphens: auto;
	}

	table.stack td:first-child {
		grid-column: 1;
		grid-row: 1 / span 5;
	}

	table.stack td:empty {
		display: none;
	}

	table.stack td[data-label]::before {
		content: attr(data-label);
		display: inline-block;
		min-width: 4.5em;
		color: var(--muted);
		font-size: 0.85rem;
	}

	table.stack .time {
		display: inline;
		margin-left: 8px;
	}
}

.counters {
	display: grid;
	grid-template-columns: repeat(4, 1fr); /* 8 counters: two even rows on tablets */
	gap: 10px;
}

@media (max-width: 600px) {
	.counters {
		grid-template-columns: repeat(2, 1fr);
	}
}

.counter {
	background: var(--card);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 12px;
	text-align: center;
}

.counter b {
	display: block;
	font-size: 2.2rem;
}

/* ---------- autocomplete ---------- */

.suggest {
	position: relative;
}

.suggest ul {
	position: absolute;
	z-index: 1100;
	left: 0;
	right: 0;
	top: 100%;
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
	background: #fff;
	border: 2px solid var(--green);
	border-radius: var(--radius);
	max-height: 320px;
	overflow-y: auto;
	box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}

.suggest li {
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
	cursor: pointer;
}

.suggest li:hover,
.suggest li.active {
	background: var(--green-light);
}

.suggest li small {
	color: var(--muted);
}

/* ---------- toast ---------- */

#toast {
	position: fixed;
	left: 50%;
	bottom: 24px;
	transform: translate(-50%, 150%);
	z-index: 2000;
	max-width: calc(100% - 32px);
	padding: 14px 22px;
	border-radius: var(--radius);
	background: var(--ink);
	color: #fff;
	font-weight: 600;
	transition: transform 0.2s;
}

#toast.show {
	transform: translate(-50%, 0);
}

#toast {
	display: flex;
	align-items: center;
	gap: 14px;
}

#toast .toast-action {
	flex-shrink: 0;
	min-height: 44px;
	padding: 6px 14px;
	border: 2px solid #fff;
	background: transparent;
	color: #fff;
	font-weight: 700;
}

#toast.error {
	background: var(--red);
}

#toast.success {
	background: var(--green);
}

.empty {
	color: var(--muted);
	padding: 12px 0;
}

@media (max-width: 600px) {
	:root {
		font-size: 17px;
	}

	main {
		padding: 10px;
	}

	.row {
		flex-wrap: wrap;
	}

	.row > *,
	.row > .narrow {
		flex: 1 1 100%;
	}
}

/* ---------- administration ---------- */

.card h3 {
	font-size: 1.05rem;
	margin: 0 0 8px;
}

.card h3 small {
	font-weight: 400;
	color: var(--muted);
}

.customer-list {
	margin-top: 8px;
}

.customer-form {
	scroll-margin-top: 90px; /* heading stays visible below the fixed header */
	margin-top: 16px;
	padding-top: 16px;
	border-top: 1px solid var(--line);
}

.stats-list li {
	padding: 6px 4px;
	align-items: baseline;
}

/* label in one piece, the value wraps on the right */
.stats-list li > .grow {
	flex: 0 0 auto;
}

.stats-list strong {
	flex: 1 1 auto;
	min-width: 0;
	text-align: right;
	overflow-wrap: anywhere;
}

.hour-bars {
	margin-top: 12px;
}

.hour-bar {
	display: grid;
	grid-template-columns: 4.5em 1fr 2.5em;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
	font-size: 0.9rem;
}

.hour-bar .bar {
	height: 14px;
	border-radius: 4px;
	background: var(--line);
	overflow: hidden;
}

.hour-bar .bar > span {
	display: block;
	height: 100%;
	background: var(--green);
}

.hour-bar b {
	text-align: right;
}

/* phones: name first, buttons below on the right; key figures stay label + value in one line */
@media (max-width: 600px) {
	.customer-list li > .grow {
		order: 0;
	}

	.stats-list li {
		flex-wrap: nowrap;
	}

	.stats-list li > .grow {
		order: 0;
		flex-basis: auto;
	}
}

/* administration: some space between the print links and the next heading */
#admin > nav.roles {
	margin-bottom: 16px;
}
