:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1b2421;
  --muted: #66736e;
  --line: #e1e6e3;
  --brand: #0f6b4f;
  --green: #1f9d55;
  --amber: #e8a317;
  --red: #d64933;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.06), 0 1px 8px rgba(16, 24, 20, 0.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--red); min-height: 1.2em; }
.warn { color: var(--red); }

/* Buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
.btn:hover { border-color: #c8d0cc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.good { color: var(--green); border-color: #bfe3cf; }
.btn.bad { color: var(--red); border-color: #f1c6bd; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); width: 100%; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); padding: 32px; border-radius: 14px; box-shadow: var(--shadow); width: min(380px, 100%); text-align: center; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card form { display: grid; gap: 10px; margin-top: 16px; text-align: left; }
.dev-note { font-size: 13px; color: var(--muted); background: #fff8e6; border: 1px solid #f3e0a8; padding: 8px 10px; border-radius: 8px; margin: 0; }
#google-btn { display: flex; justify-content: center; margin-top: 16px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 8px 12px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab.active { background: #e6f2ed; color: var(--brand); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.badge { background: var(--red); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; margin-left: 4px; }

main { padding: 20px; max-width: 1200px; margin: 0 auto; }
.section-title { font-size: 15px; font-weight: 650; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.colour-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.colour-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 10px; font-size: 14px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.sw.green { background: var(--green); } .sw.amber { background: var(--amber); } .sw.red { background: var(--red); }
.type-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.type-list li { display: flex; justify-content: space-between; font-size: 14px; }

/* Map */
.map-layout { display: grid; grid-template-columns: 260px 1fr; gap: 0; margin: -20px; height: calc(100vh - 57px); position: relative; }
main:has(.map-layout:not([hidden])) { max-width: none; }
.map-side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px; overflow-y: auto; }
#map { height: 100%; }
.field { margin-bottom: 12px; border: 0; padding: 0; }
.field label, .field legend { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; padding: 0; }
.check { display: flex !important; align-items: center; gap: 6px; color: var(--text) !important; font-size: 14px !important; margin: 4px 0 !important; }
.check input { width: auto; }
.run-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.run-list li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.run-list li.active { border-color: var(--brand); background: #eef7f3; }
.run-list .rl-top { display: flex; justify-content: space-between; font-weight: 600; }
.run-list .rl-q { color: var(--red); }
.run-legend { font-size: 13px; display: grid; gap: 4px; color: var(--muted); }
.mk { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; margin-right: 6px; }
.mk.ok { background: var(--green); } .mk.nh { background: #3b6fd6; } .mk.bad { background: var(--red); }
.run-legend .line { display: inline-block; width: 22px; height: 3px; background: #2b2b2b; vertical-align: middle; margin-right: 6px; }
.pin-mk { width: 22px; height: 22px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }

.customer-panel { position: fixed; right: 12px; top: 70px; bottom: 12px; width: min(380px, calc(100% - 24px)); background: var(--surface); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); z-index: 1100; overflow-y: auto; padding: 16px; }
.customer-panel .close { position: absolute; right: 10px; top: 6px; border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--muted); }
.cp-status { display: inline-block; padding: 2px 10px; border-radius: 10px; color: #fff; font-size: 13px; font-weight: 600; }
.cp-status.GREEN { background: var(--green); } .cp-status.AMBER { background: var(--amber); } .cp-status.RED { background: var(--red); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; margin: 10px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.mini td, .mini th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.customer-panel h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Tables */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.toolbar .section-title { margin: 0; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { white-space: nowrap; display: flex; gap: 6px; }
.sev { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.sev.HIGH { background: #fde4df; color: #a5301d; } .sev.MEDIUM { background: #fdf0d5; color: #8a5b00; } .sev.LOW { background: #e7efe9; color: #3c5a47; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.link { color: var(--brand); cursor: pointer; text-decoration: underline; }

dialog { border: 0; border-radius: 12px; padding: 20px; width: min(420px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog h3 { margin: 0 0 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

@media (max-width: 760px) {
  main { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .map-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; margin: -12px; height: calc(100vh - 96px); }
  .map-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
}

.company-pick { text-align: left; margin-top: 16px; }
.company-pick label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.sub-banner { padding: 10px 20px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.sub-banner.warn { background: #fdf0d5; color: #6b4700; }
.sub-banner.bad { background: #fde4df; color: #8a2414; }
.sub-banner button { padding: 4px 12px; }
.sub-big { font-size: 22px; font-weight: 700; margin: 4px 0; }
.sub-pay { display: grid; gap: 6px; margin-top: 12px; font-size: 14px; }

.import-intro .steps { padding-left: 20px; display: grid; gap: 6px; font-size: 14px; margin: 6px 0 12px; }
.import-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.import-row input[type=file] { width: auto; max-width: 100%; }
.row-bad td { background: #fdf3f1; }
.note-bad { color: var(--red); font-size: 13px; }
.note-warn { color: #8a5b00; font-size: 13px; }
.note-ok { color: var(--green); font-size: 13px; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--green); }

/* Paystack key (locked once connected) */
.ps-locked { display: flex; gap: 10px; align-items: flex-start; margin-top: 4px; }
.ps-locked .lock { font-size: 20px; line-height: 1.2; }
.ps-form { display: grid; gap: 8px; margin-top: 10px; max-width: 460px; }
.ps-form .actions { display: flex; gap: 8px; }

/* Everything on the overview opens the table behind it */
button.card.go { text-align: left; font: inherit; color: inherit; border: 1px solid transparent; cursor: pointer; width: 100%; }
button.card.go:hover, button.card.go:focus-visible { border-color: var(--brand); outline: none; }
.go-hint { color: var(--brand); font-size: 12px; margin-top: 6px; opacity: .75; }
button.card.go:hover .go-hint { opacity: 1; }
button.card.go.no-go { cursor: default; } button.card.go.no-go:hover { border-color: transparent; } button.card.go.no-go .go-hint { display: none; }
.go-link { border: 0; background: none; font: inherit; color: inherit; padding: 2px 4px; border-radius: 6px; cursor: pointer; }
.go-link:hover { background: #e6f2ed; }
.colour-bar span { cursor: pointer; }
.type-list li.go-row { cursor: pointer; padding: 4px 6px; border-radius: 6px; margin: 0 -6px; }
.type-list li.go-row:hover { background: #e6f2ed; }
.type-list li.go-row b::after { content: " ›"; color: var(--brand); }

/* Detail tables: rows open the customer; 📍 opens the map */
.click-rows tbody tr[data-i] { cursor: pointer; }
.click-rows tbody tr[data-i]:hover td { background: #f3f8f6; }
.d-tools { justify-content: flex-start; flex-wrap: wrap; }
.d-tools input { max-width: 340px; }
.pin-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; padding: 3px 8px; font-size: 13px; white-space: nowrap; }
.pin-btn:hover { border-color: var(--brand); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.GREEN { background: var(--green); } .pill.AMBER { background: var(--amber); } .pill.RED { background: var(--red); }
.tip { margin: -4px 0 10px; font-size: 13px; }
#a-table tbody tr { cursor: pointer; } #a-table tbody tr:hover td { background: #f3f8f6; }

/* Map: what's highlighted */
.focus-bar { background: #fff3c4; border: 1px solid #f0d77a; border-radius: 8px; padding: 8px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.focus-ring { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #ff7a00; background: rgba(255,122,0,.18); box-shadow: 0 0 0 4px rgba(255,122,0,.25); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255,122,0,.55); } 100% { box-shadow: 0 0 0 14px rgba(255,122,0,0); } }
#map-table { width: 100%; margin-bottom: 12px; }
.run-list .rl-table { color: var(--brand); text-decoration: underline; cursor: pointer; font-size: 12px; }

/* Setup tab */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; margin-top: 14px; }
.setup-grid .span-2 { grid-column: 1 / -1; }
.setup-grid .section-title small { font-weight: 400; }
.table-wrap.flat { box-shadow: none; border: 1px solid var(--line); margin-bottom: 12px; }
.s-form { display: grid; gap: 8px; }
.s-form .days, .zone-checks { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.s-form .inline, label.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.small-note { font-size: 13px; margin: 0; }
.checklist { margin: 0; padding-left: 22px; display: grid; gap: 6px; font-size: 15px; }
.checklist li.done { color: var(--green); }
.row-off td { opacity: .6; }
@media (max-width: 760px) { .setup-grid { grid-template-columns: 1fr; } }

/* Approve billing */
.ap-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); }
.ap-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); display: grid; grid-template-columns: 200px 1fr; overflow: hidden; }
.ap-card.flagged { box-shadow: inset 4px 0 0 var(--amber), var(--shadow); }
.ap-photo { background: var(--line); min-height: 180px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; cursor: zoom-in; }
.ap-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ap-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ap-body h3 { margin: 0; font-size: 16px; }
.ap-kind { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--brand); }
.ap-kind.change { color: #8a5a00; }
.ap-bill { font-weight: 650; font-variant-numeric: tabular-nums; }
.ap-warn { margin: 4px 0 0; padding: 0; list-style: none; color: #8a5a00; font-size: 14px; }
.ap-warn li::before { content: "⚠ "; }
.ap-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.cp-photo { width: 100%; border-radius: 8px; margin: 6px 0 10px; background: var(--line); cursor: zoom-in; }
dialog.photo-big { padding: 0; border: 0; border-radius: 10px; max-width: min(96vw, 1024px); }
dialog.photo-big img { display: block; max-width: 100%; max-height: 90vh; }
@media (max-width: 640px) {
  .ap-card { grid-template-columns: 1fr; }
  .ap-photo { min-height: 200px; }
}
