/*
 * Driver portal — mobile-first dark theme.
 *
 * Single-column, full-bleed layout. Touch targets ≥ 44px. Safe-area
 * insets so the header isn't clipped by an iPhone notch. Self-contained
 * (no framework) to keep the bundle small for mobile data.
 *
 * Theme tokens (consume via var(--…) below):
 *   --bg            primary page background
 *   --surface       card / section background
 *   --surface-2     slightly lighter surface (pills, tile bg)
 *   --border        card / pill border
 *   --text          primary text
 *   --text-muted    secondary / label text
 *   --accent        primary blue (CTAs, active state, links, status)
 *   --success       green (completed, money values)
 *   --warn          amber/orange (mail icon, pending)
 *   --danger        red (failed, mark-as-failed link)
 */

:root {
	--bg: #0e1117;
	--surface: #1a1d27;
	--surface-2: #232733;
	--border: #2a2f3d;
	--text: #e6e8ef;
	--text-muted: #8b8fa3;
	--accent: #5b8def;
	--accent-soft: rgba(91, 141, 239, 0.16);
	--success: #22c55e;
	--success-soft: rgba(34, 197, 94, 0.16);
	--warn: #f59e0b;
	--danger: #ef4444;
	--surface-hover: #2c3140;
	color-scheme: dark;
}
/* Light-mode token overrides. applyTheme('light') sets data-theme on
   <html>; every component reads tokens via var(--…) so the rest of
   the stylesheet just works. color-scheme flips so native widgets
   (date pickers, scrollbars) render in light too. */
:root[data-theme="light"] {
	--bg: #f6f7fb;
	--surface: #ffffff;
	--surface-2: #eef0f5;
	--border: #d9dde5;
	--text: #1f2937;
	--text-muted: #5d6577;
	--accent: #2f6fe0;
	--accent-soft: rgba(47, 111, 224, 0.12);
	--success: #16a34a;
	--success-soft: rgba(22, 163, 74, 0.14);
	--warn: #c2780a;
	--danger: #dc2626;
	--surface-hover: #dde2ec;
	color-scheme: light;
}
:root[data-theme="light"] .udldd-custom-range input[type="date"] { color-scheme: light; }

* { box-sizing: border-box; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--bg);
	color: var(--text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
	overscroll-behavior-y: none;
}

.udldd-portal-body {
	min-height: 100vh;
	padding-bottom: calc(72px + env(safe-area-inset-bottom, 0)); /* reserve room for the bottom tab bar */
}

#udldd-app {
	max-width: 720px;
	margin: 0 auto;
	min-height: 100vh;
	background: var(--bg);
	position: relative;
}

/* ---- Header ---- */
/* New layout: email/identity on the left, Logout link on the right, no
   nav button (bottom tab bar replaces the sidenav). The Back button still
   shows on the order detail view via [data-back="1"]. */
