/* FitTrack style.css v4 — All browser compatible */

/* ── Dark theme ──────────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg:        #0a0a0f;
  --surface:   #111118;
  --surface2:  #1a1a24;
  --surface3:  #22222e;
  --border:    #2a2a38;
  --accent:    #00e87a;
  --accent-d:  #00703c;
  --accent2:   #ff5f1f;
  --text:      #e8e8f0;
  --muted:     #6a6a80;
  --dim:       #3a3a50;
  --danger:    #ff3b5c;
  --info:      #4da6ff;
  --gold:      #ffd700;
  --shadow:    0 4px 24px rgba(0,0,0,.65);
  --chart-grid: rgba(42,42,56,.8);
  --chart-text: #6a6a80;
  --leaf-filter: brightness(.85) saturate(.7);
}

/* ── Light theme ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f2f2f7;
  --surface:   #ffffff;
  --surface2:  #f0f0f5;
  --surface3:  #e4e4ed;
  --border:    #d0d0dc;
  --accent:    #009050;
  --accent-d:  #006d3c;
  --accent2:   #e04e10;
  --text:      #111118;
  --muted:     #6a6a80;
  --dim:       #b0b0c0;
  --danger:    #d42b4a;
  --info:      #2070c0;
  --gold:      #b08000;
  --shadow:    0 4px 24px rgba(0,0,0,.1);
  --chart-grid: rgba(208,208,220,.6);
  --chart-text: #6a6a80;
  --leaf-filter: none;
}

/* ── Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; height: 100%; }
body {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea {
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .875rem;
  padding: .5rem .75rem;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
canvas { display: block; width: 100% !important; }

/* ── Screens ─────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100vh; height: 100dvh; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  border-radius: 6px; padding: .55rem 1.25rem; font-size: .85rem;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-full { width: 100%; }
.btn-sm { padding: .35rem .9rem; font-size: .78rem; }

.btn-icon-sm {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--muted);
  transition: color .15s, background .15s;
}
.btn-icon-sm:hover { color: var(--text); background: var(--surface2); }

.btn-install-nav {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: 'Barlow Condensed', sans-serif; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; font-size: .8rem;
  border: 1px solid var(--accent-d); color: var(--accent);
  border-radius: 6px; padding: .45rem;
  transition: all .15s;
}
.btn-install-nav:hover { background: rgba(0,144,80,.1); }

/* Track buttons */
.btn-track {
  width: 140px; height: 140px; border-radius: 50%;
  flex-direction: column; gap: .35rem; font-size: 1rem; letter-spacing: .15em;
  box-shadow: 0 0 0 4px var(--surface3), 0 0 0 6px var(--border);
  flex-shrink: 0;
}
.btn-track svg { width: 26px; height: 26px; flex-shrink: 0; }
.btn-start { background: var(--accent); color: #000; }
.btn-start svg { fill: #000; }
.btn-start:hover { filter: brightness(1.1); box-shadow: 0 0 30px rgba(0,232,122,.3), 0 0 0 4px var(--surface3), 0 0 0 6px var(--accent); }
.btn-pause { background: var(--accent2); color: #fff; }
.btn-pause svg { fill: #fff; }
.btn-stop  { background: var(--danger); color: #fff; }
.btn-stop  svg { fill: #fff; }

/* ══════════════════════════════════════════════════════
   AUTH
══════════════════════════════════════════════════════ */
#auth-screen { align-items: center; justify-content: center; position: relative; overflow: hidden; }
.auth-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 60% at 20% 80%, rgba(0,232,122,.08) 0%, transparent 70%),
              radial-gradient(ellipse 50% 50% at 80% 20%, rgba(77,166,255,.06) 0%, transparent 70%);
}
.auth-card {
  position: relative; z-index: 1;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 2rem; width: 100%; max-width: 400px; margin: 1rem;
  box-shadow: var(--shadow);
}
.auth-logo { text-align: center; margin-bottom: 1.5rem; }
.logo-icon { font-size: 2rem; color: var(--accent); display: block; margin-bottom: .5rem; }
.auth-logo h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 2rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.auth-tagline { font-size: .72rem; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; margin-top: .25rem; }

.tab-bar { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn { flex: 1; padding: .6rem; font-family: 'Barlow Condensed', sans-serif; font-size: .9rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .15s; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .35rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.alert { padding: .75rem 1rem; border-radius: 6px; font-size: .8rem; margin-top: .75rem; }
.alert-error { background: rgba(255,59,92,.12); border: 1px solid var(--danger); color: var(--danger); }

/* ══════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════ */
#app-screen { flex-direction: row; overflow: hidden; }

/* Mobile header */
#mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between;
  padding: 0 1rem;
  z-index: 2000;
}

/* Hamburger — MUST have explicit width on spans */
#btn-menu {
  width: 40px; height: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; border-radius: 6px; padding: 4px;
}
#btn-menu span {
  display: block;
  width: 22px;   /* critical — without this bars are invisible */
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all .2s;
  flex-shrink: 0;
}
.mobile-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: 1rem; color: var(--accent); }

#nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 2001; }
#nav-overlay.show { display: block; }

/* Sidebar */
#sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.25rem 0;
  z-index: 2002; flex-shrink: 0;
  transition: transform .25s ease;
}
.nav-logo { display: flex; align-items: center; gap: .6rem; padding: 0 1.25rem 1.25rem; border-bottom: 1px solid var(--border); font-family: 'Barlow Condensed', sans-serif; font-size: 1.1rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-logo .logo-icon { font-size: 1.2rem; color: var(--accent); }
.nav-user { display: flex; align-items: center; gap: .6rem; padding: 1rem 1.25rem; font-size: .8rem; color: var(--muted); }
.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-d); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.nav-links { list-style: none; flex: 1; padding: .5rem 0; }
.nav-link { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-left: 3px solid transparent; transition: all .15s; }
.nav-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; flex-shrink: 0; }
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); border-left-color: var(--accent); background: rgba(0,144,80,.08); }
.nav-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.nav-footer-row { display: flex; align-items: center; justify-content: space-between; }
.sync-status { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--muted); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); transition: background .3s; flex-shrink: 0; display: inline-block; }
.sync-dot.online  { background: var(--accent); box-shadow: 0 0 5px var(--accent); }
.sync-dot.offline { background: var(--danger); }
.sync-dot.pending { background: var(--accent2); }

