:root {
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --border: #E1E4EA;
  --text: #1B2430;
  --text-muted: #5B6472;
  --brand: #23408C;
  --brand-hover: #1A2F6B;

  /* Status colours: stronger tints so rows stand out on washed-out screens.
     Text on each tint stays above 5:1 contrast. */
  --status-booked: #1D4DBF;
  --status-booked-bg: #D3E0FB;
  --status-loading: #1D4DBF;
  --status-loading-bg: #D3E0FB;
  --status-ready-dispatch: #8A4A0C;
  --status-ready-dispatch-bg: #F7DDB8;
  --status-delivered: #11663A;
  --status-delivered-bg: #CDEBD7;
  --status-delayed: #A82424;
  --status-delayed-bg: #F7CFCF;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.login-logo {
  display: block;
  width: 240px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 14px;
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text-muted);
}

.topbar a {
  color: var(--text-muted);
  text-decoration: none;
}

.topbar a:hover {
  color: var(--text);
}

.page {
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* The two main boards stand out from the admin tabs: bold, in the
   logo's colours, and filled solid when you're on them. */
.tabs {
  align-items: center;
}

.tab-main {
  --tab-colour: #32459D;
  --tab-tint: #E6E9F6;
  margin: 7px 0;
  padding: 8px 18px;
  border-radius: 7px;
  border-bottom: none;
  font-size: 15px;
  font-weight: 700;
  color: var(--tab-colour);
  background: var(--tab-tint);
}

.tab-fabrication {
  --tab-colour: #C9281A;
  --tab-tint: #FCE5E2;
}

.tab-main:hover {
  color: var(--tab-colour);
  filter: brightness(0.96);
}

.tab-main.active {
  color: #fff;
  background: var(--tab-colour);
  border-bottom: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.tab-main .tab-icon {
  width: 18px;
  height: 18px;
}

.tab-divider {
  width: 1px;
  height: 26px;
  background: var(--border);
  margin: 0 10px;
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: -8px 0 18px;
}

.hint a {
  color: var(--brand);
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 36px;
  width: 340px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p.sub {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
  color: var(--text);
}

.field input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}

button.primary {
  width: 100%;
  padding: 10px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}

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

.error {
  background: var(--status-delayed-bg);
  color: var(--status-delayed);
  padding: 9px 11px;
  border-radius: 5px;
  font-size: 13px;
  margin-bottom: 14px;
}

.warning-banner {
  background: var(--status-ready-dispatch-bg);
  color: var(--status-ready-dispatch);
  padding: 12px 14px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.confirm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  max-width: 520px;
}

.overweight-flag {
  display: inline-block;
  margin-left: 6px;
  font-size: 12px;
  color: var(--status-delayed);
  cursor: help;
}

/* Board */
table.board {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

table.board th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}

table.board td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

table.board tr:last-child td {
  border-bottom: none;
}

.ref {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
}

.status-booked { color: var(--status-booked); background: var(--status-booked-bg); }
.status-loading { color: var(--status-loading); background: var(--status-loading-bg); }
.status-ready_to_dispatch { color: var(--status-ready-dispatch); background: var(--status-ready-dispatch-bg); }
.status-delivered { color: var(--status-delivered); background: var(--status-delivered-bg); }
.status-delayed { color: var(--status-delayed); background: var(--status-delayed-bg); }

/* Whole-row traffic-light coloring on the job list */
tr.status-row-booked td { background: var(--status-booked-bg); }
tr.status-row-ready_to_dispatch td { background: var(--status-ready-dispatch-bg); }
tr.status-row-delivered td { background: var(--status-delivered-bg); }
tr.status-row-delayed td { background: var(--status-delayed-bg); }

tr.status-row-booked td:first-child { border-left: 5px solid var(--status-booked); }
tr.status-row-ready_to_dispatch td:first-child { border-left: 5px solid var(--status-ready-dispatch); }
tr.status-row-delivered td:first-child { border-left: 5px solid var(--status-delivered); }
tr.status-row-delayed td:first-child { border-left: 5px solid var(--status-delayed); }

/* Same accent on the popup job cards */
.job-card.status-row-booked { border-left-color: var(--status-booked); }
.job-card.status-row-ready_to_dispatch { border-left-color: var(--status-ready-dispatch); }
.job-card.status-row-delivered { border-left-color: var(--status-delivered); }
.job-card.status-row-delayed { border-left-color: var(--status-delayed); }

.status-form {
  display: inline-block;
}

.status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  padding: 4px 26px 4px 10px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235B6472' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  box-shadow: inset 0 0 0 1.5px currentColor; /* stays visible on a same-colour row */
}

.status-select:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.empty {
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Edit / Delete cell. It stays a real table cell (not flex) so it stretches
   to the full row height and keeps the row's status colour behind it when
   notes wrap onto several lines. */
td.row-actions {
  white-space: nowrap;
  vertical-align: middle;
}

td.row-actions > * {
  display: inline-block;
  vertical-align: middle;
}

td.row-actions > * + * {
  margin-left: 12px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  color: var(--brand);
  cursor: pointer;
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn-danger {
  color: var(--status-delayed);
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 18px;
}

.breadcrumb a {
  color: var(--brand);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

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

.settings-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.1s, box-shadow 0.1s;
}

.settings-card:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(20, 24, 32, 0.06);
}

.settings-card-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--brand);
  margin-top: 2px;
}

