/* Haulier booking: one stylesheet for all three pages. System fonts only, no external files.
   Spacing scale: 4 / 8 / 12 / 16 / 24 / 32. Radius: 12px cards, 8px controls. */

:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #17201b;
  --muted: #5b6962;
  --border: #dde3de;
  --accent: #1f6f4a;
  --accent-hover: #185b3c;
  --danger-solid: #b42318; /* behind white text on badges and tags: at least 4.5:1 in both themes */
  --on-accent: #ffffff;
  --accent-ink: #1f6f4a;
  --accent-soft: #e3f1ea;
  --focus: #1f6f4a;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --danger-ink: #912018;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 2px 8px rgba(20, 30, 25, 0.05);
  --shadow-lift: 0 8px 24px rgba(20, 30, 25, 0.18);
  --backdrop: rgba(15, 22, 18, 0.5);
  --topbar: #ffffff;

  /* status colours: soft background, darker text, strong dot */
  --amber-bg: #fdf0d2; --amber-fg: #744400; --amber-dot: #d98b06;
  --blue-bg: #e1ebfd; --blue-fg: #1b3d8c; --blue-dot: #3b6fe0;
  --green-bg: #dbf1e3; --green-fg: #115236; --green-dot: #1f8a5b;
  --teal-bg: #d3f1ef; --teal-fg: #0a5656; --teal-dot: #12908f;
  --slate-bg: #e4e8ee; --slate-fg: #35405a; --slate-dot: #6b7690;
  --red-bg: #fbe0dd; --red-fg: #8a1b12; --red-dot: #d03a2f;
  --grey-bg: #f0f1ef; --grey-fg: #596059; --grey-dot: #98a29c;

  --plate-bg: #f7d117;
  --plate-fg: #111111;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1411;
    --surface: #171e1a;
    --surface-2: #1f2823;
    --text: #e8eee9;
    --muted: #9db0a4;
    --border: #2c3731;
    --accent: #217a52;
    --accent-hover: #1b6845;
    --danger-solid: #c9372c;
    --on-accent: #ffffff;
    --accent-ink: #6fd6a4;
    --accent-soft: #163626;
    --focus: #6fd6a4;
    --danger: #f0675c;
    --danger-soft: #3f1a17;
    --danger-ink: #fba9a1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.65);
    --topbar: #171e1a;

    --amber-bg: #3b2d0c; --amber-fg: #f6cf7a; --amber-dot: #f2b13d;
    --blue-bg: #1a2b4d; --blue-fg: #aac6fb; --blue-dot: #6b9bff;
    --green-bg: #14372a; --green-fg: #93e2b6; --green-dot: #4cc58a;
    --teal-bg: #0e3736; --teal-fg: #8ee4dd; --teal-dot: #3cc7c0;
    --slate-bg: #293041; --slate-fg: #c5cddd; --slate-dot: #8e9ab3;
    --red-bg: #471c19; --red-fg: #fcaca4; --red-dot: #f0675c;
    --grey-bg: #222826; --grey-fg: #a3aea8; --grey-dot: #707a75;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.25rem; line-height: 1.25; }
h3 { font-size: 1.05rem; }
a { color: var(--accent-ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }
.flush-top { margin-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--topbar); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; }
.brand svg { width: 26px; height: 26px; color: var(--accent-ink); }
.context { color: var(--muted); font-size: 0.95rem; padding-left: 12px; border-left: 1px solid var(--border); }
.env-tag { font-size: 0.75rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { font-weight: 600; font-size: 0.95rem; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navlink {
  color: var(--text); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 500;
  min-height: 36px; display: inline-flex; align-items: center; transition: background 0.15s;
}
.navlink:hover { background: var(--surface-2); }

main { padding: 24px 16px 48px; max-width: 1500px; margin: 0 auto; }
main.narrow-page { max-width: 640px; }

/* ---- icons ---- */
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }

/* ---- cards and panels ---- */
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel > h2:first-child { margin-bottom: 8px; }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.panel-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { font-size: 1.1rem; }

/* ---- forms and buttons ---- */
label, .label { display: block; font-weight: 600; font-size: 0.9rem; margin: 16px 0 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; min-height: 44px; width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--focus); }
input[type='checkbox'], input[type='radio'] { width: 20px; height: 20px; min-height: 0; padding: 0; accent-color: var(--accent); }
textarea.wide { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.8rem; min-height: 120px; }
.auto-width { width: auto; }
.inline-label { display: inline; margin: 0; font-weight: 500; }

