/* Plain, readable, tablet-friendly. No framework. */
:root {
  --text: #1c1f23;
  --muted: #5f6670;
  --line: #d6d9de;
  --bg: #f4f5f7;
  --card: #ffffff;
  --accent: #1f4e8c;
  --accent-text: #ffffff;
  --danger: #a4262c;
  --green: #1e7b34;
  --green-bg: #e3f3e6;
  --yellow: #8a5a00;
  --yellow-bg: #fff3cd;
  --red: #a4262c;
  --red-bg: #fbe3e4;
  --grey-bg: #eceef1;
  --radius: 6px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h2.flush-top { margin-top: 0; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .6rem 1rem; background: #20252b; color: #fff;
}
.topbar a, .topbar .linkbtn { color: #fff; }
.topbar .muted { color: #b8bfc8; }
.brand { font-weight: 700; text-decoration: none; }
.mainnav { display: flex; gap: 1rem; flex-wrap: wrap; }
.mainnav a { text-decoration: none; padding: .2rem 0; border-bottom: 2px solid transparent; }
.mainnav a[aria-current="page"] { border-bottom-color: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.topbar-menu { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; }
.menu-toggle { display: none; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* Page header: title on the left, actions on the right */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .75rem; margin-bottom: 1rem; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: .5rem; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.card-head .actions { margin-left: auto; display: flex; gap: .35rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  font: inherit; font-size: .95rem; line-height: 1.2; vertical-align: middle;
  padding: .5rem .9rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer;
  min-height: 2.4rem;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn.btn-sm { padding: .25rem .55rem; min-height: 2rem; font-size: .85rem; }
.linkbtn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; cursor: pointer;
}
form.inline { display: inline; margin: 0; }

/* Forms */
.form { max-width: 640px; }
.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field label.check { font-weight: normal; display: flex; gap: .5rem; align-items: center; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search],
input[type=date], input[type=time], input[type=tel],
select, textarea {
  width: 100%; font: inherit; padding: .5rem .6rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; min-height: 2.4rem;
}
textarea { min-height: 5rem; }
.help { display: block; color: var(--muted); margin-top: .2rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.error { display: block; color: var(--danger); margin-top: .2rem; }
.form-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-start; margin-bottom: .9rem; }
.row > .field { flex: 1 1 180px; margin-bottom: 0; }

.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.searchbar input { flex: 1 1 240px; width: auto; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.inactive td { color: var(--muted); background: #f7f7f8; }
td.nowrap, th.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table { border: 0; }

/* Flash messages */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-ok { background: var(--green-bg); border-color: #b6dfbf; }
.flash-error { background: var(--red-bg); border-color: #efb9bc; }
.flash-warn { background: var(--yellow-bg); border-color: #e0c36a; }

/* Inspection status chips: always colour + text, never colour alone. */
.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.st-green { background: var(--green-bg); color: var(--green); }
.st-yellow { background: var(--yellow-bg); color: var(--yellow); }
.st-red { background: var(--red-bg); color: var(--red); }
.st-not_applicable, .st-none { background: var(--grey-bg); color: var(--muted); }

.tag {
  display: inline-block; padding: .05rem .5rem; border-radius: var(--radius);
  font-size: .8rem; border: 1px solid var(--line); background: #fff; white-space: nowrap;
}
.tag-closed, .tag-completed { color: var(--muted); }
.tag-awaiting_approval { border-color: #e0c36a; background: var(--yellow-bg); }
.tag-warn { border-color: #e0c36a; background: var(--yellow-bg); }
.tag-wait { border-color: #9dbbe3; background: #fff; color: var(--accent); }

.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.tabs a { padding: .3rem .7rem; border-radius: var(--radius); text-decoration: none; border: 1px solid var(--line); background: #fff; }
.tabs a[aria-current="page"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.pagination { display: flex; gap: 1rem; margin-top: 1rem; }
.danger-zone { border-color: #efb9bc; }

/* --- Tablet inspection view: big tap targets, works with gloves ----------- */
.concern { background: var(--yellow-bg); border-color: #e0c36a; }
.sync-bar {
  position: sticky; top: 0; z-index: 10; padding: .55rem .9rem; margin-bottom: 1rem;
  border-radius: var(--radius); border: 1px solid; font-weight: 600;
}
.sync-ok { background: var(--green-bg); border-color: #b6dfbf; color: var(--green); }
.sync-busy { background: #e8eef7; border-color: #b9c9e3; color: var(--accent); }
.sync-warn { background: var(--yellow-bg); border-color: #e0c36a; color: var(--yellow); }
.sync-bad { background: var(--red-bg); border-color: #efb9bc; color: var(--red); }
.sync-error { color: var(--red); font-weight: normal; margin-top: .25rem; }

.section-jump { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; }
.section-jump a {
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; text-decoration: none; font-size: .9rem;
}
.insp-section h2 { margin-top: 1.5rem; scroll-margin-top: 4rem; }
.insp-item {
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .75rem; scroll-margin-top: 4rem;
}
.insp-item[data-status="green"] { border-left-color: var(--green); }
.insp-item[data-status="yellow"] { border-left-color: #d9a400; }
.insp-item[data-status="red"] { border-left-color: var(--red); }
.insp-item[data-status="not_applicable"] { border-left-color: var(--muted); }
.insp-item-head h3 { font-size: 1.05rem; margin: 0; }
.insp-item-head p { margin: .15rem 0 0; }

.status-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .75rem 0; }
.status-btn {
  font: inherit; font-weight: 600; min-height: 3.2rem; padding: .4rem;
  border-radius: var(--radius); border: 2px solid var(--line); background: #fff; color: var(--text);
  cursor: pointer; touch-action: manipulation;
}
.status-btn:disabled { cursor: default; opacity: .75; }
.status-btn[aria-pressed="true"]::before { content: "✓ "; }
.st-btn-green[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.st-btn-yellow[aria-pressed="true"] { background: #d9a400; border-color: #d9a400; color: #1c1f23; }
.st-btn-red[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.st-btn-not_applicable[aria-pressed="true"] { background: var(--muted); border-color: var(--muted); color: #fff; }

.measure { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.measure label { font-weight: 600; }
.measure input { width: 7rem; min-height: 2.8rem; font-size: 1.1rem; }
.measure .unit { font-weight: 600; }
.measure .error { flex-basis: 100%; }

details.notes { margin-bottom: .6rem; }
details.notes summary { cursor: pointer; padding: .35rem 0; font-weight: 600; color: var(--accent); }
details.notes label { display: block; font-weight: 600; margin: .4rem 0 .2rem; font-size: .9rem; }
details.notes textarea { min-height: 3.2rem; }

.media-strip { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.media-tile {
  position: relative; margin: 0; width: 96px; height: 96px; border-radius: var(--radius);
  overflow: hidden; background: var(--grey-bg); border: 1px solid var(--line);
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile.pending img { opacity: .6; }
.video-tile {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  font-weight: 600; color: var(--text);
}
.media-tile a { display: block; width: 100%; height: 100%; text-decoration: none; }
.media-progress {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); color: #fff;
  font-size: .75rem; text-align: center; padding: .1rem;
}
.media-remove {
  position: absolute; top: 2px; right: 2px; width: 2rem; height: 2rem; border-radius: 50%;
  border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.media-add { min-height: 3rem; }

.submit-bar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end;
  gap: 1rem; padding: .75rem 1rem; margin: 1rem -1rem 0; background: rgba(244,245,247,.95);
  border-top: 1px solid var(--line);
}
.submit-bar .btn { min-height: 3rem; padding: .5rem 1.5rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* PIN sign-in on shop tablets */
.pin-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin: 1rem 0 1.5rem; }
.pin-tile {
  display: flex; align-items: center; justify-content: center; min-height: 5rem; padding: .75rem;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 1.1rem; font-weight: 600; text-decoration: none; color: var(--text); text-align: center;
}
.pin-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }

/* --- Advisor board ----------------------------------------------------------- */
main.wide { max-width: none; }
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: .75rem;
  overflow-x: auto; padding-bottom: .5rem; align-items: start;
  scroll-snap-type: x proximity;
}
.board-col {
  background: #e9ebef; border-radius: var(--radius); padding: .6rem; min-height: 60vh;
  scroll-snap-align: start;
}
.board-col h2 {
  font-size: .95rem; margin: 0 0 .6rem; display: flex; justify-content: space-between; align-items: center;
}
.board-col .count {
  background: #fff; border-radius: 999px; padding: 0 .55rem; font-size: .85rem; color: var(--muted);
}
.board-empty { text-align: center; }
.board-card {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: var(--radius); padding: .6rem .7rem; margin-bottom: .5rem;
}
.board-card.card-new { border-left-color: var(--green); box-shadow: 0 0 0 2px var(--green-bg); }
.board-card.card-warn { border-left-color: #d9a400; }
.card-link { display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.card-ro { font-weight: 700; }
.card-vehicle { font-size: .92rem; }
.card-customer { font-size: .85rem; }
.card-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .4rem; }
.card-badges .chip { font-size: .75rem; padding: .05rem .45rem; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-top: .45rem; }
.card-age { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.card-age.late { color: var(--red); font-weight: 600; }
#board-status.error { color: var(--red); font-weight: 600; }

/* --- Estimate (staff) ------------------------------------------------------ */
td.num, th.num { text-align: right; }
tfoot td { font-weight: 600; background: #fafbfc; }
.prio-urgent { background: var(--red-bg); color: var(--red); }
.prio-soon { background: var(--yellow-bg); color: var(--yellow); }
.dec-approved { background: var(--green-bg); color: var(--green); }
.dec-declined { background: var(--grey-bg); color: var(--muted); }
.copy-row { display: flex; gap: .5rem; align-items: flex-start; }
.copy-row input, .copy-row textarea { flex: 1; }
details > summary.linkbtn { display: list-item; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Customer report (public, phone first) --------------------------------- */
body.public { background: #fff; }
.public-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 760px; margin: 0 auto; padding: .9rem 1rem; border-bottom: 1px solid var(--line);
}
.shop-logo { max-height: 56px; max-width: 220px; display: block; }
.public-head .btn { white-space: nowrap; }
.public-main { max-width: 760px; padding-top: 1rem; }
/* Forms fill the page like the banner above them (staff forms stay narrower). */
.public-main .form { max-width: none; }
.public-foot { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; border-top: 1px solid var(--line); }
.public-foot > div { margin-top: .25rem; }
/* Brand look (colours and typeface: css/report-status.css). Black like the logo, with the
   shop's colour as a thin accent. Buttons are black here, not the staff pages' blue. */
body.public { --accent: var(--ink); }
.public-head { border-bottom: 4px solid var(--brand, #1f4e79); }
.report-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem;
  padding: 1rem 1.1rem; border-radius: var(--radius); background: var(--ink); color: #fff;
  border-left: 8px solid var(--brand, #1f4e79);
}
.report-hero h1 { font-size: 1.25rem; margin: 0 0 .35rem; }
.report-vehicle { font-size: 1.1rem; font-weight: 600; margin-bottom: .2rem; }
.report-hero .muted { color: #c3c8cf; }
.report-hero .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.report-hero .btn { background: transparent; color: #fff; border-color: #6b727c; }
.report-hero .btn:hover { background: #2a2f37; }
.howto {
  margin: 0 0 1rem; padding: .8rem 1rem .8rem 2.3rem; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--brand, #1f4e79);
}
.howto li { margin: .15rem 0; }
.howto-done { padding-left: 1rem; background: var(--green-bg); border-color: #b9dfc1; border-left-color: var(--green); }
.report-section { margin-top: 1.75rem; }
.report-section > h2 {
  display: flex; align-items: center; gap: .55rem; font-size: 1.1rem; margin: 0 0 .2rem;
  padding-bottom: .45rem; border-bottom: 2px solid var(--ink); color: var(--ink);
}
.section-sub { margin: .4rem 0 .9rem; }
.step {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--brand, #1f4e79); color: #fff;
  font-size: .95rem; letter-spacing: 0;
}
.public-foot { border-top: 3px solid var(--ink); }
.rec { border-left-width: 5px; }
.rec.prio-border-urgent { border-left-color: var(--red); }
.rec.prio-border-soon { border-left-color: #d9a400; }
.rec.is-yes { box-shadow: 0 0 0 2px var(--green); }
.rec.is-no { background: #fafbfc; }
.rec-finding { margin-top: .6rem; padding: .6rem .7rem; border-radius: var(--radius); background: var(--bg); }
.rec-finding-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
.finding-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.finding-note { margin: .4rem 0 0; }
.finding { border-left-width: 5px; }
.finding.st-border-red { border-left-color: var(--red); }
.finding.st-border-yellow { border-left-color: #d9a400; }
.finding.st-border-green { border-left-color: var(--green); }
.answer-left { margin: 0 0 .5rem; font-weight: 600; color: var(--yellow); }
.answer-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 0 -1rem; padding: .6rem 1rem calc(.6rem + env(safe-area-inset-bottom));
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0, 0, 0, .08);
}
.answer-bar .btn { min-height: 2.8rem; padding-inline: 1.2rem; }
.answer-bar.is-hidden { display: none; }
.good-list .ok { color: var(--green); font-weight: 700; }
.other-finding { margin-top: 1rem; }
.other-finding h3 { margin-top: 0; }
.insp-item-head .inline { float: right; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td:last-child, tr.cancelled td:nth-last-child(2) { text-decoration: none; }
.rec, .finding {
  border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .75rem;
  scroll-margin-top: 1rem;
}
.rec h3, .finding h3 { font-size: 1.05rem; margin: .5rem 0 .25rem; }
.rec-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.rec-price { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.rec-details { margin: .25rem 0; }
fieldset.answer { border: 0; padding: 0; margin: .75rem 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
fieldset.answer label {
  display: flex; align-items: center; justify-content: center; gap: .4rem; min-height: 3rem;
  border: 2px solid var(--line); border-radius: var(--radius); font-weight: 600; cursor: pointer;
}
fieldset.answer label:has(input:checked).answer-yes { border-color: var(--green); background: var(--green-bg); color: var(--green); }
fieldset.answer label:has(input:checked).answer-no { border-color: var(--muted); background: var(--grey-bg); }
fieldset.answer:disabled label { cursor: default; opacity: .7; }
.totals { margin-top: 1rem; }
.totals dl { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 0 0 1rem; }
.totals dd { margin: 0; text-align: right; white-space: nowrap; }
.totals .total { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.btn-block { width: 100%; min-height: 3.2rem; font-size: 1.05rem; margin-bottom: .75rem; }
.report-media { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; margin-top: .5rem; }
.report-media img, .report-media video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); display: block; background: #000; }
.good-list { list-style: none; padding: .8rem 1rem; margin: .75rem 0 0; columns: 2 220px; }
.good-list li { padding: .15rem 0; break-inside: avoid; }

/* --- Dashboard --------------------------------------------------------------- */
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.dash-kpi { display: flex; flex-direction: column; gap: .1rem; padding: .9rem 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.dash-kpi-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dash-kpi strong { font-size: 2rem; line-height: 1.15; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; align-items: start; }
.dash-grid .card { margin: 0; }
.dash-grid h2 { margin: 0 0 .8rem; font-size: 1rem; }
/* A thin bar split in parts, a small gap between them; the list under it gives the numbers. */
.dash-split { display: flex; gap: 2px; height: .7rem; margin-bottom: .8rem; }
.dash-seg { flex: 1 0 .5rem; }
.dash-seg:first-child { border-radius: 4px 0 0 4px; }
.dash-seg:last-child { border-radius: 0 4px 4px 0; }
.dash-seg:only-child { border-radius: 4px; }
.dash-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.dash-legend li { display: flex; align-items: center; gap: .5rem; }
.dash-legend-label { flex: 1; }
.dash-key { width: .75rem; height: .75rem; border-radius: 3px; flex: none; }
.k-good { background: #1e7b34; }
.k-bad { background: #b3261e; }
.k-wait { background: #e2a500; }
.k-off { background: #9aa1ab; }
.k-a { background: #1f4e8c; }
.k-b { background: #9dbbe3; }
.dash-bars { display: grid; gap: .45rem; }
.dash-bar-row { display: grid; grid-template-columns: minmax(5.5rem, 46%) 1fr 2.2rem; align-items: center; gap: .6rem; }
.dash-bar-label { overflow-wrap: anywhere; line-height: 1.25; }
.dash-bar-track { height: .6rem; background: var(--grey-bg); border-radius: 4px; }
.dash-bar { display: block; height: 100%; min-width: 2px; background: #1f4e8c; border-radius: 4px; }
.dash-bar-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.dash-facts { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0; }
.dash-facts dt { color: var(--muted); }
.dash-facts dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-empty { text-align: center; padding: 2rem 1rem; }

.booked-for { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .5rem; border-left: 5px solid var(--accent); }
.ready-card { border-left: 5px solid #d9a400; background: var(--yellow-bg); }
.ready-card.ready-done { border-left-color: var(--green); background: var(--green-bg); }
.lang-note { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-top: .2rem; }
.cancel-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 0; }
.cancel-form .check { display: inline-flex; align-items: center; gap: .35rem; font-weight: normal; }

/* --- Notes for the technician ---------------------------------------------- */
.notes-card.has-notes { border-left: 5px solid #d9a400; }
.job-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.job-note p { flex: 1 1 100%; margin: 0; white-space: pre-line; font-weight: 600; }
.concern .job-note:last-child { border-bottom: 0; padding-bottom: 0; }
.notes-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin-top: .7rem; }
.notes-add textarea { flex: 1 1 16rem; }

/* --- Parts ------------------------------------------------------------------- */
.parts-card .table-wrap { margin-bottom: .8rem; }
.parts-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.parts-add label { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; font-weight: 600; color: var(--muted); }
.parts-qty { flex: 0 0 4.5rem; }
.parts-sku { flex: 1 1 9rem; }
.parts-name { flex: 3 1 14rem; }
.parts-add { position: relative; }
.parts-found {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 20; margin-top: .25rem;
  max-height: 18rem; overflow-y: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.parts-pick {
  display: flex; gap: .6rem; width: 100%; text-align: left; font: inherit; cursor: pointer;
  padding: .55rem .75rem; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text);
}
.parts-pick:last-child { border-bottom: 0; }
.parts-pick:hover, .parts-pick.is-on { background: var(--bg); }
.parts-pick .muted { flex: 0 0 7rem; overflow: hidden; text-overflow: ellipsis; }
.parts-none { margin: 0; padding: .55rem .75rem; color: var(--muted); font-size: .9rem; }
.parts-job .card-head { align-items: flex-start; }
.parts-urgent { border-left: 5px solid var(--red); }
.parts-cancelled { background: var(--bg); }
.parts-plain { margin: .2rem 0 0; padding-left: 1.2rem; }
.parts-known { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.parts-known input[name="sku"] { flex: 1 1 8rem; width: auto; }
.parts-known input[name="name"] { flex: 3 1 14rem; width: auto; }
.tag-alert { border-color: #e7a3a6; background: var(--red-bg); color: var(--red); font-weight: 600; }

/* --- Admin section menu ------------------------------------------------------ */
.admin-tabs { display: flex; flex-wrap: wrap; gap: .25rem 1.2rem; margin: 0 0 1.2rem; border-bottom: 1px solid var(--line); }
.admin-tabs a { padding: .45rem 0; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a[aria-current="page"] { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

/* --- Appointments calendar --------------------------------------------------- */
.cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: 1rem; }
.cal-range { display: inline-block; margin: 0 .4rem; }
.cal-range::first-letter, .cal-day h2 a::first-letter { text-transform: uppercase; }
.cal-modes { margin-left: auto; display: flex; gap: .3rem; }
.cal { display: flex; gap: .6rem; align-items: flex-start; }
/* A day column never gets too narrow to read: the week scrolls sideways instead. */
.cal-week { overflow-x: auto; padding: 2px 2px .6rem; }
/* A day with appointments side by side (double bookings) is as many times wider, so each
   card keeps a readable width; --lanes is set on the day by the page. */
.cal-week .cal-day { flex: var(--lanes, 1) 0 calc(var(--lanes, 1) * 136px + 3.5rem); }
.cal-day { flex: 1 1 0; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cal-day h2 {
  display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin: 0;
  padding: .5rem .6rem; font-size: .95rem; border-bottom: 1px solid var(--line);
}
.cal-day h2 a { display: inline-block; color: var(--text); text-decoration: none; }
.cal-day h2 .count { background: var(--grey-bg); border-radius: 999px; padding: 0 .5rem; font-size: .8rem; color: var(--muted); }
.cal-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.cal-today h2 { background: #e8eff8; }
.cal-closed { background: var(--bg); }
/* Each day is a time grid: one row per start time, the hour in the first column. An
   appointment covers every row from its start to its end; overlapping ones sit side by side. */
.cal-grid { display: grid; column-gap: .3rem; padding: 0 .4rem 0 0; }
.cal-time {
  grid-column: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .35rem 0 .3rem; font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums;
  border-top: 1px solid #eceef1;
}
.cal-line { border-top: 1px solid #eceef1; }
.cal-block { display: flex; padding: .2rem 0; min-width: 0; z-index: 1; }
.cal-block .cal-appt { flex: 1; }
/* Side by side (double-booked): tighter, and words break only where they must. */
.cal-lanes .cal-appt { font-size: .78rem; padding: .25rem .35rem; border-left-width: 3px; hyphens: auto; }
.cal-lanes .cal-appt-time { font-size: .72rem; }
.cal-extra { display: flex; flex-direction: column; gap: .25rem; padding: .5rem; border-top: 1px solid var(--line); }
.cal-appt {
  display: flex; flex-direction: column; padding: .35rem .5rem; border-radius: var(--radius);
  background: #e8eff8; border-left: 4px solid var(--accent); color: var(--text); text-decoration: none;
  font-size: .88rem; line-height: 1.3; overflow-wrap: break-word; min-width: 0;
}
.cal-appt-time { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-arrived { background: var(--green-bg); border-left-color: var(--green); }
.cal-cancelled, .cal-no_show { background: var(--grey-bg); border-left-color: var(--line); color: var(--muted); }
.cal-cancelled strong, .cal-no_show strong { text-decoration: line-through; }
.cal-badges { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .15rem; }
.cal-badges:empty { display: none; }
.cal-add {
  padding: 0 .5rem; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-decoration: none; font-size: 1rem; line-height: 1.35;
}
.cal-add:hover { border-color: var(--accent); color: var(--accent); }
.cal-full .cal-add { opacity: .45; }
.cal-day.cal-day-only { max-width: 640px; }
ul.day-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
ul.day-checks li { display: flex; align-items: center; gap: .35rem; }
ul.day-checks label { font-weight: normal; margin: 0; }

/* --- Public booking page ------------------------------------------------------ */
.book-summary { margin-top: .3rem; color: #e6e8eb; line-height: 1.4; }
.book-steps { list-style: none; display: flex; gap: .4rem 1rem; flex-wrap: wrap; margin: 0 0 1.2rem; padding: 0; font-size: .9rem; color: var(--muted); }
.book-steps li { display: flex; align-items: center; gap: .4rem; }
.book-steps .step { width: 1.5rem; height: 1.5rem; font-size: .8rem; background: var(--line); color: var(--text); }
.book-steps .current { color: var(--text); font-weight: 700; }
.book-steps .current .step { background: var(--brand, #1f4e79); color: #fff; }
.book-steps .done .step { background: var(--ink); color: #fff; }
.book-question { font-size: 1.15rem; margin: 1.2rem 0 .7rem; }
.book-choice {
  display: flex; align-items: center; gap: .8rem; padding: 1rem; margin-bottom: .6rem;
  border: 1px solid var(--line); border-left: 5px solid var(--ink); border-radius: var(--radius);
  background: #fff; color: var(--text); text-decoration: none; font-size: 1.05rem;
}
.book-choice:hover { border-color: var(--ink); background: var(--bg); }
.book-choice strong { flex: 1; }
.book-arrow { font-size: 1.5rem; line-height: 1; color: var(--muted); }
.book-day { margin-bottom: 1rem; padding-bottom: .9rem; border-bottom: 1px solid var(--line); }
.book-day h3 { margin: 0 0 .5rem; font-size: 1rem; }
.book-day h3::first-letter { text-transform: uppercase; }
.book-day-empty h3 { color: var(--muted); font-weight: 600; margin-bottom: .1rem; }
.book-day-empty p { margin: 0; }
.book-times { display: flex; flex-wrap: wrap; gap: .5rem; }
.book-time { min-width: 5.5rem; min-height: 2.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.book-time:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.book-paging { display: flex; justify-content: space-between; margin: 1rem 0; }
.book-radio { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; margin-top: .4rem; border: 1px solid var(--line); border-radius: var(--radius); font-weight: normal; cursor: pointer; }
.book-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.book-pair .book-radio { margin-top: 0; }
.book-radio:has(input:checked) { border-color: var(--ink); background: var(--bg); font-weight: 600; }
.book-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.book-card { border-left: 5px solid var(--ink); }
.book-card h2 { margin: 0 0 .4rem; }
.book-when { font-size: 1.1rem; }
.book-when::first-letter { text-transform: uppercase; }
.book-when strong { font-size: 1.5rem; }
.book-cancelled { border-left-color: var(--line); color: var(--muted); }
.book-cancelled h2, .book-cancelled .book-when { text-decoration: line-through; }

/* --- Phones ------------------------------------------------------------------ */
@media (max-width: 640px) {
  .status-buttons { grid-template-columns: repeat(2, 1fr); }
  main { padding: 1rem .75rem 3rem; }
  h1 { font-size: 1.4rem; }

  /* One slim bar; the menu opens under it. */
  .topbar { padding: .5rem .75rem; }
  .menu-toggle {
    display: block; margin-left: auto; padding: .45rem .8rem; font: inherit; font-weight: 600;
    color: #fff; background: transparent; border: 1px solid #5b636d; border-radius: var(--radius);
  }
  .topbar-menu { display: none; flex-basis: 100%; }
  .topbar-menu.open { display: block; padding: .25rem 0 .5rem; }
  .mainnav { flex-direction: column; gap: 0; }
  .mainnav a { padding: .7rem .25rem; border-bottom: 1px solid #343b43; }
  .mainnav a[aria-current="page"] { border-bottom-color: #343b43; font-weight: 700; }
  .mainnav a[aria-current="page"]::before { content: "▸ "; }
  .topbar-right { margin: .6rem 0 0; justify-content: space-between; }

  /* Calendar: days one under the other. */
  .cal { flex-direction: column; align-items: stretch; }
  .cal-week { overflow-x: visible; padding: 0; }
  .cal-week .cal-day { flex: 0 0 auto; }
  /* Phones: a day is as wide as the screen; with three cards side by side, it scrolls. */
  .cal-lanes { overflow-x: auto; }
  .cal-lanes .cal-block { min-width: 132px; }
  .cal-modes { margin-left: 0; }

  /* Board: columns one under the other instead of side by side. */
  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; overflow: visible; }
  .board-col { min-height: 0; }

  /* Tables become one card per row, each value with its column title (static/js/app.js). */
  .table-wrap { border: 0; overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tfoot, .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: .5rem .75rem; margin-bottom: .5rem;
  }
  .table-wrap tr.cancelled { opacity: .7; }
  /* Label floats left, the value (text, chips, buttons) flows on the right. */
  .table-wrap td {
    display: flow-root; border: 0; padding: .2rem 0; text-align: right; overflow-wrap: anywhere;
  }
  .table-wrap td:empty { display: none; }
  .table-wrap td[data-label]::before {
    content: attr(data-label); float: left; max-width: 45%; margin-right: 1rem; text-align: left;
    color: var(--muted); font-size: .85rem; font-weight: 600;
  }
  .table-wrap td .chip { margin: .1rem 0; }
  dl.facts dd { min-width: 0; overflow-wrap: anywhere; }

  /* Board: empty columns shrink to their title. */
  .board-col { padding: .5rem .6rem; }
  .board-col .board-empty { display: none; }
  .board-col h2 { margin-bottom: 0; }
  .board-col h2 + * { margin-top: .6rem; }
  /* The first cell is the row's title: full width, bold, no label. */
  .table-wrap tbody td:first-child { display: block; text-align: left; font-weight: 600; font-size: 1.02rem; }
  .table-wrap tbody td:first-child::before { content: none; }
  .table-wrap td .muted, .table-wrap td .small { font-weight: 400; }
  .table-wrap tfoot tr { display: flex; justify-content: space-between; padding: .3rem .75rem; }
  .table-wrap tfoot td { display: block; padding: 0; }
  .table-wrap td .inline, .table-wrap td .btn { margin-left: .25rem; }

  /* Customer report: the logo gives way to the phone button. */
  .public-head { padding: .6rem .75rem; gap: .75rem; }
  .public-brand { flex: 1; min-width: 0; }
  .public-brand .shop-logo { max-width: 100%; max-height: 44px; }
  .answer-bar { margin: 0 -.75rem; }
  .report-hero { flex-direction: column; gap: .6rem; padding: .85rem; }
  .report-hero .actions { justify-content: flex-start; }
  .report-media { grid-template-columns: repeat(2, 1fr); }
  .submit-bar { margin: 1rem -.75rem 0; padding: .6rem .75rem calc(.6rem + env(safe-area-inset-bottom)); }
}