.settings-card-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.settings-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.archived-table {
  opacity: 0.7;
}

.list-header {
  margin: 30px 0 12px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-bar label {
  font-size: 13px;
  color: var(--text-muted);
}

.filter-bar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  color: var(--text);
}

table.board.zebra tbody tr:nth-child(even) td {
  background: #FAFBFD;
}

.sortable-th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 16px !important;
}

.sortable-th:hover {
  color: var(--text);
}

.sortable-th.sort-asc::after {
  content: "▲";
  font-size: 8px;
  margin-left: 5px;
  color: var(--brand);
}

.sortable-th.sort-desc::after {
  content: "▼";
  font-size: 8px;
  margin-left: 5px;
  color: var(--brand);
}

.oos-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--status-delayed);
  background: var(--status-delayed-bg);
}

.in-service-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--status-delivered);
  background: var(--status-delivered-bg);
}

/* Add entry form */
.add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 18px;
  align-items: center;
}

.add-form input,
.add-form select,
.add-form textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  color: var(--text);
}

.add-form input {
  flex: 1 1 130px;
  min-width: 100px;
}

.add-form select {
  flex: 0 0 auto;
}

.add-form .time-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.add-form .time-field input {
  flex: 0 0 auto;
  min-width: 0;
  width: 110px;
}

.add-form input:focus,
.add-form select:focus,
.add-form textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}

.add-btn {
  flex: 0 0 auto;
  width: auto;
  padding: 8px 16px;
  margin-top: 0;
}

.notes-input {
  flex: 1 1 220px;
  min-width: 180px;
  resize: vertical;
  font-family: inherit;
}

.field-with-hint {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 160px;
  min-width: 140px;
}

.field-with-hint input {
  width: 100%;
}

.weight-hint {
  font-size: 11.5px;
  min-height: 14px;
  color: var(--text-muted);
}

.weight-hint.hint-ok {
  color: var(--status-delivered);
}

.weight-hint.hint-warn {
  color: var(--status-ready-dispatch);
}

.weight-hint.hint-danger {
  color: var(--status-delayed);
  font-weight: 600;
}

.vd-phone-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
}

.vd-phone-link:hover {
  text-decoration: underline;
}

.notes-cell {
  white-space: pre-wrap;
  min-width: 180px;
  max-width: 260px;
}

/* Month calendar */
.section-title {
  font-size: 16px;
  font-weight: 600;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 30px 0 12px;
}

.cal-nav {
  display: flex;
  gap: 14px;
}

.secondary-link {
  font-size: 13px;
  color: var(--brand);
  text-decoration: none;
}

.secondary-link:hover {
  text-decoration: underline;
}

