/* Carguala PWA — self-hosted, no CDN fonts */
:root {
  --bg0: #0b3d2e;
  --bg1: #125c45;
  --bg2: #f3efe6;
  --ink: #14201b;
  --muted: #4a5c54;
  --accent: #e8a317;
  --danger: #9b2c2c;
  --ok: #1f7a4c;
  --line: rgba(20, 32, 27, 0.12);
  --card: #fffdf8;
  --shadow: 0 10px 30px rgba(11, 61, 46, 0.12);
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", sans-serif;
  --display: "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 163, 23, 0.18), transparent 60%),
    linear-gradient(165deg, #e7f0ea 0%, var(--bg2) 45%, #dfeae4 100%);
}
a { color: var(--bg1); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(120deg, var(--bg0), var(--bg1));
  color: #f7f3ea;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}
.brand {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
}
.nav a {
  color: #e8f5ef;
  font-size: 0.92rem;
  text-decoration: none;
  opacity: 0.9;
}
.nav a:hover, .nav a.active { opacity: 1; text-decoration: underline; }

.view {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  min-height: 70vh;
}

.hero {
  padding: 1.5rem 0 0.5rem;
}
.hero h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin: 0 0 0.5rem;
  color: var(--bg0);
}
.hero p { margin: 0; color: var(--muted); max-width: 36rem; line-height: 1.45; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  color: var(--bg0);
}
.stack { display: grid; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.grow { flex: 1 1 auto; }

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  background: var(--bg0);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--bg0);
  border: 1px solid rgba(11, 61, 46, 0.35);
}
button.accent, .btn.accent { background: var(--accent); color: #1a1405; }
button.danger { background: var(--danger); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

body.driver-mode-on .topbar,
body.driver-mode-on .footer {
  display: none;
}
body.driver-mode-on .view {
  max-width: none;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
}
body.driver-mode-on {
  background: #0c1a14;
}

.driver-mode {
  display: grid;
  grid-template-rows: auto auto minmax(220px, 1fr) auto auto;
  min-height: 100vh;
  min-height: 100dvh;
  color: #f3f7f4;
  background: linear-gradient(180deg, #0c1a14 0%, #12261d 40%, #0c1a14 100%);
}
.driver-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
}
.driver-top .secondary {
  color: #e8f5ef;
  border-color: rgba(232, 245, 239, 0.35);
}
.driver-status {
  font-size: 0.9rem;
  opacity: 0.9;
}
.driver-next {
  padding: 0.5rem 1.15rem 0.85rem;
}
.driver-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
}
.driver-next h1 {
  margin: 0.25rem 0 0.4rem;
  font-family: var(--display);
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: #fff;
}
.driver-addr {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.4;
  color: #e8f5ef;
}
.driver-hint {
  margin: 0.45rem 0 0;
  color: rgba(232, 245, 239, 0.7);
  font-size: 0.9rem;
}
.driver-eta {
  margin: 0.45rem 0 0;
  color: #c5d4cb !important;
  font-size: 0.92rem;
}
.driver-map {
  margin: 0 0.75rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 240px;
  height: 38vh;
  background: #1a2e24;
}
.driver-nav, .driver-actions {
  padding: 0.75rem 1rem;
  display: grid;
  gap: 0.55rem;
}
.driver-actions {
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}
.drive-nav-main, .drive-advance {
  width: 100%;
  text-align: center;
  font-size: 1.05rem;
  padding: 0.95rem 1.2rem;
  border-radius: 14px;
}
.drive-nav-alt {
  justify-content: stretch;
}
.drive-nav-alt .btn {
  flex: 1;
  text-align: center;
  text-decoration: none;
}
.drive-advance {
  font-size: 1.15rem;
  padding: 1.1rem 1.2rem;
}

.notice {
  border-left: 4px solid var(--accent);
  background: #fff7e6;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  color: #4a3a12;
  font-size: 0.92rem;
  line-height: 1.4;
}
.notice.danger {
  border-left-color: var(--danger);
  background: #fdecec;
  color: #5c1d1d;
}
.notice.ok {
  border-left-color: var(--ok);
  background: #e8f6ee;
  color: #184832;
}

.job-list { display: grid; gap: 0.75rem; }
.job-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
}
.job-card:hover { border-color: rgba(11, 61, 46, 0.4); }
.job-card .meta { color: var(--muted); font-size: 0.86rem; }
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #e7f0ea;
  color: var(--bg0);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.map-wrap {
  height: 280px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #cfdcd5;
}
.map-wrap.tall { height: 360px; }
.map-wrap.compact { height: 220px; }
.map-hint { font-size: 0.82rem; color: var(--muted); margin-top: 0.35rem; }

