:root {
  --bg: #EEF2F0;
  --surface: #FFFFFF;
  --ink: #13201C;
  --muted: #56655F;
  --line: #D3DCD8;
  --go: #0F6E5A;
  --go-press: #0B5A49;
  --on-go: #FFFFFF;
  --visit: #F2B33D;
  --on-visit: #2A1E05;
  --alert: #B83227;
  --alert-soft: #FBE9E7;
  --info-soft: #E3F1EC;
  --radius-lg: 18px;
  --radius-sm: 8px;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1715; --surface: #18221F; --ink: #E8EFEC; --muted: #9AABA4; --line: #2C3934;
    --go: #2FA383; --go-press: #258A6E; --on-go: #04140F;
    --visit: #F2B33D; --on-visit: #2A1E05;
    --alert: #F0776B; --alert-soft: #3A1E1B; --info-soft: #17312A;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 17px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--go); outline-offset: 2px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: 0 1.25em; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface); font-weight: 700; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn:disabled { opacity: .55; cursor: progress; }
.btn-go { background: var(--go); color: var(--on-go); border-color: var(--go); }
.btn-go:active { background: var(--go-press); }
.btn-visit { background: var(--visit); color: var(--on-visit); border-color: var(--visit); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); min-height: 44px; }
.btn-small { min-height: 38px; padding: 0 .9em; border-radius: 10px; font-size: 15px; }
.btn-danger { color: var(--alert); }
.btn-block { width: 100%; }

/* fields */
label.field, div.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=month], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
}
textarea { min-height: 84px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== Salesperson app ===== */
.sp { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; }
.top .who { font-weight: 700; }
.top .date { color: var(--muted); font-size: 15px; }

/* the status band is the one loud thing on screen */
.status { margin: 8px 12px 0; padding: 22px 22px 24px; border-radius: var(--radius-lg); background: var(--surface); border: 1.5px solid var(--line); }
.status .state { font-size: 16px; color: var(--muted); }
.status .big { font-size: 34px; line-height: 1.12; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.status .sub { margin-top: 8px; color: var(--muted); }
.status[data-state="field"] { background: var(--go); border-color: var(--go); color: var(--on-go); }
.status[data-state="field"] .state, .status[data-state="field"] .sub { color: var(--on-go); opacity: .85; }
.status[data-state="visit"] { background: var(--visit); border-color: var(--visit); color: var(--on-visit); }
.status[data-state="visit"] .state, .status[data-state="visit"] .sub { color: var(--on-visit); opacity: .8; }

.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 12px 0; }
.totals div { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.totals b { display: block; font-size: 20px; }
.totals span { font-size: 14px; color: var(--muted); }

.timeline { list-style: none; margin: 18px 0 0; padding: 0 18px 160px 18px; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: -8px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--go); }
.timeline li.open::after { border-color: var(--visit); background: var(--visit); }
.timeline li.end::after { background: var(--ink); border-color: var(--ink); }
.timeline .t { font-size: 15px; color: var(--muted); }
.timeline .h { font-weight: 700; }
.timeline .d { font-size: 15px; color: var(--muted); }
.empty-note { color: var(--muted); padding: 0 18px; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.actionbar .inner { max-width: 536px; margin: 0 auto; display: grid; gap: 6px; }
.actionbar .btn-go, .actionbar .btn-visit { min-height: 60px; font-size: 19px; border-radius: 16px; }

/* sheets */
dialog.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
}
dialog.sheet::backdrop { background: rgba(10, 20, 17, .45); }
dialog.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { dialog.sheet[open] { animation: none; } }
.sheet-body { padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; max-height: 92vh; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }
.sheet p.lead { margin: 0 0 16px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); max-width: 92vw; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--alert); color: #fff; }

.login { max-width: 400px; margin: 0 auto; padding: 48px 22px; }
.login h1 { font-size: 30px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 26px; }
.consent ul { padding-left: 1.2em; }
.consent li { margin-bottom: 6px; }

