:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d2420;
  --muted: #5d6a62;
  --line: #e2ded4;
  --brand: #2f5d3a;      /* forest green */
  --brand-ink: #ffffff;
  --accent: #c8702a;     /* trail orange: walked path + position */
  --trail: #2f5d3a;
  --warn-bg: #fff4dc;
  --warn-ink: #7a4b00;
  --done: #2c7a4b;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816; --surface: #1d2320; --ink: #e8ede9; --muted: #9db0a4; --line: #2e3833;
    --brand: #6fae7f; --brand-ink: #0f1311; --accent: #f0954a; --trail: #8cc79b;
    --warn-bg: #3a2e14; --warn-ink: #f3d08a; --done: #6fd39a; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141816; --surface: #1d2320; --ink: #e8ede9; --muted: #9db0a4; --line: #2e3833;
  --brand: #6fae7f; --brand-ink: #0f1311; --accent: #f0954a; --trail: #8cc79b;
  --warn-bg: #3a2e14; --warn-ink: #f3d08a; --done: #6fd39a; --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.top { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 12px; max-width: 1200px; margin: 0 auto; }
.badge {
  flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 18px;
}
h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }

.layout {
  max-width: 1200px; margin: 0 auto; padding: 16px; display: grid; gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: 360px 1fr; align-items: start; }
  .map-wrap { position: sticky; top: 16px; }
  #map { height: calc(100vh - 120px); min-height: 520px; }
}

.panel { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.eta-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow);
}
.eta-card .label { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.eta { margin: 2px 0 0; font-size: 48px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.range { margin: 4px 0 0; color: var(--muted); }
.pickup { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-weight: 600; }
.pickup:empty { display: none; }
.eta-card.done .eta { color: var(--done); }

.status { margin: 0; font-weight: 600; }

.progress .bar { position: relative; height: 10px; border-radius: 99px; background: var(--line); overflow: visible; }
.progress .fill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .4s ease; }
.progress .turn { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--muted); }
.progress .ends { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: 6px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }
.fine { margin: 0; color: var(--muted); font-size: 13px; }

.map-wrap { min-width: 0; }
#map { height: 58vh; min-height: 320px; border-radius: 16px; border: 1px solid var(--line); background: var(--line); }

.you-are-here {
  width: 18px; height: 18px; border-radius: 50%; background: #e2560f; border: 3px solid #fff;
  box-shadow: 0 0 0 0 rgba(200,112,42,.6); animation: pulse 2s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 14px rgba(200,112,42,0); } 100% { box-shadow: 0 0 0 0 rgba(200,112,42,0); } }
@media (prefers-reduced-motion: reduce) { .you-are-here { animation: none; } }
.pin { width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; background: #3346c4; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }

/* ---------- header nav ---------- */
.top .brand { flex-wrap: wrap; }
.top .brand > div { flex: 1; min-width: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .nav { flex-basis: 100%; margin-left: -10px; }
}
.nav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--bg); }

/* ---------- buttons & forms ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 15px; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: #c0392b; }
.btn.small { font-size: 13px; padding: 5px 10px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select {
  width: 100%; font: inherit; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; }
.form-error { color: #c0392b; font-size: 14px; margin: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ---------- sign-in ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
}
.login-card h1 { font-size: 20px; margin-top: 8px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }

/* ---------- admin & history ---------- */
.page { max-width: 960px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; margin: 0 0 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.field { min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.preview { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
#previewMap { height: 240px; border-radius: 12px; border: 1px solid var(--line); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.status-badge { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 6px; }
.status-planned { background: var(--bg); color: var(--muted); }
.status-active { background: #e2560f; color: #fff; }
.status-done { background: var(--brand); color: var(--brand-ink); }
.hike-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.hike-list li { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.hike-list li:first-child { border-top: 0; }
.hike-list .meta { min-width: 0; }
.hike-list .name { font-weight: 700; }
.hike-list .when { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); margin: 0; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.totals div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.totals dt { color: var(--muted); font-size: 13px; }
.totals dd { margin: 2px 0 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.history-item a { color: inherit; text-decoration: none; }
.history-item .stats-line { color: var(--muted); font-size: 14px; }
input[type=email] {
  width: 100%; font: inherit; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.checks { border: 0; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.checks label { display: flex; gap: 10px; align-items: center; font-weight: 500; margin: 0; }
.checks input { width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.subhead { font-size: 15px; margin: 18px 0 6px; }
.alerts-card h2 { font-size: 17px; margin: 0 0 10px; }
.alert-ok { margin: 0 0 10px; color: var(--done); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.log-list li:first-child { border-top: 0; }
.log-list details summary { cursor: pointer; }
.log-list pre { white-space: pre-wrap; font: 13px/1.45 ui-monospace, Menlo, monospace; background: var(--bg); padding: 10px; border-radius: 8px; margin: 8px 0 0; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; margin: 0 0 12px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 2000; }

.replay {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  background: var(--surface); border-top: 1px solid var(--line); z-index: 1000;
}
.replay button {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
  font-size: 16px; cursor: pointer;
}
.replay input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.replay select { flex: none; width: auto; font: inherit; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.clock { flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; min-width: 70px; text-align: right; }
@media (max-width: 480px) { .clock { display: none; } }
