:root {
  --primary: #33493B;
  --primary-hover: #26362b;
  --gold: #C99A3E;
  --gold-soft: #e8d3a3;
  --dark: #14181A;
  --cream: #F7F4EC;
  --cream-surface: #EFEAE0;
  --surface: #ffffff;
  --border: rgba(20, 24, 26, 0.12);
  --danger: #b3432b;
  --ok: #33493B;
  --pending: #C99A3E;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--dark);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Shell ---------- */

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: var(--dark);
  color: var(--cream);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.2px;
}

.topbar .brand svg { flex-shrink: 0; }

.topbar .mode-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  border: 1px solid rgba(201,154,62,0.5);
  border-radius: 999px;
  padding: 3px 9px;
}

.topbar .actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  background: transparent;
  border: 1px solid rgba(247,244,236,0.25);
  color: var(--cream);
  border-radius: 999px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(247,244,236,0.1); }

main { flex: 1; width: 100%; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.wrap.narrow { max-width: 560px; }

/* ---------- Gate (setup / login) ---------- */

.gate {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
}

.gate-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 6px;
}

.gate-card p.lede {
  margin: 0 0 24px;
  color: rgba(20,24,26,0.65);
  font-size: 14.5px;
  line-height: 1.5;
}

.mode-switch {
  display: flex;
  gap: 6px;
  background: var(--cream-surface);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
}
.mode-switch button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--dark);
  opacity: 0.55;
}
.mode-switch button.active {
  background: var(--dark);
  color: var(--cream);
  opacity: 1;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(20,24,26,0.55);
  margin: 14px 0 6px;
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="tel"], input[type="email"], input[type="url"], input[type="password"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--cream);
  color: var(--dark);
}
input:focus { border-color: var(--primary); }

.field-hint {
  font-size: 12px;
  color: rgba(20,24,26,0.5);
  margin-top: 5px;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: normal;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14.5px;
  width: 100%;
  margin-top: 20px;
}
.btn-primary { background: var(--primary); color: var(--cream); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--dark); }
.btn:disabled { opacity: 0.5; cursor: default; }

.form-error {
  background: #fbe9e4;
  border: 1px solid rgba(179,67,43,0.3);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin-top: 16px;
}

.form-success {
  background: #eaf0ec;
  border: 1px solid rgba(51,73,59,0.3);
  color: var(--primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin-top: 16px;
}

/* ---------- Stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
}

.stat-card .stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(20,24,26,0.55);
  font-weight: 600;
}

.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  margin-top: 6px;
  line-height: 1.1;
}

.stat-card .stat-sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: rgba(20,24,26,0.5);
  margin-top: 4px;
}

/* ---------- Section / panel ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
}

.panel-body { padding: 4px 0 8px; }
.panel-body.padded { padding: 18px 20px 20px; }

.filter-row { display: flex; gap: 8px; align-items: center; }
select {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--cream);
}

/* ---------- Table ---------- */

.table-scroll { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(20,24,26,0.5);
  white-space: nowrap;
}
table.data td {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
table.data td.ref { font-family: var(--font-mono); }
table.data tr:hover td { background: var(--cream-surface); }

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: capitalize;
}
.pill-paid, .pill-completed, .pill-confirmed { background: #e2ebe4; color: var(--primary); }
.pill-pending, .pill-on-hold { background: #f7ecd7; color: #8a6420; }
.pill-cancelled, .pill-failed, .pill-refunded { background: #f6e2dc; color: var(--danger); }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: rgba(20,24,26,0.5);
  font-size: 14px;
}

/* ---------- Fleet grid ---------- */

.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 18px 20px 20px;
}
.fleet-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--cream);
}
.fleet-card .fc-title { font-weight: 700; font-size: 14.5px; }
.fleet-card .fc-meta { font-family: var(--font-mono); font-size: 12px; color: rgba(20,24,26,0.6); margin-top: 6px; }
.fleet-card .fc-rate { font-family: var(--font-display); font-size: 19px; margin-top: 10px; color: var(--primary); }

/* ---------- Settings ---------- */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 24px;
  padding: 4px 20px 18px;
}
.kv-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.kv-row .kv-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(20,24,26,0.5); }
.kv-row .kv-value { font-size: 14px; margin-top: 3px; }
.entity-tabs { display: flex; gap: 6px; padding: 14px 20px 0; }
.entity-tabs button {
  border: 1px solid var(--border);
  background: var(--cream);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
}
.entity-tabs button.active { background: var(--dark); color: var(--cream); border-color: var(--dark); }

/* ---------- User dashboard: booking result ---------- */

.booking-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-top: 22px;
}

.booking-card .b-ref {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: rgba(20,24,26,0.55);
}
.booking-card .b-vehicle {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 4px 0 18px;
}

.route {
  position: relative;
  padding-left: 26px;
  margin: 18px 0;
}
.route-stop {
  position: relative;
  padding-bottom: 20px;
}
.route-stop:last-child { padding-bottom: 0; }
.route-stop::before {
  content: '';
  position: absolute;
  left: -26px;
  top: 3px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--cream-surface);
  border: 2px solid var(--primary);
}
.route-stop.current::before {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(201,154,62,0.2);
}
.route-stop::after {
  content: '';
  position: absolute;
  left: -22px;
  top: 15px;
  width: 2px;
  bottom: -5px;
  background: var(--border);
}
.route-stop:last-child::after { display: none; }
.route-stop .rs-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: rgba(20,24,26,0.5); }
.route-stop .rs-value { font-size: 14.5px; margin-top: 2px; font-weight: 600; }

.booking-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.booking-meta-grid .kv-label { font-size: 11px; text-transform: uppercase; color: rgba(20,24,26,0.5); }
.booking-meta-grid .kv-value { font-size: 15px; margin-top: 2px; font-family: var(--font-mono); }

.help-line {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: rgba(20,24,26,0.65);
}
.help-line a { color: var(--primary); font-weight: 700; text-decoration: none; }

.skeleton {
  background: linear-gradient(90deg, var(--cream-surface) 25%, #e4ddcb 37%, var(--cream-surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- Mobile nav ---------- */

.tabbar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 60px;
  z-index: 15;
  overflow-x: auto;
}
.tabbar button {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  padding: 13px 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(20,24,26,0.55);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabbar button.active { color: var(--dark); border-bottom-color: var(--gold); }

.view { display: none; }
.view.active { display: block; }

@media (max-width: 640px) {
  .wrap { padding: 18px 14px 50px; }
  table.data td, table.data th { padding: 10px 14px; }
  .booking-meta-grid { grid-template-columns: 1fr; }
  .gate-card { padding: 26px 20px; }
}
