@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-semi-condensed-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-display: swap; src: url("/fonts/barlow-semi-condensed-700.woff2") format("woff2"); }

/* Same brand tokens as datayorkshire.com, plus status colours that pass 4.5:1 on white. */
:root {
  --navy: #1f277b;
  --navy-deep: #161c5e;
  --ink: #1c2148;
  --muted: #4f5470;
  --line: #d9dcea;
  --mist: #eef0f7;
  --white: #ffffff;
  --green: #3b8536;

  --owes: #b42318;
  --owes-bg: #fdecea;
  --credit: #2a6a26;
  --credit-bg: #e6f2e4;
  --clear: var(--navy);
  --clear-bg: var(--mist);

  --font-body: "Barlow", system-ui, sans-serif;
  --font-display: "Barlow Semi Condensed", "Arial Narrow", sans-serif;

  --gutter: clamp(16px, 4vw, 32px);
  --radius: 10px;
  --wide: 76rem;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100dvh;
  background: var(--mist);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
}

h1, h2 { margin: 0; font-family: var(--font-display); font-weight: 700; line-height: 1.15; color: var(--navy); }
h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); }
h2 { font-size: 1.25rem; }
p { margin: 0; }
a { color: var(--navy); text-underline-offset: 3px; text-decoration-color: var(--green); }
code { font-family: ui-monospace, monospace; }

:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* --- Top bar ----------------------------------------------------------- */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem;
  padding: 0.75rem var(--gutter);
  padding-top: max(0.75rem, env(safe-area-inset-top));
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.bar-brand { display: block; width: clamp(150px, 40vw, 220px); }
.bar-brand img { display: block; width: 100%; height: auto; }
.bar-nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.bar-nav a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 0.875rem;
  border-radius: 999px; color: var(--ink); font-weight: 600; text-decoration: none;
}
.bar-nav a:hover { background: var(--mist); }
.bar-nav a[aria-current="page"] { background: var(--navy); color: var(--white); }
.bar-user { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.875rem; }
.bar-user form { margin: 0; }

/* --- Layout -------------------------------------------------------------- */
main { padding: clamp(1rem, 0.5rem + 2vw, 2rem) var(--gutter) 3rem; }
.wrap { max-width: var(--wide); margin: 0 auto; }
.wrap-narrow { max-width: 40rem; }
.panel {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 0.75rem + 1vw, 1.5rem); margin-top: 1rem;
}
.panel > h2 + * { margin-top: 0.75rem; }
.panel-narrow { max-width: 28rem; margin: clamp(0.5rem, 2vw, 2rem) auto 0; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; margin-bottom: 1rem; }
.columns { display: grid; gap: 0 1.25rem; }
@media (min-width: 64rem) { .columns { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; } }
.back { margin-bottom: 0.75rem; font-weight: 600; }
.lede { margin-top: 0.5rem; color: var(--muted); }
.small { font-size: 0.875rem; }
.after-form { margin-top: 1rem; }
.muted { color: var(--muted); font-weight: 400; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); background: var(--white); border: 1px dashed var(--line); border-radius: var(--radius); }

/* --- The driver's balance: the one number that matters ------------------ */
.balance {
  max-width: 28rem; margin: clamp(0.5rem, 3vw, 2.5rem) auto 0; padding: 1.75rem 1.5rem 1.5rem;
  border-radius: 16px; background: var(--white); border-top: 8px solid currentColor; text-align: center;
  box-shadow: 0 1px 2px rgb(31 39 123 / 0.06), 0 18px 40px -22px rgb(31 39 123 / 0.35);
}
.balance-owes { color: var(--owes); }
.balance-credit { color: var(--credit); }
.balance-clear { color: var(--clear); }
.balance-who { color: var(--muted); font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; }
.balance-who span { display: block; font-family: var(--font-body); font-weight: 400; font-size: 0.9375rem; }
.balance-label { margin-top: 1.25rem; color: inherit; font-size: 1.5rem; font-weight: 500; }
.balance-figure {
  margin-top: 0.25rem; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(3.5rem, 2rem + 10vw, 5.5rem); line-height: 1; letter-spacing: -0.02em;
}
.balance-asof { margin-top: 1rem; color: var(--muted); font-size: 0.875rem; }
.notes { text-align: center; }
.notes p + p { margin-top: 0.5rem; }

