
:root {
  /* Cornwall Executive Travel — Vehicle Compliance (light, matches Outlook digest) */
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel2: #e5e7eb;
  --text: #222222;
  --muted: #555555;
  --accent: #14532d;
  --accent-lime: #84cc16;
  --accent-lime-text: #14532d;
  --good: #15803d;
  --warn: #a16207;
  --bad: #b91c1c;
  --border: #d1d5db;
  --sidebar-w: 240px;
  --plate: #f5c518;
  --plate-text: #0f172a;
  --header-bg: #84cc16;
  --header-fg: #14532d;
  --th-bg: #14532d;
  --th-fg: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top nav (driver) */
.topnav {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  padding: .75rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--border);
}
.topnav .brand { font-weight: 700; color: var(--text); margin-right: auto; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--text); }

/* Sidebar (admin) */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 40;
}
.sidebar-brand {
  padding: .85rem 1rem;
  background: var(--header-bg);
  border-bottom: 1px solid #65a30d;
}
.sidebar-eyebrow {
  margin: 0; font-size: .62rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--header-fg);
}
.sidebar-title { margin: .2rem 0 0; font-size: .92rem; font-weight: 700; color: var(--header-fg); line-height: 1.25; }
.sidebar-logo { display: block; max-width: 100%; height: auto; max-height: 48px; margin: 0 0 .45rem; }
.sidebar-nav {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .6rem .5rem; flex: 1; overflow-y: auto;
}
.sidebar-nav a {
  color: var(--muted); padding: .55rem .75rem; border-radius: 8px;
  font-size: .9rem; font-weight: 550; text-decoration: none;
}
.sidebar-nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active {
  background: #ecfccb; color: var(--accent); font-weight: 700;
}
.sidebar-divider { height: 1px; background: var(--border); margin: .5rem .4rem; }
.sidebar-foot {
  padding: .75rem 1rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: .85rem;
}
.sidebar-foot a { color: var(--muted); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.wrap-sidebar {
  max-width: none;
  margin-left: var(--sidebar-w);
  padding: 1.35rem 1.5rem 2rem;
}

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem;
}
.page-head h1 { margin: .15rem 0 .25rem; font-size: 1.35rem; }
.eyebrow {
  margin: 0; font-size: .7rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
}

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.15rem; margin-bottom: 1rem;
}
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
h1,h2,h3 { margin-top: 0; }
.muted { color: var(--muted); }
.btn {
  display: inline-block; background: var(--accent); color: #fff !important;
  border: 0; border-radius: 8px; padding: .5rem .9rem; cursor: pointer;
  font-weight: 600; text-decoration: none !important;
}
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--panel2); color: var(--text) !important; border: 1px solid var(--border); }
.btn.danger { background: var(--bad); color: #fff !important; }
.btn.lime { background: var(--accent-lime); color: var(--accent-lime-text) !important; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .5rem 0 .2rem; }
input, select, textarea {
  width: 100%; padding: .5rem .65rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
textarea { min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
.fleet-table { min-width: 960px; font-size: .875rem; }
.fleet-table thead th {
  padding: .85rem 1rem; font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; background: var(--th-bg); color: var(--th-fg);
  border-bottom: 1px solid var(--th-bg);
}
.fleet-table td { padding: .75rem 1rem; vertical-align: middle; }
.fleet-table tbody tr:hover { background: #f0fdf4; }
.right { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem !important; }
.veh-name { font-weight: 600; color: var(--text); }
.veh-meta { font-size: .72rem; color: var(--muted); margin-top: .1rem; }

/* UK registration plate */
.reg-plate {
  display: inline-flex; align-items: center;
  background: var(--plate); color: var(--plate-text) !important;
  border: 1px solid rgba(120, 90, 0, .45);
  border-radius: 6px; padding: .15rem .5rem;
  font-family: ui-monospace, "Courier New", monospace;
  font-size: .78rem; font-weight: 800; letter-spacing: .06em;
  text-decoration: none !important; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.reg-plate:hover { filter: brightness(1.05); text-decoration: none !important; }

/* Due / tone badges */
.due {
  display: inline-flex; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 6px; border: 1px solid transparent;
  padding: .15rem .45rem; font-size: .72rem; font-weight: 650;
}
.due-overdue { color: #fff; background: #b91c1c; border-color: #b91c1c; }
.due-soon { color: #fff; background: #c2410c; border-color: #c2410c; }
.due-booked { color: #fff; background: #0369a1; border-color: #0369a1; }
.due-ok { color: #fff; background: #14532d; border-color: #14532d; }
.due-missing { color: var(--muted); background: var(--panel2); border-color: var(--border); }
.due-defect { color: #fff; background: #b91c1c; border-color: #b91c1c; text-decoration: none !important; }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--panel2);
}
.badge.ok { background: #14532d; color: #fff; }
.badge.warn { background: #a16207; color: #fff; }
.badge.bad { background: #b91c1c; color: #fff; }

/* KPI cards */
.kpi-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: 1rem;
}
.kpi {
  border-radius: 12px; border: 1px solid var(--border);
  padding: .75rem 1rem; background: var(--panel);
}
.kpi-label {
  margin: 0; font-size: .65rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; opacity: .75;
}
.kpi-value { margin: .25rem 0 0; font-size: 1.65rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi-bad { border-color: #b91c1c; background: #fef2f2; color: #991b1b; }
.kpi-warn { border-color: #a16207; background: #fffbeb; color: #854d0e; }
.kpi-ok { border-color: #166534; background: #f0fdf4; color: #14532d; }
.kpi-neutral { border-color: var(--border); background: var(--panel); color: var(--text); }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.toolbar .search { max-width: 280px; }
.sort-toggle {
  display: inline-flex; gap: .2rem; padding: .2rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--panel);
}
.sort-btn {
  border: 0; background: transparent; color: var(--muted);
  border-radius: 999px; padding: .35rem .85rem; font-size: .8rem;
  font-weight: 650; cursor: pointer;
}
.sort-btn.active { background: var(--accent); color: #fff; }
.chip {
  display: inline-block; padding: .35rem .8rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); font-size: .85rem;
  text-decoration: none !important;
}
.chip.active, .chip:hover { background: var(--panel2); color: var(--text); }

.inline-form { display: inline-block; margin: 0; }
.inline-form select { width: auto; padding: .25rem .4rem; font-size: .8rem; }

.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  display: grid; grid-template-columns: 140px 1fr; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid var(--border);
}
.history-when { color: var(--muted); font-size: .85rem; }
.history-body .reg-plate { margin: 0 .4rem; vertical-align: middle; }
.history-body p { margin: .35rem 0 0; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .8rem; }
.flash.success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }
.flash.danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash.warning, .flash.info { background: #ecfccb; color: #14532d; border: 1px solid #bef264; }
.login-box { max-width: 380px; margin: 4rem auto; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .4rem .8rem; }
.checkgrid label { display: flex; gap: .4rem; align-items: center; color: var(--text); }
.checkgrid input { width: auto; }
.section-title { margin: 1.2rem 0 .6rem; font-size: 1.05rem; }

@media (max-width: 900px) {
  .sidebar {
    position: static; width: 100%; height: auto;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; overflow-x: auto; }
  .sidebar-foot { display: none; }
  .wrap-sidebar { margin-left: 0; }
  .fleet-table { min-width: 720px; }
  .history-list li { grid-template-columns: 1fr; gap: .25rem; }
}
@media (max-width: 700px) {
  .topnav { gap: .6rem; padding: .65rem .85rem; font-size: .9rem; }
  .wrap { padding: .85rem; }
  .btn { text-align: center; padding: .75rem; }
  .btn.small { width: auto; display: inline-block; margin: 0; padding: .3rem .6rem; }
  table { font-size: .88rem; }
}
.install-hint {
  background: #ecfccb; border: 1px solid #bef264; color: #14532d;
  border-radius: 10px; padding: .85rem 1rem; margin-bottom: 1rem; font-size: .9rem;
}

/* ---- Driver pages: phone layout + defect photos ---- */
body { -webkit-text-size-adjust: 100%; }
.topnav { padding-top: max(.65rem, env(safe-area-inset-top)); }
.driver-cta { margin: 0 0 1rem; }
.photo-input {
  position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden;
  clip: rect(0 0 0 0); pointer-events: none;
}
.photo-pick {
  display: flex; align-items: center; gap: .6rem; cursor: pointer;
  margin: .2rem 0 0; padding: .8rem .9rem; border-radius: 8px;
  border: 1px dashed var(--border); background: var(--bg); color: var(--text); font-size: .95rem;
}
.photo-pick:hover, .photo-pick:focus-within { border-color: var(--accent); }
.photo-pick-icon { font-size: 1.3rem; line-height: 1; }
.photo-previews { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.photo-thumb {
  width: 96px; height: 96px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--panel2);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; color: var(--muted); text-align: center; word-break: break-all;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 700px) {
  .topnav .brand { flex-basis: 100%; }
  .topnav a, .topnav span { padding: .15rem 0; }
  h1 { font-size: 1.4rem; }
  .card { padding: .85rem .9rem; }
  input, select, textarea { font-size: 16px; padding: .65rem .7rem; } /* no zoom-on-focus */
  .driver-cta .btn, .form-actions .btn { display: block; width: 100%; margin-bottom: .5rem; }
  .photo-thumb { width: 80px; height: 80px; }
  /* Stack wide tables into cards on phones */
  .stack-table.defects-stack thead { display: none; }
  .stack-table.defects-stack tr {
    display: block; padding: .6rem 0; border-bottom: 1px solid var(--border);
  }
  .stack-table.defects-stack td {
    display: flex; gap: .75rem; border: 0; padding: .2rem 0;
  }
  .stack-table.defects-stack td::before {
    content: attr(data-label); flex: 0 0 5.5rem; color: var(--muted); font-size: .8rem;
  }
  .stack-table td { vertical-align: middle; }
}
input, select, textarea, button { font-family: inherit; }
button.btn { font-size: inherit; }
.reg-plate, .btn.small { white-space: nowrap; }

/* ---- Sign out: always visible (driver top bar + admin sidebar), incl. phone width ---- */
.topnav .signout { order: 10; color: var(--text) !important; }
.topnav .topnav-user { order: 9; }
.topnav .topnav-break { display: none; }
.sidebar-foot .signout { color: var(--text) !important; }
@media (max-width: 700px) {
  .topnav .brand { flex-basis: auto; order: 0; margin-right: auto; }
  .topnav .signout { order: 1; }
  .topnav .topnav-break { display: block; order: 2; flex-basis: 100%; height: 0; }
  .topnav .nav-link { order: 3; }
  .topnav .topnav-user { order: 4; margin-left: auto; font-size: .8rem; }
}
@media (max-width: 900px) {
  .sidebar-foot { display: flex; gap: .75rem; padding: .5rem 1rem; }
}

/* Tyre info — grouped fittings (one row per vehicle per date, expandable) */
.tyre-groups .tg-toggle-col { width: 2.25rem; padding-right: 0 !important; }
.tyre-groups tr.tg-row { cursor: pointer; }
.tyre-groups tr.tg-row.open { background: #ecfccb; }
.tg-toggle {
  width: 1.7rem; height: 1.7rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); cursor: pointer; line-height: 1; padding: 0;
}
.tg-toggle:hover { border-color: var(--accent); }
.tg-caret { display: inline-block; transition: transform .15s ease; }
.tg-toggle[aria-expanded="true"] .tg-caret { transform: rotate(90deg); }
.tyre-groups tr.tg-detail > td { background: #f9fafb; padding: .5rem 1rem 1rem 3.25rem !important; }
.tyre-groups:not(.fleet-table) tr.tg-detail > td { padding: .4rem .5rem .8rem !important; }
.tg-inner { width: 100%; font-size: .82rem; border-collapse: collapse; }
.tg-inner th { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: left; padding: .35rem .5rem; }
.tg-inner td { padding: .4rem .5rem; border-top: 1px solid var(--border); border-bottom: 0; vertical-align: top; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Parts — status colours (needed = red, ordered = orange, received = green, fitted = blue) and grouped list */
.part-status, .ps-count {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; border: 1px solid transparent;
  font-size: .75rem; font-weight: 700; line-height: 1.35; white-space: nowrap;
}
.ps-needed   { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.ps-ordered  { background: #c2410c; color: #fff; border-color: #c2410c; }
.ps-received { background: #14532d; color: #fff; border-color: #14532d; }
.ps-fitted   { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.ps-other    { background: var(--panel2); color: var(--muted); border-color: var(--border); }
.ps-summary { display: inline-flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.ps-sep { color: var(--muted); font-size: .8rem; }
.ps-legend .part-status { font-size: .68rem; padding: .05rem .45rem; }
.parts-caption { font-size: .85rem; margin: -.4rem 0 .8rem; }
.parts-expand { display: inline-flex; gap: .35rem; margin-left: auto; }
.chip-n { display: inline-block; min-width: 1.2em; margin-left: .2rem; font-size: .75rem; font-weight: 700; opacity: .8; }
.chip-needed::before, .chip-ordered::before, .chip-received::before, .chip-fitted::before {
  content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem; vertical-align: .02rem;
}
.chip-needed::before { background: #ef4444; }
.chip-ordered::before { background: #f97316; }
.chip-received::before { background: #22c55e; }
.chip-fitted::before { background: #3b82f6; }
.part-groups .tg-inner .btn.small { margin: 0; }
.parts-vsummary { margin: .2rem 0 .6rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.parts-inner td .veh-meta { max-width: 36ch; }
@media (max-width: 700px) {
  .parts-expand { margin-left: 0; }
  .tyre-groups tr.tg-detail > td { padding-left: .6rem !important; }
}

/* History — part status changes (old → new badges) */
.ph-change { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .35rem 0 0; }
.ph-arrow { color: var(--muted); font-weight: 700; }
.ph-by { font-size: .8rem; margin-left: .2rem; }
.history-compact li { padding: .6rem 0; }

/* Worksheets */
.ws-status {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px; border: 1px solid;
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
.ws-open      { background: #a16207; color: #fff; border-color: #a16207; }
.ws-completed { background: #14532d; color: #fff; border-color: #14532d; }
.chip-ws-open::before, .chip-ws-completed::before {
  content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem;
}
.chip-ws-open::before { background: #f59e0b; }
.chip-ws-completed::before { background: #22c55e; }
.ws-groups .ps-summary { gap: .3rem; }
.ws-inner .btn.small { margin: 0 0 0 .25rem; }
.nowrap { white-space: nowrap; }
.ws-torque-inline { display: inline-flex; flex-wrap: wrap; gap: .15rem .6rem; font-variant-numeric: tabular-nums; font-size: .82rem; }
.ws-torque-inline b { color: var(--muted); font-weight: 600; font-size: .72rem; }
.req { color: var(--bad); }
.ws-form h2 { font-size: 1.05rem; margin-bottom: .4rem; }
.ws-row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .ws-row-3 { grid-template-columns: 1fr; } }
.ws-card-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .4rem; }
.ws-card-head h2 { margin: 0; }
.ws-lines-head, .ws-line { display: grid; grid-template-columns: 1fr 120px 40px; gap: .5rem; align-items: start; }
.ws-parts-head, .ws-part { display: grid; grid-template-columns: 1fr 90px minmax(210px, auto) 40px; gap: .5rem; align-items: center; }
.ws-lines-head, .ws-parts-head { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: .3rem 0; }
.ws-line, .ws-part { margin-bottom: .5rem; }
.ws-line textarea { min-height: 2.6rem; resize: vertical; }
.ws-remove { width: 2.2rem; height: 2.2rem; padding: 0 !important; font-size: 1.2rem !important; line-height: 1; }
.ws-part-link { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--muted); }
.ws-part-link .part-status { font-size: .66rem; }
.ws-fit, .ws-inline-check { display: inline-flex; align-items: center; gap: .35rem; margin: 0; color: var(--text); font-size: .85rem; }
.ws-fit input, .ws-inline-check input { width: auto; margin: 0; }
.ws-picker { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ws-picker select { width: auto; min-width: 240px; padding: .3rem .5rem; font-size: .85rem; }
.ws-hint { font-size: .82rem; margin: .35rem 0 0; }
.ws-apply { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.ws-apply input[type=number] { width: 90px; padding: .3rem .5rem; }
.ws-torque-grid { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: .75rem; margin-top: .6rem; }
@media (max-width: 800px) { .ws-torque-grid { grid-template-columns: repeat(2, 1fr); } }
.ws-wheel { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .65rem .6rem; }
.ws-wheel label { margin-top: 0; font-weight: 700; color: var(--text); letter-spacing: .06em; }
.ws-wheel-spare { border-style: dashed; }
.ws-nm { display: flex; align-items: center; gap: .35rem; }
.ws-nm input { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ws-nm span { color: var(--muted); font-size: .8rem; }
.ws-prev { margin-top: .3rem; font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ws-torque-grid input[data-prefilled] { border-color: #475569; color: #cbd5e1; font-style: italic; }
.ws-retorque { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.ws-retorque input.ws-small { width: 80px; } .ws-retorque input.ws-mid { width: 120px; } .ws-retorque input.ws-date { width: 165px; }
.ws-inline-label { display: inline; margin: 0; }
.ws-actions { margin-top: .5rem; }
.ws-delete { margin: 1rem 0 2rem; text-align: right; }
.ws-actions-top { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
/* worksheet view */
.ws-sheet { max-width: 900px; }
.ws-sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid var(--border); padding-bottom: .6rem; margin-bottom: .8rem; }
.ws-sheet-head h2 { margin: .1rem 0 0; }
.ws-sheet-id { text-align: right; display: grid; gap: .3rem; justify-items: end; }
.ws-sheet h3 { font-size: .95rem; margin: 1.1rem 0 .35rem; }
.ws-kv th { width: 18%; font-size: .8rem; }
.ws-kv td { width: 32%; }
.ws-table { font-size: .9rem; }
.ws-table .ws-n { width: 2.2rem; color: var(--muted); }
.ws-table .ws-num { text-align: right; width: 7rem; font-variant-numeric: tabular-nums; }
.ws-torque-table .ws-num { width: auto; text-align: center; }
.ws-prev-row td { font-size: .78rem; border-bottom: 0; }
.ws-pre { white-space: pre-wrap; }
.ws-notes { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; min-height: 3rem; }
.ws-small-note { font-size: .78rem; margin: .25rem 0; }
.ws-retorque-line { margin: .7rem 0 0; }
.ws-box { display: inline-block; width: 1.05rem; height: 1.05rem; border: 1.5px solid var(--muted); border-radius: 3px; text-align: center; line-height: 1rem; font-weight: 700; vertical-align: -2px; margin-right: .35rem; }
.ws-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; margin-top: 1.8rem; }
.ws-sig-line { border-bottom: 1px solid var(--muted); height: 2.6rem; }
.ws-sig-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-top: .3rem; }
.ws-sig-meta { font-size: .85rem; margin-top: .2rem; }
.ws-sheet-foot { margin-top: 1.4rem; font-size: .75rem; }
.ws-fit[hidden], .ws-part-tag:empty { display: none !important; }

/* Admin "Report defect" entry points */
.sidebar-nav a.nav-report-defect { background: #7f1d1d; color: #fee2e2; font-weight: 700; margin-bottom: .35rem; }
.sidebar-nav a.nav-report-defect:hover, .sidebar-nav a.nav-report-defect.active { background: #991b1b; color: #fff; }
.btn.btn-defect { background: var(--bad); }

/* Duplicate defects: open-defect list on the report form, duplicate warning, follow-ups */
.od-panel { margin: .75rem 0 .25rem; padding: .7rem .8rem; border: 1px solid #92400e; background: #2a1f0f; border-radius: 10px; }
.od-head { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; color: #fde68a; }
.od-hint { font-size: .82rem; margin: .3rem 0 .5rem; }
.od-none { font-size: .85rem; margin: .4rem 0 0; }
.od-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.od-item { display: grid; grid-template-columns: 56px 1fr auto; gap: .65rem; align-items: center; padding: .55rem; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.od-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--panel2); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.od-desc { font-size: .92rem; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.od-meta { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
.od-status { display: inline-block; padding: 0 .4rem; border-radius: 999px; background: #78350f; color: #fde68a; font-weight: 700; text-transform: capitalize; }
.od-in_progress, .od-acknowledged { background: #0c4a6e; color: #bae6fd; }
.od-add { white-space: normal; max-width: 9.5rem; line-height: 1.2; }
@media (max-width: 560px) {
  .od-item { grid-template-columns: 48px 1fr; }
  .od-thumb { width: 48px; height: 48px; }
  .od-item .od-add { grid-column: 1 / -1; max-width: none; width: 100%; display: block; padding: .6rem; }
}
.dd-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(5, 8, 12, .78); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.dd-overlay[hidden] { display: none; }
.dd-box { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; background: var(--panel); border: 1px solid #b45309; border-radius: 12px; padding: 1rem 1.1rem; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.dd-box h2 { margin: 0 0 .3rem; font-size: 1.15rem; color: #fde68a; }
.dd-box > p.muted { font-size: .88rem; margin: 0 0 .7rem; }
.dd-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .9rem 0 0; }
.rep-count { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; background: #1e3a8a; color: #dbeafe; white-space: nowrap; }
.fu-list { list-style: none; margin: .4rem 0 0; padding: 0; }
.fu-list li { padding: .6rem 0; border-top: 1px solid var(--border); }
.fu-who { font-weight: 700; }
.fu-note { white-space: pre-wrap; margin: .25rem 0 0; }
.merge-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.merge-form select { width: auto; max-width: 100%; flex: 1 1 260px; }
.badge.merged { background: #3b0764; color: #e9d5ff; }

/* Tyre info — one row per vehicle, every tyre newest first */
.tv-positions div + div { margin-top: .1rem; }
.tv-inner tr.tv-sep td { padding: .55rem .5rem .2rem; border-top: 1px dashed #3b4b63; }
.tv-inner tr.tv-sep span { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #93c5fd; }
.tv-inner tr.tv-sep + tr td { border-top: 0; }
.tv-inner tr.tv-removed td { opacity: .6; }
.tv-vsummary { font-size: .88rem; margin: 0 0 .5rem; }
.card .tv-inner { min-width: 520px; }

/* Part delete (admin) */
.part-actions { white-space: nowrap; }
.part-actions .inline-form { margin-left: .3rem; vertical-align: middle; }
.part-delete-form { margin-top: .75rem; text-align: right; }

/* History grouped by vehicle */
.history-groups tr.tg-detail > td { padding-top: .2rem !important; padding-bottom: .4rem !important; }
.hg-list li { grid-template-columns: 130px 1fr; }
.hg-list li:last-child { border-bottom: 0; }
.hg-latest { font-size: .85rem; margin-top: .15rem; }
.hg-latest .badge { margin-right: .25rem; }
.hk-summary { text-transform: none; }
.badge.hk { text-transform: lowercase; }
.badge.hk-service { background: #1e3a5f; color: #93c5fd; }
.badge.hk-defect { background: #7f1d1d; color: #fca5a5; }
.badge.hk-part { background: #78350f; color: #fcd34d; }
.badge.hk-tyre { background: #312e81; color: #c7d2fe; }
.badge.hk-worksheet { background: #14532d; color: #86efac; }
.badge.hk-appointment { background: #0c4a6e; color: #bae6fd; }
.badge.hk-check { background: #134e4a; color: #99f6e4; }
.badge.hk-fuel-card { background: #4a044e; color: #f5d0fe; }
.chip-hk::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .35rem; background: var(--muted); }
.chip-hk-service::before { background: #3b82f6; }
.chip-hk-defect::before { background: #ef4444; }
.chip-hk-part::before { background: #f59e0b; }
.chip-hk-tyre::before { background: #818cf8; }
.chip-hk-worksheet::before { background: #22c55e; }
.chip-hk-appointment::before { background: #38bdf8; }
.chip-hk-check::before { background: #2dd4bf; }
.chip-hk-fuel-card::before { background: #e879f9; }
@media (max-width: 700px) { .hg-list li { grid-template-columns: 1fr; } }

/* Worksheet: general stock parts */
.ws-stock-hint { font-size: .75rem; color: #fcd34d; }
.ws-stock-hint:empty { display: none; }
.ws-part-general .ws-part-tag { color: #fcd34d; }
.ws-parts-head, .ws-part { grid-template-columns: 1fr 90px 260px 40px; }  /* fixed link column so rows line up */

/* Parts: Inventory / Fitted / All views */
.view-tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 0 0 .9rem; flex-wrap: wrap; }
.view-tab { padding: .5rem .9rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); text-decoration: none; margin-bottom: -1px; }
.view-tab:hover { color: var(--text); }
.view-tab.active { background: var(--panel); border-color: var(--border); color: var(--text); font-weight: 600; }
.view-tab .muted { font-size: .8rem; font-weight: 400; }
.fitted-when { margin-top: .2rem; }
details.fitted-parts { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .7rem; }
details.fitted-parts > summary { cursor: pointer; font-weight: 600; }
details.fitted-parts[open] > summary { margin-bottom: .5rem; }

/* Defect delete */
.defect-actions { white-space: nowrap; }
.defect-actions .inline-del { display: inline; margin-left: .5rem; }
.card.danger-zone { border-color: rgba(239, 68, 68, .45); }

/* ---- Daily vehicle checks ---- */
.btn.btn-daily-check,
.sidebar-nav a.nav-daily-check {
  background: #0f766e;
  color: #ccfbf1;
  font-weight: 700;
}
.btn.btn-daily-check:hover,
.sidebar-nav a.nav-daily-check:hover,
.sidebar-nav a.nav-daily-check.active {
  background: #0d9488;
  color: #fff;
}
.sidebar-nav a.nav-daily-check { margin-bottom: .35rem; }
.badge.hk-daily-check { background: #134e4a; color: #99f6e4; }
.chip-hk-daily-check::before { background: #2dd4bf; }

.dc-unchecked-list { list-style: none; margin: 0; padding: 0; }
.dc-unchecked-list li {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .55rem 0; border-bottom: 1px solid var(--border, #2a3544);
}
.dc-unchecked-list li:last-child { border-bottom: 0; }

.dc-list { display: flex; flex-direction: column; gap: .65rem; margin-top: .75rem; }
.dc-item {
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 10px;
  padding: .7rem .8rem;
}
.dc-item-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: .5rem; flex-wrap: wrap;
}
.dc-result { display: inline-flex; gap: .35rem; flex-wrap: wrap; }
.dc-radio {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .35rem .55rem; border-radius: 999px; font-size: .85rem;
  background: #1a2332; border: 1px solid #334155; cursor: pointer;
}
.dc-radio.ok:has(input:checked) { background: #14532d; border-color: #22c55e; color: #bbf7d0; }
.dc-radio.bad:has(input:checked) { background: #7f1d1d; border-color: #ef4444; color: #fecaca; }
.dc-radio.na:has(input:checked) { background: #334155; border-color: #94a3b8; }
.dc-note { width: 100%; margin-top: .45rem; }
.dc-raise, .dc-same { display: block; margin-top: .4rem; font-size: .9rem; }

.dc-photos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem; margin-top: .5rem;
}
.dc-slot .photo-pick { min-height: 88px; }

.dc-compare-row { margin-bottom: 1.1rem; }
.dc-compare-row h3 { margin: 0 0 .4rem; font-size: .95rem; }
.dc-compare-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
}
@media (max-width: 640px) {
  .dc-compare-cols { grid-template-columns: 1fr; }
  .dc-item-head { flex-direction: column; }
  .dc-result { width: 100%; }
  .dc-radio { flex: 1; justify-content: center; }
}
.dc-thumbs { display: flex; flex-wrap: wrap; gap: .4rem; }
.dc-thumb {
  display: block; width: 96px; height: 72px; border-radius: 8px; overflow: hidden;
  border: 1px solid #334155; background: #0f172a;
}
.dc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dc-lightbox {
  border: none; border-radius: 12px; padding: 1rem; max-width: min(96vw, 900px);
  background: #0f172a; color: inherit;
}
.dc-lightbox::backdrop { background: rgba(0,0,0,.72); }
.dc-lightbox img { max-width: 100%; max-height: 80vh; display: block; margin-top: .5rem; }

.dc-dash-banner {
  margin: 1rem 0; padding: .85rem 1rem; border-radius: 12px;
  background: rgba(15, 118, 110, 0.12); border: 1px solid rgba(45, 212, 191, 0.35);
}
.dc-dash-banner h2 { margin: 0 0 .5rem; font-size: 1rem; }

/* Part units: qty + unit side by side on worksheet part rows */
.ws-parts-head, .ws-part { grid-template-columns: 1fr 150px 260px 40px; }
.ws-qty-unit { display: flex; gap: .25rem; min-width: 0; }
.ws-qty-unit input { flex: 1; min-width: 0; }
.ws-qty-unit select { width: auto; flex: 0 0 auto; padding-left: .3rem; padding-right: .3rem; }
.part-fits { color: var(--accent, #2563eb); }
.alloc-choice { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .35rem; }
.alloc-choice label.inline { display: inline-flex; gap: .3rem; align-items: center; font-weight: normal; }
.alloc-choice input[type=radio] { width: auto; margin: 0; }
.alloc-choice label.inline { white-space: nowrap; }

/* Alignment reports */
.align-thumb { display: block; max-width: 90px; max-height: 64px; border-radius: 6px; border: 1px solid var(--border); margin-bottom: .25rem; object-fit: cover; }
.align-notes { max-width: 280px; white-space: pre-wrap; font-size: .85rem; }
.align-table .nowrap, .nowrap { white-space: nowrap; }
.chip-hk-alignment::before { background: #14b8a6; }

/* Alignment reports: multi-photo */
.align-thumbs { display:inline-flex; gap:.25rem; align-items:center; text-decoration:none; }
.align-doc { display:inline-flex; align-items:center; justify-content:center; min-width:2.6rem; height:2.6rem; padding:0 .3rem; border:1px solid #cbd5e1; border-radius:6px; font-size:.75rem; font-weight:600; color:#475569; background:#f8fafc; }
.align-doc.big { width:100%; height:8rem; font-size:1.4rem; }
.align-pick { display:flex; gap:.5rem; flex-wrap:wrap; margin:.2rem 0 .4rem; }
.align-pick .btn { cursor:pointer; }
.align-previews { display:flex; flex-wrap:wrap; gap:.5rem; margin:.4rem 0; }
.align-previews .photo-thumb { position:relative; width:5.5rem; height:5.5rem; border:1px solid #cbd5e1; border-radius:6px; overflow:hidden; display:flex; align-items:center; justify-content:center; font-size:.7rem; background:#f8fafc; text-align:center; word-break:break-all; }
.align-previews .photo-thumb img { width:100%; height:100%; object-fit:cover; }
.align-previews .photo-thumb b { position:absolute; left:3px; top:3px; background:rgba(15,23,42,.75); color:#fff; border-radius:4px; padding:0 .3rem; font-size:.7rem; }
.align-previews .photo-thumb button { position:absolute; right:2px; top:2px; border:0; background:rgba(220,38,38,.9); color:#fff; border-radius:50%; width:1.4rem; height:1.4rem; line-height:1; cursor:pointer; }
.align-pages { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:1rem; }
.align-page { margin:0; }
.align-page img { width:100%; border-radius:6px; display:block; }
.align-page iframe { width:100%; height:420px; border:1px solid #e2e8f0; border-radius:6px; }
.align-page figcaption { margin-top:.4rem; font-size:.85rem; display:flex; flex-wrap:wrap; gap:.3rem; align-items:center; }

/* Taxi plates + MOT sheets */
.chip-hk-taxi_plate::before { background: #eab308; }
.chip-hk-mot_sheet::before { background: #6366f1; }
.plate-status, .mot-result { display:inline-block; padding:.1rem .5rem; border-radius:999px; font-size:.75rem; font-weight:600; }
.plate-current { background:#14532d; color:#bbf7d0; }
.plate-expired { background:#7f1d1d; color:#fecaca; }
.plate-replaced { background:#334155; color:#cbd5e1; }
.mot-pass { background:#14532d; color:#bbf7d0; }
.mot-advisories { background:#713f12; color:#fde68a; }
.mot-fail { background:#7f1d1d; color:#fecaca; }
tr.row-muted td { opacity:.65; }
.check-row { display:flex; gap:.5rem; align-items:center; margin-top:.6rem; font-weight:500; }
.check-row input { width:auto; }

/* Clickable dashboard tiles + detail panel */
a.kpi-link { display: block; text-decoration: none; color: inherit; cursor: pointer; transition: transform .08s, box-shadow .08s; }
a.kpi-link:hover { transform: translateY(-1px); box-shadow: 0 2px 10px rgba(0,0,0,.35); }
a.kpi-link.kpi-active { outline: 2px solid #60a5fa; outline-offset: 1px; }
.kpi-sub { margin: .15rem 0 0; font-size: .75rem; opacity: .8; display: flex; justify-content: space-between; gap: .5rem; }
.kpi-caret { font-size: .7rem; }
.kpi-panel { margin-bottom: 1rem; }
.kpi-panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.kpi-panel-head h2 { margin: 0; font-size: 1.1rem; }
.kpi-items { list-style: none; margin: 0; padding: 0; }
.kpi-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem .75rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.kpi-item:first-child { border-top: 0; }
.kpi-item-main { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .6rem; min-width: 0; }
.kpi-item-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.kpi-desc { flex-basis: 100%; font-size: .85rem; opacity: .85; }
@media (max-width: 640px) {
  .kpi-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-item-actions { width: 100%; }
  .kpi-item-actions .btn { flex: 1; text-align: center; }
}


/* ---- CET Vehicle Compliance brand extras ---- */
a.kpi-link { color: inherit; }
a.kpi-link.kpi-active { outline: 2px solid var(--accent); outline-offset: 1px; }
.card { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.table-card .fleet-table thead th:first-child { border-radius: 0; }
.topnav .brand { color: var(--header-fg); font-weight: 800; }
.topnav {
  background: var(--header-bg); border-bottom: 1px solid #65a30d;
}
.topnav a { color: var(--header-fg); }
.topnav a:hover { color: #052e16; }
.topnav .muted, .topnav .topnav-user { color: #3f6212 !important; }
.brand-lockup { display: flex; align-items: center; gap: .65rem; text-decoration: none !important; color: inherit; }
.brand-lockup img { height: 40px; width: auto; display: block; }
.brand-lockup .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-lockup .brand-name { font-size: .78rem; font-weight: 800; color: var(--header-fg); letter-spacing: .02em; }
.brand-lockup .brand-sub { font-size: .68rem; font-weight: 650; color: #3f6212; }
.login-hero {
  background: #111827; border-radius: 10px 10px 0 0; margin: -1rem -1.15rem 1rem;
  padding: 1.25rem 1.15rem; text-align: center; border-bottom: 4px solid var(--accent-lime);
}
.login-hero img { max-width: 260px; width: 100%; height: auto; }
.login-box h1 { color: var(--accent); font-size: 1.25rem; margin: 0 0 .35rem; }
.login-box .login-sub { margin: 0 0 1rem; }
.page-foot {
  margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border);
  font-size: .8rem; color: var(--muted); text-align: center;
}
.nav-report-defect { background: #b91c1c !important; color: #fff !important; font-weight: 700 !important; }
.nav-report-defect:hover { filter: brightness(1.05); color: #fff !important; }
.nav-daily-check { background: var(--accent) !important; color: #fff !important; font-weight: 700 !important; }
.nav-daily-check:hover { filter: brightness(1.05); color: #fff !important; }
.btn-defect { background: #b91c1c !important; }
.btn-daily-check { background: var(--accent) !important; color: #fff !important; }
th { color: var(--muted); }
.fleet-table thead th { color: var(--th-fg); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-lime); outline-offset: 1px; border-color: var(--accent);
}


/* ---- Theme toggle ---- */
.theme-toggle {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 999px; padding: .3rem .65rem; font-size: .78rem; font-weight: 700;
  cursor: pointer; line-height: 1.2; white-space: nowrap;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle-icon::before { content: "☾"; font-size: .95rem; }
html[data-theme="dark"] .theme-toggle-icon::before { content: "☀"; }
.theme-toggle-guest {
  position: fixed; top: .75rem; right: .75rem; z-index: 50;
}
.sidebar-foot {
  flex-wrap: wrap; gap: .5rem; align-items: flex-start;
}
.sidebar-foot-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-left: auto; }
.sidebar-foot-user { min-width: 0; }
.topnav .theme-toggle { order: 9; }

/* ---- Dark theme (CET) ---- */
html[data-theme="dark"] {
  --bg: #0f172a;
  --panel: #111827;
  --panel2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #84cc16;
  --accent-lime: #84cc16;
  --accent-lime-text: #14532d;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --border: #334155;
  --header-bg: #84cc16;
  --header-fg: #14532d;
  --th-bg: #14532d;
  --th-fg: #ffffff;
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] a { color: #a3e635; }
html[data-theme="dark"] a:hover { color: #bef264; }
html[data-theme="dark"] .card { box-shadow: 0 1px 3px rgba(0,0,0,.35); }
html[data-theme="dark"] .sidebar { background: var(--panel); border-right-color: var(--border); }
html[data-theme="dark"] .sidebar-nav a { color: var(--muted); }
html[data-theme="dark"] .sidebar-nav a:hover { background: var(--panel2); color: var(--text); }
html[data-theme="dark"] .sidebar-nav a.active { background: #1a2e05; color: #bef264; }
html[data-theme="dark"] .sidebar-foot { border-top-color: var(--border); }
html[data-theme="dark"] .btn { background: #14532d; color: #fff !important; }
html[data-theme="dark"] .btn.danger { background: #b91c1c; color: #fff !important; }
html[data-theme="dark"] .btn.secondary { background: var(--panel2); color: var(--text) !important; border-color: var(--border); }
html[data-theme="dark"] .btn.lime { background: var(--accent-lime); color: #14532d !important; }
html[data-theme="dark"] .btn-daily-check { background: #14532d !important; color: #fff !important; }
html[data-theme="dark"] .nav-daily-check { background: #14532d !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #0b1220; color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .fleet-table tbody tr:hover { background: #1a2e05; }
html[data-theme="dark"] .kpi-bad { border-color: #b91c1c; background: #3f1212; color: #fecaca; }
html[data-theme="dark"] .kpi-warn { border-color: #a16207; background: #3b2710; color: #fde68a; }
html[data-theme="dark"] .kpi-ok { border-color: #166534; background: #052e16; color: #bbf7d0; }
html[data-theme="dark"] .kpi-neutral { border-color: var(--border); background: var(--panel); color: var(--text); }
html[data-theme="dark"] a.kpi-link.kpi-active { outline-color: #84cc16; }
html[data-theme="dark"] .flash.success { background: #052e16; color: #bbf7d0; border-color: #166534; }
html[data-theme="dark"] .flash.danger { background: #450a0a; color: #fecaca; border-color: #7f1d1d; }
html[data-theme="dark"] .flash.warning,
html[data-theme="dark"] .flash.info { background: #1a2e05; color: #d9f99d; border-color: #3f6212; }
html[data-theme="dark"] .install-hint { background: #1a2e05; border-color: #3f6212; color: #d9f99d; }
html[data-theme="dark"] .sort-btn.active { background: #14532d; color: #fff; }
html[data-theme="dark"] .chip.active,
html[data-theme="dark"] .chip:hover { background: var(--panel2); color: var(--text); }
html[data-theme="dark"] .tyre-groups tr.tg-row.open { background: #1a2e05; }
html[data-theme="dark"] .tyre-groups tr.tg-detail > td { background: #0b1220; }
html[data-theme="dark"] .photo-pick { background: #0b1220; }
html[data-theme="dark"] .photo-thumb { background: var(--panel2); }
html[data-theme="dark"] .topnav a:hover { color: #052e16; }
html[data-theme="dark"] .brand-lockup .brand-sub { color: #3f6212; }
html[data-theme="dark"] .page-foot { color: var(--muted); }
html[data-theme="dark"] .login-box h1 { color: #bef264; }
html[data-theme="dark"] .due-ok { background: #14532d; color: #fff; }
html[data-theme="dark"] .due-missing { background: var(--panel2); color: var(--muted); }
html[data-theme="dark"] .plate-current,
html[data-theme="dark"] .mot-pass { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .plate-expired,
html[data-theme="dark"] .mot-fail { background: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .plate-replaced { background: #334155; color: #cbd5e1; }
html[data-theme="dark"] .mot-advisories { background: #713f12; color: #fde68a; }
html[data-theme="dark"] .align-page iframe { border-color: var(--border); }
html[data-theme="dark"] .fc-active { background: #14532d; color: #fff; }
html[data-theme="dark"] .fc-where .driver-pill { background: #1a2e05; color: #bef264; }
html[data-theme="dark"] .checkgrid label { color: var(--text); }

/* Appointment actions */
.appt-actions { white-space: nowrap; }
.appt-actions .inline-form { margin-left: .25rem; }
.appt-form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.card.danger-zone h2 { color: var(--bad); font-size: 1rem; }

/* Keep Users / bottom admin links readable in dark mode */
html[data-theme="dark"] .sidebar-nav a { color: #cbd5e1; }
html[data-theme="dark"] .sidebar-nav a:hover { color: #f8fafc; }
html[data-theme="dark"] .sidebar-nav {
  padding-bottom: .75rem;
}

/* Service sheet 3-point tread depths */
.tread-block { margin: .4rem 0 1rem; }
.tread-table { width: 100%; max-width: 36rem; border-collapse: collapse; }
.tread-table th, .tread-table td {
  border: 1px solid var(--border);
  padding: .4rem .55rem;
  text-align: center;
  vertical-align: middle;
}
.tread-table thead th {
  background: #14532d;
  color: #fff;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tread-table tbody th {
  text-align: left;
  background: var(--panel2);
  font-weight: 650;
  white-space: nowrap;
}
.tread-table tbody th .muted { font-weight: 500; font-size: .8em; margin-left: .25rem; }
.tread-table input[type="number"] {
  width: 100%;
  max-width: 6.5rem;
  margin: 0;
  text-align: center;
}
.tread-hint { font-size: .82rem; margin: .4rem 0 0; }
.tread-reading {
  display: inline-block;
  min-width: 2.4rem;
  padding: .12rem .4rem;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.tread-warn-low {
  background: #fef3c7;
  color: #92400e;
}
.tread-warn-legal {
  background: #fee2e2;
  color: #991b1b;
  font-weight: 800;
}
html[data-theme="dark"] .tread-table thead th { background: #14532d; color: #fff; }
html[data-theme="dark"] .tread-table th,
html[data-theme="dark"] .tread-table td { border-color: var(--border); }
html[data-theme="dark"] .tread-table tbody th { background: var(--panel2); color: var(--text); }
html[data-theme="dark"] .tread-warn-low { background: #78350f; color: #fde68a; }
html[data-theme="dark"] .tread-warn-legal { background: #7f1d1d; color: #fecaca; }
.svc-print-head { display: none; }
@media (max-width: 700px) {
  .tread-table { max-width: none; }
  .tread-table input[type="number"] { max-width: none; }
}

/* Weekly PDC inspections */
.pdc-result {
  display: inline-block; padding: .12rem .5rem; border-radius: 6px;
  font-size: .78rem; font-weight: 700; text-transform: capitalize;
}
.pdc-result-pass { background: #dcfce7; color: #14532d; }
.pdc-result-advisory { background: #fef3c7; color: #92400e; }
.pdc-result-fail { background: #fee2e2; color: #991b1b; }
.not-fit-badge, .badge.not-fit-badge {
  background: #b91c1c; color: #fff; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; font-size: .72rem; padding: .2rem .55rem; border-radius: 6px;
}
.pdc-notfit-banner { border-color: #b91c1c; }
.pdc-item-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .75rem 1rem; margin: 0 0 .75rem; background: var(--panel);
}
.pdc-item-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.pdc-item-head h3 { margin: 0; font-size: 1rem; }
.pdc-result-radios { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.pdc-radio { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; font-weight: 650; font-size: .85rem; }
.pdc-radio input { width: auto; margin: 0; }
.pdc-radio-pass:has(input:checked) { background: #dcfce7; border-color: #14532d; color: #14532d; }
.pdc-radio-advisory:has(input:checked) { background: #fef3c7; border-color: #92400e; color: #92400e; }
.pdc-radio-fail:has(input:checked) { background: #fee2e2; border-color: #991b1b; color: #991b1b; }
.pdc-declare { display: flex; align-items: flex-start; gap: .5rem; margin: .75rem 0; font-weight: 650; }
.pdc-declare input { width: auto; margin-top: .2rem; }
.pdc-existing-photos { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.pdc-existing-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.pdc-check-table { width: 100%; border-collapse: collapse; }
.pdc-check-table th, .pdc-check-table td { border: 1px solid var(--border); padding: .45rem .6rem; vertical-align: top; }
.pdc-check-table thead th { background: #14532d; color: #fff; font-size: .78rem; text-transform: uppercase; }
.pdc-tyre-table input { max-width: 6rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.pdc-declaration { margin-top: 1rem; padding-top: .5rem; border-top: 1px solid var(--border); }
html[data-theme="dark"] .pdc-result-pass { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .pdc-result-advisory { background: #78350f; color: #fde68a; }
html[data-theme="dark"] .pdc-result-fail { background: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .pdc-item-card { background: var(--panel); }
html[data-theme="dark"] .pdc-radio-pass:has(input:checked) { background: #14532d; color: #bbf7d0; border-color: #84cc16; }
html[data-theme="dark"] .pdc-radio-advisory:has(input:checked) { background: #78350f; color: #fde68a; border-color: #f59e0b; }
html[data-theme="dark"] .pdc-radio-fail:has(input:checked) { background: #7f1d1d; color: #fecaca; border-color: #f87171; }
html[data-theme="dark"] .pdc-check-table thead th { background: #14532d; }
html[data-theme="dark"] .not-fit-badge { background: #7f1d1d; color: #fecaca; }
.users-inspector-yes { color: #14532d; font-weight: 650; }
html[data-theme="dark"] .users-inspector-yes { color: #bbf7d0; }
.user-flag-row { margin-top: .85rem; }
.user-flag-row label { display: flex; align-items: flex-start; gap: .5rem; font-weight: 650; }
.user-flag-row input[type="checkbox"] { width: auto; margin-top: .2rem; flex: none; }
.user-flag-row .muted { margin: .25rem 0 0 1.5rem; font-weight: 400; }