.btn, button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 16px; min-height: 40px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button { white-space: nowrap; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }
button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
button.danger.solid { background: var(--danger-solid); color: #fff; }
button.danger.solid:hover:not(:disabled) { background: var(--danger); filter: brightness(0.92); }
button.ghost { background: none; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
button.small { font-size: 0.85rem; padding: 4px 12px; min-height: 32px; border-radius: 8px; }
button.xs { font-size: 0.75rem; padding: 2px 8px; min-height: 26px; border-radius: 6px; font-weight: 600; }
button.big { min-height: 48px; font-size: 1.05rem; padding: 12px 24px; }
button.icon-btn { padding: 0; width: 40px; }
button.small.icon-btn { width: 32px; }
@media (pointer: coarse) {
  .btn, button { min-height: 44px; }
  button.small, button.xs { min-height: 44px; padding-left: 12px; padding-right: 12px; }
  button.icon-btn { width: 44px; }
}
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.row input, .row select { width: auto; flex: 1 1 12rem; }
.row .grow { flex: 1 1 14rem; }

/* ---- messages and toasts ---- */
.msg { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid transparent; }
.msg.error { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger); }
.msg.ok { background: var(--accent-soft); color: var(--accent-ink); }
.msg.locked { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.msg.note { margin: 12px 0 0; font-size: 0.9rem; }
#toasts { position: fixed; z-index: 100; left: 0; right: 0; bottom: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; background: #1d2a23; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lift);
  max-width: 34rem; display: flex; gap: 12px; align-items: flex-start; font-size: 0.95rem; animation: toast-in 0.2s ease-out;
  border-left: 4px solid #4cc58a;
}
.toast.error { background: #5a1a15; border-left-color: #f0675c; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- skeletons and empty states ---- */
.skeleton {
  border-radius: 12px; min-height: 96px; margin-bottom: 12px; border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton.slim { min-height: 40px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; list-style: none; }
.empty strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }
.empty .icon { width: 36px; height: 36px; color: var(--muted); display: block; margin: 0 auto 8px; opacity: 0.7; }

/* ---- status pills ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; line-height: 1.25;
  padding: 2px 12px 2px 8px; border-radius: 999px; background: var(--st-bg, var(--grey-bg)); color: var(--st-fg, var(--grey-fg));
}
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--st-dot, var(--grey-dot)); flex: none; }
.pill.plain::before { display: none; }
.pill.plain { padding-left: 12px; }
.s-no-time, .s-none { --st-bg: var(--amber-bg); --st-fg: var(--amber-fg); --st-dot: var(--amber-dot); }
.s-requested { --st-bg: var(--blue-bg); --st-fg: var(--blue-fg); --st-dot: var(--blue-dot); }
.s-confirmed { --st-bg: var(--green-bg); --st-fg: var(--green-fg); --st-dot: var(--green-dot); }
.s-arrived { --st-bg: var(--teal-bg); --st-fg: var(--teal-fg); --st-dot: var(--teal-dot); }
.s-unloaded, .s-received { --st-bg: var(--slate-bg); --st-fg: var(--slate-fg); --st-dot: var(--slate-dot); }
.s-cancelled, .s-moved-away, .s-moved-here, .s-alert { --st-bg: var(--red-bg); --st-fg: var(--red-fg); --st-dot: var(--red-dot); }
.s-not-in-import { --st-bg: var(--grey-bg); --st-fg: var(--grey-fg); --st-dot: var(--grey-dot); }
.s-not-in-import .pill { border: 1px dashed var(--grey-dot); }
.pill.s-not-in-import { border: 1px dashed var(--grey-dot); }
.pill.type { --st-bg: var(--surface-2); --st-fg: var(--muted); }
.pill.type::before { display: none; }
.pill.type { padding-left: 12px; }

/* ---- registration plates ---- */
.plate {
  display: inline-flex; align-items: center; gap: 8px; background: var(--plate-bg); color: var(--plate-fg);
  border: 2px solid #1b1b1b; border-radius: 8px; padding: 2px 12px; font-weight: 800; letter-spacing: 0.08em;
  font-size: 1.15rem; line-height: 1.3; text-transform: uppercase; max-width: 100%; white-space: nowrap;
  font-family: "Arial Black", "Segoe UI", system-ui, sans-serif; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}
.plate.plate-sea, .plate.plate-air, .plate.plate-tbc {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--muted); box-shadow: none;
  font-weight: 700; letter-spacing: 0.03em; text-transform: none; font-family: inherit; font-size: 1rem;
}
.plate.plate-air { background: var(--blue-bg); color: var(--blue-fg); border-color: var(--blue-dot); }
.plate.plate-sea { white-space: normal; }
.plate.plate-sea .plate-text { overflow-wrap: anywhere; text-transform: uppercase; }
.plate.plate-tbc { border-style: dashed; font-weight: 600; color: var(--muted); }
.plate.sm { font-size: 0.85rem; padding: 0 8px; border-width: 1.5px; border-radius: 6px; letter-spacing: 0.05em; }
.plate.sm.plate-sea, .plate.sm.plate-air, .plate.sm.plate-tbc { font-size: 0.8rem; border-width: 1px; }

/* ---- haulier page ---- */
.hero { text-align: center; padding: 8px 0 16px; }
.hero h1 { font-size: 1.6rem; line-height: 1.2; }
.hero p { color: var(--muted); margin-top: 4px; }
.login-card { padding: 24px; }
.login-card button.primary { width: 100%; margin-top: 24px; }
.login-card .help { margin-top: 16px; text-align: center; }
.pin-input { letter-spacing: 0.5em; font-size: 1.4rem; text-align: center; }
.page-intro { margin-bottom: 16px; }
.page-intro h1 { font-size: 1.5rem; }
.page-intro p { color: var(--muted); margin-top: 4px; font-size: 0.95rem; }
.day-group { margin-bottom: 24px; }
.day-heading { display: flex; align-items: baseline; gap: 8px; margin: 24px 0 8px; }
.day-heading h2 { font-size: 1.15rem; }
.day-heading span { color: var(--muted); font-size: 0.9rem; }
.truck-card { border-left: 4px solid var(--st-dot, var(--border)); padding: 16px; margin-bottom: 12px; transition: box-shadow 0.2s; }
.truck-card:hover { box-shadow: 0 2px 4px rgba(20, 30, 25, 0.08), 0 6px 18px rgba(20, 30, 25, 0.08); }
.truck-card.locked-card { opacity: 0.85; }
.card-head { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; justify-content: space-between; }
.card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: 0.9rem; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); font-size: 0.95rem; list-style: none; }
.facts li { display: contents; }
.facts .po { font-weight: 600; font-variant-numeric: tabular-nums; }
.facts .sup { color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.product-line { margin-top: 8px; font-size: 0.95rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip-static { background: var(--surface-2); border-radius: 999px; padding: 2px 12px; font-size: 0.85rem; font-weight: 600; }
.status-text { margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: var(--st-bg, var(--surface-2)); color: var(--st-fg, var(--text)); font-size: 0.92rem; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.card-actions button { flex: 1 1 8rem; }
.card-actions button.primary { flex: 2 1 12rem; }

/* ---- dialogs: modal, bottom sheet, side drawer ---- */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lift); width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto;
}
dialog::backdrop { background: var(--backdrop); }
dialog[open] { animation: pop-in 0.18s ease-out; }
dialog[open]::backdrop { animation: fade-in 0.18s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.dialog-body { padding: 24px; }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; margin-bottom: 16px; }
.dialog-head h2, .dialog-head h3 { margin: 0; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 24px; }
.dialog-foot button { flex: 1 1 8rem; }
.dialog-foot button.primary { flex: 2 1 12rem; }
.field-hint { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0 0; width: 100%; max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; border-bottom: 0; }
  dialog.sheet[open] { animation: sheet-up 0.2s ease-out; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.time-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; border: 0; padding: 0; min-width: 0; }
.time-chip { position: relative; }
.time-chip label { margin: 0; }
.time-chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; cursor: pointer; }
.time-chip span {
  display: flex; align-items: center; justify-content: center; min-height: 44px; border: 1px solid var(--border); border-radius: 8px;
  font-weight: 600; font-variant-numeric: tabular-nums; background: var(--surface); transition: background 0.15s, border-color 0.15s;
}
.time-chip input:hover:not(:disabled):not(:checked) + span { border-color: var(--accent); background: var(--accent-soft); }
.time-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.time-chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.time-chip input:disabled { cursor: not-allowed; }
.time-chip input:disabled + span { opacity: 0.4; background: var(--surface-2); text-decoration: line-through; }
legend.label { padding: 0; margin-top: 16px; }
.day-warning {
  margin-top: 16px; padding: 12px 16px; border-radius: 12px; background: var(--amber-bg); color: var(--amber-fg);
  border: 2px solid var(--amber-dot); animation: pop-in 0.18s ease-out;
}
.day-warning strong { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.day-warning .confirm-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; font-weight: 600; }
.day-warning .confirm-row label { margin: 0; font-size: 0.95rem; }

