/* RoadRecord — cards, buttons, forms, chips, empty states. */

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.card-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-grow { flex: 1; min-width: 0; }

.card-title {
  font-size: 15px;
  font-weight: 640;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  margin: 2px 0 0;
}

.card-metric {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card-metric-unit {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  margin-left: 3px;
}

/* Rego plate — the primary identifier of a vehicle, so it looks like a plate. */
.plate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  white-space: nowrap;
}

.plate-state {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

/* ---- Chips ---- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.chip-shared { background: var(--accent-soft); color: var(--accent); }
.chip-ok     { background: var(--ok-soft);     color: var(--ok); }
.chip-warn   { background: var(--warn-soft);   color: var(--warn); }

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.14s ease;
}

.btn:active { opacity: 0.78; }
.btn:disabled { opacity: 0.4; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn-quiet {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger { background: var(--danger-soft); color: var(--danger); }

.btn-sm {
  width: auto;
  min-height: 36px;
  font-size: 13px;
  padding: 0 13px;
  border-radius: 8px;
}

.btn-row {
  display: flex;
  gap: 9px;
}

.btn-row .btn { width: auto; flex: 1; }

/* ---- Forms ---- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 620;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
  line-height: 1.45;
}

.field-err {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}

.field.invalid .field-err { display: block; }
.field.invalid input,
.field.invalid select { border-color: var(--danger); }

input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* 16px stops iOS/Android zooming the viewport on focus */
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

input::placeholder { color: var(--text-faint); }

/* Rego entry is state + plate side by side. */
.field-split {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 9px;
}

#v-rego {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- Notices ---- */

.notice {
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.notice-info  { background: var(--accent-soft); border-color: rgba(240,180,41,0.3); color: var(--text); }
.notice-warn  { background: var(--warn-soft);   border-color: rgba(232,135,58,0.3); color: var(--text); }
.notice-err   { background: var(--danger-soft); border-color: rgba(224,82,82,0.3);  color: var(--text); }
.notice b { color: var(--accent); }
.notice-warn b { color: var(--warn); }

/* ---- The servo hint ----
   The only card the app raises on its own, so it is tinted to read as a question
   rather than as another statistic in the stack. Its title is allowed to WRAP —
   .card-title ellipsises by default, which is right for a rego and wrong for
   "Add fuel for Kempsey Roadhouse?", where the servo's name is the whole point. */
.card-hint {
  background: var(--accent-soft);
  border-color: rgba(240, 180, 41, 0.32);
}

.card-hint .card-title {
  white-space: normal;
  overflow: visible;
}

.card-hint .btn-row { margin-bottom: 0; }

/* ---- Empty state ---- */

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-dim);
}

.empty-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  opacity: 0.45;
}

.empty-icon svg {
  width: 46px; height: 46px;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}

.empty-title { font-size: 15px; font-weight: 620; color: var(--text); margin-bottom: 6px; }
.empty-body  { font-size: 13px; line-height: 1.55; max-width: 300px; margin: 0 auto 18px; }

/* ---- Sync / status strip ---- */

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 0 2px 12px;
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  flex: none;
}

.status.online  .status-dot { background: var(--ok); }
.status.offline .status-dot { background: var(--warn); }
.status.online  { color: var(--text-dim); }
.status.offline { color: var(--warn); }

/* ---- Toast ---- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  font-weight: 560;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err  { border-color: rgba(224, 82, 82, 0.5); }

/* ---- Onboarding slides ---- */

.slide-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 22px 0 20px;
}

.slide-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.16s ease, width 0.16s ease;
}

.slide-dot.on { background: var(--accent); width: 20px; border-radius: 4px; }

.gate-logo {
  width: 62px; height: 62px;
  margin-bottom: 20px;
}

.gate-h1 {
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  line-height: 1.2;
}

.gate-p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 8px;
}

.gate-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.gate-list li {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  padding: 7px 0;
}

.gate-list li::before {
  content: "";
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
}