.udldd-header {
	display: none !important;
}
.udldd-header-title {
	flex: 1;
	font-size: 16px;
	font-weight: 600;
	margin: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.udldd-header-logout {
	color: var(--text-muted);
	font-size: 14px;
	background: transparent;
	border: 0;
	cursor: pointer;
	padding: 6px 4px;
}
.udldd-header-logout:hover { color: var(--text); }
.udldd-icon-btn {
	flex: 0 0 36px;
	height: 36px;
	background: transparent;
	border: 0;
	color: inherit;
	cursor: pointer;
	display: grid;
	place-content: center;
	border-radius: 50%;
}
.udldd-icon-btn:hover { background: var(--surface-2); }
.udldd-icon-btn svg {
	width: 22px;
	height: 22px;
	stroke: currentColor;
	stroke-width: 2;
	fill: none;
}

/* ---- Main / screen ---- */

.udldd-main {
	padding: 14px 14px 24px;
	min-height: calc(100vh - 56px - 72px);
}

.udldd-loading,
.udldd-empty {
	text-align: center;
	color: var(--text-muted);
	padding: 32px 12px;
}

/* ---- Buttons + fields ---- */

.udldd-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 46px;
	padding: 0 18px;
	border-radius: 10px;
	font-size: 15px;
	font-weight: 600;
	border: 1px solid transparent;
	cursor: pointer;
	text-decoration: none;
	transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.udldd-btn-primary {
	background: var(--accent);
	color: #fff;
}
.udldd-btn-primary:hover { background: #4576d9; }
.udldd-btn-primary:disabled { background: #3b4a66; cursor: not-allowed; opacity: 0.7; }
.udldd-btn-secondary {
	background: var(--surface-2);
	color: var(--accent);
	border-color: transparent;
}
.udldd-btn-secondary:hover { background: var(--surface-hover); }
.udldd-btn-success {
	background: var(--success);
	color: #06270f;
	font-weight: 700;
	letter-spacing: 0.4px;
	text-transform: uppercase;
}
.udldd-btn-success:hover { background: #1aa84d; }
.udldd-btn-danger {
	background: var(--danger);
	color: #fff;
}
.udldd-btn-danger:hover { background: #d83232; }
/* Used for the Complete Delivery CTA on cash orders — signals
   "take cash before tapping" via the warn (orange) palette. */
.udldd-btn-warn {
	background: var(--warn);
	color: #261705;
	font-weight: 700;
	letter-spacing: 0.4px;
	text-transform: uppercase;
}
.udldd-btn-warn:hover { background: #d18707; }

.udldd-field {
	display: block;
	margin-bottom: 14px;
}
.udldd-field-label {
	display: block;
	font-size: 12px;
	font-weight: 600;
	color: var(--text-muted);
	margin-bottom: 6px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.udldd-field input,
.udldd-field select,
.udldd-textarea,
.udldd-select {
	display: block;
	width: 100%;
	height: 48px;
	padding: 0 14px;
	border: 1px solid var(--border);
	border-radius: 10px;
	font-size: 16px; /* iOS won't zoom into 16px+ inputs */
	background: var(--surface);
	color: var(--text);
}
/* Replace the native select chevron with the dashboard's two-gradient
   chevron so the driver portal matches the main UD admin UI. */
.udldd-field select,
.udldd-select {
	appearance: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	padding-right: 36px;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
	                  linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
	background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
}
.udldd-field select::-ms-expand,
.udldd-select::-ms-expand { display: none; }
.udldd-textarea { padding: 12px 14px; height: auto; resize: vertical; }
/* Input with a leading symbol (e.g. "$"). Prefix sits inside the
   field; the input strips its own left padding so the text starts
   right after the symbol. */
.udldd-field-prefixed { position: relative; }
.udldd-field-prefixed .udldd-field-prefix {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-muted);
	font-size: 16px;
	font-weight: 600;
	pointer-events: none;
}
.udldd-field-prefixed input { padding-left: 28px; }
.udldd-field-prefixed input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.udldd-field-prefixed input[type="number"]::-webkit-outer-spin-button,
.udldd-field-prefixed input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
/* Input with a trailing symbol (e.g. "%"). Mirrors .udldd-field-prefixed. */
.udldd-field-suffixed { position: relative; }
.udldd-field-suffixed .udldd-field-suffix {
	position: absolute;
	right: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-muted);
	font-size: 16px;
	font-weight: 600;
	pointer-events: none;
}
.udldd-field-suffixed input { padding-right: 32px; }
.udldd-field-suffixed input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.udldd-field-suffixed input[type="number"]::-webkit-outer-spin-button,
.udldd-field-suffixed input[type="number"]::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}
.udldd-field input:focus,
.udldd-field select:focus,
.udldd-textarea:focus,
.udldd-select:focus {
	outline: 0;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px var(--accent-soft);
}

.udldd-link {
	display: inline-block;
	color: var(--accent);
	text-decoration: none;
	font-weight: 600;
	padding: 4px 0;
}

/* ---- Login ---- */

.udldd-login {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 24px 20px;
	background: var(--bg);
}
.udldd-login-brand {
	text-align: center;
	color: var(--text);
	margin-bottom: 28px;
}
.udldd-login-logo {
	font-size: 48px;
	margin-bottom: 4px;
}
.udldd-login-title {
	margin: 0;
	font-size: 22px;
	font-weight: 600;
}
.udldd-login-form {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 22px;
}
.udldd-login-form .udldd-btn {
	width: 100%;
	margin-top: 6px;
}
.udldd-login-error {
	margin-top: 12px;
	color: #ff8585;
	font-size: 13px;
	min-height: 18px;
	text-align: center;
}

/* ---- Dashboard / stat pills row ---- */
/* Horizontal row of compact stat pills (Deliveries / Tips / Earnings).
   Scrolls horizontally if the screen is narrow. */
.udldd-stat-pills {
	display: flex;
	gap: 6px;
	margin: 0 0 14px;
	padding: 0;
}
.udldd-stat-pill {
	flex: 1 1 0;
	min-width: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 10px 8px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 24px;
	font-size: 12px;
	font-weight: 600;
	color: var(--text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.udldd-stat-pill-label { color: var(--text);  }
.udldd-stat-pill-value { font-variant-numeric: tabular-nums; }
.udldd-stat-pill-value.is-money { color: var(--success); }
.udldd-stat-pill-value.is-tips { color: var(--accent); }

/* Optimize Route hero button — full-width dark card with a centred
   label. Tighter vertical padding (10px) than the original so the
   button reads as a CTA, not a section. */
.udldd-optimize {
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 10px 18px;
	margin: 4px 0 18px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	color: var(--text);
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
}
.udldd-optimize:hover { background: var(--surface-2); }
.udldd-optimize svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

/* Section divider used between "current" and "completed today" lists. */
.udldd-section-label {
	font-size: 18px;
	color: var(--text);
	letter-spacing: 0.02em;
	font-weight: 700;
	margin: 22px 4px 12px;
}

/* Legacy dashboard layout (still rendered until phase 2 swaps it). */
.udldd-dashboard {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.udldd-avail {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--surface);
	border-radius: 12px;
	border: 1px solid var(--border);
}
.udldd-avail-label { font-size: 13px; color: var(--text-muted); }
.udldd-avail-label strong { color: var(--text); margin-left: 4px; }

.udldd-switch { position: relative; display: inline-block; width: 48px; height: 28px; }
.udldd-switch input { opacity: 0; width: 0; height: 0; }
.udldd-switch-slider {
	position: absolute; cursor: pointer;
	top: 0; left: 0; right: 0; bottom: 0;
	background: var(--surface-2);
	border-radius: 14px;
	transition: background 0.15s;
}
.udldd-switch-slider::before {
	content: '';
	position: absolute;
	height: 22px; width: 22px;
	left: 3px; bottom: 3px;
	background: #fff;
	border-radius: 50%;
	transition: transform 0.15s;
	box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.udldd-switch input:checked + .udldd-switch-slider { background: var(--success); }
.udldd-switch input:checked + .udldd-switch-slider::before { transform: translateX(20px); }

.udldd-earnings-card {
	background: var(--surface);
	border: 1px solid var(--border);
	color: var(--text);
	padding: 16px 18px;
	border-radius: 14px;
}
.udldd-earnings-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.udldd-earnings-value { font-size: 28px; font-weight: 700; margin-top: 2px; color: var(--success); }

.udldd-earnings-3 { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; }
.udldd-earn-row { display: flex; align-items: baseline; justify-content: space-between; }
.udldd-earn-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.udldd-earn-value { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--success); }
.udldd-earn-row.udldd-earn-primary .udldd-earn-label { color: var(--text); font-size: 12px; }
.udldd-earn-row.udldd-earn-primary .udldd-earn-value { font-size: 28px; font-weight: 700; }

.udldd-cards {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}
.udldd-cards-available { grid-template-columns: 1fr; }
.udldd-card.udldd-card-available {
	flex-direction: row;
	align-items: center;
	gap: 14px;
	padding: 16px 18px;
	background: var(--accent);
	border-color: transparent;
	color: #fff;
}
.udldd-card-available-body { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.udldd-card-available-body .udldd-card-label { color: rgba(255,255,255,0.9); letter-spacing: 0.04em; }
.udldd-card-available-body .udldd-card-count { font-size: 22px; color: #fff; }
.udldd-card-available-cta { font-size: 13px; font-weight: 600; padding: 6px 14px; background: rgba(255,255,255,0.18); border-radius: 999px; }

.udldd-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 18px 12px;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	cursor: pointer;
	color: var(--text);
}
.udldd-card-icon { color: var(--accent); }
.udldd-card-icon .udldd-icon { width: 28px; height: 28px; }
.udldd-card-count { font-size: 24px; font-weight: 700; color: var(--success); }
.udldd-card-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* "My Stats" grid layout — 2 columns of stat tiles + a wide bottom tile. */
.udldd-stat-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
	margin-top: 14px;
}
.udldd-stat-tile {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 22px 14px;
	text-align: center;
}
.udldd-stat-tile-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.udldd-stat-tile-value { font-size: 28px; font-weight: 700; color: var(--success); margin-top: 8px; font-variant-numeric: tabular-nums; }
.udldd-stat-tile-wide { grid-column: 1 / -1; }
/* Earnings-section tiles (Your Tip Share + Commission). Tinted green
   to differentiate them from the small grey per-metric tiles above,
   and given top-margin so the section reads as its own block. */
.udldd-stat-tile-divider {
	margin-top: 22px;
	background: var(--success-soft);
	border-color: var(--success);
}
.udldd-stat-tile-divider .udldd-stat-tile-label { color: var(--success); }
/* "Total Earnings" — emphasised so the grand-total reads as the
   summary of the two wide tiles above it. */
.udldd-stat-tile-total {
	background: var(--accent-soft, rgba(82, 132, 235, 0.12));
	border-color: var(--accent);
}
.udldd-stat-tile-total .udldd-stat-tile-label { color: var(--accent); }
.udldd-stat-tile-total .udldd-stat-tile-value { font-size: 32px; }

/* Period filter pills (Today / Yesterday / This Week / This Month / Last Month / Custom).
   Used on the Cash History and My Stats views. */
.udldd-period-pills {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 8px 0 16px;
}
.udldd-period-pill {
	flex: 0 0 auto;
	padding: 9px 18px;
	border-radius: 14px;
	background: var(--surface);
	border: 1px solid var(--border);
	color: var(--text-muted);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
}
.udldd-period-pill:hover { color: var(--text); }
.udldd-period-pill.is-active {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	font-weight: 600;
}

/* Custom date / date-range picker rendered under the pills when the
   Custom pill is active. Single-day on Cash, from + to on Stats. */
.udldd-custom-range {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 10px;
	margin: 0 0 16px;
	padding: 12px;
	border: 1px solid var(--border);
	border-radius: 12px;
	background: var(--surface);
}
.udldd-custom-range-field {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1 1 140px;
}
.udldd-custom-range-label {
	font-size: 12px;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.4px;
}
.udldd-custom-range input[type="date"] {
	width: 100%;
	padding: 9px 12px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: var(--surface-2, var(--surface));
	color: var(--text);
	font-size: 15px;
	color-scheme: dark;
}
.udldd-custom-range-apply {
	flex: 0 0 auto;
	padding: 10px 18px;
}

/* Big "Total" / summary card sitting above a list (cash history). */
.udldd-total-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 22px;
	text-align: center;
	margin-bottom: 12px;
}
.udldd-total-card-label {
	font-size: 12px;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
	font-weight: 600;
}
.udldd-total-card-value {
	font-size: 38px;
	font-weight: 800;
	color: var(--success);
	margin-top: 6px;
	font-variant-numeric: tabular-nums;
}
.udldd-total-card-sub {
	font-size: 13px;
	color: var(--text-muted);
	margin-top: 4px;
}

/* ---- Orders list ---- */

.udldd-order-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}
.udldd-order-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 14px 16px;
	cursor: pointer;
	text-align: left;
	display: flex;
	flex-direction: column;
	gap: 6px;
	color: var(--text);
}
.udldd-order-card-row1 {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
}
/* Right-side cluster on the top row: time · payment tag · kebab. */
.udldd-order-card-right {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}
/* Static ↑↓ hint next to the time/payment tag on delivering cards.
   Pure indicator — tells the driver they can long-press + drag to
   reorder. Not interactive. */
.udldd-order-reorder {
	display: inline-flex;
	align-items: center;
	color: var(--text-muted);
	font-size: 14px;
	letter-spacing: -1px;
	user-select: none;
	pointer-events: none;
}

/* "Lifted" state of a card while it's being dragged. Adds a soft
   shadow + tiny scale so the card visibly detaches from the list. */
.udldd-order-dragging {
	z-index: 10;
	box-shadow: 0 12px 28px rgba(0, 0, 0, 0.6);
	transition: none !important;
	cursor: grabbing;
}
.udldd-order-list { position: relative; }
/* Envelope icon next to the order number when there's a customer note.
   Acts as a button — tapping opens a popup with the note inline. */
.udldd-order-note-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--warn);
	background: transparent;
	border: 0;
	padding: 2px 4px;
	margin-left: 6px;
	cursor: pointer;
	border-radius: 4px;
	vertical-align: -3px;
}
.udldd-order-note-icon:hover { background: rgba(245, 158, 11, 0.15); }
.udldd-order-note-icon .udldd-icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

/* Customer-note popup — tiny modal that appears in the center of the
   screen with the note's text. Fits short notes; long notes scroll
   inside the popup body. */
.udldd-note-popup {
	position: fixed;
	inset: 0;
	z-index: 60;
	display: grid;
	place-items: center;
	background: rgba(0, 0, 0, 0.6);
	padding: 24px;
}
.udldd-note-popup-card {
	width: min(360px, 100%);
	max-height: 70vh;
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}
.udldd-note-popup-head {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 14px;
	border-bottom: 1px solid var(--border);
}
.udldd-note-popup-title {
	flex: 1;
	font-size: 13px;
	font-weight: 700;
	color: var(--text);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.udldd-note-popup-close {
	flex: 0 0 28px;
	width: 28px;
	height: 28px;
	border: 0;
	background: transparent;
	color: var(--text-muted);
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	border-radius: 6px;
}
.udldd-note-popup-close:hover { background: var(--surface-2); color: var(--text); }
.udldd-note-popup-body {
	padding: 14px;
	overflow-y: auto;
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-wrap; /* preserve line breaks the customer entered */
	word-wrap: break-word;
}
/* Spacer fills available horizontal space inside row3 so the status pill
   anchors to the right edge regardless of how many money items render. */
.udldd-order-card-spacer { flex: 1; }
/* Card typography — kept tight and uniform per the design reference:
   the order number, customer name, and price are all the same weight
   and approximate size so no single field shouts louder than the
   others. */
.udldd-order-num { font-weight: 700; font-size: 16px; }
.udldd-order-card-customer { font-size: 15px; color: var(--text); font-weight: 600; }
.udldd-order-card-customer .udldd-route-num { color: var(--accent); font-weight: 700; margin-left: 6px; }
.udldd-order-card-city { font-size: 13px; color: var(--text-muted); }
.udldd-order-card-row3 {
	margin-top: 6px;
	display: flex;
	gap: 10px;
	align-items: center;
	font-size: 14px;
}
.udldd-order-total { font-weight: 700; font-size: 15px; color: var(--text); }
.udldd-order-commission { color: var(--success); }
.udldd-order-items { margin-left: auto; color: var(--text-muted); }
.udldd-order-tip { color: var(--accent); font-size: 13px; }
.udldd-order-card-time { font-size: 13px; color: var(--text-muted); }
/* Inline action button at the bottom of an order card (Call Customer).
   Compact — slightly shorter than the global .udldd-btn — and without
   the default <a> underline. */
.udldd-order-card-action {
	margin-top: 8px;
	width: 100%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 34px;
	padding: 6px 14px;
	background: var(--surface-2);
	color: var(--accent);
	border: 0;
	border-radius: 8px;
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	text-decoration: none;
}
.udldd-order-card-action:hover { background: var(--surface-hover); text-decoration: none; }

/* Store / channel tag (e.g. "EMT") shown to the right of the order number. */
.udldd-store-tag {
	display: inline-flex;
	align-items: center;
	padding: 3px 9px;
	border-radius: 6px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	background: var(--accent-soft);
	color: var(--accent);
}
.udldd-store-tag.is-cash {
	background: var(--success-soft);
	color: var(--success);
}

/* Status pills — match the target screenshots. */
.udldd-order-status-pill {
	font-size: 11px;
	font-weight: 700;
	padding: 5px 12px;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}
.udldd-status-processing      { background: var(--accent-soft); color: var(--accent); }
.udldd-status-on-hold         { background: rgba(245, 158, 11, 0.16); color: var(--warn); }
.udldd-status-completed       { background: var(--success-soft); color: var(--success); }
.udldd-status-cancelled       { background: rgba(107, 114, 128, 0.20); color: var(--text-muted); }
.udldd-status-refunded        { background: rgba(239, 68, 68, 0.16); color: var(--danger); }
.udldd-status-udldd-assigned   { background: rgba(245, 158, 11, 0.16); color: var(--warn); }
.udldd-status-udldd-delivering { background: var(--accent-soft); color: var(--accent); }
.udldd-status-udldd-failed     { background: rgba(239, 68, 68, 0.16); color: var(--danger); }

/* ---- Order detail ---- */

.udldd-order {
	display: flex;
	flex-direction: column;
	gap: 14px;
}
.udldd-order-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 4px 0 4px;
}
.udldd-order-head-title { flex: 1; text-align: center; font-size: 18px; font-weight: 700; }
.udldd-order-head-back {
	color: var(--accent);
	background: transparent;
	border: 0;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	padding: 6px 0;
}
.udldd-order-mark-failed {
	display: block;
	text-align: right;
	color: var(--danger);
	background: transparent;
	border: 0;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	padding: 0 4px 6px;
	margin-left: auto;
}
.udldd-order-section {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 16px 18px;
}
.udldd-order-section h3 {
	margin: 0 0 12px;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-muted);
	font-weight: 700;
}
.udldd-address { line-height: 1.5; margin-bottom: 10px; color: var(--accent); font-weight: 600; }
.udldd-note { color: var(--text-muted); line-height: 1.5; }

