:root {
  --bg:        #0f0f0f;
  --surface:   #181818;
  --surface2:  #222222;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --muted:     #888;
  --accent:    #fc4c02;
  --accent-h:  #ff6a1f;
  --radius:    10px;
  --font:      'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── NAV ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
}

.nav-logo span { color: var(--accent); }

.nav-links { display: flex; gap: 1.5rem; font-size: .875rem; color: var(--muted); }
.nav-links a:hover { color: var(--text); }

/* ── HERO ── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6rem 1rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero h1 span { color: var(--accent); }

.hero p {
  color: var(--muted);
  font-size: 1.1rem;
  max-width: 420px;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1.75rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  border: none;
}

.btn-strava {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 16px rgba(252,76,2,.35);
}

.btn-strava:hover {
  background: var(--accent-h);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(252,76,2,.45);
}

.btn-strava:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: #2a2a2a; }

/* ── MAIN LAYOUT ── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── STATS BAR ── */
.stats-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1.25rem;
  flex: 1;
  min-width: 140px;
}

.stat-card .label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .25rem;
}

.stat-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.toolbar h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.toolbar-right { display: flex; align-items: center; gap: .75rem; }

select {
  appearance: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .45rem .9rem;
  border-radius: 7px;
  font-size: .875rem;
  cursor: pointer;
}

select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── TABLE ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

tbody td {
  padding: .75rem 1rem;
  color: var(--text);
  white-space: nowrap;
}

.td-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .2rem .55rem;
  font-size: .72rem;
  color: var(--muted);
  font-weight: 500;
}

.td-muted { color: var(--muted); }

/* ── PAGINATION ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
}

.pag-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(252,76,2,.4);
}

.pag-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.pag-btn:hover { background: #2a2a2a; border-color: #444; }

.pag-dots { color: var(--muted); cursor: default; }

/* ── NAV ACTIVE & PROFILE ── */
.nav-links a.nav-active { color: var(--accent); }

.nav-profile { display: flex; align-items: center; }

/* ── LANG SWITCH ── */
.lang-switch {
  display: flex;
  gap: .25rem;
}

.lang-btn {
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .45rem;
  border-radius: 5px;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all .15s;
}

.lang-btn:hover   { color: var(--text); border-color: var(--border); }
.lang-active      { color: var(--accent) !important; border-color: var(--accent) !important; }

/* ── DROPDOWN ── */
.dropdown { position: relative; }

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 8px;
  transition: background .15s;
}
.dropdown-toggle:hover { background: var(--surface2); }

.dropdown-arrow { font-size: .65rem; color: var(--muted); }

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 160px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 200;
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-menu a {
  display: block;
  padding: .65rem 1rem;
  font-size: .875rem;
  color: var(--text);
  transition: background .1s;
}
.dropdown-menu a:hover { background: var(--surface2); }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: .25rem 0;
}

.dropdown-lang-active {
  color: var(--accent) !important;
}

/* ── PROFILE PAGE ── */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 480px;
}

.profile-card-pic {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.profile-card-name { font-size: 1.2rem; font-weight: 700; margin-bottom: .2rem; }
.profile-card-username { font-size: .85rem; margin-bottom: .4rem; }
.profile-card-meta { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }

.badge-premium {
  display: inline-block;
  margin-top: .5rem;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  padding: .2rem .6rem;
  border-radius: 5px;
}

.profile-pic {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  align-self: center;
  flex-shrink: 0;
}

.profile-name {
  font-size: .875rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; word-break: break-word; }
.text-muted { color: var(--muted); font-size: .9rem; }

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 480px;
}

.card-info { font-size: .875rem; color: var(--muted); }

.status-msg { font-size: .875rem; color: var(--accent); min-height: 1.2em; }

/* ── PROGRESS BAR ── */
.progress-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-bottom: .5rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .6s ease;
  min-width: 2px;
}

.progress-label {
  font-size: .75rem;
  color: var(--muted);
  text-align: right;
  margin-bottom: 1rem;
}

/* ── CLICKABLE ROWS ── */
.tr-link, .tr-link td { cursor: pointer; }
.tr-link:hover { background: var(--surface2); }
.tr-link:hover td:first-child { border-left: 3px solid var(--accent); }

/* ── ACTIVITY DETAIL ── */
.back-link {
  display: inline-flex;
  align-items: center;
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: .75rem;
  padding: .25rem 0;
  min-height: 32px;
}
.back-link:hover { color: var(--text); }

/* ── STATS PAGE ── */
.stats-section-nav {
  display: flex;
  gap: .375rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .75rem;
}

.stats-section-btn {
  padding: .35rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s;
}

.stats-section-btn:hover { color: var(--text); }

.stats-section-btn.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.stats-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.stats-controls .stats-toggle { margin-bottom: 0; }

.stats-toggle {
  display: flex;
  gap: .375rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem;
  width: fit-content;
}

