:root {
  color-scheme: dark;
  --bg: #081018;
  --panel: #101b27;
  --panel2: #142333;
  --line: #26384a;
  --text: #eef7ff;
  --muted: #9db0c2;
  --brand: #2fe6b8;
  --blue: #3e7bfa;
  --purple: #9b4dff;
  --danger: #ff6074;
  --walk: #44e08f;
  --bike: #45b7ff;
  --drive: #9b4dff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 20% 0, #173653 0, transparent 32rem), var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  color: var(--text);
}

.wrap { width: min(1180px, calc(100% - 32px)); margin: auto; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(8, 16, 24, .82);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.nav, .footer { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; text-decoration: none; }
.brand img { width: 32px; }
.brand span, .eyebrow { color: var(--brand); }
.footer { color: var(--muted); font-size: .9rem; }

/* Hero */
.hero { padding: 56px 0; max-width: 720px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 5rem); line-height: .95; margin: 0 0 16px; }
.hero p { color: var(--muted); font-size: 1.1rem; }
.panel-hero {
  max-width: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(47, 230, 184, .12), rgba(62, 123, 250, .1));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  margin-top: 24px;
}

/* Auth */
.auth-shell { display: grid; grid-template-columns: 1.1fr .9fr; gap: 32px; align-items: center; }
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .18);
}
.auth-card { max-width: 460px; margin-left: auto; width: 100%; }
.hidden { display: none !important; }

/* Tabs / filter pills */
.tabs, .section-tabs, .filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button, .section-tabs button, .filters button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tabs button:hover, .section-tabs button:hover, .filters button:hover { border-color: var(--brand); color: var(--text); }
.tabs .active, .section-tabs .active, .filters .active {
  background: var(--brand);
  color: #04221b;
  border-color: transparent;
  font-weight: 800;
}

/* Forms */
label { display: grid; gap: 8px; margin: 12px 0; color: var(--muted); font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0b1520;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  transition: border-color .15s ease;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 800;
  font: inherit;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--blue)); color: #04131a; border: 0; }
.btn.danger { background: rgba(255, 96, 116, .12); border-color: rgba(255, 96, 116, .5); color: #ff9aaa; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.muted { color: var(--muted); }
a { color: var(--brand); }
.small { font-size: .9rem; }

.message { padding: 12px 14px; border-radius: 14px; margin: 12px 0; }
.message.error { background: rgba(255, 96, 116, .12); color: #ffb2bf; }
.message.ok { background: rgba(47, 230, 184, .12); color: #aaffea; }

/* Dashboard grid */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { padding: 18px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.stat .value { font-size: 1.7rem; font-weight: 900; margin-top: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }

.chart { display: flex; align-items: end; gap: 5px; height: 180px; border-bottom: 1px solid var(--line); padding-top: 12px; }
.bar { flex: 1; min-width: 3px; background: linear-gradient(180deg, var(--brand), var(--blue)); border-radius: 7px 7px 0 0; }

.mode-row, .activity {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  transition: background .15s ease;
}
.mode-row:last-child, .activity:last-child { border-bottom: none; }
.activity { grid-template-columns: 1fr auto; }
.activity:hover { background: rgba(255, 255, 255, .03); }
.mode-icon { font-size: 1.8rem; }
.pill { display: inline-flex; border-radius: 999px; padding: 4px 9px; background: #192a3a; color: var(--muted); font-size: .82rem; margin-right: 6px; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }

.replay-map { width: 100%; height: 420px; background: #07111a; border-radius: 18px; margin-top: 12px; z-index: 0; }
.replay-map .leaflet-tile-pane { filter: brightness(0.72) saturate(0.9) invert(1) hue-rotate(180deg); }
.replay-map .leaflet-control-zoom a {
  background: var(--panel2);
  color: var(--text);
  border-color: var(--line) !important;
}
.replay-map .leaflet-control-zoom a:hover { background: var(--panel); }
.replay-map .leaflet-control-attribution {
  background: rgba(8, 16, 24, .75);
  color: var(--muted);
}
.replay-map .leaflet-control-attribution a { color: var(--muted); }
.replay-cursor { filter: drop-shadow(0 0 6px currentColor); animation: replay-pulse 1s ease-in-out infinite; }
@keyframes replay-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.replay-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.replay-controls .btn { padding: 10px 14px; line-height: 1; }
.replay-progress { flex: 1; height: 6px; border-radius: 999px; background: var(--panel2); overflow: hidden; }
.replay-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--blue)); transition: width .1s linear; }

.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-right: 10px; }
.unit-toggle button {
  border: 0;
  background: var(--panel);
  color: var(--muted);
  padding: 10px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.unit-toggle button.active { background: var(--brand); color: #04221b; }

.avatar-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar-row img { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; background: #07111a; border: 1px solid var(--line); }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 850px) {
  .auth-shell, .two-col { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-hero { display: block; }
  .panel-hero .btn { margin-top: 16px; }
  .hero { padding: 32px 0; }
  .auth-card { margin: 0; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
}