.udldd-order-items-list { list-style: none; margin: 0; padding: 0; }
.udldd-order-items-list li {
	display: flex; gap: 8px; padding: 10px 0;
	border-bottom: 1px solid var(--border);
	align-items: center;
}
.udldd-order-items-list li:last-child { border-bottom: 0; }
.udldd-order-item-qty { min-width: 32px; font-weight: 600; color: var(--accent); }
.udldd-order-item-name { flex: 1; }
.udldd-order-item-total { font-weight: 600; }

.udldd-order-total-section { font-size: 15px; }
.udldd-order-total-section > div { padding: 4px 0; }
.udldd-order-pay { font-size: 12px; color: var(--text-muted); }

.udldd-info-card .udldd-info-row {
	display: flex;
	gap: 14px;
	padding: 8px 0;
	font-size: 14px;
	border-bottom: 1px solid var(--border);
}
.udldd-info-card .udldd-info-row:last-child { border-bottom: 0; }
.udldd-info-card .udldd-info-label {
	flex: 0 0 88px;
	color: var(--text-muted);
	font-size: 14px;
}
.udldd-info-card .udldd-info-value { flex: 1; min-width: 0; text-align: right; color: var(--text); font-weight: 600; }
.udldd-info-card .udldd-info-value.is-link { color: var(--accent); }