/* ---- planner ---- */
.alert-banner { background: var(--danger-soft); border: 2px solid var(--danger); border-radius: 12px; padding: 16px; margin-bottom: 16px; color: var(--text); }
.alert-banner h2 { color: var(--danger-ink); display: flex; gap: 8px; align-items: center; font-size: 1.1rem; margin-bottom: 8px; }
.alert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.alert { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--danger); border-radius: 8px; padding: 8px 12px; }
.alert .alert-text { flex: 1 1 18rem; min-width: 0; }
.alert-tag { display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.05em; background: var(--danger-solid); color: #fff; padding: 0 8px; border-radius: 6px; margin-right: 4px; }
.alert .muted { display: block; }
.alert-name { width: 11rem; flex: 0 0 auto; min-height: 36px; padding: 4px 12px; }

.day-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 12px; margin: 0 -4px 8px; scroll-snap-type: x proximity; }
.day-chip {
  flex: 0 0 auto; min-width: 5.6rem; flex-direction: column; gap: 0; padding: 8px 12px; line-height: 1.25; border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow); scroll-snap-align: start; position: relative; min-height: 76px; font-weight: 500; justify-content: flex-start;
}
.day-chip .chip-wd { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.day-chip .chip-date { font-size: 1.2rem; font-weight: 700; }
.day-chip .chip-count { font-size: 0.78rem; color: var(--muted); }
.day-chip.selected, .day-chip.selected:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.day-chip.selected .chip-wd, .day-chip.selected .chip-count { color: rgba(255, 255, 255, 0.85); }
.attention-badge { background: var(--danger-solid); color: #fff; border-radius: 999px; font-size: 0.7rem; font-weight: 700; padding: 0 8px; line-height: 1.5; margin-top: 4px; white-space: nowrap; }

.day-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 16px; }
.day-head h2 { font-size: 1.5rem; margin: 0 8px; }
.day-head .spacer { flex: 1; }
.day-head input[type='date'] { width: auto; }
.import-state { font-size: 0.85rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); border-top: 4px solid var(--st-dot, var(--border)); }
.tile .num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .lbl { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.tile.hot { background: var(--st-bg); }
.tile.hot .num { color: var(--st-fg); }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 480px); gap: 24px; align-items: start; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }
.col-calendar { align-self: stretch; } /* full row height, so the sticky calendar has room to stay in view */
.cal-card { position: sticky; top: 72px; padding: 12px; }
@media (max-width: 1000px) { .cal-card { position: static; } }
.cal-card .panel-head { margin: 0 0 8px 4px; }
.cal-scroll { max-height: calc(100vh - 72px - 24px - 56px - 24px); max-height: calc(100dvh - 72px - 24px - 56px - 24px); overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 1000px) { .cal-scroll { max-height: none; } }