/* Main content */
#main-content { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; min-width: 0; }
.view { display: none; padding: 1.5rem; min-height: 100%; }
.view.active { display: block; }
.view-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.view-header h2 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.view-header-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* ══════════════════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════════════════ */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; transition: border-color .15s; }
.stat-card:hover { border-color: var(--accent-d); }
.stat-card.accent { border-color: var(--accent-d); background: rgba(0,144,80,.05); }
.stat-label { font-size: .65rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-unit  { font-size: .7rem; color: var(--muted); margin-top: .25rem; }

/* ══════════════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════════════ */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.chart-card h3 { font-family: 'Barlow Condensed', sans-serif; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 1rem; }

.map-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 1.5rem; }
.map-card-header { padding: .75rem 1.25rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.map-card-header h3 { font-family: 'Barlow Condensed', sans-serif; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.last-act-stats { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }
.last-act-stats span { color: var(--text); font-weight: 600; }
#dashboard-map { height: 280px; min-height: 280px; }

.recent-section h3 { font-family: 'Barlow Condensed', sans-serif; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .75rem; }
.recent-section small { font-size: .65rem; color: var(--dim); letter-spacing: 0; text-transform: lowercase; }

/* ══════════════════════════════════════════════════════
   ACTIVITY LIST ITEMS
══════════════════════════════════════════════════════ */
.activity-list { display: flex; flex-direction: column; gap: .5rem; }
.activity-item {
  display: grid; grid-template-columns: 36px 1fr auto;
  gap: .75rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: .75rem 1rem; cursor: pointer; transition: all .15s; user-select: none;
}
.activity-item:hover  { border-color: var(--accent-d); background: var(--surface2); }
.activity-item.active { border-color: var(--accent); background: rgba(0,144,80,.05); }
.act-type-icon { width: 36px; height: 36px; border-radius: 6px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.act-info { min-width: 0; }
.act-name { font-family: 'Barlow Condensed', sans-serif; font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-date { font-size: .7rem; color: var(--muted); margin-top: .1rem; }
.act-stats { display: flex; gap: .75rem; font-size: .75rem; color: var(--muted); flex-wrap: wrap; }
.act-stat-val { color: var(--text); font-weight: 600; }

/* ══════════════════════════════════════════════════════
   TRACK VIEW
══════════════════════════════════════════════════════ */
#view-track { padding: 0; display: none; flex-direction: column; height: 100vh; height: 100dvh; }
#view-track.active { display: flex; }
#track-map { flex: 1; background: var(--surface2); min-height: 200px; }
.track-metrics { display: flex; align-items: center; background: var(--surface); border-top: 1px solid var(--border); padding: .65rem 1rem; }
.metric-item { text-align: center; flex: 1; }
.metric-val { display: block; font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.metric-lbl { font-size: .6rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.metric-sep { width: 1px; height: 36px; background: var(--border); margin: 0 .5rem; flex-shrink: 0; }
.track-time-bar { display: flex; justify-content: space-between; padding: .25rem 1rem; font-size: .72rem; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.track-controls { background: var(--surface); border-top: 1px solid var(--border); padding: .75rem 1.5rem 1.25rem; display: flex; flex-direction: column; align-items: center; gap: .75rem; }
.activity-type-row { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.type-btn { padding: .3rem .75rem; border-radius: 20px; font-size: .75rem; color: var(--muted); border: 1px solid var(--border); transition: all .15s; cursor: pointer; background: transparent; }
.type-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(0,144,80,.1); }
.control-row { display: flex; gap: 1.5rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.gps-status { font-size: .7rem; letter-spacing: .1em; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.gps-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex-shrink: 0; animation: gpsp 1.5s ease-in-out infinite; display: inline-block; }
.gps-dot.good { background: var(--accent); animation: none; }
.gps-dot.poor { background: var(--accent2); }
@keyframes gpsp { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.4;transform:scale(.8)} }

/* Finish dialog */
.dialog { position: absolute; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.75); }
.dialog-content { background: var(--surface); border-top: 1px solid var(--border); border-radius: 12px 12px 0 0; padding: 1.5rem; width: 100%; max-width: 500px; }
.dialog-content h3 { font-family: 'Barlow Condensed', sans-serif; font-size: 1.1rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .75rem; }
.finish-summary { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; font-size: .85rem; }
.finish-summary span { color: var(--accent); font-weight: 700; }
.dialog-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: .75rem; }

/* ══════════════════════════════════════════════════════
   HISTORY — two-pane
══════════════════════════════════════════════════════ */
.filter-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.select-sm, .input-sm { width: auto; font-size: .8rem; padding: .4rem .6rem; }
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.page-btn { width: 32px; height: 32px; border-radius: 6px; font-size: .78rem; background: var(--surface); border: 1px solid var(--border); color: var(--muted); cursor: pointer; transition: all .15s; }
.page-btn.active, .page-btn:hover { border-color: var(--accent); color: var(--accent); }

.history-layout { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; align-items: start; }
.history-list-col { display: flex; flex-direction: column; gap: .5rem; }

.history-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 420px;
  /* CRITICAL: position sticky so detail panel stays visible while scrolling list */
  position: sticky;
  top: 1.5rem;
}
.detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 420px; gap: 1rem; color: var(--muted); opacity: .5; }
.detail-empty svg { stroke: var(--muted); }
.detail-empty p { font-size: .85rem; }

.detail-mobile-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--border); gap: .5rem; flex-wrap: wrap; background: var(--surface); }
.detail-act-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: .9rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-act-actions { display: flex; gap: .4rem; }
#btn-history-back { display: none; } /* shown on mobile only */

.panel-stats { padding: 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: .75rem; }
.panel-stat { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: .75rem; }
.panel-stat-label { font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .3rem; }
.panel-stat-value { font-size: 1.15rem; font-weight: 700; }

/* Context menu */
.ctx-menu { position: fixed; z-index: 5000; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; min-width: 200px; }
.ctx-item { display: block; width: 100%; padding: .85rem 1.25rem; text-align: left; font-size: .85rem; color: var(--text); transition: background .15s; cursor: pointer; background: transparent; border: none; font-family: inherit; }
.ctx-item:hover { background: var(--surface2); }
.ctx-danger { color: var(--danger); }

/* ══════════════════════════════════════════════════════
   PROFILE
══════════════════════════════════════════════════════ */
.profile-banner { display: flex; align-items: center; gap: 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar-lg { width: 72px; height: 72px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-d), var(--accent)); color: #000; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 900; font-family: 'Barlow Condensed', sans-serif; }
.avatar-camera-btn { position: absolute; bottom: -2px; right: -2px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent2); display: flex; align-items: center; justify-content: center; cursor: pointer; border: 2px solid var(--surface); transition: transform .15s; }
.avatar-camera-btn:hover { transform: scale(1.1); }
.avatar-camera-btn svg { width: 13px; height: 13px; stroke: #fff; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-family: 'Barlow Condensed', sans-serif; font-size: 1.4rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.profile-meta { font-size: .75rem; color: var(--muted); margin-top: .2rem; }
.profile-streak { text-align: center; }
.streak-val { display: block; font-size: 2.2rem; font-weight: 700; color: var(--accent2); line-height: 1; }
.streak-lbl { font-size: .68rem; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }

.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1.4rem; margin-bottom: 1rem; }
.settings-card h3 { font-family: 'Barlow Condensed', sans-serif; font-size: .85rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.danger-zone { border-color: rgba(212,43,74,.3); }
.danger-zone h3 { color: var(--danger); }
.danger-zone p  { font-size: .8rem; color: var(--muted); margin-bottom: 1rem; }

/* ══════════════════════════════════════════════════════
   TOASTS & INSTALL
══════════════════════════════════════════════════════ */
#toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; max-width: 340px; }
.toast { padding: .75rem 1.1rem; border-radius: 6px; font-size: .82rem; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); animation: tin .2s ease, tout .3s ease 2.7s forwards; pointer-events: all; }
.toast.success { border-color: var(--accent);  color: var(--accent); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--info);    color: var(--info); }
@keyframes tin  { from{transform:translateX(20px);opacity:0} to{transform:none;opacity:1} }
@keyframes tout { to{opacity:0;transform:translateX(20px)} }

