:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #131a24;
  --muted: #6b7787;
  --line: #e5e8ec;
  --brand: #1d4ed8;
  --brand-soft: #eaf0ff;
  --green: #10794a;
  --green-soft: #e3f5ec;
  --amber: #a45c07;
  --amber-soft: #fdf1dd;
  --red: #b42318;
  --red-soft: #fdeceb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px -12px rgba(16,24,40,.18);
}
/* Dark colours: used when the system asks for them, unless light was chosen
   by hand, and always when dark was chosen by hand. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151c; --panel: #171e27; --ink: #e8ecf2; --muted: #96a2b3; --line: #26303c;
    --brand: #7ea2ff; --brand-soft: #1c2740; --green: #4ade9a; --green-soft: #15302a;
    --amber: #f0b357; --amber-soft: #302713; --red: #ff8a80; --red-soft: #341c1c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  --bg: #10151c; --panel: #171e27; --ink: #e8ecf2; --muted: #96a2b3; --line: #26303c;
  --brand: #7ea2ff; --brand-soft: #1c2740; --green: #4ade9a; --green-soft: #15302a;
  --amber: #f0b357; --amber-soft: #302713; --red: #ff8a80; --red-soft: #341c1c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -14px rgba(0,0,0,.7);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
a { color: var(--brand); }
button { font: inherit; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }

.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 600; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.link { background: none; color: var(--brand); padding: 4px; border: 0; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; background: var(--line); color: var(--muted);
}
.badge.available { background: var(--green-soft); color: var(--green); }
.badge.inuse { background: var(--amber-soft); color: var(--amber); }
.badge.reserved { background: var(--brand-soft); color: var(--brand); }
.badge.overdue { background: var(--red-soft); color: var(--red); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; font-size: 20px; }
.brandmark .glyph { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 18px; }
.login-card p.help { color: var(--muted); margin: 6px 0 22px; }
.notice { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.notice.error { background: var(--red-soft); color: var(--red); }
.notice.info { background: var(--brand-soft); color: var(--brand); word-break: break-all; }

/* ---------- shell ---------- */
header.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
}
header.topbar nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
nav .tab { background: none; border: 0; padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
nav .tab.active { background: var(--brand-soft); color: var(--brand); }
.topbar .spacer { flex: 1; }
.lang-select { width: auto; padding: 8px 10px; border-radius: 9px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; cursor: pointer; border: 0; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.02em; }
.page-head .spacer { flex: 1; }

/* ---------- cars ---------- */
.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.car-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.car-photo { cursor: pointer; height: 150px; overflow: hidden; background: linear-gradient(135deg, var(--brand-soft), var(--line)); display: grid; place-items: center; font-size: 42px; color: var(--muted); }
.car-photo img { width: 100%; height: 150px; object-fit: cover; display: block; transition: transform .25s ease; }
.car-photo:hover img { transform: scale(1.03); }
.car-photo:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.car-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.car-title { display: flex; align-items: start; gap: 8px; }
.car-title h3 { font-size: 17px; }
.car-title .plate { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.meta { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; flex-wrap: wrap; }

/* ---------- lists ---------- */
.list { display: grid; gap: 10px; }
.item {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
}
.item .grow { flex: 1; min-width: 210px; }
.item h4 { margin: 0 0 2px; font-size: 15px; }
.item .sub { font-size: 13px; color: var(--muted); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 10px; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(14,20,28,.55); display: grid; place-items: center; padding: 18px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); width: 100%; max-width: 540px; margin: auto; }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); border-radius: 18px 18px 0 0; }
.modal-head h2 { font-size: 18px; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.icon-btn { background: none; border: 0; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px 8px; }

.checklist { display: grid; gap: 6px; max-height: 230px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.checklist label { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); font-size: 14px; margin: 0; padding: 4px; cursor: pointer; }
.checklist input { width: auto; }

.comment { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.comment .who { font-size: 12px; color: var(--muted); }
.comment.issue { border-color: var(--red); }
.photo-preview { width: 100%; height: 160px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }

table.people { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.people th, table.people td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
table.people th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
table.people tr:last-child td { border-bottom: 0; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 14px; z-index: 100; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.error { background: var(--red); color: #fff; }

@media (max-width: 620px) {
  header.topbar { flex-wrap: wrap; padding: 10px 14px; }
  header.topbar nav { order: 3; width: 100%; margin-left: 0; }
  nav .tab { flex: 1; text-align: center; padding: 8px 6px; font-size: 14px; }
  main { padding: 18px 14px 70px; }
  .row { grid-template-columns: 1fr; }
}

/* ---------- calendar ---------- */
:root { --cal-head: #5a6bb0; --busy: #dd7a22; --mine: #0f9b8e; --sel: #4f6bd8; --done: #98a2b1; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cal-head: #3c4a80; --busy: #c96a19; --mine: #12897f; --sel: #4f6bd8; --done: #5b6675; }
}
:root[data-theme="dark"] { --cal-head: #3c4a80; --busy: #c96a19; --mine: #12897f; --sel: #4f6bd8; --done: #5b6675; }
.cal-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; color: var(--muted); font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.segmented button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.12); }
.cal-datewrap { position: relative; display: inline-flex; }
button.cal-date { font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); background: none;
  border: 1px solid transparent; border-radius: 9px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
button.cal-date:hover { background: var(--brand-soft); color: var(--brand); }
.cal-datewrap input[type="date"] { position: absolute; left: 0; bottom: 0; width: 100%; opacity: 0; pointer-events: none; }
.cal-datewrap.picking input[type="date"] { position: static; opacity: 1; pointer-events: auto; width: auto; }
.cal-datewrap.picking .cal-date { display: none; }

.cal-scroll { overflow-x: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); }
/* The full day (00-24) always fits; only a very narrow window scrolls sideways. */
.cal-day, .cal-week { min-width: 700px; }
.cal { user-select: none; }
.cal-day .cal-head { display: grid; grid-template-columns: 160px 1fr; background: var(--cal-head); color: #fff; }
.cal-corner { position: sticky; left: 0; z-index: 4; background: var(--cal-head); padding: 12px 14px; font-weight: 700; font-size: 14px; }
.cal-hourhead { display: grid; }
.cal-hourcell { padding: 11px 0; text-align: center; font-size: 11.5px; font-weight: 700; border-left: 1px solid rgba(255,255,255,.22); }
.cal-row { display: grid; grid-template-columns: 160px 1fr; border-bottom: 1px solid var(--line); }
.cal-row:last-child { border-bottom: 0; }
.cal-rowlabel { position: sticky; left: 0; z-index: 3; background: var(--panel); border-right: 1px solid var(--line); padding: 10px 14px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.cal-rowlabel b { font-size: 14px; }
.cal-rowlabel span { font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.cal-track { position: relative; display: grid; touch-action: pan-y; cursor: crosshair; }
.cal-day .cal-track { height: 58px; }
.cal-track.y { touch-action: pan-x; }
.cal-slot { border-left: 1px solid var(--line); }
.cal-slot.half { border-left-color: color-mix(in srgb, var(--line) 45%, transparent); }
.cal-track.y .cal-slot { border-left: 0; border-top: 1px solid var(--line); }
.cal-track.y.today { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }

.cal-ev { position: absolute; border-radius: 7px; padding: 3px 6px; background: var(--busy); color: #fff;
  overflow: hidden; font-size: 12.5px; line-height: 1.3; cursor: pointer; box-shadow: 0 1px 2px rgba(16,24,40,.25); }
.cal-day .cal-ev { top: 5px; bottom: 5px; font-size: 11.5px; }
.cal-week .cal-ev { min-height: 18px; }
.cal-ev.mine { background: var(--mine); }
.cal-ev.overdue { background: var(--red); }
.cal-ev.done { background: var(--done); }
.cal-ev.sel { background: var(--sel); opacity: .9; pointer-events: none; }
.cal-ev.dragging { opacity: .85; box-shadow: 0 6px 18px rgba(16,24,40,.35); z-index: 5; }
.cal-ev[data-move="1"] { cursor: grab; }
.cal-ev-text { display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-ev-text span { opacity: .85; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-handle { position: absolute; }
.cal-ev-handle.x { top: 0; right: 0; width: 8px; height: 100%; cursor: ew-resize; }
.cal-ev-handle.y { left: 0; bottom: 0; height: 8px; width: 100%; cursor: ns-resize; }
.cal-now { position: absolute; background: var(--red); z-index: 4; pointer-events: none; }
.cal-now.x { top: 0; bottom: 0; width: 2px; }
.cal-now.y { left: 0; right: 0; height: 2px; }

.cal-weekhead { display: grid; grid-template-columns: 56px repeat(7, 1fr); background: var(--cal-head); color: #fff; }
.cal-dayhead { padding: 10px 4px; text-align: center; font-size: 12px; border-left: 1px solid rgba(255,255,255,.22); cursor: pointer; }
.cal-dayhead b { display: block; font-size: 17px; }
.cal-dayhead.today b { background: #fff; color: var(--cal-head); border-radius: 999px; width: 26px; height: 26px; line-height: 26px; margin: 2px auto 0; }
/* 24 equal hour rows sized to the window, so a whole day is visible at once. */
.cal-weekbody { display: grid; grid-template-columns: 56px repeat(7, 1fr);
  height: clamp(430px, calc(100vh - 310px), 820px); overflow: hidden; }
.cal-gutter { display: grid; }
.cal-guttercell { position: relative; border-top: 1px solid var(--line); }
.cal-guttercell span { position: absolute; top: -7px; right: 7px; font-size: 10.5px; color: var(--muted); background: var(--panel); padding: 0 2px; }
.cal-guttercell:first-child span { top: 0; }
.cal-weekbody.sparse .cal-guttercell:nth-child(even) span { display: none; }
.cal-weekbody.sparse .cal-track.y .cal-slot:nth-child(even) { border-top-color: color-mix(in srgb, var(--line) 45%, transparent); }
.cal-weekbody .cal-track { border-left: 1px solid var(--line); }

.cal-month { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.cal-monthnames { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--cal-head); color: #fff; }
.cal-monthname { padding: 10px 6px; text-align: center; font-size: 12px; font-weight: 700; }
.cal-monthgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-monthcell { min-height: 104px; min-width: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 3px; cursor: copy; overflow: hidden; }
.cal-monthcell.weekend { background: color-mix(in srgb, var(--brand-soft) 40%, transparent); }
.cal-monthcell.weekend.other { background: color-mix(in srgb, var(--brand-soft) 22%, transparent); }
.cal-monthname.weekend { background: rgba(255,255,255,.12); }
.cal-monthcell.other { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.cal-monthcell.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-monthcell:nth-child(7n) { border-right: 0; }
.cal-monthday { align-self: flex-start; background: none; border: 0; color: var(--muted); font-weight: 700; font-size: 12px; cursor: pointer; padding: 2px 5px; border-radius: 6px; }
.cal-monthday:hover { background: var(--brand-soft); color: var(--brand); }
.cal-chip { background: var(--busy); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: 11.5px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cal-chip.mine { background: var(--mine); }
.cal-chip.overdue { background: var(--red); }
.cal-chip.done { background: var(--done); }
.cal-chip span { font-weight: 700; }
.cal-more { font-size: 11px; color: var(--muted); cursor: pointer; padding-left: 4px; }

.cal-legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 4px 0; font-size: 13px; color: var(--muted); }
.cal-legend .sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; vertical-align: -2px; margin-right: 6px; border: 1px solid var(--line); }
.cal-legend .sw.free { background: var(--panel); }
.cal-legend .sw.busy { background: var(--busy); border-color: transparent; }
.cal-legend .sw.mine { background: var(--mine); border-color: transparent; }
.cal-legend .sw.overdue { background: var(--red); border-color: transparent; }
.cal-legend .sw.done { background: var(--done); border-color: transparent; }
.cal-legend .cal-hint { margin-left: auto; font-style: italic; }

@media (max-width: 620px) {
  .cal-day .cal-head, .cal-row { grid-template-columns: 120px 1fr; }
  .cal-monthcell { min-height: 78px; font-size: 11px; }
  .cal-legend .cal-hint { display: none; }
  .cal-date { min-width: 0; }
}
.cal-nav { display: flex; align-items: center; gap: 8px; }

/* compact day-grid, used for one car's availability inside the car modal */
.section-title.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cal-mininav { display: flex; gap: 4px; text-transform: none; letter-spacing: 0; }
.cal-compact { min-width: 560px; }
.cal-compact .cal-head, .cal-compact .cal-row { grid-template-columns: 96px 1fr; }
.cal-compact .cal-corner { padding: 8px 10px; font-size: 12px; }
.cal-compact .cal-hourcell { padding: 8px 0; font-size: 10.5px; }
.cal-compact .cal-rowlabel { padding: 6px 10px; flex-direction: row; align-items: baseline; gap: 5px; white-space: nowrap; }
.cal-compact .cal-rowlabel b { font-size: 13px; }
.cal-compact .cal-rowlabel.today b { color: var(--brand); }
.cal-compact.cal-day .cal-track { height: 40px; }
.cal-compact .cal-ev { top: 4px; bottom: 4px; padding: 2px 5px; font-size: 11px; }
.cal-compact .cal-ev-text span { display: none; }
.cal-monthgrid { touch-action: pan-y; }
.cal-monthcell.selecting { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }

/* ---------- share-my-location field + driver log ---------- */
.loc-row { display: flex; gap: 8px; align-items: center; }
.loc-row input { flex: 1; }
.loc-row .btn { white-space: nowrap; }
.loc-status { font-size: 12.5px; color: var(--muted); margin-top: 6px; min-height: 16px; }
.loc-status a { font-weight: 600; }

.legs { display: grid; gap: 8px; margin-bottom: 6px; }
.leg { border-left: 3px solid var(--mine); padding: 4px 0 4px 12px; }
.leg.parked { border-left-color: var(--line); }
.leg.live { border-left-color: var(--busy); }
.leg-time { font-size: 12px; color: var(--muted); }
.leg-who { font-size: 14px; }
.leg-note { font-size: 13px; color: var(--muted); font-style: italic; }
@media (max-width: 620px) {
  .loc-row { flex-wrap: wrap; }
  .loc-row input { flex: 1 1 100%; }
}
.muted-tag { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }

/* ---------- one-click driver switch ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip-btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip-btn:hover { border-color: var(--brand); color: var(--brand); }
.chip-btn.on { background: var(--mine); border-color: transparent; color: #fff; }
.chip-btn.park.on { background: var(--done); }

/* ---------- driving-time editor (drag the blocks, Toggl style) ---------- */
.legcal-wrap { margin-bottom: 8px; }
.legcal { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); user-select: none; }
.legcal-row { display: grid; grid-template-columns: 62px 1fr; border-top: 1px solid var(--line); }
.legcal-row:first-child { border-top: 0; }
.legcal-head { background: var(--bg); }
.legcal-label { padding: 6px 8px; font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; }
.legcal-hours { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 9.5px; color: var(--muted); }
.legcal-hours span { text-align: center; padding: 5px 0; border-left: 1px solid var(--line); }
.legcal-track { position: relative; display: grid; grid-template-columns: repeat(24, 1fr); height: 40px; touch-action: pan-y; }
.legcal-slot { border-left: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.legcal-slot.mark { border-left-color: var(--line); }
.legcal-leg { position: absolute; top: 5px; bottom: 5px; border-radius: 7px; cursor: grab;
  background: hsl(var(--hue) 55% 42%); color: #fff; font-size: 11.5px; font-weight: 600;
  display: flex; align-items: center; padding: 0 6px; overflow: hidden; white-space: nowrap; }
.legcal-leg.open { background: repeating-linear-gradient(45deg,
  hsl(var(--hue) 55% 42%), hsl(var(--hue) 55% 42%) 6px, hsl(var(--hue) 55% 36%) 6px, hsl(var(--hue) 55% 36%) 12px); }
.legcal-leg.pending { outline: 2px dashed var(--amber); outline-offset: -2px; }
.legcal-leg.dragging { opacity: .9; box-shadow: 0 4px 14px rgba(16,24,40,.35); z-index: 3; cursor: grabbing; }
.legcal-name { pointer-events: none; overflow: hidden; text-overflow: ellipsis; }
.legcal-h { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; }
.legcal-h.l { left: 0; } .legcal-h.r { right: 0; }
.legcal-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); pointer-events: none; }
.legcal-hint { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 6px; }
.leg-pending { font-size: 12.5px; color: var(--amber); background: var(--amber-soft); border-radius: 8px;
  padding: 6px 8px; margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.leg-decide { display: flex; gap: 6px; margin-left: auto; }
.legcal-leg.blank { background: transparent; border: 2px dashed hsl(var(--hue) 45% 55%); color: var(--ink); }
.legcal-label.today { color: var(--brand); }
.legcal-zoom { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.legcal-zoom:hover { color: var(--brand); }
/* a band along the edge of a booking: who actually drove which part */
.cal-stint { position: absolute; z-index: 2; background: hsl(var(--hue) 70% 55%); cursor: help;
  box-shadow: inset -1px 0 0 rgba(255,255,255,.65); }
.cal-stint:hover { filter: brightness(1.25); }
.cal-stint.x { bottom: 0; height: 5px; }
.cal-stint.y { right: 0; width: 5px; box-shadow: inset 0 -1px 0 rgba(255,255,255,.65); }
.cal-ev .cal-ev-text { position: relative; z-index: 1; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.legcal-leg.ghost { background: var(--sel); opacity: .85; pointer-events: none; }
.legcal-track { cursor: crosshair; }

/* the × that drops a booking straight from the planning */
.cal-ev-del { position: absolute; top: 2px; right: 2px; z-index: 3; width: 18px; height: 18px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 13px; line-height: 1;
  cursor: pointer; opacity: 0; transition: opacity .12s; padding: 0; }
.cal-ev:hover .cal-ev-del, .cal-ev-del:focus-visible { opacity: 1; }
.cal-ev-del:hover { background: var(--red); }
@media (hover: none) { .cal-ev-del { opacity: .85; } }
.car-now { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px;
  background: var(--amber-soft); color: var(--amber); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.car-now.parked { background: var(--bg); color: var(--muted); }
.car-now .btn { margin-left: auto; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.muted-tag.danger { color: var(--red); background: var(--red-soft); border-color: transparent; }
.access-banner { max-width: 1100px; margin: 14px auto -6px; padding: 10px 14px; border-radius: 10px;
  background: var(--amber-soft); color: var(--amber); font-size: 14px; font-weight: 600; }
.access-banner.urgent { background: var(--red-soft); color: var(--red); }
.table-scroll { overflow-x: auto; }
.table-scroll .people { min-width: 640px; }

/* ---------- theme switch ---------- */
.theme-btn { font-size: 17px; line-height: 1; padding: 6px 8px; border-radius: 9px; cursor: pointer; }
.theme-btn:hover { background: var(--brand-soft); }
.login-theme { position: absolute; top: 10px; right: 10px; }
.login-card { position: relative; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  header.topbar { gap: 8px; padding: 10px 12px; }
  header.topbar .brandmark { font-size: 16px; gap: 8px; }
  header.topbar .brandmark .glyph { width: 30px; height: 30px; font-size: 16px; }
  .lang-select { padding: 7px 6px; font-size: 13px; max-width: 118px; }
  .avatar { width: 32px; height: 32px; }

  /* the planning toolbar, stacked instead of squeezed */
  .page-head.cal-toolbar { gap: 8px; }
  .page-head.cal-toolbar h1 { width: 100%; font-size: 20px; margin-bottom: 2px; }
  .cal-toolbar .segmented { width: 100%; }
  .cal-toolbar .segmented button { flex: 1; padding: 9px 4px; }
  .cal-nav { width: 100%; }
  .cal-nav .cal-datewrap { flex: 1; }
  .cal-nav button.cal-date { width: 100%; text-align: left; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; }

  /* On a small screen the blocks are too narrow for a cross that covers them:
     open the booking and cancel it there instead. */
  .cal-ev-del { display: none; }
  .cal-toolbar .spacer { display: none; }
  .cal-toolbar select.lang-select { flex: 1; max-width: none; }
  .cal-toolbar > .btn { width: 100%; }

  /* modals behave like a sheet: full width, own scroll, footer in reach */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: 100%; max-height: 94dvh; display: flex; flex-direction: column;
    border-radius: 18px 18px 0 0; margin: 0; }
  .modal-head { border-radius: 18px 18px 0 0; }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-foot { position: sticky; bottom: 0; background: var(--panel); }
  .modal-foot .btn { flex: 1 1 40%; }

  /* comfortable thumbs */
  .btn.sm { padding: 9px 12px; }
  .cal-ev-del { width: 24px; height: 24px; font-size: 16px; }
  .chip-btn { padding: 9px 14px; }
  .row-actions { justify-content: flex-start; }
  .car-now { font-size: 13px; }
  .car-now .btn { margin-left: 0; }

  /* nothing may push the page sideways */
  main, .page-head, .item, .car-card { max-width: 100%; }
  .item { gap: 10px; }
  .item .grow { min-width: 0; }
}

@media (max-width: 400px) {
  header.topbar .brandmark span:not(.glyph) { display: none; }   /* icon only */
  .lang-select { max-width: 96px; }
}
