:root {
  --navy: #111c2d;
  --gold: #d7b36a;
  --bg: #f3f5f8;
  --ink: #17202b;
  --muted: #667085;
  --line: #e1e6ed;
  --white: #fff;
  --green: #16794b;
  --red: #b42318;
  --amber: #855800;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: var(--safe-bottom);
}
.topbar {
  background: var(--navy); color: #fff;
  padding: calc(14px + var(--safe-top)) max(16px, calc((100vw - 1080px) / 2)) 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 3px solid var(--gold);
}
.brand { font-weight: 900; letter-spacing: 1.4px; font-size: 20px; }
.brand span { color: var(--gold); }
.tag { font-size: 11px; color: #cbd2dc; letter-spacing: .7px; }
main { max-width: 1080px; margin: 20px auto; padding: 0 14px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; box-shadow: 0 5px 18px #18223008; margin-bottom: 14px; }
.card.narrow { max-width: 460px; margin: 30px auto; }
#authForm { display: grid; gap: 14px; }
#authForm .actions { margin-top: 4px; }
#authForm .check.remember { padding: 0; align-self: start; font-weight: 600; }
#authForm .check.remember input { width: 20px; height: 20px; }
#authForm .remember-hint { margin: -8px 0 0; }
h1 { font-size: 23px; margin: 0 0 5px; }
h2 { font-size: 18px; margin: 0 0 10px; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.hidden { display: none !important; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
button { border: 0; border-radius: 10px; padding: 11px 14px; font: inherit; font-weight: 700; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .swipe-track:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.tab { background: #e7ebf1; color: #344054; }
.tab.active, button.primary { background: var(--navy); color: #fff; }
button.gold { background: var(--gold); color: var(--navy); }
button.secondary { background: #edf1f5; color: #273444; }
button.danger { background: #fdecea; color: var(--red); }
button.link { background: none; color: var(--navy); text-decoration: underline; padding: 11px 4px; font-weight: 600; }
button.small { padding: 6px 10px; font-size: 12px; }
button:disabled { opacity: .55; cursor: not-allowed; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 200px; }
.full { grid-column: 1 / -1; }
label, .label { font-size: 13px; font-weight: 700; color: #344054; }
input, select, textarea {
  width: 100%; border: 1px solid #d0d7e0; border-radius: 9px; padding: 11px 12px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming into fields */
  color: var(--ink); background: #fff;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); background: #fff7f6; }
textarea { min-height: 85px; resize: vertical; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radio { display: flex; gap: 7px; align-items: center; border: 1px solid var(--line); padding: 9px 12px; border-radius: 9px; font-weight: 500; }
.radio input, .check input { width: auto; }
.check { display: flex; gap: 7px; align-items: center; font-weight: 600; align-self: end; padding-bottom: 12px; }
.calc { font-weight: 800; background: #f5f7fa; padding: 11px; border-radius: 9px; }
.calc.bad { color: var(--red); background: #fff0ef; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 17px; align-items: center; }
.topline { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }

.status { margin-top: 12px; padding: 10px 12px; border-radius: 9px; font-size: 13px; }
.status.ok { background: #eaf7ef; color: #16633f; }
.status.err { background: #fff0ef; color: #a52218; }
.status.info { background: #eef3fb; color: #22406e; }

.queue-banner { background: #fff2d7; color: var(--amber); padding: 10px max(16px, calc((100vw - 1080px) / 2)); display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.toolbar .field { flex: 0 1 150px; }
.toolbar .field.grow { flex: 1 1 200px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 0 0 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.stat small { color: var(--muted); }
.stat strong { display: block; font-size: 20px; margin-top: 4px; font-variant-numeric: tabular-nums; }

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 820px; }
table.compact { min-width: 520px; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th { background: #f8fafc; color: #526071; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tr.voided td { color: #98a2b3; text-decoration: line-through; }
tr.voided td:last-child, tr.voided td:first-child { text-decoration: none; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 8px; background: #eaf7ef; color: #16633f; font-weight: 800; font-size: 11px; }
.pill.pending { background: #fff2d7; color: var(--amber); }
.pill.void { background: #f2f4f7; color: #475467; }
.pill.queued { background: #eef3fb; color: #22406e; }
.empty { padding: 25px; text-align: center; color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.report-list { display: grid; gap: 10px; }
.report-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.report-item .head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }

.inline-form { display: flex; gap: 10px; align-items: end; margin-bottom: 12px; flex-wrap: wrap; }

.swipe-wrap { margin-top: 18px; display: grid; gap: 6px; }
.swipe-track { height: 58px; border-radius: 999px; background: #e9edf2; border: 1px solid #d6dde6; position: relative; display: flex; align-items: center; padding: 5px; user-select: none; -webkit-user-select: none; touch-action: pan-y; overflow: hidden; }
.swipe-track .swipe-label { position: absolute; left: 72px; right: 16px; text-align: center; font-size: 13px; font-weight: 800; color: #596579; pointer-events: none; }
.swipe-thumb { position: relative; z-index: 2; width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; background: var(--navy); color: var(--gold); display: flex; align-items: center; justify-content: center; font-size: 23px; box-shadow: 0 2px 7px #111c2d35; cursor: grab; touch-action: none; }
.swipe-track.done { background: #eaf7ef; border-color: #a9d8bc; }
.swipe-track.done .swipe-thumb { background: var(--green); color: #fff; }
.swipe-track.done .swipe-label { color: var(--green); }
.swipe-track.busy .swipe-thumb { opacity: .65; }

.receipt-preview { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.receipt-item { width: 90px; }
.receipt-item img { width: 90px; height: 75px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; display: block; }
.receipt-item span { display: block; font-size: 10px; overflow-wrap: anywhere; color: var(--muted); }

dialog { border: 0; border-radius: 16px; padding: 20px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px #0004; }
dialog::backdrop { background: #111c2d99; }
.history { display: grid; gap: 8px; font-size: 13px; }
.history div { border-left: 3px solid var(--line); padding-left: 10px; }

.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--gold); color: var(--navy); font-size: 11px; font-weight: 800; margin-left: 4px; }
.pill.new { background: var(--gold); color: var(--navy); }
.pill.settled { background: #eef3fb; color: #22406e; }
.owes { color: var(--red); font-weight: 700; }
.owed { color: var(--green); font-weight: 700; }

h2.spaced { margin-top: 18px; }

.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; background: #f2f4f7; }
.receipt-large { display: grid; gap: 12px; }
.receipt-large img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #f2f4f7; display: block; }
.receipt-large span { font-size: 12px; color: var(--muted); }

/* Phones: each job report becomes a card instead of a wide table row. */
@media (max-width: 640px) {
  #reportRows, #reportRows tr, #reportRows td { display: block; }
  .tablewrap:has(#reportRows) table { min-width: 0; }
  .tablewrap:has(#reportRows) thead { display: none; }
  #reportRows tr { border-bottom: 6px solid var(--bg); padding: 4px 0; }
  #reportRows td { border-bottom: 0; padding: 6px 12px; }
  #reportRows td[data-label]:not([data-label="Job"])::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; color: #526071; text-transform: uppercase; letter-spacing: .04em; }
  #reportRows tr.voided td { text-decoration: none; }
}

.day-group { display: grid; gap: 8px; margin-bottom: 16px; }
.day-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 2px solid var(--gold); position: sticky; top: 0; background: #fff; z-index: 1; }
.report-item.is-voided { opacity: .6; }
details.card > summary { cursor: pointer; padding: 2px 0; }
details.card[open] > summary { margin-bottom: 10px; }

input.locked { background: #f2f4f7; color: #344054; font-weight: 700; }

.finishing { background: #fff8e8; border: 1px solid #f0d9a4; border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.extensions { display: grid; gap: 4px; margin-top: 6px; font-size: 13px; }
.extensions div { border-left: 3px solid var(--gold); padding-left: 8px; }
.thumb-label { flex-basis: 100%; font-size: 11px; font-weight: 700; color: #526071; text-transform: uppercase; letter-spacing: .04em; }
h3.photo-head { font-size: 14px; margin: 14px 0 8px; }
.alert-options { display: grid; gap: 4px; margin-bottom: 10px; }
.alert-options .check { padding-bottom: 4px; align-self: start; font-weight: 500; }
.alert-bar { background: #eef3fb; color: #22406e; }

.review-list { display: grid; gap: 12px; margin-top: 12px; }
.review-card { border: 1px solid #e3e7ee; border-radius: 12px; padding: 12px; background: #fff; }
.review-head { margin-bottom: 8px; line-height: 1.6; }
.review-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0 0 8px; font-size: 14px; }
.review-facts dt { color: var(--muted); }
.review-facts dd { margin: 0; overflow-wrap: anywhere; }

/* View-only managers: no change controls (the database refuses changes anyway). */
body.view-only .tab[data-panel="report"],
body.view-only #panel-report,
body.view-only [data-act="correct"],
body.view-only [data-act="void"],
body.view-only #settleRows button,
body.view-only #unpaidRows button,
body.view-only #loginForm,
body.view-only #loginRows button,
body.view-only #mgrLoginRows button,
body.view-only #handlerForm,
body.view-only #handlerLoginRows button,
body.view-only #rosterForm,
body.view-only #rosterRows button,
body.view-only [data-km="set"],
body.view-only [data-act="extend"],
body.view-only #liveRows [data-act="void"],
body.view-only [data-review="finalize"],
body.view-only [data-review="flag"],
body.view-only [data-review="reopen"] { display: none !important; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { padding-left: 15px; padding-right: 15px; }
  .grid { grid-template-columns: 1fr; }
  .full { grid-column: auto; }
  .card { padding: 15px; }
  h1 { font-size: 20px; }
  .toolbar .field { flex: 1 1 45%; }
  .toolbar-actions { margin-left: 0; width: 100%; }
  .toolbar-actions button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Pre-booking and Schedule */
.check.inline { align-self: start; padding: 0 0 10px; font-weight: 500; }
.report-item.has-clash { border-color: #f3b4ae; background: #fffafa; }
.clash-line { color: var(--red); font-weight: 700; font-size: 13px; }
.clash-box { background: #fdecea; color: var(--red); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; display: grid; gap: 2px; font-size: 13px; }
button.link.clash-link { color: var(--red); text-align: left; padding: 2px 0; font-size: 13px; }
.cal-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.cal-bar h2 { margin: 0; min-width: 150px; text-align: center; }
.cal-filter { flex: 0 1 220px; margin-left: auto; }
.cal-filter select { padding: 7px 10px; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.cal-legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.cal-head { background: #f8fafc; font-size: 12px; font-weight: 700; color: #526071; padding: 6px; text-align: center; }
button.cal-day { min-height: 96px; border-radius: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; align-items: stretch; gap: 3px; background: #fff; text-align: left; font-weight: 400; min-width: 0; }
button.cal-day:nth-child(7n+1) { border-left: 0; }
button.cal-day.other { background: #fafbfc; color: #98a2b3; }
button.cal-day.selected { box-shadow: inset 0 0 0 2px var(--gold); }
.cal-num { font-size: 12px; font-weight: 800; align-self: flex-start; padding: 0 5px; }
.cal-day.today .cal-num { background: var(--navy); color: #fff; border-radius: 999px; }
.chip { display: block; font-size: 11px; line-height: 1.3; padding: 2px 5px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #eef3fb; color: #22406e; font-weight: 600; }
.cal-legend .chip { display: inline-block; }
.chip.live { background: #fff2d7; color: var(--amber); }
.chip.done { background: #eaf7ef; color: #16633f; }
.chip.clash { background: #fdecea; color: var(--red); box-shadow: inset 3px 0 0 var(--red); }
.chip.more { background: none; color: var(--muted); padding-left: 2px; }
@media (max-width: 640px) {
  button.cal-day { min-height: 62px; padding: 2px; }
  .chip { font-size: 9px; padding: 1px 3px; }
  .chip .t { display: none; }
  .cal-filter { margin-left: 0; flex: 1 1 100%; }
}

/* Daily work: expense lines, checklists, warnings, cash and reports */
.expense-lines { display: grid; gap: 10px; margin-bottom: 8px; }
.expense-line { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 8px; align-items: end; border: 1px solid #e3e7ee; border-radius: 10px; padding: 10px; }
@media (max-width: 640px) { .expense-line { grid-template-columns: 1fr 1fr; } }
.spaced-label { display: block; margin-top: 8px; }
.checklist { display: grid; gap: 6px; border: 1px solid #e3e7ee; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.checklist legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
.checklist .check { font-weight: 500; }
.warn-list { margin: 0 0 8px; padding: 8px 12px 8px 28px; background: #fff6e0; border-radius: 8px; font-size: 14px; color: #6b4b00; }
.review-card.flagged { border-color: #e5a29b; }
.callout-list { display: grid; gap: 8px; }
.callout-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; border: 1px solid #e3e7ee; border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.exc-list { display: grid; gap: 6px; }
.exc-list .exc { border-left: 4px solid #d0d5dd; padding: 6px 10px; background: #fafbfc; border-radius: 6px; font-size: 14px; }
.exc-list .exc.must { border-left-color: #b42318; }
.exc-list .exc.review { border-left-color: #b8913f; }
.stat .d { font-size: 12px; font-variant-numeric: tabular-nums; }
.stat .d.up { color: #16794b; }
.stat .d.down { color: #b42318; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
@media print {
  .topbar, .tabs, .toolbar, #reportsMessage, .card:not(.report-doc), #reportView ~ *, .row-actions, .footer { display: none !important; }
  #panel-reports > .card { display: none !important; }
  .report-doc { border: 0; box-shadow: none; }
}
