/* R Group Water — shared design system for the customer/driver app, Supplier Platform and team panel.
 * Palette: reservoir ink, tank teal, JoJo-tank green, borehole amber on a cool mist background.
 * Type: Barlow (self-hosted), tabular figures wherever litres or rand are shown. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("../fonts/barlow-latin-700-normal.woff2") format("woff2"); }

:root {
  --ink: #10303a;
  --ink-soft: #4a656c;
  --mist: #edf3f2;
  --surface: #ffffff;
  --line: #d3e0de;
  --teal: #157a8a;
  --teal-strong: #0f5f6c;
  --teal-wash: #dcefef;
  --green: #3d7a3a;
  --green-wash: #e2f0df;
  --amber: #b77713;
  --amber-wash: #fbefd7;
  --clay: #b0442d;
  --clay-wash: #f8e2dc;
  --water: #4fb3c4;
  --shadow: 0 1px 2px rgba(16, 48, 58, .08), 0 4px 14px rgba(16, 48, 58, .06);
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --tap: 46px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e2eef0; --ink-soft: #9cb5ba; --mist: #0b1c21; --surface: #12282f; --line: #27424a;
    --teal: #4fb3c4; --teal-strong: #7fcbd8; --teal-wash: #143840; --green: #86c780; --green-wash: #183420;
    --amber: #e9b55c; --amber-wash: #33270f; --clay: #f0998a; --clay-wash: #3b1d17; --water: #4fb3c4;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.5 "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--mist); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.005em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--teal-strong); }
.num, .money, .litres { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-soft); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: var(--tap); padding: 0 1.1em;
  border: 0; border-radius: var(--r); background: var(--teal); color: #fff; font: 600 1rem/1 "Barlow", sans-serif; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--teal-strong); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.quiet { background: var(--teal-wash); color: var(--ink); }
.btn.quiet:hover { background: var(--line); }
.btn.ghost { background: transparent; color: var(--teal-strong); padding: 0 .6em; }
.btn.danger { background: var(--clay); }
.btn.go { background: var(--green); }
.btn.small { min-height: 36px; padding: 0 .8em; font-size: .9rem; border-radius: var(--r-sm); }
.btn.busy { position: relative; color: transparent; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: .75rem; }

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-weight: 600; font-size: .95rem; margin-bottom: .3rem; }
.field input, .field select, .field textarea { width: 100%; min-height: var(--tap); padding: .55rem .8rem; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 400 1rem "Barlow", sans-serif; }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { display: block; font-size: .85rem; color: var(--ink-soft); margin-top: .3rem; }
.field .err { display: block; font-size: .9rem; color: var(--clay); font-weight: 600; margin-top: .3rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--clay); }
.checkline { display: flex; gap: .6rem; align-items: flex-start; margin: 0 0 1rem; }
.checkline input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--teal); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--teal-wash); padding: 4px; border-radius: var(--r); margin: 0 0 1rem; }
.seg button { min-height: 42px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink); font: 600 .95rem "Barlow", sans-serif; cursor: pointer; padding: 0 .5rem; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); color: var(--teal-strong); }
.form-error { background: var(--clay-wash); color: var(--clay); padding: .7rem .9rem; border-radius: var(--r-sm); font-weight: 600; margin: 0 0 1rem; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem 1.2rem; margin: 0 0 1rem; }
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: .6rem; }
.banner { border-radius: var(--r); padding: .8rem 1rem; margin: 0 0 1rem; font-weight: 600; }
.banner.test { background: var(--amber-wash); color: var(--amber); }
.banner.info { background: var(--teal-wash); color: var(--ink); }
.banner.good { background: var(--green-wash); color: var(--green); }
.banner.bad { background: var(--clay-wash); color: var(--clay); }
.pill { display: inline-flex; align-items: center; gap: .3em; padding: .1em .65em; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--teal-wash); color: var(--ink); white-space: nowrap; }
.pill.good { background: var(--green-wash); color: var(--green); }
.pill.warn { background: var(--amber-wash); color: var(--amber); }
.pill.bad { background: var(--clay-wash); color: var(--clay); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-soft); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); padding: .8rem 0; }
.list > li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- tables (supplier + team) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.t { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.t th, table.t td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-weight: 600; color: var(--ink-soft); font-size: .85rem; background: var(--mist); position: sticky; top: 0; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--teal-wash); }

/* ---------- sheet (bottom on phones, centred on desktop) ---------- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(8, 24, 29, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 1000; }
.sheet { background: var(--surface); width: min(560px, 100%); max-height: 92vh; overflow: auto; border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 1.2rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: var(--r-lg); } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.sheet-head h2 { margin: 0; }
.x { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--ink-soft); cursor: pointer; min-width: var(--tap); min-height: var(--tap); }

/* ---------- toast ---------- */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); z-index: 1100; display: grid; gap: .5rem; width: min(440px, calc(100% - 32px)); }
.toast { overflow-wrap: anywhere; background: var(--ink); color: var(--mist); padding: .8rem 1rem; border-radius: var(--r); font-weight: 600; box-shadow: var(--shadow); }
.toast.bad { background: var(--clay); color: #fff; }
.toast.good { background: var(--green); color: #fff; }

/* ---------- the tank gauge (the one memorable element) ---------- */
.tank { position: relative; width: 112px; height: 168px; flex: none; }
.tank .shell { position: absolute; inset: 10px 0 0; border: 3px solid var(--ink); border-radius: 16px 16px 12px 12px; overflow: hidden; background: var(--surface); }
.tank .lid { position: absolute; left: 36px; right: 36px; top: 0; height: 14px; border: 3px solid var(--ink); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface); }
.tank .water { position: absolute; left: 0; right: 0; bottom: 0; background: var(--water); transition: height .35s ease; }
.tank .water::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 6px; background: rgba(255,255,255,.35); }
.tank .rib { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid rgba(16, 48, 58, .28); z-index: 1; }
.tank .label { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-weight: 700; font-size: 1.15rem; z-index: 2; color: var(--ink); font-variant-numeric: tabular-nums; }
.tank-row { display: flex; gap: 1.1rem; align-items: center; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; flex: 1; }
.presets button { min-height: 42px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 1rem "Barlow", sans-serif; cursor: pointer; font-variant-numeric: tabular-nums; }
.presets button[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-wash); }
.fillbar { height: 10px; border-radius: 99px; background: var(--teal-wash); overflow: hidden; }
.fillbar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* ---------- delivery code tag ---------- */
.code-tag { display: inline-flex; gap: .35rem; }
.code-tag b { display: inline-grid; place-items: center; width: 2.6rem; height: 3.2rem; border: 2px solid var(--ink); border-radius: var(--r-sm); font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface); }

/* ---------- order progress ---------- */
.steps { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.steps li { font-size: .78rem; text-align: center; color: var(--ink-soft); }
.steps li::before { content: ""; display: block; height: 6px; border-radius: 99px; background: var(--line); margin-bottom: .35rem; }
.steps li.done::before { background: var(--green); }
.steps li.now { color: var(--ink); font-weight: 700; }
.steps li.now::before { background: var(--teal); }

/* ---------- maps ---------- */
.map { height: 260px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--teal-wash); z-index: 0; }
.map.tall { height: 360px; }
.pin-drop { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--teal); transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin-truck { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.pin-order { width: 16px; height: 16px; border-radius: 50%; background: var(--amber); border: 2px solid #fff; }
.leaflet-container { font: inherit; }

@media (min-width: 860px) { .toasts { top: auto; bottom: 24px; left: auto; right: 24px; transform: none; width: 380px; } }
.sheet .row.end { position: sticky; bottom: calc(-1.2rem - env(safe-area-inset-bottom)); background: var(--surface); padding: .8rem 0 .2rem; margin-top: .5rem; border-top: 1px solid var(--line); }