table.month-cal {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: fixed;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

table.month-cal th {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 10px 4px;
  background: #FAFBFC;
  border-bottom: 1px solid var(--border);
}

td.month-day {
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  height: 150px;
  min-width: 140px;
  padding: 8px;
  transition: background 0.1s;
}

table.month-cal tr td:last-child {
  border-right: none;
}

td.month-day:hover {
  background: #F8FAFD;
}

td.month-day.other-month {
  background: #FBFBFC;
}

td.month-day.weekend-day {
  background: #F5F5F6;
}

td.month-day.weekend-day.other-month {
  background: #F5F5F6;
  opacity: 0.7;
}

th.weekend-col {
  color: var(--text-muted);
  opacity: 0.75;
}

td.month-day.other-month .day-num {
  color: var(--text-muted);
}

td.month-day.is-today {
  background: #F4F8FF;
}

td.month-day.is-today .day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
}

.day-cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.day-num {
  font-size: 14px;
  font-weight: 600;
}

.day-add-btn {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s;
}

td.month-day:hover .day-add-btn {
  opacity: 1;
}

.day-add-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.day-vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 105px;
  overflow-y: auto;
}

.day-vehicle-pill {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--status-loading-bg);
  color: var(--status-loading);
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-vehicle-pill:hover {
  filter: brightness(0.95);
}

/* ---- Calendar view switch (Day / Week / Month) ---- */

.cal-controls {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.view-toggle a {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-right: 1px solid var(--border);
}

.view-toggle a:last-child {
  border-right: none;
}

.view-toggle a:hover {
  background: #F4F6FA;
  color: var(--text);
}

.view-toggle a.active {
  background: var(--brand);
  color: #fff;
}

a.day-num {
  color: inherit;
  text-decoration: none;
}

a.day-num:hover {
  text-decoration: underline;
}

/* Job chips, shared by Week and Day views */

.job-chip {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--status-booked);
  border-radius: 4px;
  padding: 5px 7px;
  margin-top: 4px;
  text-decoration: none;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.job-chip:hover {
  border-color: var(--brand);
  background: #F8FAFD;
}

.job-chip.status-row-ready_to_dispatch { border-left-color: var(--status-ready-dispatch); }
.job-chip.status-row-delivered { border-left-color: var(--status-delivered); opacity: 0.75; }
.job-chip.status-row-delayed { border-left-color: var(--status-delayed); }

.job-chip-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.job-chip-stop {
  flex: 0 0 auto;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.job-chip-ref {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-chip-meta {
  display: block;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-note {
  display: inline-block;
  background: var(--status-ready-dispatch-bg);
  color: var(--status-ready-dispatch);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 0 4px 4px 0;
}

.week-empty {
  color: var(--text-muted);
  font-size: 12px;
  margin: 6px 0 0;
  opacity: 0.8;
}

.pill-count {
  float: right;
  font-weight: 700;
  opacity: 0.7;
}

.run-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 8px 0 2px;
}

.lane-run + .lane-run {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.lane-run-head {
  margin-bottom: 2px;
}

.lane-run-head .run-label {
  margin-top: 4px;
}

.modal-run-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.modal-run-heading:first-child {
  margin-top: 0;
}

/* Week view: seven columns */

.week-cal {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) repeat(2, minmax(0, 0.6fr));
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--border);
  gap: 1px;
}

.week-day {
  background: var(--surface);
  padding: 8px;
  min-height: 320px;
  min-width: 0;
}

.week-day.weekend-day {
  background: #F5F5F6;
}

.week-day.is-today {
  background: #F4F8FF;
}

.week-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.week-day-head a {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.week-day-head a:hover .week-day-name {
  text-decoration: underline;
}

.week-day-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.week-day-num {
  font-size: 16px;
  font-weight: 700;
}

.week-day.is-today .week-day-num {
  color: var(--brand);
}

.week-day:hover .day-add-btn {
  opacity: 1;
}

.week-vehicle {
  margin-bottom: 10px;
}

/* Day view: one lane per vehicle */

.day-driver-notes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}

.day-driver-notes .driver-note {
  margin: 0;
}

.day-lanes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.day-lane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.day-lane.lane-oos {
  background: #F5F5F6;
}

.day-lane-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.day-lane-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 6px;
}

.day-lane-title .vd-phone-link {
  font-size: 12px;
  font-weight: 500;
}

.lane-badge {
  display: inline-block;
  background: var(--status-delayed-bg);
  color: var(--status-delayed);
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
}

.load-meter small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.load-bar {
  height: 6px;
  background: #ECEFF4;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}

.load-bar span {
  display: block;
  height: 100%;
  background: var(--status-delivered);
}

.load-meter.near .load-bar span { background: var(--status-ready-dispatch); }
.load-meter.over .load-bar span { background: var(--status-delayed); }
.load-meter.over small { color: var(--status-delayed); font-weight: 600; }

.day-lane-jobs {
  padding: 6px 12px 10px;
  flex: 1;
}

.day-lane-foot {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  min-height: 18px;
}

@media (max-width: 900px) {
  .week-cal {
    grid-template-columns: 1fr;
  }
  .week-day {
    min-height: 0;
  }
  .day-add-btn {
    opacity: 1;
  }
}

.modal-subheading {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin: 20px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

#day-modal,
#vehicle-day-modal {
  width: 820px;
  max-width: 96vw;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  padding: 30px 32px;
  border-radius: 12px;
}

#day-jobs-list,
#vd-jobs-list {
  margin-bottom: 4px;
}

.jobs-list-prominent {
  font-size: 14px;
}

.job-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(20, 24, 32, 0.06);
}

