:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d1f23;
  --muted: #6b7280;
  --border: #e3e5e8;
  --brand: #f5b301;       /* tuk-tuk yellow */
  --brand-dark: #c98f00;
  --accent: #16a34a;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

header {
  background: var(--brand);
  color: #1d1f23;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 1.15rem; margin: 0; }
header a { color: #1d1f23; text-decoration: none; font-weight: 600; font-size: .9rem; }

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 72px; /* bottom space for the fixed footer */
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { font-size: 1rem; margin: 0 0 12px; }

.rate-info { font-size: .9rem; color: var(--muted); margin: 0; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.tab.active { background: var(--brand); border-color: var(--brand-dark); }
.panel { display: none; }
.panel.active { display: block; }

/* Forms */
label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 6px; }
input[type="number"], input[type="text"], input[type="password"] {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* 16px stops iOS zoom on focus */
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 20px; height: 20px; }
.hint { font-size: .8rem; color: var(--muted); margin: 6px 0 0; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  display: inline-block;
  width: 100%;
  padding: 14px;
  margin-top: 14px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--brand);
  color: #1d1f23;
}
.btn:active { transform: scale(.99); }
.btn.secondary { background: #e9eaee; }
.btn.danger { background: #fde2e2; color: var(--danger); }
.btn.small { width: auto; padding: 8px 12px; margin-top: 8px; font-size: .85rem; }

/* Map */
#map {
  width: 100%;
  height: 300px;
  border-radius: 10px;
  margin-top: 12px;
  background: #e9eaee;
  position: relative;
  z-index: 0; /* keep Leaflet's layers below the sticky header/footer */
}

/* Place search */
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
.btn.search-btn { width: auto; margin-top: 0; padding: 0 16px; }
input[type="search"] {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
}
.search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}
.search-results li {
  padding: 10px 12px;
  font-size: .9rem;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.search-results li:first-child { border-top: none; }
.search-results li:hover, .search-results li:active { background: #fff7e0; }
.search-results li.muted { color: var(--muted); cursor: default; background: none; }

/* A / B pins on OpenStreetMap */
.pin span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--brand);
  border: 2px solid #1d1f23;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.pin b { transform: rotate(45deg); font-weight: 800; color: #1d1f23; }
.selected-place { font-size: .8rem; color: var(--muted); margin-top: 4px; min-height: 1em; }

.notice {
  background: #fff7e0;
  border: 1px solid #f3d27a;
  border-radius: 10px;
  padding: 12px;
  font-size: .9rem;
}
.error { color: var(--danger); font-size: .9rem; margin-top: 8px; min-height: 1em; }

/* Result */
.result { text-align: center; }
.result .total { font-size: 2.4rem; font-weight: 800; margin: 4px 0; color: var(--accent); }
.result .distance { color: var(--muted); }
.breakdown {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: .9rem;
  text-align: left;
}
.breakdown td { padding: 6px 0; border-top: 1px solid var(--border); }
.breakdown td:last-child { text-align: right; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  background: #1d1f23;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: .9rem;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.hidden { display: none !important; }

/* Footer bar */
footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  background: var(--brand);
  color: #1d1f23;
  text-align: center;
  font-size: .85rem;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
footer b { color: #1d1f23; font-weight: 800; }

/* Receipt buttons */
.receipt-box { text-align: left; margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--border); }

/* Locked fields (e.g. rates controlled by the online rates file) */
input:disabled { background: #f0f1f3; color: var(--muted); cursor: not-allowed; }
.notice { margin-bottom: 8px; }

/* Install app */
.header-actions { display: flex; align-items: center; gap: 12px; }
.install-btn {
  border: 2px solid #1d1f23;
  background: transparent;
  color: #1d1f23;
  font-weight: 700;
  font-size: .85rem;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.install-hint { position: relative; background: #fff7e0; border-color: #f3d27a; padding-right: 40px; }
.install-hint p { margin: 6px 0 0; font-size: .9rem; }
.hint-close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
}
.share-icon {
  display: inline-block;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  padding: 0 4px;
  font-size: .8rem;
}

/* Keep the header on one line on small phones */
header h1, .header-actions a, .install-btn { white-space: nowrap; }
@media (max-width: 360px) {
  header { padding: 12px; }
  header h1 { font-size: 1rem; }
  .header-actions { gap: 8px; }
  .install-btn { padding: 4px 8px; font-size: .8rem; }
  header a { font-size: .85rem; }
}

/* Cost per km calculator */
.calc-table td { vertical-align: top; }
.calc-table .row-note { font-size: .75rem; color: var(--muted); }
.calc-table tr.strong td { font-weight: 700; }
.charge-box { text-align: center; margin: 16px 0 12px; }
.charge-box .total { font-size: 2rem; font-weight: 800; color: var(--accent); margin: 2px 0; }

select {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
/* Fare rates tabs (one per vehicle type) */
.fare-tabs { margin: 4px 0 8px; }
.fare-tabs .tab { padding: 10px 6px; font-size: .9rem; }
.shared-rates { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--border); }
.calc-price { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; }
.calc-price.active { border: 1px solid #f3d27a; background: #fff7e0; }
.calc-price .hint { margin-top: 4px; }
.rounded-price { text-align: center; margin: 12px 0; font-size: 1rem; }

/* Waiting time box inside the Map / Meter card, above Calculate Fare */
.waiting-box { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.waiting-box h2 { font-size: .95rem; margin: 0; }

/* Vehicle type on the fare page */
.vehicle-label { margin-top: 0; }
#vehicleSelect { margin-bottom: 12px; font-weight: 600; }


/* Header title used as a link (Admin -> home) */
header h1 a { color: inherit; font-size: inherit; font-weight: inherit; text-decoration: none; }

/* Cost per km: save / defaults */
.cost-actions .btn { margin-top: 16px; }
.cc-figures-status { margin-top: 6px; }
.cc-figures-status.unsaved { color: #b45309; font-weight: 600; }

/* Admin fare tabs: where each figure comes from */
.fare-panel .field { margin-bottom: 2px; }
.src-line { font-size: .75rem; margin-top: 3px; color: var(--muted); }
.src-line.src-local { color: #b45309; font-weight: 600; }
.src-reset { border: none; background: none; color: #1a73e8; font-weight: 600; font-size: .75rem; padding: 2px 0; cursor: pointer; }
.fare-panel h3.sub { font-size: .95rem; margin: 18px 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
.fuel-box { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.fuel-box summary { font-weight: 700; font-size: .95rem; cursor: pointer; }
.fuel-box .fuel-sum { font-weight: 400; color: var(--muted); font-size: .85rem; }
.vno-label { margin-top: 14px; }

/* Rider / Passenger mode (body[data-mode] is set by js/passenger.js) */
body[data-mode="rider"] .passenger-only,
body[data-mode="rider"] .chooser-only,
body[data-mode="passenger"] .rider-only,
body[data-mode="passenger"] .chooser-only,
body[data-mode="choose"] main > :not(.chooser-only):not(#iosInstallHint),
body[data-mode="choose"] .mode-switch,
body[data-mode="choose"] header .rider-only { display: none !important; }
body.fare-page:not([data-mode]) main { visibility: hidden; } /* home page, until the mode is known */

.mode-switch {
  border: 2px solid #1d1f23;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .8rem !important;
}
.mode-btn { display: block; text-align: left; padding: 16px; font-size: 1.05rem; }
.mode-btn small { display: block; font-weight: 400; font-size: .85rem; margin-top: 4px; opacity: .8; }

/* Passenger estimate */
.est-places { font-size: .85rem; margin: 8px 0 4px; color: var(--muted); }
.est-places div { margin-top: 2px; }
.est-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.est-row:first-child { border-top: none; }
.est-name small { display: block; color: var(--muted); font-size: .78rem; margin-top: 2px; }
.est-price { font-weight: 800; font-size: 1.15rem; color: var(--accent); white-space: nowrap; text-align: right; }
#estimateList { margin-top: 8px; border-top: 1px solid var(--border); }

/* Small phones: header buttons as icons only (full words stay in the tooltip) */
@media (max-width: 400px) {
  .hide-small { display: none; }
}

/* "Use the expressway" tick */
.expressway-box { margin-top: 14px; }
.expressway-box .hint { margin: 2px 0 0; }