.gate-foot {
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.55;
  text-align: center;
  margin-top: 16px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px;
}

/* Sits under the password field, pulled up tight against it and right-aligned so it
   reads as belonging to that field rather than as a second action next to Sign in.
   Still a full-height tap target — this gets pressed one-handed in a ute. */
.auth-forgot {
  display: block;
  margin: -8px 0 12px auto;
  padding: 8px 2px;
  font-size: 12.5px;
}

/* ---- Trips ---- */

/* The three classification states get the colours reserved in theme.css, so the
   Today legend and a trip card can never drift apart. "Unset" is deliberately dull:
   it is a gap to be filled, not a fourth category. */
.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-business { background: var(--accent-soft); color: var(--business); }
.pill-private  { background: rgba(126, 147, 232, 0.16); color: var(--private); }
.pill-skip     { background: var(--surface-3); color: var(--text-faint); }
.pill-unset    { background: var(--surface-3); color: var(--text-dim); border: 1px dashed var(--line-strong); }

.trip-group { margin-bottom: 18px; }

.trip-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 3px 7px;
}

.trip-card { margin-bottom: 8px; cursor: pointer; }
.trip-card:active { opacity: 0.8; }

.trip-route {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

/* ---- Stat strip — the Trips summary and the vehicle detail sheet ---- */

.trip-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.trip-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 10px;
  text-align: center;
}

.trip-stat-n {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.trip-stat-n.is-warn { color: var(--warn); }
.trip-stat-u { font-size: 12px; font-weight: 600; color: var(--text-faint); margin-left: 1px; }

.trip-stat-l {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ---- Route map ---- */

.trip-map {
  height: 190px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

/* The offline SVG trail fills the box; Leaflet manages its own sizing once it
   takes over, so this only applies to the fallback. */
.trip-map.has-trail { display: block; }
.trip-trail { display: block; width: 100%; height: 100%; }

.trip-map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
  padding: 0 20px;
}

.trip-stat-row {
  display: flex;
  gap: 14px;
  align-items: baseline;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.trip-stat-row strong { color: var(--text); font-size: 15px; font-weight: 700; }
.trip-source { margin-left: auto; font-size: 11.5px; color: var(--text-faint); }

/* ---- Segmented control ---- */

.seg {
  display: flex;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 6px;
  cursor: pointer;
}
.seg-btn:active { opacity: 0.8; }
.seg-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Purpose is only ATO-required for business travel, so the hint changes rather
   than the field being validated after the fact. */
.field-hint.is-required { color: var(--warn); }

/* ---- Switch ---- */

.switch { position: relative; display: inline-block; flex-shrink: 0; }
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.switch-track {
  display: block;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.switch-track::after {
  content: '';
  display: block;
  width: 21px;
  height: 21px;
  margin: 2px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(19px);
  background: var(--accent);
}

/* ---- Attribution prompt ---- */

.attr-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 11px;
}
.attr-row select { flex: 1; min-width: 0; margin: 0; }
.attr-row .btn { width: auto; flex-shrink: 0; }

/* ---- Fuel entries — the list on the vehicle detail sheet ---- */

.fuel-row {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.fuel-row:last-child { border-bottom: 0; }

.fuel-row-grow { flex: 1; min-width: 0; }
.fuel-row-main {
  font-size: 14px;
  font-weight: 620;
  color: var(--text);
  line-height: 1.3;
}
.fuel-row-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fuel-row-cost { font-size: 14px; font-weight: 700; color: var(--text); flex-shrink: 0; }

/* A partial fill is kept and shown, but cannot contribute to the running average —
   the chip is how the driver knows why their sample count did not move. */
.fuel-row .chip { margin-left: 6px; vertical-align: 1px; }

.receipt-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--surface-2);
}

.receipt-preview {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-top: 8px;
}

/* The file input itself is unstyleable across browsers; the label is the button. */
.file-btn {
  display: block;
  text-align: center;
  cursor: pointer;
}
.file-btn input[type="file"] { display: none; }
