:root {
  --brand: #0b7a54;
  --brand-dark: #085c3f;
  --brand-soft: #e7f6ef;
  --ink: #12241c;
  --muted: #5d7268;
  --line: #e4ece7;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --danger: #d61f4e;
  --radius: 18px;
  --shadow: 0 8px 28px rgba(18, 36, 28, 0.08);
  --topbar-h: 60px;
  --tabbar-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.app-body {
  padding-top: calc(var(--topbar-h) + var(--safe-top));
}

body.has-tabbar {
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }

.app-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

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

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: 14px;
  padding: 0 12px;
  font-weight: 600;
}

.icon-btn.ghost {
  background: transparent;
  color: var(--muted);
}

.btn,
button,
a.btn,
.icon-btn,
.tabbar a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.app-content {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 24px;
}

.page-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 6px;
}

.page-sub {
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.45;
}

.surface-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary,
.btn-dark {
  background: var(--brand);
  color: #fff !important;
}

.btn-primary:hover,
.btn-dark:hover { background: var(--brand-dark); color: #fff !important; }

.btn-primary:disabled,
.btn-dark:disabled {
  background: #9bb8ac;
  cursor: not-allowed;
}

.btn-ghost,
.btn-outline-dark {
  background: #fff;
  color: var(--ink) !important;
  border: 1px solid var(--line);
}

.btn-success { background: var(--brand); color: #fff !important; }
.btn-outline-danger {
  background: #fff;
  color: var(--danger) !important;
  border: 1px solid #f3c5d1;
}

.btn-lg { min-height: 52px; padding: 0 20px; font-size: 1rem; }
.w-100 { width: 100%; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.tabbar a.active { color: var(--brand-dark); }
.tabbar svg { width: 22px; height: 22px; }

.form-label {
  font-weight: 700;
  font-size: 0.84rem;
  margin-bottom: 6px;
  color: var(--ink);
}

.form-control,
input.form-control,
.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="email"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.form-control:focus,
.auth-form input:focus {
  outline: 3px solid var(--brand-soft);
  border-color: var(--brand);
}

.auth-form p { margin-bottom: 14px; }
.auth-form label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 0.84rem;
}
.auth-form .helptext,
.auth-form .helptext ul {
  color: var(--muted);
  font-size: 0.75rem;
  padding-left: 16px;
  margin-top: 6px;
}

@media (max-width: 899px) {
  .auth-form .helptext { display: none; }
}
.errorlist {
  color: var(--danger);
  list-style: none;
  padding-left: 0;
  font-size: 0.85rem;
  margin: 6px 0 0;
}

.alert {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
}
.alert-info { background: var(--brand-soft); color: var(--brand-dark); }
.alert-warning { background: #fff6e5; color: #8a5a00; }
.alert-success { background: var(--brand-soft); color: var(--brand-dark); }
.alert-error { background: #fde8ee; color: var(--danger); }

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.chip.warn { background: #fff6e5; color: #8a5a00; }
.chip.neutral { background: #eef1f0; color: var(--muted); }

.list-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }

.route-line { font-weight: 700; line-height: 1.35; }
.meta { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }

.empty-state {
  text-align: center;
  padding: 28px 12px;
  color: var(--muted);
}

.hero {
  display: grid;
  gap: 22px;
  padding: 12px 0 8px;
}

.hero h1 {
  font-size: clamp(2rem, 7vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.05em;
  margin: 0 0 12px;
}

.hero .lead { color: var(--muted); font-size: 1.05rem; margin: 0; }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.steps { margin: 0; padding-left: 18px; }
.steps li { margin-bottom: 10px; }

.map-layout {
  display: grid;
  gap: 16px;
  grid-template-areas:
    "map"
    "form";
}
.form-panel { grid-area: form; }
.map-panel { grid-area: map; overflow: hidden; padding: 0; }
#route-map,
#meeting-map {
  height: 38vh;
  min-height: 220px;
  width: 100%;
  background: #dfe8e3;
}

.places-widget,
gmp-place-autocomplete { width: 100%; }

input[data-maps="origin"],
input[data-maps="destination"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}
.route-meta { min-height: 1.4rem; color: var(--muted); }

.sticky-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  z-index: 5;
}

.match-card { padding: 16px; height: 100%; display: flex; flex-direction: column; }
.match-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.incoming-actions { display: flex; gap: 8px; margin-top: 10px; }
.incoming-actions .btn { flex: 1; }

.data-table {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}

.data-table-head,
.data-row summary {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 1fr 0.9fr;
  gap: 10px;
  align-items: center;
}

.data-table-head {
  padding: 12px 16px;
  background: var(--brand-soft);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-dark);
}

.data-row {
  border-top: 1px solid var(--line);
}

.data-row summary {
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  min-height: 56px;
}

.data-row summary::-webkit-details-marker { display: none; }
.data-row summary::after {
  content: "›";
  justify-self: end;
  color: var(--muted);
  font-size: 1.2rem;
}
.data-row[open] summary::after { content: "⌄"; }
.data-row summary:hover { background: #f7fbf8; }

.data-row-body {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.data-row .col-route { font-weight: 700; color: var(--ink); }
.data-row .col-muted { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 899px) {
  .data-table-head { display: none; }
  .data-row summary {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "route chev"
      "meta chev";
  }
  .data-row .col-driver { display: none; }
  .data-row .col-route { grid-area: route; }
  .data-row .col-time,
  .data-row .col-status { grid-area: meta; }
  .data-row .col-time { display: none; }
}

.dash-stack {
  display: grid;
  gap: 22px;
}

.match-grid {
  display: grid;
  gap: 12px;
}

.desktop-nav { display: none; }

@media (min-width: 900px) {
  .hero {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    padding-top: 48px;
  }
  .map-layout {
    grid-template-areas: "form map";
    grid-template-columns: 400px 1fr;
    align-items: start;
  }
  #route-map,
  #meeting-map {
    height: min(70vh, 620px);
    min-height: 420px;
  }
  .sticky-actions { position: static; }
  .tabbar { display: none; }
  body.has-tabbar { padding-bottom: 24px; }
  .desktop-nav { display: inline-flex; min-height: 40px; }
  .app-content { width: min(1120px, calc(100% - 48px)); padding-top: 24px; }
  .match-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 899px) {
  .desktop-only { display: none !important; }
}