.install-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 8000; background: var(--surface2); border-top: 1px solid var(--accent-d); padding: .75rem 1rem; display: flex; align-items: center; gap: .75rem; font-size: .82rem; }
.install-banner span { flex: 1; }

/* ── Leaflet overrides ───────────────────────────────── */
.leaflet-container { background: #1a1a24 !important; font-family: 'JetBrains Mono', monospace; }
[data-theme="light"] .leaflet-container { background: #e0e8f0 !important; }
.leaflet-tile-pane { filter: var(--leaf-filter); }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
/* Keep Leaflet controls below our header/sidebar */
.leaflet-top, .leaflet-bottom { z-index: 400 !important; }

/* ══════════════════════════════════════════════════════
   MOBILE ≤ 768px
══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #mobile-header { display: flex; }
  #main-content { padding-top: 52px; }

  /* Sidebar: off-canvas */
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); width: 260px; min-width: 0; z-index: 2002; }
  #sidebar.open { transform: translateX(0); }

  /* Track: height minus fixed header */
  #view-track { height: calc(100vh - 52px); height: calc(100dvh - 52px); margin-top: 52px; }
  .btn-track { width: 120px; height: 120px; font-size: .85rem; }
  .btn-track svg { width: 22px; height: 22px; }
  .metric-val { font-size: 1.4rem; }

  /* Stats: 2 col */
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  #dashboard-map { height: 200px; min-height: 200px; }

  /* History: single pane, detail slides in */
  .history-layout { grid-template-columns: 1fr; }
  .history-detail {
    position: fixed;
    top: 52px; left: 0; right: 0; bottom: 0;
    transform: translateX(100%);
    transition: transform .25s ease;
    border-radius: 0;
    min-height: 0;
    z-index: 1000;
  }
  .history-detail.open { transform: translateX(0); }
  .detail-empty { height: 300px; }
  #btn-history-back { display: inline-flex; }
  #panel-map { height: 220px !important; }
  .panel-stats { grid-template-columns: repeat(2,1fr); }

  /* Filters stack */
  .filter-row { flex-direction: column; }
  .select-sm, .input-sm { width: 100%; }

  /* Profile */
  .profile-banner { flex-direction: column; text-align: center; }
  .view { padding: 1rem; }
}

/* ══════════════════════════════════════════════════════
   DESKTOP > 768px
══════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  #mobile-header { display: none; }
  #nav-overlay   { display: none !important; }
  #view-track { height: calc(100vh - 0px); height: calc(100dvh - 0px); }
  .btn-track { width: 100px; height: 100px; font-size: .85rem; }
  .btn-track svg { width: 22px; height: 22px; }
  .stat-value { font-size: 2.4rem; }
  #dashboard-map { height: 320px; min-height: 320px; }
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