/* --- Forms ---------------------------------------------------------------- */
form { margin: 0; }
.field { margin-top: 1rem; min-width: 0; }
.field label, fieldset legend { display: block; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.875rem; }
.error { color: var(--owes); font-weight: 600; font-size: 0.9375rem; }
.field-error input { border-color: var(--owes); border-width: 2px; }
input[type="text"], input[type="password"], input[type="tel"], select {
  width: 100%; min-height: var(--tap); margin-top: 0.375rem; padding: 0.5rem 0.75rem;
  border: 1.5px solid #8a8fa8; border-radius: 8px; background: var(--white); color: var(--ink);
  font: inherit; font-size: 1rem;
}
input:focus-visible, select:focus-visible { outline: 3px solid var(--green); outline-offset: 1px; }
.input-prefix { display: flex; align-items: stretch; margin-top: 0.375rem; }
.input-prefix span {
  display: grid; place-items: center; padding: 0 0.75rem; border: 1.5px solid #8a8fa8; border-right: 0;
  border-radius: 8px 0 0 8px; background: var(--mist); font-weight: 600;
}
.input-prefix input { margin-top: 0; border-radius: 0 8px 8px 0; }
.form-row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); align-items: end; }
.form-row > .btn { margin-top: 1rem; }
fieldset { margin: 1rem 0 0; padding: 0; border: 0; min-width: 0; }
.segmented { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.segmented legend { width: 100%; margin-bottom: 0.375rem; }
.segmented label {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: var(--tap); padding: 0 0.875rem;
  border: 1.5px solid var(--line); border-radius: 999px; background: var(--white); cursor: pointer; font-weight: 600;
}
.segmented label:has(input:checked) { border-color: var(--navy); background: var(--clear-bg); color: var(--navy); }
.segmented input { accent-color: var(--navy); width: 1.1rem; height: 1.1rem; margin: 0; }
.check { display: flex; align-items: center; gap: 0.625rem; min-height: var(--tap); margin-top: 0.75rem; font-weight: 600; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--navy); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); margin-top: 1.25rem;
  padding: 0 1.25rem; border: 2px solid transparent; border-radius: 999px; cursor: pointer;
  font: 600 1rem var(--font-body); text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, transform 80ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-deep); }
.btn-secondary { background: var(--white); border-color: var(--navy); color: var(--navy); }
.btn-secondary:hover { background: var(--clear-bg); }
.btn-quiet { margin-top: 0; background: transparent; border-color: var(--line); color: var(--ink); }
.btn-quiet:hover { border-color: var(--navy); }
.btn-small { min-height: 36px; padding: 0 0.875rem; font-size: 0.875rem; }
.btn-block { width: 100%; }