.stats-toggle-btn {
  padding: .4rem 1.1rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: .85rem;
  font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.stats-toggle-btn:hover { color: var(--text); }

.stats-toggle-btn.active {
  background: var(--surface2);
  color: var(--text);
}

.chart-tool-btn {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .75rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.chart-tool-btn:hover   { color: var(--text); border-color: #444; }
.chart-tool-btn.active  { border-color: var(--accent); color: var(--accent); }

.stats-metric-cycle {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.stats-metric-cycle:hover { border-color: #444; color: var(--accent); }

.stats-year-selector {
  display: flex;
  flex-wrap: wrap;
  gap: .375rem;
  margin-bottom: 1.25rem;
}

.stats-year-btn {
  padding: .3rem .85rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: border-color .15s, color .15s;
}

.stats-year-btn:hover { color: var(--text); border-color: #444; }

.stats-year-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

#map {
  width: 100%;
  height: 380px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

#map:fullscreen { height: 100vh; border-radius: 0; }

#chart {
  width: 100%;
  height: 180px;
  margin-top: 1rem;
}

.zone-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid #3b82f6;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  margin-top: .75rem;
  font-size: .875rem;
  flex-wrap: wrap;
}

.zone-label { color: #3b82f6; font-weight: 600; }
.zone-item  { display: flex; gap: .4rem; }
.zone-key   { color: var(--muted); }
.zone-val   { color: var(--text); font-weight: 600; }
.zone-clear {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 .25rem;
}
.zone-clear:hover { color: var(--text); }

.fs-btn {
  width: 30px;
  height: 30px;
  font-size: 1rem;
  background: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1rem;
  gap: 1rem;
}
.empty-state--small { padding: 2rem 1rem; }

.empty-icon { font-size: 3rem; line-height: 1; }

.empty-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.empty-text {
  color: var(--muted);
  font-size: .95rem;
  max-width: 380px;
  line-height: 1.6;
}

.empty-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: .5rem;
}

/* ── SEARCH INPUT ── */
.search-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .45rem .9rem;
  border-radius: 7px;
  font-size: .875rem;
  width: 180px;
  font-family: var(--font);
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.search-input::placeholder { color: var(--muted); }

/* ── RECORDS PAGE ── */
.records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.record-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: border-color .15s;
}
.record-card:hover { border-color: #444; }

.record-emoji { font-size: 1.5rem; flex-shrink: 0; line-height: 1.2; }

.record-body { min-width: 0; flex: 1; }

.record-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .25rem;
}

.record-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
  line-height: 1.1;
}

.record-name {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: .15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-name:hover { color: var(--accent); }

.record-meta { font-size: .8rem; color: var(--muted); }

/* ── HEATMAP PAGE ── */
.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.heatmap-header h1 { font-size: 1.5rem; font-weight: 700; }

.heatmap-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.heatmap-count {
  font-size: .875rem;
  color: var(--muted);
}

#heatmap-map {
  width: 100%;
  height: calc(100vh - 56px - 120px);
  min-height: 400px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── ACCOUNTS PAGE ── */
.account-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1.25rem;
  transition: border-color .15s;
}

.account-card-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.account-info     { flex: 1; min-width: 0; }
.account-name     { font-weight: 600; font-size: .95rem; }
.account-username { font-size: .8rem; color: var(--muted); }

.account-badge-active {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: .2rem .7rem;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

/* ── Hamburger button (hidden on desktop) ── */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  margin-left: auto;
  flex-shrink: 0;
  transition: background .15s;
}
.nav-hamburger:hover { background: var(--surface2); }

/* ── Mobile nav panel (hidden on desktop) ── */
.nav-mobile {
  display: none;
  flex-direction: column;
  position: fixed;
  top: 56px;
  left: 0; right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 98;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.nav-mobile.open { display: flex; }

.nav-mobile a {
  padding: .9rem 1.5rem;
  font-size: .95rem;
  color: var(--muted);
  border-left: 3px solid transparent;
  transition: color .1s, background .1s;
}
.nav-mobile a:hover         { color: var(--text); background: var(--surface2); }
.nav-mobile-active          { color: var(--accent) !important; border-left-color: var(--accent) !important; }
.nav-mobile-lang-active     { color: var(--accent) !important; }
.nav-mobile-divider         { height: 1px; background: var(--border); }

/* ── Tablet & mobile nav ── */
@media (max-width: 768px) {
  nav { padding: 0 1rem; }
  .nav-links      { display: none; }
  .nav-profile    { display: none; }
  .nav-hamburger  { display: flex; }
}

/* ── Mobile layout ── */
@media (max-width: 640px) {
  .page { padding: 1rem; }

  /* Stats bar: 2 cards per row */
  .stats-bar { gap: .625rem; }
  .stat-card { min-width: calc(50% - .375rem); flex: none; }
  .stat-card .value { font-size: 1.2rem; }

  /* Toolbar: stack selects */
  .toolbar { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .toolbar-right { flex-wrap: wrap; width: 100%; }

  /* Table: horizontal scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Pagination: smaller buttons */
  .pagination a, .pagination span { width: 32px; height: 32px; font-size: .8rem; }

  /* Stats section nav */
  .stats-section-nav { gap: 0; }

  /* Stats controls: stack vertically */
  .stats-controls { flex-direction: column; align-items: stretch; gap: .625rem; }
  .stats-controls .stats-toggle { width: 100%; justify-content: stretch; }
  .stats-toggle-btn { flex: 1; text-align: center; justify-content: center; }
  .stats-toggle { width: 100%; }

  /* Year selector: smaller pills */
  .stats-year-btn { padding: .25rem .6rem; font-size: .75rem; }

  /* Activity page: smaller map */
  #map { height: 240px; }

  /* Zone stats: compact */
  .zone-stats { gap: .6rem; padding: .5rem .75rem; font-size: .8rem; }

  /* Profile card: stack */
  .profile-card { flex-direction: column; align-items: flex-start; max-width: 100%; }
}

/* ── Login page ────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.login-logo { margin-bottom: .5rem; }
.login-title { font-size: 2rem; font-weight: 700; margin: 0; }
.login-sub { color: var(--muted); font-size: .95rem; text-align: center; margin: 0 0 1rem; }