.udldd-customer-name { font-weight: 600; margin-bottom: 8px; }
.udldd-customer-actions { display: flex; gap: 8px; }
.udldd-customer-actions .udldd-btn { flex: 1; }
.udldd-btn-whatsapp { background: #25d366; color: #fff; border-color: transparent; }
.udldd-btn-whatsapp:hover { background: #1ebe5d; }

.udldd-items-with-images .udldd-order-item { display: flex; gap: 10px; align-items: center; }
.udldd-order-item-img {
	width: 44px;
	height: 44px;
	border-radius: 8px;
	object-fit: cover;
	background: var(--surface-2);
	border: 1px solid var(--border);
	flex-shrink: 0;
}
.udldd-order-item-img-blank { display: grid; place-content: center; color: var(--text-muted); font-size: 18px; }
.udldd-order-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.udldd-order-item-body .udldd-order-item-name { font-size: 14px; line-height: 1.3; }
.udldd-order-item-sku { font-size: 11px; color: var(--text-muted); font-family: ui-monospace, monospace; margin-top: 2px; }
.udldd-order-item-body .udldd-order-item-qty { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }

.udldd-totals-card { font-size: 14px; }
.udldd-totals-row { display: flex; justify-content: space-between; padding: 6px 0; }
.udldd-totals-label { color: var(--text-muted); }
.udldd-totals-value { font-variant-numeric: tabular-nums; }
.udldd-totals-row.udldd-totals-strong {
	font-weight: 700;
	font-size: 16px;
	border-top: 1px solid var(--border);
	padding-top: 10px;
	margin-top: 4px;
}
.udldd-totals-row.udldd-totals-refund .udldd-totals-value { color: var(--danger); }
.udldd-totals-row.udldd-totals-commission .udldd-totals-value { color: var(--success); font-weight: 600; }

.udldd-order-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.udldd-order-actions .udldd-btn { width: 100%; }
.udldd-order-actions-note { font-size: 12px; color: var(--text-muted); text-align: center; }
/* Row that pairs Call Customer with the camera/POD button. The phone
   button stretches; the icon button is a fixed square so the SVG
   reads as a glyph rather than a label. */
.udldd-actions-row { display: flex; gap: 10px; }
.udldd-actions-row .udldd-actions-row-main { flex: 1 1 auto; width: auto; }
.udldd-actions-row .udldd-actions-row-icon {
	flex: 0 0 56px;
	width: 56px;
	padding: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.udldd-actions-row .udldd-actions-row-icon .udldd-icon {
	width: 22px; height: 22px;
	stroke: currentColor; stroke-width: 2; fill: none;
	stroke-linecap: round; stroke-linejoin: round;
}

/* ---- Settings ---- */

.udldd-settings-form { display: flex; flex-direction: column; gap: 12px; }
.udldd-settings-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 14px;
	padding: 18px;
}
.udldd-settings-card-title {
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--text-muted);
	font-weight: 700;
	margin: 0 0 14px;
}
.udldd-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.udldd-field-help { font-size: 11px; color: var(--text-muted); margin: -8px 0 8px; }
.udldd-settings-actions { margin-top: 6px; }
.udldd-settings-actions .udldd-btn { width: 100%; }

/* Profile photo editor (Settings → Photo card) */
.udldd-photo-edit { display: flex; align-items: center; gap: 14px; }
.udldd-photo-preview {
	width: 64px; height: 64px;
	border-radius: 50%;
	object-fit: cover;
	background: var(--surface-2);
	border: 1px solid var(--border);
}
.udldd-photo-edit .udldd-btn { flex: 1; }

.udldd-nav-photo {
	width: 56px; height: 56px;
	border-radius: 50%;
	object-fit: cover;
	margin-bottom: 10px;
	border: 2px solid var(--accent-soft);
}

/* ---- Sidenav (legacy — kept until phase 2 swap). ---- */

.udldd-sidenav {
	position: fixed;
	top: 0; bottom: 0; right: 0;
	width: min(320px, 85%);
	background: var(--surface);
	z-index: 30;
	box-shadow: -2px 0 14px rgba(0, 0, 0, 0.4);
	transform: translateX(100%);
	transition: transform 0.2s ease-out;
	padding-top: calc(env(safe-area-inset-top, 0));
}
#udldd-app[data-nav="open"] .udldd-sidenav { transform: translateX(0); }

.udldd-scrim {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.48);
	z-index: 20;
	opacity: 0;
	transition: opacity 0.2s ease-out;
}
#udldd-app[data-nav="open"] .udldd-scrim { opacity: 1; }