.leaflet-div-icon.carguala-pin-host {
  background: transparent !important;
  border: none !important;
}
.carguala-pin-dot {
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(11, 61, 46, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
  font-family: var(--font);
  pointer-events: auto;
}
.carguala-pin-dot.pickup { background: #1f7a4c; color: #fff; }
.carguala-pin-dot.dropoff { background: var(--accent); color: var(--ink); }
.carguala-pin-dot.passenger { background: #2563eb; color: #fff; }
.carguala-pin-dot.dropoff_passenger {
  background: linear-gradient(135deg, var(--accent) 0 50%, #2563eb 50% 100%);
  color: var(--ink);
  font-size: 9px;
  letter-spacing: -0.02em;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.45rem;
}
.map-legend .leg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  font-style: normal;
  margin-right: 0.25rem;
  vertical-align: middle;
  color: #fff;
}
.map-legend .leg.pickup { background: #1f7a4c; }
.map-legend .leg.dropoff { background: var(--accent); color: var(--ink); }
.map-legend .leg.passenger { background: #2563eb; }

.route-addresses {
  margin-top: 0.65rem;
  padding: 0.75rem 0.85rem;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.45;
}
.route-addresses .addr-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.route-addresses .addr-tag {
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-width: 5.5rem;
  padding-top: 0.15rem;
}
.route-addresses .addr-text { flex: 1; word-break: break-word; }
.route-addresses .addr-arrow {
  text-align: center;
  color: var(--bg1);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.15rem 0;
  opacity: 0.75;
}
.suggest-list button .dist {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
  margin-top: 0.15rem;
}

.chat {
  display: grid;
  gap: 0.5rem;
  max-height: 320px;
  overflow: auto;
  padding: 0.5rem;
  background: #f7faf8;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.bubble {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.92rem;
  white-space: pre-wrap;
}
.bubble.mine {
  justify-self: end;
  background: #e7f0ea;
  border-color: rgba(11, 61, 46, 0.2);
}
.bubble .who {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.65rem;
  margin-bottom: 0.4rem;
  line-height: 1.25;
}
.bubble .who-name {
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bg0);
  letter-spacing: 0.01em;
}
.bubble.mine .who-name { color: var(--bg1); }
.bubble .who-time {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.bubble .bubble-body {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
}

.live-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(31, 122, 76, 0.55);
  animation: live-pulse 1.6s ease-out infinite;
  vertical-align: middle;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 122, 76, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(31, 122, 76, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 122, 76, 0); }
}
.provider-filter {
  margin: 0 0 1.25rem;
  padding: 0 0 1.15rem;
  border-bottom: 1px solid var(--line);
}
.provider-filter h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}
.provider-filter > .muted {
  margin: 0 0 0.75rem;
  max-width: 42rem;
}
.provider-select { margin-bottom: 0; }
.provider-select label { font-weight: 600; }
.chat-section {
  margin-top: 0.15rem;
}
.chat-section > h3 {
  margin-top: 0;
}
.bubble-actions { margin-top: 0.4rem; }
.bubble-actions button { font-size: 0.8rem; padding: 0.25rem 0.55rem; }

.bid-list { display: grid; gap: 0.85rem; }
.bid-group { display: grid; gap: 0.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid rgba(11, 61, 46, 0.12); }
.bid-group:last-child { border-bottom: 0; }
.bid-group-title { font-weight: 600; font-size: 0.92rem; }
.bid-row {
  border: 1px solid rgba(11, 61, 46, 0.18);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}
.bid-row.bid-current {
  border-color: var(--accent, #1f7a4c);
  box-shadow: inset 3px 0 0 var(--accent, #1f7a4c);
  background: rgba(31, 122, 76, 0.06);
}
.bid-row.bid-increase {
  border-color: #b45309;
  background: rgba(180, 83, 9, 0.06);
}
.bid-top { display: flex; flex-wrap: wrap; gap: 0.35rem 0.5rem; align-items: center; }
.bid-note { margin-top: 0.35rem; font-size: 0.9rem; white-space: pre-wrap; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.ok { background: #d1fae5; color: #065f46; }
.pay-summary {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}
.pay-log { margin: 0.75rem 0; display: grid; gap: 0.35rem; }
.pay-log h4 { margin: 0.25rem 0; }

.checklist { display: grid; gap: 0.5rem; }
.checklist button { justify-self: start; }

.auth-gate {
  text-align: center;
  padding: 2.5rem 1rem;
}
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; }
.footer {
  padding: 1rem;
  text-align: center;
}
.fineprint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 40rem;
  margin-inline: auto;
  line-height: 1.4;
}
.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  margin: 0.65rem 0 0;
}
.legal-links a {
  color: var(--bg1);
  text-decoration: none;
  font-size: 0.85rem;
}
.legal-links a:hover { text-decoration: underline; }
.legal-doc {
  line-height: 1.55;
  font-size: 0.95rem;
}
.legal-doc h1 {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--bg0);
  margin: 0 0 0.75rem;
}
.legal-doc h2 {
  font-size: 1.15rem;
  margin: 1.4rem 0 0.5rem;
  color: var(--bg0);
}
.legal-doc h3 {
  font-size: 1rem;
  margin: 1.1rem 0 0.4rem;
}
.legal-doc ul, .legal-doc ol {
  padding-left: 1.25rem;
  margin: 0.4rem 0 0.8rem;
}
.legal-doc li { margin: 0.25rem 0; }
.legal-doc p { margin: 0.5rem 0; }
.legal-doc code {
  font-size: 0.88em;
  background: #e7f0ea;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.legal-pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.78rem;
  line-height: 1.4;
  background: #0c1a14;
  color: #e8f5ef;
  padding: 1rem;
  border-radius: 10px;
  overflow: auto;
  max-height: 70vh;
}

/* Pronounced toggle switches */
.toggle {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.9rem;
  padding: 0.95rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  grid-template-columns: unset;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.toggle-ui {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 32px;
  border-radius: 999px;
  background: #c5d0ca;
  transition: background 0.2s ease;
}
.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}
.toggle input:checked + .toggle-ui {
  background: var(--bg0);
}
.toggle input:checked + .toggle-ui::after {
  transform: translateX(24px);
}
.toggle input:focus-visible + .toggle-ui {
  outline: 3px solid rgba(232, 163, 23, 0.55);
  outline-offset: 2px;
}
.toggle-text {
  display: grid;
  gap: 0.15rem;
  color: var(--ink);
}
.toggle-text strong {
  font-size: 1rem;
  font-weight: 700;
}
.toggle-text small {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.3;
}

.choice-row {
  display: grid;
  gap: 0.65rem;
}
.choice {
  text-align: left;
  background: #fffdf8;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  box-shadow: none;
  color: var(--ink);
  font: inherit;
  width: 100%;
}
.choice strong { display: block; font-size: 1rem; }
.choice small { display: block; color: var(--muted); margin-top: 0.25rem; line-height: 1.35; }
.choice.on {
  border-color: var(--bg1);
  background: #e7f0ea;
}
.choice:hover { border-color: rgba(11, 61, 46, 0.35); }

.suggest {
  position: relative;
}
.suggest-list {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 220px;
  overflow: auto;
  box-shadow: var(--shadow);
  z-index: 5;
}
.suggest-list button {
  width: 100%;
  text-align: left;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
}
.suggest-list button:last-child { border-bottom: 0; }
.suggest-list button:hover { background: #e7f0ea; }

/* Wizard */
.wizard-summary {
  display: grid;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.wizard-chip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}
.wizard-chip .chip-body {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}
.wizard-chip .chip-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.wizard-chip .chip-value {
  font-size: 0.95rem;
  color: var(--ink);
  word-break: break-word;
}
.wizard-chip button {
  flex: 0 0 auto;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.wizard-steps span {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #e7f0ea;
  color: var(--muted);
  font-weight: 600;
}
.wizard-steps span.on {
  background: var(--bg0);
  color: #fff;
}
.wizard-steps span.done {
  background: #d8ebe1;
  color: var(--bg0);
}
.search-status {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
.search-status.err { color: var(--danger); }

.track-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e8a317;
  border: 3px solid #0b3d2e;
  box-shadow: 0 0 0 6px rgba(232,163,23,0.25);
}

@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .nav { gap: 0.5rem 0.85rem; }
}