/* ===== Admin ===== */
.admin { max-width: 1200px; margin: 0 auto; padding: 18px 20px 60px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-head h1 { font-size: 24px; margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 16px 0 20px; border-bottom: 1.5px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 14px; border-bottom: 3px solid transparent; margin-bottom: -1.5px; cursor: pointer; color: var(--muted); font-weight: 700; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--go); }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label.field { margin: 0; }
.toolbar input, .toolbar select { min-height: 42px; width: auto; }
.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 18px; }
.sp-row { display: grid; grid-template-columns: minmax(140px, 1.4fr) repeat(5, minmax(80px, 1fr)) auto; gap: 10px; align-items: center; }
.sp-row .k { font-size: 13px; color: var(--muted); }
.sp-row .v { font-weight: 700; }
.flag { display: inline-block; font-size: 14px; padding: 3px 9px; border-radius: 999px; background: var(--alert-soft); color: var(--alert); margin: 3px 4px 0 0; }
.flag.info { background: var(--info-soft); color: var(--go); }
.detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } .sp-row { grid-template-columns: 1fr 1fr; } }
.map { height: 340px; border-radius: 12px; border: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 700; font-size: 14px; }
td .muted, .muted { color: var(--muted); }
.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--line); }
.approve { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: var(--alert-soft); border-radius: 10px; }
.approve input { width: auto; min-height: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.form-grid label.field { margin: 0; }
.marker { width: 26px; height: 26px; border-radius: 50%; background: var(--go); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.marker.se { background: #13201C; }
.photo-view { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; border-radius: 12px; }
.phone-link { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
#qr { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); line-height: 0; }
dialog.modal { border: 0; border-radius: 16px; padding: 16px; background: var(--surface); color: var(--ink); max-width: 90vw; }
dialog.modal::backdrop { background: rgba(10,20,17,.55); }

/* ===== v2 additions ===== */
.actionbar .row2 { gap: 6px; }
.actionbar .btn-secondary { min-height: 52px; }
.pending { margin: 10px 12px 0; padding: 10px 14px; border-radius: 12px; background: var(--alert-soft); color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
.pending.ok { background: var(--info-soft); }
.tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--alert-soft); color: var(--alert); margin-left: 6px; vertical-align: 2px; font-weight: 400; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--line); }
.notice { margin: 10px 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); font-size: 15px; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: zoom-in; background: var(--line); display: block; }
.gallery figcaption { font-size: 13px; color: var(--muted); margin-top: 2px; }
.site-block { padding: 10px 0; border-bottom: 1px solid var(--line); }
.site-block:last-child { border-bottom: 0; }
.site-block h4 { margin: 0 0 6px; font-size: 16px; }
.flag.check { background: #FFF3D6; color: #7A5300; }
@media (prefers-color-scheme: dark) { .flag.check { background: #3A2E12; color: #F2C66B; } }
.shift-row { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.shift-row:last-child { border-bottom: 0; }
.marker.site { background: #B8740A; }

.cam-video { width: 100%; max-height: 55vh; background: #000; border-radius: 12px; display: block; object-fit: contain; }
/* on a computer, give the salesperson screen a little more room */
@media (min-width: 900px) and (pointer: fine) {
  .sp { padding-top: 12px; }
  .actionbar { background: none; }
}

.party-list { list-style: none; margin: 10px 0; padding: 0; max-height: 46vh; overflow-y: auto; border-top: 1px solid var(--line); }
.party-list button { width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 14px 4px; cursor: pointer; color: var(--ink); }
.party-list small { display: block; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span { display: inline-block; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line); cursor: pointer; }
.chips input:checked + span { background: var(--go); color: var(--on-go); border-color: var(--go); }
.chips input:focus-visible + span { outline: 3px solid var(--go); outline-offset: 2px; }
.report-line { font-size: 15px; color: var(--muted); margin-top: 2px; }

table.register { width: auto; min-width: 60%; }
table.register th, table.register td { white-space: nowrap; padding: 8px 14px; }
table.register tbody td:first-child { color: var(--muted); }
td.reg { cursor: pointer; border-left: 1px solid var(--line); }
td.reg small { color: var(--muted); font-size: 13px; }
td.reg.s-absent { color: var(--muted); cursor: default; }
td.reg.s-approve { background: var(--alert-soft); }
td.reg.s-approve small { color: var(--alert); }
td.reg.s-open { background: var(--info-soft); }
tr.sun td { background: color-mix(in srgb, var(--line) 35%, transparent); }
table.register tfoot th { border-top: 1.5px solid var(--line); }

.size-choice { display: grid; gap: 10px; margin-bottom: 8px; }
.size-choice .btn { min-height: 64px; font-size: 20px; justify-content: space-between; }
.size-choice .btn small { font-weight: 400; color: var(--muted); font-size: 14px; }
.size-tag { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 999px; background: var(--info-soft); color: var(--go); margin-left: 6px; vertical-align: 2px; font-weight: 700; }