.udldd-nav-header { padding: 22px 20px 14px; border-bottom: 1px solid var(--border); }
.udldd-nav-name { font-weight: 600; font-size: 16px; }
.udldd-nav-phone { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.udldd-nav-list { list-style: none; margin: 0; padding: 8px 0; }
.udldd-nav-link {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	padding: 14px 20px;
	background: transparent;
	border: 0;
	font-size: 15px;
	cursor: pointer;
	color: inherit;
	text-align: left;
}
.udldd-nav-link:hover { background: var(--surface-2); }
.udldd-nav-link .udldd-icon { width: 22px; height: 22px; stroke: var(--text-muted); stroke-width: 2; fill: none; }
.udldd-nav-label { flex: 1; }
.udldd-nav-count {
	font-size: 11px;
	font-weight: 600;
	background: var(--accent);
	color: #fff;
	padding: 2px 8px;
	border-radius: 999px;
}
.udldd-nav-logout { border-top: 1px solid var(--border); margin-top: 8px; color: var(--danger); }
.udldd-nav-logout .udldd-icon { stroke: var(--danger); }

/* ---- Bottom tab bar (phase 2 will wire this up; styles ready now). ---- */
.udldd-tabbar {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	z-index: 25;
	/* Auto-fit so the bar handles 4 or 5 tabs without breaking. Each
	   tab gets an equal slice of the width. */
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	background: var(--surface);
	border-top: 1px solid var(--border);
	padding-bottom: env(safe-area-inset-bottom, 0);
}
.udldd-tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 3px;
	height: 62px;
	padding: 0 2px;
	min-width: 0; /* allow shrinking inside the grid track */
	background: transparent;
	border: 0;
	color: var(--text-muted);
	cursor: pointer;
	font-size: 10px;
	font-weight: 600;
	letter-spacing: 0.02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.udldd-tab svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2; fill: none; }
