:root {
  /* Plain defaults. The tenant's colours and font replace --brand, --brand-dark, --brand-pale and --font (BrandHead). */
  --brand: #1f4e79;
  --brand-dark: #163a5a;
  --brand-pale: #eef3f8;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --brand-text: #ffffff;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --text: #1b1b1b;
  --muted: #5a5a5a;
  --line: #d6d6d6;
  --panel: #ffffff;
  --page: #f4f5f7;
  --warn-bg: #fff4e5;
  --warn-text: #7a4100;
  --bad-bg: #fdecea;
  --bad-text: #8a1c12;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--page);
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--brand);
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  color: var(--brand-dark);
}

h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--brand-dark);
}

/* Header: the tenant's logo and name beside the product's name. */
.brand-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: -1rem -1rem 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 3px solid var(--brand);
}

.brand-logo {
  display: block;
  max-height: 44px;
  max-width: 9rem;
}

.brand-name {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Layout: the form and results on the left, the map on the right; stacked on a phone. */
.planner {
  display: grid;
  grid-template-columns: minmax(20rem, 27rem) 1fr;
  height: 100vh;
}

.panel {
  overflow-y: auto;
  padding: 1rem;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.map-panel {
  position: relative;
  min-height: 0;
}

/* Two classes, so this beats MapLibre's own ".maplibregl-map { position: relative }" (its stylesheet loads after
   ours). Without it the map's box has no height and the map is invisible, with no error. */
.map-panel .route-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

@media (max-width: 760px) {
  .planner {
    grid-template-columns: 1fr;
    grid-template-rows: auto 60vh;
    height: auto;
  }

  .panel {
    border-right: none;
  }

  .map-panel {
    order: -1;
    height: 60vh;
  }
}

/* Form */
fieldset {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: end;
  margin: 0 0 1rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

fieldset.pair {
  grid-template-columns: 1fr 1fr;
}

legend {
  padding: 0 0.25rem;
  font-weight: 600;
  color: var(--brand-dark);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.9rem;
}

label.wide,
.hint.wide,
fieldset > .drops,
fieldset > .picking,
fieldset > .secondary,
fieldset > .check {
  grid-column: 1 / -1;
}

.hint.wide {
  margin: -0.25rem 0 0;
  padding: 0;
}

label.check {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
}

.hint {
  padding-bottom: 0.55rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 0.45rem 0.5rem;
  font: inherit;
  border: 1px solid #b9b9b9;
  border-radius: 4px;
}

input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 4px;
}

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

button.primary {
  width: 100%;
  padding: 0.7rem;
  font-weight: 600;
  color: var(--brand-text);
  background: var(--brand);
  border: none;
  border-radius: var(--radius);
}

button.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

button.secondary {
  justify-self: start;
  padding: 0.4rem 0.75rem;
  color: var(--brand);
  background: none;
  border: 1px solid var(--brand);
}

button.small {
  padding: 0.35rem 0.5rem;
  background: #fff;
  border: 1px solid #b9b9b9;
}

/* Drops */
.drops {
  margin: 0;
  padding: 0;
  list-style: none;
}

.drop {
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--line);
}

.drop-main,
.drop-extra {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.drop-extra {
  gap: 1rem;
  margin: 0.3rem 0 0 1.85rem;
  font-size: 0.85rem;
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

label.inline input {
  width: 6.5rem;
  padding: 0.3rem 0.4rem;
}

label.check.small-check {
  gap: 0.35rem;
  font-size: 0.85rem;
}

label.check.small-check input {
  width: 1rem;
  height: 1rem;
}

.drop input,
.drop-pin {
  flex: 1;
  min-width: 0;
}

.drop-pin {
  font-size: 0.9rem;
}

.drop-number {
  width: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.picking {
  margin: 0;
  font-weight: 600;
  color: var(--brand);
}

.problems {
  margin: 0 0 1rem;
  padding: 0.6rem 0.6rem 0.6rem 1.6rem;
  color: var(--bad-text);
  background: var(--bad-bg);
  border-radius: 6px;
}

/* Results */
.result {
  margin-top: 1.25rem;
}

.total {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.checked,
.key {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.leg {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-left: 6px solid var(--leg-color);
  background: var(--brand-pale);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.leg-fuel {
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.reasons {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.reasons li {
  margin-top: 0.15rem;
}

details.ways {
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

details.ways summary {
  cursor: pointer;
  color: var(--brand);
}

/* Analysis: totals, order, truck against car. */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.tile {
  display: flex;
  flex-direction: column;
  padding: 0.45rem 0.5rem;
  background: var(--brand-pale);
  border-radius: var(--radius);
}

.tile-label,
.tile-note {
  font-size: 0.75rem;
  color: var(--muted);
}

.tile-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-dark);
}

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

.analysis-block {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.analysis-block p {
  margin: 0.4rem 0 0;
  font-size: 0.9rem;
}

table.compare {
  width: 100%;
  margin-top: 0.3rem;
  font-size: 0.85rem;
  border-collapse: collapse;
}

table.compare th,
table.compare td {
  padding: 0.25rem 0.3rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
}

table.compare th:first-child {
  text-align: left;
  font-weight: 600;
}

table.compare thead th {
  font-weight: 600;
  color: var(--muted);
}

table.compare tr.chosen {
  background: var(--brand-pale);
}

.leg-title {
  font-weight: 600;
}

.notice-none {
  font-size: 0.9rem;
  color: var(--muted);
}

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

.notice {
  margin-top: 0.25rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  color: var(--warn-text);
  background: var(--warn-bg);
  border-radius: 4px;
}

.notice.critical {
  color: var(--bad-text);
  background: var(--bad-bg);
  font-weight: 600;
}

.responsibility {
  margin-top: 1rem;
  padding: 0.6rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* On the map: the legs to pick from (top left) and the picked leg's card (bottom left). */
.map-legs {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: 17rem;
  max-height: 45%;
  overflow-y: auto;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-leg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.35rem 0.5rem;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
}

.map-leg:hover {
  background: var(--brand-pale);
}

.map-leg.selected {
  background: var(--brand-pale);
  border-color: var(--brand);
}

.map-leg-name {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.map-leg-detail {
  font-size: 0.8rem;
  color: var(--muted);
}

.swatch {
  flex: none;
  width: 0.9rem;
  height: 0.3rem;
  background: var(--leg-color);
  border-radius: 2px;
}

.map-key {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  padding: 0.3rem 0.5rem 0;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.key-truck,
.key-car {
  width: 1.2rem;
  height: 0;
  border-top: 4px solid var(--brand);
}

.key-car {
  margin-left: 0.5rem;
  border-top: 3px dashed #888;
}

.map-card {
  position: absolute;
  bottom: 2.25rem;
  left: 0.75rem;
  z-index: 2;
  width: 22rem;
  max-height: 45%;
  overflow-y: auto;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border-left: 6px solid var(--leg-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.map-card p {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
}

.map-card-links a {
  color: var(--brand);
}

.leg.selected {
  outline: 2px solid var(--brand);
}

/* On a phone the map is short: keep only the leg list, as a strip. */
@media (max-width: 760px) {
  .map-legs {
    right: 0.75rem;
    width: auto;
    max-height: 35%;
  }

  .map-card {
    display: none;
  }
}

/* The access code screen. */
.gate {
  max-width: 26rem;
  margin: 3rem auto;
  padding: 1rem;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gate .brand-bar {
  margin: -1rem -1rem 1rem;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gate-loading {
  padding: 2rem;
  color: var(--muted);
}

/* Lanes and bends from map data. */
.drop-warning {
  margin: 0 0 0.6rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  color: var(--bad-text);
  background: var(--bad-bg);
  border-left: 4px solid var(--bad-text);
  border-radius: 4px;
}

.road-notes {
  margin-top: 0.35rem;
  font-size: 0.9rem;
}

.road-summary {
  font-weight: 600;
}

.road-problems {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.road-problem {
  color: var(--warn-text);
}

.road-problem.serious {
  color: var(--bad-text);
}

.road-more,
.road-replanned {
  margin-top: 0.2rem;
  color: var(--muted);
}

.problem-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font: 700 13px system-ui, sans-serif;
  color: #000;
  background: #f5b700;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.problem-pin--serious {
  color: #fff;
  background: #c62828;
}

/* Map pins (made by routeMap.js, so not scoped CSS). */
.stop-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font: 600 14px system-ui, sans-serif;
  color: #fff;
  background: #222;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.stop-pin--depot {
  background: var(--brand);
  border-radius: 6px;
}

/* Exports */
.exports {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

a.secondary {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  color: var(--brand);
  text-decoration: none;
  border: 1px solid var(--brand);
  border-radius: 4px;
}

.leg-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.leg-links a,
button.link {
  padding: 0;
  font-size: 0.9rem;
  color: var(--brand);
  background: none;
  border: none;
  text-decoration: underline;
}

.qr {
  display: block;
  width: 10rem;
  height: 10rem;
  margin-top: 0.5rem;
  image-rendering: pixelated;
}

/* Driver sheet: a plain page that prints on A4. */
.sheet {
  max-width: 50rem;
  margin: 0 auto;
  padding: 1rem;
  background: var(--panel);
}

.sheet-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sheet-actions .primary {
  width: auto;
  padding: 0.5rem 1.5rem;
}

.sheet .brand-bar {
  margin: 0 0 0.5rem;
  padding: 0 0 0.5rem;
}

.sheet-trip {
  margin: 0 0 0.75rem;
  color: var(--muted);
}

.sheet-why {
  font-size: 0.9rem;
}

.sheet-block {
  margin-top: 1rem;
}

.vehicle {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}

.vehicle dt {
  font-weight: 600;
}

.vehicle dd {
  margin: 0;
}

.sheet-stops {
  margin: 0;
  padding-left: 1.5rem;
}

.sheet-leg {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  break-inside: avoid;
}

.sheet-leg h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.sheet-leg p,
.sheet-leg ul {
  margin: 0.2rem 0;
}

.sheet-leg .critical {
  font-weight: 600;
  color: var(--bad-text);
}

.sheet-qr {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
}

.sheet-qr img {
  width: 7rem;
  height: 7rem;
  image-rendering: pixelated;
}

.sheet-footer {
  margin-top: 1.5rem;
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .sheet {
    max-width: none;
    padding: 0;
  }
}

/* Links to the other pages, under the header. */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem;
  margin: -0.5rem 0 1rem;
}

.site-nav a {
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
  color: var(--brand);
  text-decoration: none;
  border-radius: 999px;
}

.site-nav a:hover {
  background: var(--brand-pale);
}

.site-nav a.active {
  color: var(--brand-text);
  background: var(--brand);
}

/* Vehicles and drivers: a list and a form, one column. */
.setup-page {
  max-width: 64rem;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem;
  background: var(--panel);
}

table.records {
  width: 100%;
  margin: 0 0 1rem;
  font-size: 0.9rem;
  border-collapse: collapse;
}

table.records th,
table.records td {
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

table.records thead th {
  font-weight: 600;
  color: var(--muted);
}

table.records tr.editing {
  background: var(--brand-pale);
}

@media (max-width: 760px) {
  table.records thead {
    display: none;
  }

  table.records tr {
    display: block;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
  }

  table.records th,
  table.records td {
    display: block;
    padding: 0.15rem 0;
    border: none;
  }
}

.plate {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: #ffd200;
  border: 1px solid #c9a400;
  border-radius: 3px;
}

.ok {
  color: #2e7d32;
}

.record-warnings {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--warn-text);
}

.form-warnings {
  margin: 0 0 1rem;
  padding: 0.5rem 0.6rem 0.5rem 1.6rem;
  background: var(--warn-bg);
  border-radius: var(--radius);
}

.record-form {
  max-width: 40rem;
}

.record-form textarea {
  width: 100%;
  padding: 0.45rem 0.5rem;
  font: inherit;
  border: 1px solid #b9b9b9;
  border-radius: 4px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.record-actions .primary {
  width: auto;
  padding: 0.55rem 1.5rem;
}

button.danger {
  padding: 0.4rem 0.75rem;
  color: #fff;
  background: var(--bad-text);
  border: none;
}

/* Yards */
.yard-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.yard {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}

.yard.editing {
  background: var(--brand-pale);
}

.yard .hint {
  padding: 0.15rem 0 0;
}

.yard-steps {
  grid-column: 1 / -1;
}

.yard-steps p {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.9rem;
}

.yard-steps button {
  margin-right: 0.5rem;
}

.yard-steps .primary {
  width: auto;
  padding: 0.4rem 0.75rem;
}

/* The planner's driver checks. */
.driver-warnings {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.5rem 0.6rem 0.5rem 1.6rem;
  font-size: 0.9rem;
  color: var(--warn-text);
  background: var(--warn-bg);
  border-radius: var(--radius);
}

.yard-list ~ .key {
  margin-top: 1rem;
}

/* The driver's day: settings, totals, rules and timeline. */
.day-settings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.day-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.hours-findings {
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.hours-finding {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.3rem;
}

.hours-mark {
  flex: none;
  width: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.hours-finding.ok .hours-mark {
  color: #2e7d32;
}

.hours-finding.warning {
  color: var(--warn-text);
}

.hours-finding.problem {
  font-weight: 600;
  color: var(--bad-text);
}

.timeline {
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  border-left: 3px solid var(--line);
}

.timeline-item {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 0.5rem;
  padding: 0.3rem 0 0.3rem 0.6rem;
}

.timeline-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.timeline-length {
  color: var(--muted);
  white-space: nowrap;
}

.timeline-item.break {
  margin-left: -3px;
  background: var(--brand-pale);
  border-left: 3px solid var(--brand);
}

.timeline-item.end {
  color: var(--muted);
}

@media print {
  .sheet-day {
    break-inside: avoid;
  }
}

/* A saved vehicle's sizes, folded away on the planner. */
.vehicle-details {
  grid-column: 1 / -1;
}

.vehicle-details summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
}

.vehicle-details summary::after {
  content: " · change for this trip";
  color: var(--brand);
}

.vehicle-details[open] summary::after {
  content: "";
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 0.75rem;
  align-items: end;
  margin-top: 0.5rem;
}

.drop-near {
  padding: 0.2rem 0 0 2rem;
}

.drop-extra {
  flex-wrap: wrap;
  row-gap: 0.3rem;
}

.drop-extra label.inline input[type="number"] {
  width: 5rem;
}

/* Vehicles and drivers: the list sits where the planner's map does, so the header and links don't move between tabs. */
.records-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  background: var(--panel);
}

.records-empty {
  color: var(--muted);
}

@media (max-width: 760px) {
  .records-panel {
    border-top: 1px solid var(--line);
  }
}

/* References and saving a route. */
.ref-input {
  width: 7rem !important;
}

.sheet-ref {
  margin: 0.1rem 0;
  font-weight: 700;
}

.save-route {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
  margin: 0 0 0.75rem;
}

.save-route label {
  flex: 1 1 9rem;
}

.warn-text {
  color: var(--warn-text);
}

/* Routes: import and the calendar. */
.import-heading {
  margin-top: 1.5rem;
}

.import-list {
  margin: 0 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}

.file-pick input {
  padding: 0.3rem 0;
  border: none;
}

.route-stops .drop-extra input {
  width: 5rem;
}

.drop-notes {
  flex: 1 1 100%;
}

.drop-notes input {
  width: 100% !important;
}

.calendar-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.75rem;
}

.calendar-head h2 {
  min-width: 10rem;
  margin: 0;
  text-align: center;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.calendar-day-name {
  padding: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.calendar-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 6.5rem;
  padding: 0.25rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.calendar-cell.other-month {
  background: var(--page);
}

.calendar-cell.today .calendar-date {
  color: var(--brand-text);
  background: var(--brand);
}

.calendar-date {
  align-self: flex-start;
  min-width: 1.8rem;
  padding: 0.1rem 0.35rem;
  font-size: 0.85rem;
  text-align: center;
  background: none;
  border: none;
  border-radius: 999px;
}

.calendar-date:hover {
  background: var(--brand-pale);
}

.route-chip {
  display: flex;
  flex-direction: column;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  text-align: left;
  background: var(--brand-pale);
  border: 1px solid transparent;
  border-left: 3px solid var(--brand);
  border-radius: 4px;
}

.route-chip.editing {
  border-color: var(--brand);
}

.route-chip-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.route-chip-detail {
  color: var(--muted);
}

@media (max-width: 760px) {
  .calendar-cell {
    min-height: 4rem;
  }

  .route-chip-detail {
    display: none;
  }
}

/* Roadworks and incidents from the traffic check: amber, orange, red by how much they matter. */
.incident-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font: 700 12px system-ui, sans-serif;
  color: #fff;
  background: #8d6e00;
  border: 2px solid #fff;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.incident-pin--minor {
  background: #c77700;
}

.incident-pin--major {
  background: #d84315;
}

.incident-pin--critical {
  background: #b71c1c;
}

.traffic-line {
  margin: 0.2rem 0;
  font-size: 0.9rem;
}

.incidents {
  margin: 0.25rem 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.incident.major,
.incident.minor {
  color: var(--warn-text);
}

.incident.critical {
  font-weight: 600;
  color: var(--bad-text);
}

.traffic-note {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

/* A yard's opening hours: day, opens, closes. */
fieldset.hours {
  grid-template-columns: 6.5rem 1fr 1fr;
  align-items: center;
}

.hours-day {
  font-size: 0.9rem;
}

/* The planned route's summary over the map: compact, with the full breakdown a click away. */
.map-summary {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 19rem;
  max-height: calc(100% - 4rem);
  overflow-y: auto;
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.map-summary-head {
  display: flex;
  gap: 0.5rem;
  align-items: start;
  justify-content: space-between;
}

.map-summary-name {
  color: var(--brand-dark);
  overflow-wrap: anywhere;
}

.map-summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  font-weight: 600;
}

.map-summary-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.badge {
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
  background: var(--page);
  border-radius: 999px;
}

.badge.ok {
  color: #1b5e20;
  background: #e8f5e9;
}

.badge.warn {
  color: var(--warn-text);
  background: var(--warn-bg);
}

.badge.bad {
  color: var(--bad-text);
  background: var(--bad-bg);
}

.map-legs-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.map-summary .map-key {
  margin: 0;
}

.key-works {
  margin-left: 0.5rem;
  color: #d84315;
}

.map-summary-actions {
  display: flex;
  gap: 0.4rem;
}

.map-summary-actions .primary {
  width: auto;
  flex: 1;
  padding: 0.45rem 0.6rem;
}

.result-note {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  background: var(--brand-pale);
  border-radius: var(--radius);
}

.stops-details {
  grid-column: 1 / -1;
}

.stops {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.stops > .secondary {
  align-self: start;
}

/* The route breakdown pop-up. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.35);
}

.modal {
  position: fixed;
  top: 4vh;
  left: 50%;
  z-index: 21;
  display: flex;
  flex-direction: column;
  width: min(48rem, calc(100vw - 2rem));
  max-height: 92vh;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
}

.modal-body {
  overflow-y: auto;
  padding: 1rem;
}

@media (max-width: 760px) {
  .map-summary {
    right: 0.75rem;
    width: auto;
    max-height: calc(100% - 1.5rem);
  }

  .modal {
    top: 0;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }
}