.error-summary {
  margin-top: 1rem; padding: 1rem 1.25rem; border: 3px solid var(--owes); border-radius: var(--radius); background: var(--white);
}
.error-summary h2 { color: var(--owes); font-size: 1.125rem; }
.error-summary ul { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.error-summary a { color: var(--owes); font-weight: 600; }
.flash {
  margin-bottom: 1rem; padding: 0.75rem 1rem; border-left: 5px solid var(--green); border-radius: 6px;
  background: var(--credit-bg); color: var(--credit); font-weight: 600;
}

/* --- Numbers and status --------------------------------------------------- */
.stats { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 100%), 1fr)); margin: 0 0 1rem; }
.stat { padding: 1rem 1.125rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.stat dt { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.stat dd { margin: 0.25rem 0 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.1rem); line-height: 1.1; color: var(--navy); }
.stat-owes { border-color: #f1b8b2; }
.stat-owes dd { color: var(--owes); }
.stats-driver .stat dd { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.tag {
  display: inline-flex; align-items: center; min-height: 1.6rem; padding: 0 0.625rem; border-radius: 999px;
  font-family: var(--font-body); font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
}
.tag-owes { background: var(--owes-bg); color: var(--owes); }
.tag-credit { background: var(--credit-bg); color: var(--credit); }
.tag-clear { background: var(--clear-bg); color: var(--clear); }

.money { white-space: nowrap; font-weight: 600; }
.money-owes { color: var(--owes); }
.money-credit { color: var(--credit); }
.money-zero { color: #9a9eb4; font-weight: 400; }

.car-badge {
  display: inline-grid; place-items: center; min-width: 2.6rem; height: 2.6rem; padding: 0 0.5rem; margin-right: 0.25rem;
  border-radius: 8px; background: var(--navy); color: var(--white); font-size: 1.4rem; vertical-align: middle;
}

/* --- Tables --------------------------------------------------------------- */
.list-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.search-form { display: flex; gap: 0.5rem; flex: 1 1 18rem; max-width: 28rem; }
.search-form input[type="search"] {
  flex: 1; min-width: 0; min-height: var(--tap); padding: 0.5rem 0.75rem; border: 1.5px solid #8a8fa8; border-radius: 999px;
  background: var(--white); color: var(--ink); font: inherit;
}
.search-form .btn { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Simple payment screen */
.btn-top { margin-top: 0; }
.quick-balance { padding: 1.25rem 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.quick-label { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.quick-figure {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.125rem;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(2.25rem, 1.6rem + 3vw, 3rem); line-height: 1.1;
}
.quick-figure.money-clear { color: var(--navy); }
.quick-balance .small { margin-top: 0.25rem; }
.chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.875rem; border: 1.5px solid var(--line);
  border-radius: 999px; background: var(--white); color: var(--ink); font-weight: 600; font-size: 0.9375rem; text-decoration: none;
}
.chip[aria-current="true"] { border-color: var(--navy); background: var(--navy); color: var(--white); }
.week-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.week-form select { width: auto; margin-top: 0; }
.week-form .btn { margin-top: 0; }

.ledger { width: 100%; border-collapse: collapse; background: var(--white); }
.ledger th, .ledger td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; }
.ledger thead th {
  position: sticky; top: 0; background: var(--navy); color: var(--white);
  font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
}
.ledger .num { text-align: right; }
.ledger tbody tr:hover { background: #f6f7fb; }
.ledger .strong { font-weight: 700; }
.ledger-drivers { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ledger-drivers .car a {
  display: inline-grid; place-items: center; min-width: 2.25rem; height: 2.25rem; border-radius: 6px;
  background: var(--mist); font-family: var(--font-display); font-weight: 700; text-decoration: none;
}
.ledger-drivers td a { font-weight: 600; }
.ledger-drivers .inactive { color: var(--muted); }
.ledger-history tbody th { font-weight: 600; white-space: nowrap; }
.table-scroll { overflow-x: auto; margin: 0 calc(-1 * clamp(1rem, 0.75rem + 1vw, 1.5rem)); }

/* Phones: the driver table becomes a list of rows; numbers keep their labels. */
@media (max-width: 40rem) {
  .ledger-drivers, .ledger-drivers tbody, .ledger-drivers tr, .ledger-drivers td { display: block; }
  .ledger-drivers thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .ledger-drivers { border: 0; background: transparent; }
  .ledger-drivers tr {
    display: grid; grid-template-columns: auto 1fr auto; gap: 0.125rem 0.75rem; align-items: center;
    margin-bottom: 0.5rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white);
  }
  .ledger-drivers td { padding: 0; border: 0; }
  .ledger-drivers .car { grid-row: span 2; }
  .ledger-drivers td[data-label="Status"] { grid-column: 3; grid-row: 1; }
  .ledger-drivers td.num { grid-column: 2 / 4; display: flex; justify-content: space-between; font-size: 0.875rem; text-align: left; }
  .ledger-drivers td.num::before { content: attr(data-label); color: var(--muted); }
}

/* --- Entry lists ----------------------------------------------------------- */
details.panel > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); }
details.panel > summary::after { content: "Show"; color: var(--navy); font-weight: 600; }
details[open].panel > summary::after { content: "Hide"; }
details.panel > summary h2 { display: inline; }
.entries { margin: 0.75rem 0 0; padding: 0; list-style: none; }
.entries li { display: grid; grid-template-columns: 1fr auto; gap: 0.125rem 1rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.entries li > div { grid-column: 1; }
.entries li > form { grid-column: 2; grid-row: 1 / span 2; }
.entries .reversed > div:first-child { text-decoration: line-through; text-decoration-color: var(--muted); }
.rates { margin: 0.75rem 0 0; padding-left: 1.25rem; }

/* --- Admin sign-in --------------------------------------------------------- */
.steps { margin: 1rem 0 0; padding-left: 1.25rem; }
.steps li + li { margin-top: 0.75rem; }
.qr-wrap { margin: 0.75rem 0; }
.qr { display: block; width: min(220px, 100%); height: auto; border: 1px solid var(--line); border-radius: 8px; }
.secret { display: inline-block; margin-top: 0.25rem; padding: 0.125rem 0.375rem; border-radius: 4px; background: var(--mist); word-break: break-all; }
.pin-reveal { padding: 1rem; border: 2px dashed var(--navy); border-radius: var(--radius); background: var(--clear-bg); }
.pin-reveal strong { font-family: var(--font-display); font-size: 2rem; letter-spacing: 0.15em; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