.udldd-tab.is-active { color: var(--accent); }
/* Wraps the icon so the count bubble can sit at its top-right. */
.udldd-tab-icon-wrap {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
/* Notification bubble (e.g. number of pending Assigned orders). Sits
   on top-right of the tab's icon. Uses the danger red so unread/
   pending work catches the eye. */
.udldd-tab-badge {
	position: absolute;
	top: -6px;
	right: -10px;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	background: var(--danger);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 18px;
	text-align: center;
	border-radius: 999px;
	font-variant-numeric: tabular-nums;
	box-shadow: 0 0 0 2px var(--surface); /* halo so the bubble pops off the tab bar bg */
}

/* ---- Toast ---- */

.udldd-toast {
	position: fixed;
	left: 50%;
	bottom: calc(84px + env(safe-area-inset-bottom, 0));
	transform: translateX(-50%);
	background: var(--surface);
	color: var(--text);
	border: 1px solid var(--border);
	padding: 12px 18px;
	border-radius: 10px;
	font-size: 14px;
	box-shadow: 0 6px 18px rgba(0,0,0,0.4);
	z-index: 40;
	max-width: 90%;
}
.udldd-toast[data-kind="error"] { background: rgba(239, 68, 68, 0.16); color: #ff8585; border-color: rgba(239, 68, 68, 0.36); }

/* ---- Phase 7: claim "Take →" chip + hint banner ---- */

.udldd-avail-hint {
	background: rgba(245, 158, 11, 0.12);
	border: 1px solid rgba(245, 158, 11, 0.3);
	color: var(--warn);
	padding: 10px 12px;
	border-radius: 10px;
	font-size: 12px;
	margin-bottom: 10px;
}
.udldd-order-claim-cta {
	font-size: 12px;
	font-weight: 600;
	padding: 4px 12px;
	border-radius: 12px;
	background: var(--accent);
	color: #fff;
}

/* ---- Bottom sheet (POD modals) ---- */

.udldd-sheet { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.udldd-sheet.open { pointer-events: auto; }
.udldd-sheet-scrim {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.6);
	opacity: 0;
	transition: opacity 0.2s ease-out;
}
.udldd-sheet.open .udldd-sheet-scrim { opacity: 1; }
.udldd-sheet-card {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	max-height: 92vh;
	background: var(--surface);
	border-radius: 18px 18px 0 0;
	display: flex;
	flex-direction: column;
	transform: translateY(100%);
	transition: transform 0.25s ease-out;
	padding-bottom: env(safe-area-inset-bottom, 0);
	overflow: hidden;
}
.udldd-sheet.open .udldd-sheet-card { transform: translateY(0); }
.udldd-sheet-head {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 16px 18px;
	border-bottom: 1px solid var(--border);
}
.udldd-sheet-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 600; }
.udldd-sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 18px 8px; }
.udldd-sheet-foot {
	padding: 14px 18px;
	border-top: 1px solid var(--border);
	background: var(--bg);
}
.udldd-sheet-actions { display: flex; gap: 10px; }
.udldd-sheet-actions .udldd-btn { flex: 1; min-width: 0; }

