:root {
  --bg: #14161c;
  --panel: #1c1f27;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --accent: #e8590c;
  --line: #2a2f3a;
  --up: #37b24d;
  --down: #f03e3e;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
h3 { font-size: 0.9rem; margin: 0 0 0.25rem; color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); font-size: 0.85em; }
.up { color: var(--up); }
.down { color: var(--down); }

/* nav */
.topnav {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1100;
}
.topnav .brand { font-weight: 700; margin-right: 0.5rem; }
.topnav a { color: var(--muted); }
.topnav a.active, .topnav a:hover { color: var(--text); text-decoration: none; }
.topnav .logout { margin-left: auto; }
.topnav button {
  background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: 0.25rem 0.75rem; cursor: pointer;
}
.topnav button:hover { color: var(--text); border-color: var(--muted); }

main { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.page-head .count { color: var(--muted); font-weight: 400; font-size: 1rem; }
.toggle { color: var(--muted); }
.btn-edit {
  align-self: center; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 0.35rem 0.8rem; color: var(--muted); font-size: 0.9rem;
}
.btn-edit:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.ride-sub { color: var(--muted); margin-top: 0.25rem; }

/* stat tiles */
.statgrid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem; margin: 1.25rem 0;
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.9rem 1rem; display: flex; flex-direction: column;
}
.stat .cap { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .v { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 0.85rem; }
.stat .sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; }

/* tables */
.tablewrap { overflow-x: auto; }
table.data, table.records, table.kv { border-collapse: collapse; width: 100%; }
table.data th, table.data td, table.records td, table.kv td {
  padding: 0.45rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left;
  white-space: nowrap;
}
table.data th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
table.records .rv { font-weight: 700; white-space: nowrap; }
table.records .rd { color: var(--muted); white-space: nowrap; }
table.kv { max-width: 640px; margin: 1rem 0; }
table.kv td:first-child { color: var(--muted); width: 10rem; }
.flag { color: #fab005; font-size: 0.8rem; }
.ytd { font-size: 1.05rem; }

/* charts */
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem; margin: 1rem 0; }
.u-legend { color: var(--muted); }

/* ride list */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; align-items: center; }
.filters select, .filters input, .filters button {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.4rem 0.6rem; font-size: 0.9rem;
}
.filters button { cursor: pointer; }
.filters .clear { color: var(--muted); font-size: 0.85rem; }

.ridelist { list-style: none; padding: 0; margin: 1rem 0; }
.ridelist li { margin-bottom: 0.6rem; }
.ridelist .empty { color: var(--muted); }
.ride {
  display: flex; gap: 1rem; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 0.6rem 0.9rem; color: var(--text);
}
.ride:hover { border-color: var(--accent); text-decoration: none; }
.thumb {
  width: 96px; height: 72px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
  background: var(--bg);
}
.nothumb {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.7rem; text-align: center;
  border: 1px dashed var(--line);
}
.ride-main { display: flex; flex-direction: column; min-width: 0; }
.ride-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ride-meta, .ride-nums { color: var(--muted); font-size: 0.85rem; }

.pager { display: flex; gap: 1.5rem; justify-content: center; margin: 1.5rem 0; color: var(--muted); }

/* map */
.ridemap { height: 420px; border-radius: 10px; border: 1px solid var(--line); margin: 1rem 0; z-index: 0; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2rem 2.5rem; text-align: center; }
.login-box h1 { margin-bottom: 1.25rem; }
.login-box input {
  display: block; width: 100%; margin-bottom: 0.75rem;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 0.6rem 0.8rem; font-size: 1rem;
}
.login-box button {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 6px; padding: 0.6rem; font-size: 1rem; cursor: pointer;
}
.login-box .error { color: var(--down); }

@media (max-width: 600px) {
  .topnav { gap: 0.75rem; padding: 0.6rem 0.75rem; flex-wrap: wrap; }
  .thumb { width: 72px; height: 54px; }
}
