:root {
  --bg: #0c1218; --panel: #141c25; --panel2: #1b2531; --line: #263241;
  --text: #eef2f6; --muted: #8e9bab; --gold: #c8a24a; --gold-ink: #1a1405;
  --green: #3fb27f; --red: #e06a5f; --amber: #e3a948; --blue: #5aa2e6;
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; }
body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: 12px 14px; background: var(--panel2); }
button:disabled { opacity: .45; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .04em; color: var(--gold); }
.brand span { color: var(--text); font-weight: 600; }
.status { font-size: 14px; color: var(--green); }
.bell { position: relative; background: none; border: 0; color: var(--text); padding: 8px; min-height: 44px; min-width: 44px; display: flex; align-items: center; justify-content: center; }
.bell[hidden], .bell-n[hidden] { display: none; }
.bell-n { position: absolute; top: 2px; right: 0; background: var(--red); color: #fff; border-radius: 10px; font-size: 12px; font-weight: 800; min-width: 20px; height: 20px; line-height: 20px; padding: 0 5px; text-align: center; }
.status.off { color: var(--red); }
.status.queue { color: var(--amber); }
main { padding: 12px 14px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 6px 0 2px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 10px 0; }
.btn-gold { background: var(--gold); color: var(--gold-ink); font-weight: 700; }
.btn-green { background: var(--green); color: #06180f; font-weight: 700; }
.btn-red { background: #3a1f1f; color: #ffb4ab; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-big { padding: 16px; font-size: 17px; width: 100%; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); color: var(--muted); }
.pill.gold { background: #2a2312; color: var(--gold); }
.pill.green { background: #10291e; color: var(--green); }
.pill.red { background: #331a18; color: var(--red); }
.pill.amber { background: #33270f; color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.job { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin: 10px 0; }
.job.active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.job.done { opacity: .6; }
.job .name { font-weight: 700; font-size: 17px; }
.job .addr { color: var(--muted); font-size: 14px; }
.job .access { margin-top: 6px; font-size: 14px; color: var(--amber); }
.job .acts { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }
.job .acts.two { grid-template-columns: 1fr 1fr; }
.job .acts a { color: var(--text); }
.order { display: flex; flex-direction: column; gap: 4px; }
.order button { padding: 4px 10px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 8px 12px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); font-size: 14px; }
.chip.on { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 700; }
.pick { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.pick input { width: 22px; height: 22px; accent-color: var(--gold); }
.pick .who { flex: 1; }
input[type=date], input[type=time], input[type=email], input[type=number], input[type=password], input[type=text], select, textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--panel); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 6px; z-index: 6; }
.tabs button { background: transparent; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--panel2); color: var(--gold); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 1000; }
.sheet > div { width: 100%; max-width: 640px; margin: 0 auto; background: var(--panel); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet .opts { display: grid; gap: 8px; margin-top: 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom));
  background: var(--panel2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 12px; z-index: 1100; font-size: 14px; }
.breakbar { background: #33270f; color: var(--amber); border-radius: 12px; padding: 10px 12px; margin: 10px 0; display: flex; justify-content: space-between; align-items: center; }
.sticky-foot { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.daynav { margin-bottom: 8px; }
.daynav button { padding: 10px 16px; }

.routebar { border-color: #3a3220; }
#map { height: 320px; border-radius: 12px; margin-top: 10px; background: #1b2531; position: relative; z-index: 0; isolation: isolate; }
.pin { width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: var(--gold-ink); font: 700 13px/28px system-ui, sans-serif;
  text-align: center; border: 2px solid #0c1218; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.pin.done { background: var(--green); color: #06180f; }
.pin.skip { background: var(--red); color: #fff; }
.leg { font-size: 12px; color: var(--muted); margin: -2px 0 6px; }
.leaflet-container { font: 13px system-ui, sans-serif; }
.pin.end { background: #5aa2e6; color: #04121f; }
.endleg { font-size: 12px; color: var(--muted); margin: -4px 0 10px 4px; }

.tabs button { padding: 12px 4px; font-size: 14px; }
.form { display: grid; gap: 6px; }
.form label.small { margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }
.linkbtn { text-align: center; text-decoration: none; padding: 12px; border-radius: 12px; color: var(--text); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.thumb.missing { opacity: .4; }
.pick[data-cid] { cursor: pointer; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.pick select { width: auto; padding: 8px; }
.linky { background: none; padding: 8px 0 0; color: var(--gold); font-size: 14px; font-weight: 600; }
.btn-gold.linkbtn { color: var(--gold-ink); font-weight: 700; }
/* map key, pin states */
.pin.live { background: #5aa2e6; color: #04121f; }
.pin.later { background: #8a6d2a; color: #fff; }
.pin.wait { background: #6b7280; color: #fff; }
.pin.multi { box-shadow: 0 0 0 3px #a78bfa; }
.mapkey { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.mapkey span { display: inline-flex; align-items: center; gap: 5px; }
.mapkey i.pin { width: 12px; height: 12px; display: inline-block; font-size: 0; line-height: 0; }
.lasttime { margin-top: 4px; border-left: 2px solid var(--line); padding-left: 8px; }
/* weather */
.wx { margin-top: 4px; color: var(--muted); }
.wx.warn { color: var(--amber); }
.wx.bad { color: var(--red); font-weight: 700; }
.wxbad { outline: 2px solid var(--red); border-radius: 6px; }
/* week strip */
.week .wkdays { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 8px 0; }
.wkday { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 11px; }
.wkday b { font-size: 17px; }
.wkday.on { border-color: var(--gold); background: #2a2312; }
.wkday.off { opacity: .5; }
.bar { height: 8px; border-radius: 99px; background: var(--panel2); overflow: hidden; display: flex; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--gold); }
.bar.three i.d, .key.d { background: var(--green); }
.bar.three i.b, .key.b { background: var(--gold); }
.bar.three i.o, .key.o { background: #5a6b80; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

/* quotes */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 99px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; margin-left: 2px; }
.qcard .who b { font-size: 16px; }
.qbig { font-size: 26px; font-weight: 800; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

/* move one job */
.movegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.movebtn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 6px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.movebtn b { font-size: 15px; }

/* drag to reorder */
.handle { font-size: 22px; color: var(--muted); padding: 8px 4px 8px 12px; touch-action: none; cursor: grab; user-select: none; }
.job.draggable .name { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.job { transition: transform .15s ease; }
.job.dragging { transition: none; position: relative; z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,.5); border-color: var(--gold); }
body.dragmode { overflow-anchor: none; }
.early { color: var(--red); font-weight: 700; }
/* checklists */
.checklist .chk { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.checklist .chk input { width: 26px; height: 26px; accent-color: var(--gold); }
.chknote { margin: 6px 0 4px; }

/* ---------- patch 21 Nov: alerts, van, SOPs ---------- */
.alertcard { display: block; width: 100%; text-align: left; line-height: 1.5; }
.vandates { margin-top: 8px; display: grid; gap: 6px; }
.sopsteps { padding-left: 22px; margin: 12px 0; }
.sopsteps li { margin: 0 0 12px; }
.sopsteps li b { display: block; }
.sopsteps li div { color: var(--muted); font-size: 15px; }
.sopstop { border-color: var(--gold); color: var(--gold); font-weight: 600; }

/* ---------- desktop: same app, laid out for a big screen ---------- */
.wide-only { display: none; }
@media (min-width: 900px) {
  .wide-only { display: block; }
  body { padding-bottom: 0; }
  body.signed-in { padding-left: 220px; }
  body.signed-in .top { margin-left: -220px; padding-left: 24px; }
  .tabs { top: 0; bottom: 0; right: auto; width: 220px; grid-auto-flow: row; grid-auto-columns: auto; grid-auto-rows: min-content;
    align-content: start; padding: 72px 12px 12px; border-top: 0; border-right: 1px solid var(--line); z-index: 4; }
  .tabs button { text-align: left; padding: 13px 16px; font-size: 16px; }
  main { max-width: 1180px; padding: 20px 32px 48px; }
  h1 { font-size: 26px; }
  .sheet { align-items: center; }
  .sheet > div { border-radius: 18px; max-width: 620px; max-height: 88vh; overflow-y: auto; }
  .toast { bottom: 28px; }
  .sticky-foot { bottom: 0; }
  /* Today: list and map side by side */
  .todaygrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .todaygrid #map { position: sticky; top: 80px; height: calc(100vh - 140px); margin-top: 0; }
  /* lists of cards go two across */
  .cards2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  /* customer page: two columns */
  .cdetail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
}
/* desktop tables */
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.dt th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  padding: 8px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; background: var(--panel); }
table.dt th.on { color: var(--gold); }
table.dt td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.dt tr[data-cid]:hover td { background: var(--panel2); cursor: pointer; }
table.dt td input, table.dt td select { padding: 6px 8px; border-radius: 8px; font-size: 14px; min-width: 110px; }
table.dt .bad { color: var(--amber); font-size: 13px; }
input[type=time] { min-height: 48px; color-scheme: dark; }
input[type=date] { color-scheme: dark; }
.timegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timegrid label { display: block; margin-bottom: 4px; }

/* ---------- desktop week planner (23 Nov) ---------- */
@media (min-width: 900px) {
  main.full { max-width: none; padding-left: 24px; padding-right: 24px; }
  .wtop { gap: 10px; align-items: center; flex-wrap: wrap; }
  .wkname { white-space: nowrap; }
  .wplan { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; margin-top: 12px; align-items: start; }
  .wdue { position: sticky; top: 60px; max-height: calc(100vh - 72px); overflow-y: auto; padding-right: 4px; }
  .wdue input[type=text] { margin: 8px 0; }
  .wboard { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(150px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
  .wcol { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-height: calc(100vh - 190px); display: flex; flex-direction: column; }
  .wcol.today { border-color: var(--gold); }
  .wcol.off { opacity: .45; }
  .wcol.past .wcard { cursor: default; }
  .wcol.dropon { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
  .wlist { flex: 1; }
  .whead { padding: 2px 2px 8px; border-bottom: 1px solid var(--line); }
  .whead .linky { padding: 2px 0; }
  .wcount { font-weight: 700; font-size: 13px; color: var(--muted); }
  .wcount.over { color: var(--amber); }
  .wcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; margin-top: 6px; font-size: 14px; line-height: 1.3; }
  .wcard[draggable=true] { cursor: grab; }
  .wcard[draggable=true]:hover { border-color: var(--gold); }
  .wcard.due { border-left: 3px solid var(--gold); }
  .wcard.done { opacity: .5; }
  .wcard.skipped, .wcard.no_access, .wcard.rain { opacity: .5; border-style: dashed; }
  .wcard.dragging { opacity: .3; }
  .wcard.dropbefore { box-shadow: 0 -3px 0 var(--gold); }
  .wcol.dropend .wlist::after { content: ''; display: block; height: 3px; background: var(--gold); border-radius: 2px; margin-top: 6px; }
  .wempty { padding: 16px 4px; text-align: center; }
}

/* ---------- customer page tabs (23 Nov) ---------- */
.ctabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 0; margin: 14px 0 4px; border-bottom: 1px solid var(--line); }
.ctab { background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); font-weight: 700; padding: 12px 2px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 48px; }
.ctab.on { color: var(--gold); border-bottom-color: var(--gold); }
.cmap { height: 170px; border-radius: 12px; margin-top: 12px; border: 1px solid var(--line); }
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.msgday { align-self: center; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; margin: 8px 0 2px; }
.msg { max-width: 86%; border-radius: 14px; padding: 9px 12px; border: 1px solid var(--line); }
.msg.out { align-self: flex-end; background: #2a2412; border-color: #4a3d18; border-bottom-right-radius: 4px; }
.msg.in { align-self: flex-start; background: var(--panel2); border-bottom-left-radius: 4px; }
.mbody { white-space: normal; line-height: 1.4; }
.mmeta { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (min-width: 900px) { .thread, .ctabs ~ .btn-gold { max-width: 760px; } }

/* ---------- capacity (23 Nov) ---------- */
table.cap td.capcell { text-align: center; font-weight: 700; cursor: pointer; border-radius: 6px; }
table.cap td.capcell.over { background: rgba(240, 160, 40, .22); color: var(--amber); }
table.cap td.capcell.full { background: rgba(200, 162, 74, .14); color: var(--gold); }
table.cap td.capcell.empty { color: var(--muted); font-weight: 400; }
table.cap .bar { margin-top: 4px; }

/* How to */
details.how{border-bottom:1px solid var(--line)}details.how:last-child{border-bottom:0}details.how summary{padding:14px;cursor:pointer;list-style:none}details.how summary::-webkit-details-marker{display:none}details.how summary::after{content:'›';float:right;color:var(--muted)}details.how[open] summary::after{content:'⌄'}
.ovtile { text-align:left; color:var(--text); font:inherit; cursor:pointer; }
.ovtile.warn b { color:var(--amber); }
.ovbar { flex:1; height:8px; background:var(--panel2); border-radius:4px; overflow:hidden; margin:0 10px; }
.ovbar i { display:block; height:100%; background:var(--gold); }
button.pick { background:none; border:0; border-bottom:1px solid var(--line); color:var(--text); font:inherit; text-align:left; }
.fileic { display:inline-flex; align-items:center; justify-content:center; width:52px; height:52px; border-radius:10px; background:var(--panel2); color:var(--gold); font-weight:700; font-size:12px; flex:none; cursor:pointer; }
.pick .thumb { width:52px; height:52px; object-fit:cover; border-radius:10px; flex:none; cursor:pointer; }
.pick .who[data-cfopen] { cursor:pointer; }

/* 28 Nov: every map keeps its layers to itself, so sheets and toasts always sit on top */
.leaflet-container { position: relative; z-index: 0; isolation: isolate; }

/* 28 Nov: More split into headings. Phone: one More tab with every heading on it. Computer: each heading in the side bar. */

body:not(.is-owner) .tabs button.owneronly { display: none !important; }
@media (min-width: 900px) { .tabs button.deskonly { display: block; } }
.moregrp { margin: 16px 0 4px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }

/* 28 Nov (Kieron): on the phone, a ☰ menu like Squeegee's instead of the bottom bar. Same buttons as the computer's side bar,
   plus each heading's pages underneath. */
.menubtn { display: none; background: none; border: 0; color: var(--text); padding: 6px; margin-left: -6px; }
body.signed-in .menubtn { display: inline-flex; }
.navshade { display: none; }
.navsub { display: flex; flex-direction: column; }
.navsub button { text-align: left; background: transparent; color: var(--muted); font-weight: 500; padding: 9px 18px 9px 36px; font-size: 15px; }
.navsub button.on { color: var(--gold); }
@media (max-width: 899px) {
  .tabs { top: 0; bottom: 0; left: 0; right: auto; width: min(320px, 86vw); display: flex; flex-direction: column; overflow-y: auto; z-index: 900;
          transform: translateX(-105%); transition: transform .2s ease; padding: calc(10px + env(safe-area-inset-top)) 0 calc(16px + env(safe-area-inset-bottom)); box-shadow: 4px 0 24px rgba(0,0,0,.4); }
  .notrans .tabs { transition: none; }
  body.menu-open .tabs { transform: none; }
  .tabs button { text-align: left; padding: 14px 18px; font-size: 17px; border-radius: 0; }
  .tabs button[data-grp] { margin-top: 10px; padding: 12px 18px 6px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); border-top: 1px solid var(--line, rgba(255,255,255,.08)); }
  .tabs .navsub button { padding: 10px 18px 10px 30px; font-size: 16px; font-weight: 500; color: var(--text, #e8edf2); }
  .tabs .navsub button.on { color: var(--gold); background: rgba(255,255,255,.05); }
  body.menu-open .navshade { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 890; }
}
@media (min-width: 900px) { .navsub { display: none; } body.signed-in .menubtn { display: none; } }