.slot { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; min-height: 40px; border-bottom: 1px solid var(--border); background: var(--surface); transition: background 0.15s, box-shadow 0.15s; }
.slot:last-child { border-bottom: 0; }
.slot .time { background: var(--surface-2); padding: 8px 0 0 8px; font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.slot .drop { padding: 4px 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-width: 0; }
.slot .count { padding: 8px 8px 0 4px; font-size: 0.75rem; color: var(--muted); font-weight: 700; min-width: 1.75rem; text-align: right; }
.slot.past { background: var(--surface-2); }
.slot.past .time { color: var(--muted); }
.slot.now .time { background: var(--amber-bg); color: var(--amber-fg); box-shadow: inset 3px 0 0 var(--amber-dot); }
.slot.over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.slot.blocked, .slot.blocked .time { background: var(--red-bg); }
.slot.blocked { box-shadow: inset 4px 0 0 var(--red-dot); cursor: not-allowed; }
.slot.blocked .time { color: var(--red-fg); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st-dot, var(--border));
  border-radius: 8px; padding: 2px 4px 2px 8px; font-size: 0.8rem; max-width: 100%; box-shadow: var(--shadow); transition: transform 0.15s, box-shadow 0.15s;
}
.chip .chip-open { background: none; border: 0; padding: 0; min-height: 0; gap: 4px; font-weight: 600; font-size: inherit; text-align: left; min-width: 0; flex: 0 1 auto; }
.chip .chip-open .plate { flex: none; }
.chip .chip-open:hover:not(:disabled) { background: none; }
.chip .chip-sub { color: var(--muted); max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.chip.s-requested { background: var(--blue-bg); }
[draggable='true'] { cursor: grab; }
[draggable='true']:hover { box-shadow: 0 2px 4px rgba(20, 30, 25, 0.1), 0 6px 16px rgba(20, 30, 25, 0.12); }
.dragging { opacity: 0.55; transform: scale(1.02) rotate(-0.5deg); box-shadow: var(--shadow-lift) !important; cursor: grabbing; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: none; min-height: 32px; padding: 4px 12px; font-weight: 500; }
.seg button.selected { background: var(--surface); box-shadow: var(--shadow); color: var(--accent-ink); font-weight: 700; }
.count-badge:not(:empty) { background: var(--danger-solid); color: #fff; border-radius: 999px; font-size: 0.75rem; padding: 0 8px; line-height: 1.5; }
.filters .spacer { flex: 1; }
.filters select { width: auto; min-height: 36px; padding: 4px 12px; }

.day-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--st-dot, var(--border)); border-radius: 12px;
  padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; transition: box-shadow 0.15s, transform 0.15s;
}
.list-item.tint { background: var(--st-bg); }
.list-item.s-not-in-import { border-style: dashed; opacity: 0.8; background: var(--surface-2); }
.li-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; grid-column: 1; }
.li-time { grid-column: 2; grid-row: 1; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.li-time.none { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
.li-info { grid-column: 1 / -1; font-size: 0.9rem; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.li-info .line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-actions { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.panel .li-note { color: var(--muted); }

.request-list { display: grid; gap: 8px; }

/* detail drawer */
dialog.drawer {
  margin: 0 0 0 auto; width: min(540px, 100vw); max-width: 100vw; height: 100vh; height: 100dvh; max-height: none; border-radius: 12px 0 0 12px; border-right: 0; border-top: 0; border-bottom: 0;
}
dialog.drawer[open] { animation: drawer-in 0.2s ease-out; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer .dialog-body { display: grid; gap: 4px; }
.section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 24px 0 8px; }
.detail-head-main { display: grid; gap: 8px; }
.detail-list { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 0.92rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 480px) { .detail-list { grid-template-columns: 1fr; } .detail-list dd { margin-bottom: 8px; } }
.mini-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.mini-table th, .mini-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.mini-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.tag-list { display: flex; gap: 8px; flex-wrap: wrap; }
ol.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); display: grid; gap: 12px; }
ol.timeline li { position: relative; font-size: 0.9rem; }
ol.timeline li::before { content: ''; position: absolute; left: -23px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
ol.timeline .ev { font-weight: 700; }
ol.timeline .when { color: var(--muted); font-size: 0.8rem; }

/* hour picker */
.hours { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: 8px; margin: 16px 0 0; }
.hours button { font-variant-numeric: tabular-nums; }
#picker-hours button:disabled { background: var(--red-bg); color: var(--red-fg); border-color: var(--red-dot); opacity: 0.7; }

/* hauliers table */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.data th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data input { min-height: 36px; padding: 4px 8px; }
.cell-inline { display: flex; gap: 8px; align-items: center; }
.cell-inline input { min-width: 9rem; }

details.panel > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 28px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; }
details.panel[open] > summary::before { transform: rotate(45deg); }
details.panel[open] > summary { margin-bottom: 12px; }

/* import dialog */
dialog.wide { width: min(880px, calc(100vw - 32px)); }
ol.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.step { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.step.done { opacity: 0.9; }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.step h3 { margin-bottom: 4px; }
.step label:first-of-type { margin-top: 12px; }
.import-result .stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 4px 12px; font-size: 0.9rem; }
.stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.import-result table { max-width: 32rem; }
.preview-note { margin: 4px 0; }
input[type='file'] { padding: 8px; }
input[type='file']::file-selector-button { font: inherit; font-weight: 600; margin-right: 12px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.sticky-foot { position: sticky; bottom: 0; margin: 16px -24px -24px; padding: 12px 24px; background: var(--surface); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; z-index: 1; }
.sticky-foot button { min-width: 12rem; }
@media (max-width: 600px) { .sticky-foot { margin: 16px -16px -16px; padding: 12px 16px; } .sticky-foot button { width: 100%; } }
.info-card { display: flex; gap: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.info-card .icon { width: 24px; height: 24px; color: var(--accent-ink); margin-top: 2px; }
.info-card strong { display: block; }

/* ---- outbox ---- */
.mail-list { display: grid; gap: 12px; }
.mail { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; transition: box-shadow 0.2s; }
.mail:hover { box-shadow: 0 2px 4px rgba(20, 30, 25, 0.08), 0 6px 18px rgba(20, 30, 25, 0.08); }
.mail summary { list-style: none; cursor: pointer; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; }
.mail summary::-webkit-details-marker { display: none; }
.mail summary:focus-visible { outline-offset: -3px; }
.mail .subject { font-weight: 700; overflow-wrap: anywhere; }
.mail .meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.88rem; display: flex; gap: 4px 16px; flex-wrap: wrap; }
.mail .chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; display: inline-block; margin-left: 8px; }
.mail[open] .chev { transform: rotate(-135deg); }
pre.body { white-space: pre-wrap; font: 0.9rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; margin: 0; padding: 16px; background: var(--surface-2); border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.s-mail-confirmed { --st-bg: var(--green-bg); --st-fg: var(--green-fg); --st-dot: var(--green-dot); }
.s-mail-moved { --st-bg: var(--blue-bg); --st-fg: var(--blue-fg); --st-dot: var(--blue-dot); }
.s-mail-reminder { --st-bg: var(--amber-bg); --st-fg: var(--amber-fg); --st-dot: var(--amber-dot); }
.s-mail-movedback { --st-bg: var(--green-bg); --st-fg: var(--green-fg); --st-dot: var(--green-dot); }
.s-mail-alert { --st-bg: var(--red-bg); --st-fg: var(--red-fg); --st-dot: var(--red-dot); }

@media (max-width: 600px) {
  .topbar { flex-wrap: nowrap; }
  .who { max-width: 7.5rem; flex: 0 1 auto; }
  .brand { font-size: 0.98rem; white-space: nowrap; }
  main { padding: 16px 12px 48px; }
  .topbar { padding: 8px 12px; }
  .env-tag { display: none; }
  .context { display: none; }
  .truck-card { padding: 12px; }
  .plate { font-size: 1.3rem; }
  .time-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .dialog-body { padding: 16px; }
  .day-head h2 { font-size: 1.25rem; }
}
@media (max-width: 360px) { .time-grid { grid-template-columns: repeat(3, 1fr); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
fieldset.time-grid-wrap { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.detail-actions { margin: 4px 0 8px; }

/* Planner and Outbox have several links in the top bar: on phones, let them drop onto a second row. */
@media (max-width: 600px) {
  .topbar.wrap-narrow { flex-wrap: wrap; row-gap: 4px; }
  .topbar.wrap-narrow .top-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
}

/* ---- load builder (v5) ---- */
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border-radius: 12px; }
.tabs button { min-height: 48px; border: 0; background: none; font-size: 1rem; border-radius: 8px; color: var(--muted); }
.tabs button[aria-selected='true'] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs button:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.day-heading.sub { margin: 16px 0 8px; }
.day-heading.sub h3 { font-size: 1rem; }
.po-card { display: flex; gap: 16px; align-items: flex-start; cursor: pointer; margin-bottom: 8px; padding: 16px; border-left: 4px solid var(--border); font-weight: 400; font-size: 1rem; }
.po-card:hover { border-color: var(--accent); }
.po-card.picked { background: var(--accent-soft); border-color: var(--accent); }
.po-card.dragging { opacity: 0.5; }
input.po-check { width: 28px; height: 28px; flex: none; margin: 0; cursor: pointer; }
.po-body { min-width: 0; flex: 1; display: grid; gap: 2px; }
.po-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.po-sup { overflow-wrap: anywhere; }
.load-pos { list-style: none; margin: 12px 0 0; padding: 12px 0 0; border-top: 1px solid var(--border); display: grid; gap: 12px; }
.load-pos li { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.load-pos .lp-main { min-width: 0; font-size: 0.95rem; }
.load-pos .lp-sup { overflow-wrap: anywhere; }
.load-pos button { flex: none; }
.load-card.drop-target { border-style: dashed; border-color: var(--accent); }
.load-card.drop-over, .drop-new.drop-over { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.drop-new { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 24px; margin-bottom: 12px; border: 2px dashed var(--accent); border-radius: 12px; color: var(--accent-ink); font-weight: 600; }
.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: var(--shadow); } }
.selbar { position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(20, 30, 25, 0.12); max-width: 640px; margin: 0 auto; }
.selbar button.primary { flex: 1; }
body.has-selbar main { padding-bottom: 112px; }
body.has-selbar #toasts { bottom: 88px; }
.warn-list { margin: 8px 0 0; padding-left: 20px; }
.msg.locked { margin: 12px 0 0; }
@media (max-width: 600px) { .load-pos li { flex-direction: column; } .load-pos li button { align-self: flex-start; } }
@media (hover: none) { .drop-new { display: none !important; } }

/* planner: load builder switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; margin: 0; font-size: 0.9rem; }
.switch input { appearance: none; width: 44px; height: 26px; min-height: 0; padding: 0; border-radius: 999px; background: var(--border); border: 1px solid var(--muted); position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); transition: transform 0.15s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.detail-pos { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 0.92rem; }

.load-card.empty-load { opacity: 0.8; }
.load-card.empty-load .load-pos { color: var(--muted); }
.code-input { text-transform: uppercase; letter-spacing: 0.08em; }