/* ---- Signature pad ---- */

.udldd-sigpad {
	position: relative;
	border: 1px dashed var(--border);
	border-radius: 8px;
	background:
		repeating-linear-gradient(135deg, var(--surface), var(--surface) 8px, var(--surface-2) 8px, var(--surface-2) 9px);
	height: 180px;
	margin: 6px 0 4px;
}
.udldd-sigpad-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.udldd-sigpad-hint {
	position: absolute; inset: 0;
	display: grid;
	place-content: center;
	color: var(--text-muted);
	font-size: 13px;
	pointer-events: none;
	transition: opacity 0.15s;
}
.udldd-sigpad-clear {
	position: absolute;
	top: 6px; right: 6px;
	background: rgba(255,255,255,0.06);
	border: 1px solid var(--border);
	border-radius: 4px;
	font-size: 11px;
	font-weight: 600;
	padding: 4px 10px;
	cursor: pointer;
	color: var(--text);
}

/* ---- POD photo grid + picker ---- */

.udldd-photo-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 6px;
	margin: 4px 0;
}
.udldd-photo-tile {
	position: relative;
	aspect-ratio: 1 / 1;
	background: var(--surface-2);
	border: 1px solid var(--border);
	border-radius: 8px;
	overflow: hidden;
}
.udldd-photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.udldd-photo-del {
	position: absolute;
	top: 4px; right: 4px;
	width: 24px; height: 24px;
	border: 0; border-radius: 50%;
	background: rgba(0,0,0,0.6);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	display: grid;
	place-content: center;
}
.udldd-photo-picker { margin: 6px 0 2px; }
.udldd-photo-add { width: 100%; }
.udldd-pod-existing .udldd-pod-sig-preview {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 6px;
}
.udldd-pod-existing .udldd-pod-sig-preview img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
