/* Supplier delivery portal. Built on the platform design tokens
   (/_brain/tokens.css); the customer's brand colours and logo arrive at
   runtime through /_brain/theme.js as the --brand-* tokens. Phone-first:
   sized for one thumb, in a yard. Rebuilt from the approved mockup. */
:root {
  /* Phone scale: the platform's type scale is for desks. 16px+ inputs also
     stop iOS zooming on focus. */
  --tap: 56px;
  --m-body: 1.06rem;
  --m-label: .95rem;
  --m-h1: 1.55rem;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font); font-size: var(--m-body); line-height: 1.4;
  color: var(--ink); background: var(--wash);
  display: flex; flex-direction: column;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header: site from the QR code, always visible */
.top {
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-5) var(--sp-7);
  background: var(--brand-sidebar); color: var(--on-sidebar);
}
.logo { width: 40px; height: 40px; border-radius: var(--radius-sm); flex-shrink: 0; object-fit: contain; }
.site { display: flex; flex-direction: column; min-width: 0; }
.eyebrow {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: var(--tracking-eyebrow);
  color: var(--brand-accent); font-weight: 600;
}
.site-name { font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back {
  width: 44px; height: 44px; margin-left: calc(-1 * var(--sp-3)); flex-shrink: 0;
  display: grid; place-items: center; border: 0; border-radius: var(--radius);
  background: var(--on-sidebar-hover); cursor: pointer;
}
.back svg { width: 26px; height: 26px; fill: none; stroke: var(--on-sidebar); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.back:active { background: var(--on-sidebar-line); }

/* Progress: three steps before "sent" */
.steps { display: flex; gap: var(--sp-2); padding: var(--sp-5) var(--sp-7) 0; }
.steps i { flex: 1; height: 5px; border-radius: var(--radius-pill); background: var(--line); }
.steps i.on { background: var(--brand-primary); }
.steps.done { visibility: hidden; }

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 520px; margin: 0 auto; }
.screen {
  flex: 1; display: flex; flex-direction: column; gap: var(--sp-7);
  padding: var(--sp-8) var(--sp-7) calc(var(--sp-9) + env(safe-area-inset-bottom));
}
h1 { margin: 0; font-size: var(--m-h1); line-height: 1.2; letter-spacing: -.01em; }

.field { display: flex; flex-direction: column; gap: var(--sp-3); }
.field > span, legend { font-size: var(--m-label); font-weight: 700; color: var(--ink); }
input[type="text"], input[type="tel"], input[type="email"] {
  width: 100%; height: var(--tap); padding: 0 var(--sp-7);
  font-size: 1.12rem; background: var(--paper);
  border: 2px solid var(--line); border-radius: var(--radius);
  outline: none; appearance: none;
}
input:focus { border-color: var(--brand-primary); box-shadow: 0 0 0 4px var(--brand-ring); }
input.invalid { border-color: var(--danger-ink); }
input.ok { border-color: var(--ok); }

.hint { margin: 0; color: var(--ink-60); font-size: var(--m-label); }
.error { margin: 0; color: var(--danger-ink); font-size: var(--m-label); font-weight: 600; }

/* Company autocomplete */
.suggestions { list-style: none; margin: calc(-1 * var(--sp-3)) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-2); }
.suggestions:empty { display: none; }
.suggestions button {
  width: 100%; min-height: var(--tap); padding: var(--sp-4) var(--sp-7); text-align: left;
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  font-size: 1.05rem; cursor: pointer;
}
.suggestions button:active { background: var(--brand-tint-3); border-color: var(--brand-primary); }
.suggestions mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: var(--brand-primary); text-decoration-thickness: 2px; }
.matched {
  margin: 0; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-7); border-radius: var(--radius);
  background: var(--ok-bg); color: var(--ok-ink); font-weight: 700;
}
.matched svg { width: 26px; height: 26px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Chips */
.group { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.group.missing legend { color: var(--danger-ink); }
.group.missing legend::after { content: " — needed"; font-weight: 600; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.chips.vehicles { grid-template-columns: repeat(2, 1fr); }
.chip {
  min-height: var(--tap); padding: var(--sp-3) var(--sp-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
  font-size: 1rem; font-weight: 600; line-height: 1.15; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip small { font-size: .8rem; font-weight: 500; color: var(--ink-60); }
.chip[aria-pressed="true"] { background: var(--brand-primary); border-color: var(--brand-primary); color: var(--brand-on-primary); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .85; }
.chip:disabled { opacity: .35; cursor: not-allowed; }
.chip svg { width: 40px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chips.vehicles .chip { min-height: 72px; }

/* The one big action, pinned to the bottom of short screens */
.primary {
  margin-top: auto; width: 100%; min-height: 60px; border: 0; border-radius: var(--radius-lg);
  background: var(--brand-primary); color: var(--brand-on-primary);
  font-size: 1.15rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand-primary) 30%, transparent);
}
.primary:active { background: var(--brand-primary-hover); }
.primary:disabled { background: var(--ink-40); box-shadow: none; cursor: not-allowed; }

/* Sent */
.sent { align-items: center; justify-content: center; text-align: center; gap: var(--sp-8); padding-top: 12vh; }
.sent-tick { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-primary); }
.sent-tick svg { width: 50px; height: 50px; fill: none; stroke: var(--brand-on-primary); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.sent-msg { margin: 0; font-size: 1.15rem; max-width: 22em; }
.sent-msg strong { white-space: nowrap; }
.ref {
  margin: 0; padding: var(--sp-5) var(--sp-8); border-radius: var(--radius);
  background: var(--paper); border: 2px dashed var(--secondary-border); color: var(--ink-60);
}
.ref strong { display: block; margin-top: 2px; font-size: 1.5rem; letter-spacing: .08em; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---- Week calendar ------------------------------------------------------
   One grid: a time gutter, then for each day a column group of lanes
   (gates/bays; one lane today). Header sits outside the scroller so day
   names stay visible while the 07:00-17:00 rows scroll. */
.sub-label { font-size: var(--m-label); font-weight: 700; }
.sub-label small { font-weight: 500; color: var(--ink-60); }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.week-label { font-weight: 700; font-size: 1.02rem; }
.week-btn {
  width: 48px; height: 44px; display: grid; place-items: center; cursor: pointer;
  background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius);
}
.week-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.week-btn:disabled { opacity: .3; cursor: not-allowed; }

.cal { --gutter: 44px; --row: 34px; background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; touch-action: pan-y; }
.cal-head, .cal-body { display: grid; grid-template-columns: var(--gutter) var(--cols); }
.cal-head { border-bottom: 2px solid var(--line); background: var(--paper); }
.cal-day {
  grid-row: 1; padding: var(--sp-2) 0; text-align: center; line-height: 1.1;
  font-size: .82rem; font-weight: 700; border-left: 1px solid var(--line);
}
.cal-day small { display: block; font-size: .78rem; font-weight: 500; color: var(--ink-60); }
.cal-day.today { color: var(--brand-primary); }
.cal-day.today small { color: inherit; }
.cal-lane { grid-row: 2; font-size: .62rem; text-align: center; color: var(--ink-60); border-left: 1px solid var(--line); }
.cal-scroll { max-height: min(58vh, 440px); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.cal-body { grid-auto-rows: var(--row); position: relative; }
.cal-time {
  grid-column: 1; font-size: .7rem; color: var(--ink-60); text-align: right; padding-right: 6px;
  transform: translateY(-.55em); font-variant-numeric: tabular-nums;
}
.cal-time:first-child { transform: none; }
.cell {
  border: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--ink-07);
  background: none; padding: 0; margin: 0; min-width: 0;
}
.cell.hour { border-top-color: var(--line); }
.cell.day-start { border-left: 2px solid var(--line); }
button.cell { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.cell:active { background: var(--brand-tint-3); }
.cell.past {
  background: repeating-linear-gradient(135deg, var(--wash) 0 6px, color-mix(in srgb, var(--ink) 4%, var(--wash)) 6px 12px);
}
.booked { margin: 2px 3px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 22%, var(--wash)); pointer-events: none; }
.sel {
  margin: 2px 3px; border-radius: 6px; z-index: 1; pointer-events: none;
  background: var(--brand-primary); color: var(--brand-on-primary);
  font-size: .68rem; font-weight: 700; line-height: 1.1; padding: 4px 3px; overflow: hidden;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--brand-primary) 40%, transparent);
}
.sel.clash {
  background: repeating-linear-gradient(135deg, var(--danger-bg) 0 6px, color-mix(in srgb, var(--danger) 28%, transparent) 6px 12px);
  color: var(--danger-ink); outline: 2px solid var(--danger-ink); outline-offset: -2px; box-shadow: none;
}
.cal-key { display: flex; gap: var(--sp-7); font-size: .8rem; color: var(--ink-60); }
.cal-key span { display: inline-flex; align-items: center; gap: var(--sp-2); }
.cal-key i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.k-free { background: var(--paper); }
.k-taken { background: color-mix(in srgb, var(--ink) 22%, var(--wash)); }
.k-past { background: repeating-linear-gradient(135deg, var(--wash) 0 3px, color-mix(in srgb, var(--ink) 8%, var(--wash)) 3px 6px); }

.slot-pick { display: flex; flex-direction: column; gap: var(--sp-3); }
.slot-summary { margin: 0; padding: var(--sp-4) var(--sp-6); border-radius: var(--radius); background: var(--brand-tint-3); font-weight: 700; }
.slot-pick.clash .slot-summary { background: var(--danger-bg); color: var(--danger-ink); }
.chips.durations { grid-template-columns: repeat(4, 1fr); }
.chips.durations .chip { min-height: 50px; font-size: .95rem; }

/* Submitting */
.primary[aria-busy="true"] { opacity: .7; cursor: progress; }

/* A site that can't be booked */
.closed { justify-content: center; text-align: center; padding-top: 14vh; }