.job-card:nth-child(even) {
  background: #FAFBFD;
}

.job-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.job-card-ref {
  font-weight: 700;
  font-size: 16px;
}

.job-card-edit {
  margin-left: auto;
}

.reorder-controls {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
}

.reorder-btn {
  width: 20px;
  height: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 8px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
}

.reorder-btn:hover:not(:disabled) {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.reorder-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.reorder-stop-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.job-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px 24px;
}

.jc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.jc-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.jc-value {
  font-size: 14.5px;
  color: var(--text);
}

.job-card-notes {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.modal-close-x {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-close-x:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-compact-form {
  margin-top: 0;
}

.modal-compact-form input,
.modal-compact-form select,
.modal-compact-form textarea {
  font-size: 12.5px;
  padding: 7px 9px;
}

/* Add-job modal */
dialog {
  border: none;
  border-radius: 8px;
  padding: 24px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

dialog::backdrop {
  background: rgba(20, 24, 32, 0.45);
}

dialog h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

.modal-form .field {
  margin-bottom: 12px;
}

.modal-form .field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.modal-form input,
.modal-form select,
.modal-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

button.secondary {
  padding: 9px 14px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
  cursor: pointer;
}

button.secondary:hover {
  color: var(--text);
}

.day-lane-foot span {
  display: inline-flex;
  gap: 12px;
}

/* Bar shown when jobs changed while someone was mid-way through typing */
.live-update-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--text);
  color: #fff;
  padding: 10px 12px 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.live-update-bar[hidden] {
  display: none;
}

.live-update-bar button {
  background: #fff;
  color: var(--text);
  border: 0;
  border-radius: 5px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Licence ---- */

.licence-banner {
  padding: 9px 24px;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

.licence-banner a {
  color: inherit;
  margin-left: 8px;
  text-decoration: underline;
}

.licence-banner-warn {
  background: var(--status-ready-dispatch-bg);
  color: var(--status-ready-dispatch);
}

.licence-banner-bad {
  background: var(--status-delayed-bg);
  color: var(--status-delayed);
}

.licence-card {
  max-width: 620px;
}

.licence-state {
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.licence-valid { background: var(--status-delivered-bg); color: var(--status-delivered); }
.licence-warn { background: var(--status-ready-dispatch-bg); color: var(--status-ready-dispatch); }
.licence-bad { background: var(--status-delayed-bg); color: var(--status-delayed); }

.licence-details {
  display: grid;
  gap: 6px;
  margin: 0 0 18px;
  font-size: 14px;
}

.licence-details div {
  display: flex;
  gap: 12px;
}

.licence-details dt {
  flex: 0 0 110px;
  color: var(--text-muted);
}

.licence-details dd {
  margin: 0;
}

a.licence-btn {
  display: inline-block;
  padding: 9px 16px;
  background: var(--brand);
  color: #fff;
  border-radius: 5px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

a.licence-btn:hover {
  background: var(--brand-hover);
}

.licence-form label {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  margin: 8px 0 6px;
}

.licence-form textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  word-break: break-all;
}

/* ---- Fabrication board ---- */

.fab-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.fab-legend-item,
.fab-legend-clear {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 11px 5px 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.fab-legend-clear {
  padding-left: 11px;
  color: var(--brand);
}

.fab-legend-item.active {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text);
}

.fab-legend-item.dimmed {
  opacity: 0.45;
}

.fab-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.fab-legend-count {
  color: var(--text-muted);
  font-weight: 500;
}

.fab-cal td.month-day {
  height: 120px;   /* minimum: the row grows to fit up to 4 jobs + "more" */
}

.fab-day-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fab-pill {
  display: block;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fab-pill:hover {
  filter: brightness(0.93);
}

.fab-pill[hidden],
.fab-table tr[hidden] {
  display: none;
}

.fab-table tbody tr td:first-child {
  border-left: 5px solid var(--row-colour, transparent);
}

.fab-status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.fab-status-select option {
  background: #fff;
  color: var(--text);
}

.fab-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 28px;
  align-items: start;
}

.fab-inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fab-inline-form input[type="text"] {
  flex: 1 1 140px;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
}

.fab-inline-form input[type="color"] {
  width: 38px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  flex: 0 0 auto;
  cursor: pointer;
}

.fab-preview {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.fab-move {
  white-space: nowrap;
  width: 1%;
}

.fab-move form {
  display: inline;
}

.fab-legend-clear[hidden] {
  display: none;
}

.fab-pill {
  flex: 0 0 auto;
}

.fab-list-table .fab-inline-form {
  flex-wrap: nowrap;
}

.fab-list-table .fab-preview {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.add-form.fab-inline-form input[type="color"] {
  flex: 0 0 38px;
  min-width: 0;
}

.login-card p.sub {
  text-align: center;
}

.brand-logo {
  height: 44px;
}

/* Fabrication: day filter */
.fab-day-filter {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.fab-day-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.fab-day-pick input {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
}

button.fab-day-btn {
  background: none;
  border: 0;
  padding: 0 4px;
  margin-left: -4px;
  border-radius: 4px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
}

button.fab-day-btn:hover {
  background: #E6E9F6;
  color: var(--brand);
}

td.month-day.is-today button.fab-day-btn {
  margin-left: 0;
  padding: 0;
}

.fab-cal td.month-day.fab-day-selected {
  box-shadow: inset 0 0 0 2px var(--brand);
  background: #F4F7FF;
}

/* ---- Customer list ---- */
.customer-dialog {
  max-width: 460px;
  width: calc(100% - 32px);
}

.customer-dialog-lead {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

.customer-dialog .field input {
  width: 100%;
  box-sizing: border-box;
}

.customer-dialog-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.customer-table input[type="text"],
.customer-table input[type="tel"] {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
  font-family: inherit;
}

.customer-table td {
  vertical-align: middle;
}

.customer-search {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}

.customer-search input {
  flex: 0 1 320px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13.5px;
}

/* An input stacked above its hint must not stretch to the add-form's
   130px flex-basis (in a column that becomes its height). */
.add-form .field-with-hint input {
  flex: 0 0 auto;
}

.customer-count {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Highlights the Save button on a customer row that has unsaved changes */
.customer-table tr.dirty td {
  background: #FFF8E6;
}

.customer-table tr.dirty button[type="submit"].link-btn:not(.link-btn-danger) {
  font-weight: 700;
}

td.row-actions form {
  margin-top: 0;
  margin-bottom: 0;
}

td.row-actions .link-btn {
  line-height: 1.4;
  vertical-align: middle;
}

.fab-more {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 2px 4px;
  margin-top: 1px;
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  cursor: pointer;
}

.fab-more:hover {
  background: #E6E9F6;
}

.fab-more[hidden] {
  display: none;
}

/* Line every box on the booking forms up along the top, so a box with a hint
   line underneath (Customer, Weight) sits level with its neighbours. */
.add-form {
  align-items: flex-start;
}

.add-form .weight-hint:empty {
  min-height: 0;
}

.add-form input:not([type="color"]),
.add-form select {
  height: 36px;
  box-sizing: border-box;
}

/* Vehicle and driver availability side by side (stacked on narrow screens) */
.availability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 28px;
  align-items: start;
}

.availability-col {
  min-width: 0;
}

.availability-col table.board td,
.availability-col table.board th {
  padding: 9px 10px;
  font-size: 13px;
}

.availability-col .add-form {
  padding: 12px;
}

.availability-col .add-form input[type="date"] {
  flex: 1 1 140px;
}

.availability-col .add-form input[type="text"] {
  flex: 1 1 100%;
}

.availability-col .time-field {
  flex: 1 1 auto;
}

@media (max-width: 1000px) {
  .availability-grid {
    grid-template-columns: 1fr;
  }
}

.lane-badge-part {
  background: var(--status-ready-dispatch-bg);
  color: var(--status-ready-dispatch);
}

.availability-col td.ref,
.availability-col td:nth-child(2),
.availability-col td:nth-child(3),
.availability-col td:nth-child(4),
.availability-col td:last-child {
  white-space: nowrap;
}

.fab-issued-by {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 36px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #F4F6FA;
  font-size: 13.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.fab-issued-by strong {
  color: var(--text);
}

.fab-issued-by-edit {
  display: flex;
  width: 100%;
  font-weight: 600;
  color: var(--text);
}

/* Fabrication status filters: equal-width buttons in a tidy grid. Long names
   wrap inside their button; every button in a row is the same height. */
.fab-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
}

.fab-legend-item,
.fab-legend-clear {
  justify-content: flex-start;
  min-height: 34px;
  border-radius: 10px;
  text-align: left;
  line-height: 1.2;
}

.fab-legend-item .fab-legend-count {
  margin-left: auto;
  padding-left: 6px;
}

.fab-legend-clear {
  justify-content: center;
}

/* Fabrication: Galv In / Galv Out */
.fab-date-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.fab-date-field[hidden] {
  display: none;
}

.add-form .fab-date-field input {
  flex: 0 0 auto;
  min-width: 0;
  width: 150px;
}

.fab-pill-kind {
  display: inline-block;
  margin-right: 5px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.85);
  color: #111827;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.fab-two-dates {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
  white-space: nowrap;
}

/* Settings > Driver rest reminders */
.breaks-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 16px;
}

.breaks-times {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.breaks-times input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 14px;
}

/* Jobs on a van that's been marked out of service (e.g. accident):
   solid red so they stand out from "Delayed" until reallocated. */
tr.vehicle-out-row td { background: #D32F2F !important; color: #fff; }
tr.vehicle-out-row td:first-child { border-left: 5px solid #7F1414 !important; }
tr.vehicle-out-row td a, tr.vehicle-out-row .link-btn { color: #fff; }
tr.vehicle-out-row .status-select { background: #fff; }
.vehicle-out-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: #fff; color: #B71C1C; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.job-chip.vehicle-out, .job-chip.vehicle-out:hover {
  background: #D32F2F; border-color: #B71C1C; border-left-color: #7F1414; color: #fff; opacity: 1;
}
.job-chip.vehicle-out .job-chip-meta { color: #FFE3E3; }
.vehicle-out-flag { color: #fff; font-weight: 700; }
.day-vehicle-pill.vehicle-out { background: #D32F2F !important; color: #fff !important; border-color: #B71C1C !important; }
.job-card.vehicle-out { background: #FDECEC; border-left-color: #D32F2F !important; }
.vehicle-out-note {
  background: #D32F2F; color: #fff; font-weight: 600; font-size: 13px;
  padding: 6px 10px; border-radius: 4px; margin-bottom: 8px;
}
.vehicle-out-banner {
  display: flex; flex-direction: column; gap: 3px;
  background: #D32F2F; color: #fff; border-radius: 6px; padding: 12px 14px; margin-bottom: 14px;
}
.vehicle-out-banner strong { font-size: 15px; }

/* Day view: vehicles off the road and drivers off, on separate lines */
.day-driver-notes { flex-direction: column; align-items: flex-start; gap: 6px; }
.day-notes-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.day-notes-row strong { min-width: 62px; }
.driver-note.vehicle-note { background: #FDECEC; color: #A82424; }

/* Rough journey estimate */
.journey-cell { white-space: nowrap; }
.journey-hint { display: block; margin-top: 4px; color: var(--text-muted); }

/* Origin: depot dropdown, or a typed postcode */
.origin-picker { display: flex; gap: 6px; min-width: 0; }
.origin-picker select, .origin-picker input { flex: 1 1 0; min-width: 0; width: 100%; }
.origin-picker .origin-other[hidden] { display: none !important; }
.depot-table input[type="text"] { width: 100%; }
.depot-default { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--status-delivered-bg); color: var(--status-delivered); font-size: 12px; font-weight: 600; }
.depot-add-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.depot-add-form input[name="name"] { flex: 2 1 180px; }
.depot-add-form input[name="postcode"] { flex: 0 1 120px; }
.depot-add-form button { width: auto; padding: 9px 16px; }
.add-form .origin-picker { flex: 1 1 140px; min-width: 120px; }
.add-form .origin-picker:has(.origin-select):has(.origin-other:not([hidden])) { flex: 2 1 260px; }
.add-form .origin-picker select { flex: 1 1 0; }
.journey-miles { display: block; font-weight: 700; }
.journey-time { display: block; font-size: 12px; color: var(--text-muted); }
.journey-est { font-weight: 400; font-size: 11px; color: var(--text-muted); }
.w3w-link { display: block; font-size: 11.5px; color: #E11F26; text-decoration: none; font-weight: 600; }
.w3w-link:hover { text-decoration: underline; }

/* Fabrication calendar: the whole day square is clickable */
.fab-cal td.month-day[data-date] { cursor: pointer; }
.fab-cal td.month-day[data-date]:not(.fab-day-selected):not(.is-today):hover { background: #F1F5FB; }
.fab-cal td.month-day[data-date] .fab-pill { cursor: pointer; }

/* Notes the driver wrote on the van phone */
.driver-notes-line { display: block; margin-top: 3px; padding: 2px 6px; border-radius: 4px; background: #FFF4D6; color: #6B4E00; font-size: 12px; }
.job-card-driver-notes { background: #FFF4D6; }
.driver-notes-box { padding: 9px 11px; border-radius: 6px; background: #FFF4D6; color: #4A3600; white-space: pre-wrap; }

/* Jobs that came from the Fabrication board (courier "Ours") */
.fab-badge { display: inline-block; padding: 0 5px; border-radius: 3px; background: #6D28D9; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .03em; vertical-align: 1px; font-family: inherit; }
.fab-link-note { margin-bottom: 12px; padding: 10px 12px; border-radius: 6px; background: #F3EEFF; color: #3B1D7A; font-size: 13.5px; }

/* Delivery photos */
.photo-link { display: inline-block; margin-right: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.job-card-photo { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: 6px; border: 1px solid var(--border); }
.edit-photo { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--border); }

/* Job list: keep neighbouring jobs apart even when they share a status colour.
   A white gap between rows, plus every other row a shade darker. */
table.board tbody tr[class*="status-row-"] td { border-bottom: 4px solid var(--surface, #fff); }
table.board tbody tr[class*="status-row-"]:nth-child(even) td { box-shadow: inset 0 0 0 9999px rgba(15, 23, 42, 0.045); }
table.board tbody tr[class*="status-row-"]:hover td { box-shadow: inset 0 0 0 9999px rgba(15, 23, 42, 0.09); }
