/* ============================================================
   ancientfit-frontend/css/tachydronics-trackers.css
   TACHYDRONICS TRACKER — AncientFit Design System v3.0
   PORTRAIT-FIRST · MOBILE OPTIMIZED · REFRESH RESILIENT
   POPUP TOP BAR · 4-HOUR SESSION · START BUTTON LOCK
   STATS TOGGLE BUTTON · MILITARY COMPASS (MAP CONTROL)
   FULL ROUTE VIEW OVERLAY · HISTORY ROUTE VIEW
   COMPASS ALWAYS-ON · COMPASS STYLE TOGGLE
   MAP THEME TOGGLE (DARK / LIGHT)
   ============================================================ */

/* ===== SECTION VARIABLES ===== */
.tachydronics-tracker-section {
    --t-green: #00b894;
    --t-green-dark: #00a07a;
    --t-green-light: #00d6a8;
    --t-green-glow: rgba(0, 184, 148, 0.30);
    --t-green-border: rgba(0, 184, 148, 0.35);
    --t-gold: #D39D55;
    --t-gold-glow: rgba(211, 157, 85, 0.30);
    --t-red: #ff3b3b;
    --t-red-glow: rgba(255, 59, 59, 0.30);
    --t-glass: rgba(0, 0, 0, 0.65);
    --t-glass-deep: rgba(0, 0, 0, 0.85);
    --t-glass-mid: rgba(0, 0, 0, 0.55);
    --t-border: rgba(255, 255, 255, 0.09);
    --t-border-hover: rgba(255, 255, 255, 0.15);
    --t-text: rgba(255, 255, 255, 0.95);
    --t-muted: rgba(255, 255, 255, 0.70);
    --t-hint: rgba(255, 255, 255, 0.45);
    --t-blur: blur(12px);
    --t-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --t-radius-xl: 24px;
    --t-radius-lg: 20px;
    --t-radius-md: 16px;
    --t-radius-sm: 12px;
    --t-radius-pill: 60px;
}

/* ===== SECTION WRAPPER ===== */
.tachydronics-tracker-section {
    background: var(--t-glass);
    border-radius: var(--t-radius-xl);
    padding: 20px 16px;
    margin: 12px auto;
    border: 1px solid var(--t-border);
    border-left: 4px solid var(--t-green);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: var(--t-transition);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

.tachydronics-tracker-section::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(0, 184, 148, 0.08), transparent 70%);
    opacity: 0.5;
    z-index: -1;
    animation: t-rotate 30s linear infinite;
    pointer-events: none;
}

@keyframes t-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== TRACKER HEADER ===== */
.tracker-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    padding-bottom: 20px;
}

.tracker-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--t-green), transparent);
}

.tracker-header i {
    font-size: 2rem;
    color: var(--t-green);
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 12px var(--t-green-glow));
}

.tracker-header h2 {
    font-family: system-ui, -apple-system, 'Plus Jakarta Sans', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, var(--t-green-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 8px;
}

.tracker-header .subtitle {
    color: var(--t-muted);
    font-style: italic;
    font-size: 0.85rem;
    font-family: system-ui, sans-serif;
}

/* ===== BUTTONS ===== */
.tracker-auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 280px;
    padding: 14px 24px;
    border-radius: var(--t-radius-pill);
    border: 1px solid var(--t-green-border);
    font-family: system-ui, sans-serif;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.25), rgba(0, 100, 80, 0.2));
    color: var(--t-text);
    transition: var(--t-transition);
    backdrop-filter: var(--t-blur);
    -webkit-backdrop-filter: var(--t-blur);
    box-shadow: 0 4px 16px rgba(0, 184, 148, 0.15);
}

.tracker-auth-btn:active {
    transform: scale(0.97);
}

.history-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--t-green-border);
    color: var(--t-green);
    padding: 10px 20px;
    border-radius: var(--t-radius-pill);
    cursor: pointer;
    transition: var(--t-transition);
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: var(--t-blur);
}

.history-btn:active:not(:disabled) {
    transform: scale(0.97);
    background: rgba(0, 184, 148, 0.15);
}

.history-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== MODAL OVERLAY - FREEZES BACKGROUND ===== */
.tracker-popup-overlay,
.history-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.94) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* ===== POPUP CONTAINER ===== */
.tracker-popup,
.history-content {
    width: 100%;
    max-width: 550px;
    height: auto;
    max-height: 90vh;
    background: rgba(8, 12, 20, 0.98);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--t-green);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    animation: t-popup-in 0.3s ease-out;
}

@keyframes t-popup-in {
    from { opacity: 0; transform: scale(0.96) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== POPUP TOP BAR ===== */
.popup-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(0, 184, 148, 0.25);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    border-radius: 32px 32px 0 0;
    box-sizing: border-box;
}

.popup-top-bar-device {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.popup-top-bar-device i {
    color: var(--t-green-light);
    font-size: 0.95rem;
}

.popup-top-bar-device span {
    color: var(--t-green-light);
    font-size: 0.82rem;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.popup-top-bar-close {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.popup-top-bar-close:active {
    transform: scale(0.9);
    background: rgba(255, 59, 59, 0.25);
    border-color: rgba(255, 59, 59, 0.4);
    color: #ff7675;
}

/* ===== LOGIN PANEL HEADER ===== */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}

.popup-header h3 {
    font-family: system-ui, sans-serif;
    color: var(--t-green-light);
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-close {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--t-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.popup-close:active {
    transform: scale(0.92);
    background: rgba(255, 59, 59, 0.2);
}

/* ===== LOGIN PANEL ===== */
.popup-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px 20px;
}

.tracker-auth-panel {
    width: 100%;
    background: var(--t-glass-mid);
    backdrop-filter: blur(8px);
    padding: 24px 20px;
    border-radius: 24px;
    border: 1px solid var(--t-border);
}

/* ===== v3.0: FRIENDLY AUTH PANEL ICON ===== */
.auth-panel-icon {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
}

.auth-panel-icon i {
    font-size: 2.8rem;
    color: var(--t-green);
    margin-bottom: 14px;
    display: block;
    filter: drop-shadow(0 0 16px rgba(0, 184, 148, 0.5));
    animation: authIconPulse 2.5s ease-in-out infinite;
}

@keyframes authIconPulse {
    0%, 100% { filter: drop-shadow(0 0 10px rgba(0, 184, 148, 0.4)); transform: scale(1); }
    50%       { filter: drop-shadow(0 0 22px rgba(0, 184, 148, 0.7)); transform: scale(1.06); }
}

.auth-panel-icon h3 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #fff 40%, var(--t-green-light));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
}

.auth-panel-icon p {
    font-size: 0.8rem;
    color: var(--t-hint);
    line-height: 1.5;
}

/* ===== INPUT GROUPS ===== */
.auth-input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    margin-bottom: 12px;
    padding: 12px 16px;
    border: 1px solid var(--t-border);
    transition: all 0.2s;
}

.auth-input-group:focus-within {
    border-color: var(--t-green);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.2);
}

.auth-input-group i {
    color: var(--t-green);
    width: 20px;
    font-size: 0.9rem;
}

.auth-input-group input {
    background: transparent;
    border: none;
    color: white;
    padding: 4px 0;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
    font-family: system-ui, sans-serif;
}

.auth-input-group input::placeholder {
    color: var(--t-hint);
}

/* ===== CREDENTIALS HINT ===== */
.auth-credentials-hint {
    font-size: 0.72rem;
    color: var(--t-hint);
    text-align: center;
    margin: 4px 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.4;
}

.auth-credentials-hint i {
    color: var(--t-green);
    font-size: 0.7rem;
    flex-shrink: 0;
}

.no-id-link {
    text-align: center;
    margin: 8px 0 20px;
    font-size: 0.75rem;
    color: var(--t-hint);
}

.no-id-link a {
    color: var(--t-green);
    text-decoration: none;
    font-weight: 600;
}

.tracker-error {
    color: #ff7675;
    text-align: center;
    margin-top: 12px;
    font-size: 0.8rem;
    padding: 10px;
    background: rgba(255, 59, 59, 0.1);
    border-radius: 12px;
}

/* ===== v3.0: AUTH SUBMIT BUTTON (styled like start btn) ===== */
.tracker-auth-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 15px 24px;
    border-radius: var(--t-radius-pill);
    border: 1px solid var(--t-green-border);
    font-family: system-ui, sans-serif;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.35), rgba(0, 120, 90, 0.28));
    color: #fff;
    transition: var(--t-transition);
    backdrop-filter: var(--t-blur);
    -webkit-backdrop-filter: var(--t-blur);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.22), inset 0 1px 0 rgba(255,255,255,0.08);
    letter-spacing: 0.02em;
    margin-top: 4px;
}

.tracker-auth-submit-btn:hover {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.48), rgba(0, 140, 105, 0.38));
    box-shadow: 0 6px 28px rgba(0, 184, 148, 0.35);
    transform: translateY(-1px);
}

.tracker-auth-submit-btn:active {
    transform: scale(0.97) translateY(0);
}

.tracker-auth-submit-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* ===== PROFILE SIDEBAR ===== */
.profile-sidebar {
    width: 100%;
    background: linear-gradient(160deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.4));
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    box-sizing: border-box;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.profile-flag {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.profile-header > div { flex: 1; }

.profile-name {
    font-family: system-ui, sans-serif;
    font-size: 1.1rem;
    font-weight: 800;
    color: white;
    margin-bottom: 4px;
}

.profile-id {
    font-size: 0.7rem;
    color: var(--t-hint);
    font-family: monospace;
    word-break: break-all;
}

/* ===== CERT BADGE ===== */
.cert-badge {
    border-radius: 16px;
    padding: 10px 14px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 14px;
}

.cert-badge.l1  { border-color: #2c5e2c; background: rgba(44, 94, 44, 0.2); }
.cert-badge.l2  { border-color: #969696; background: rgba(100, 100, 100, 0.2); }
.cert-badge.apex { border-color: var(--t-green); background: rgba(0, 184, 148, 0.15); }

.cert-badge span { font-size: 0.7rem; display: block; color: var(--t-muted); }

.badge-name {
    font-weight: 700;
    margin-top: 4px;
    color: var(--t-green);
    font-size: 0.8rem;
}

/* ===== PROFILE STATS GRID ===== */
.profile-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label { font-size: 0.75rem; color: var(--t-muted); }
.stat-value { font-size: 0.8rem; color: var(--t-green); font-weight: 700; }

/* ===== POPUP CONTENT - PORTRAIT COLUMN LAYOUT ===== */
.popup-content.map-view {
    padding: 0 !important;
    flex-direction: column !important;
    display: flex !important;
    width: 100% !important;
}

/* ===== MAP AREA ===== */
.map-area {
    flex: 1;
    position: relative !important;
    min-height: 420px;
    background: #0a1520;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
    width: 100% !important;
}

#trackerMap {
    width: 100%;
    flex: 1;
    min-height: 380px;
    position: relative;
    z-index: 1;
}

/* ===== ATHLETE OVERLAY ===== */
.athlete-map-overlay {
    position: absolute !important;
    top: 12px !important;
    left: 12px !important;
    right: 70px !important;
    z-index: 500 !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-radius: 60px !important;
    border: 1px solid rgba(0, 184, 148, 0.3) !important;
    padding: 7px 16px 7px 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
}

.athlete-map-overlay.stats-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
}

.overlay-left-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.overlay-flag { font-size: 1.1rem; flex-shrink: 0; }

.overlay-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.overlay-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-id {
    font-size: 0.6rem;
    color: var(--t-green);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.overlay-activity-type {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--t-green-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.overlay-compass {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* ===== LEAFLET COMPASS CONTROL — v3.0 LARGER + STYLE TOGGLE ===== */
.leaflet-compass-wrap {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 10px 10px 0 0 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
}

/* Base compass dial — military style (default) */
.leaflet-compass-control {
    width: 56px;      /* +2mm equivalent — was 48px */
    height: 56px;
    border-radius: 50%;
    position: relative;
    background:
        radial-gradient(circle at 35% 30%, rgba(255,255,255,0.07) 0%, transparent 60%),
        radial-gradient(circle at center, #0d1a14 0%, #060e0a 70%, #000 100%);
    box-shadow:
        0 0 0 1px rgba(0, 184, 148, 0.60),
        0 0 0 2px rgba(0, 0, 0, 0.9),
        0 0 0 3px rgba(0, 184, 148, 0.25),
        0 0 12px rgba(0, 184, 148, 0.40),
        inset 0 0 6px rgba(0, 0, 0, 0.8),
        inset 0 1px 2px rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.25s ease, transform 0.2s ease;
    cursor: pointer;
}

.leaflet-compass-control:active {
    transform: scale(0.94);
}

/* Hover glow */
.leaflet-compass-wrap:hover .leaflet-compass-control {
    box-shadow:
        0 0 0 1px rgba(0, 184, 148, 0.80),
        0 0 0 2px rgba(0, 0, 0, 0.9),
        0 0 0 3px rgba(0, 184, 148, 0.40),
        0 0 20px rgba(0, 184, 148, 0.55),
        inset 0 0 6px rgba(0, 0, 0, 0.8);
}

.leaflet-compass-control svg {
    width: 54px;
    height: 54px;
    display: block;
}

/* Classic compass style — toggled via JS adding .classic-style */
.leaflet-compass-control.classic-style {
    background:
        radial-gradient(circle at 38% 32%, rgba(255,255,255,0.12) 0%, transparent 55%),
        radial-gradient(circle at center, #1a1a2e 0%, #0f0f1e 65%, #000 100%);
    box-shadow:
        0 0 0 1px rgba(180, 160, 220, 0.55),
        0 0 0 2px rgba(0, 0, 0, 0.9),
        0 0 0 3px rgba(150, 120, 200, 0.22),
        0 0 12px rgba(140, 100, 200, 0.30),
        inset 0 0 6px rgba(0, 0, 0, 0.8);
}

.leaflet-compass-wrap:hover .leaflet-compass-control.classic-style {
    box-shadow:
        0 0 0 1px rgba(200, 180, 255, 0.75),
        0 0 0 2px rgba(0, 0, 0, 0.9),
        0 0 0 3px rgba(180, 140, 240, 0.38),
        0 0 20px rgba(160, 120, 220, 0.50),
        inset 0 0 6px rgba(0, 0, 0, 0.8);
}

#map-compass-needle-group {
    transform-origin: 50% 50%;
    transition: transform 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ===== ACTIVITY CONTROLS ===== */
.activity-controls {
    position: absolute !important;
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    background: rgba(0, 0, 0, 0.92) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-radius: 24px !important;
    padding: 14px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    z-index: 400 !important;
    width: auto !important;
    max-width: calc(100% - 24px) !important;
    margin: 0 !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
}

.activity-controls.stats-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(12px) !important;
}

.activity-controls.stats-hidden #endControl {
    opacity: 1 !important;
    pointer-events: auto !important;
}

.controls-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-direction: column;
}

.control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 60px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.control-btn:active { transform: scale(0.97); }
.control-btn.running { background: linear-gradient(135deg, #1a6b3a, #0f4a28); }
.control-btn.cycling { background: linear-gradient(135deg, #1a5a6b, #0f3a4a); }
.control-btn.end     { background: linear-gradient(135deg, #8b1a1a, #5a0f0f); }

/* ===== ACTIVE STATS GRID ===== */
.active-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.active-stat {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 10px 6px;
    text-align: center;
    font-size: 0.7rem;
    color: var(--t-muted);
}

.active-stat .value {
    font-family: system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: var(--t-green-light);
    display: block;
    margin-bottom: 4px;
}

/* ===== STATS TOGGLE BUTTON ===== */
.stats-toggle-btn {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 600 !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.82) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(0, 184, 148, 0.4) !important;
    color: var(--t-green-light) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 0.9rem !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.stats-toggle-btn:active {
    transform: translateY(-50%) scale(0.92) !important;
}

.stats-toggle-btn.stats-off {
    background: rgba(0, 184, 148, 0.2) !important;
    border-color: var(--t-green) !important;
    box-shadow: 0 0 12px rgba(0, 184, 148, 0.3) !important;
}

/* ===== v3.0: MAP THEME TOGGLE BUTTON ===== */
.map-theme-toggle-btn {
    position: absolute !important;
    right: 58px !important; /* sits left of the fullscreen btn */
    bottom: 20px !important;
    z-index: 600 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid var(--t-green-border) !important;
    color: var(--t-green-light) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 1rem !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.map-theme-toggle-btn:active {
    transform: scale(0.92) !important;
}

/* When light mode is active, give a sunny tint */
.map-theme-toggle-btn.light-mode {
    background: rgba(255, 248, 220, 0.92) !important;
    border-color: rgba(210, 160, 50, 0.7) !important;
    color: #a06010 !important;
    box-shadow: 0 4px 16px rgba(200, 150, 30, 0.35) !important;
}

/* ===== HISTORY MODAL ===== */
.history-content {
    max-width: 550px;
    max-height: 85vh;
}

.history-filters {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.history-filters select,
.history-filters button {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--t-border);
    padding: 10px 14px;
    border-radius: 60px;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: system-ui, sans-serif;
}

.history-filters button {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.2), rgba(0, 100, 80, 0.1));
    border-color: var(--t-green-border);
    font-weight: 600;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.history-item {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 12px;
    border-left: 3px solid var(--t-green);
    transition: all 0.2s;
}

.history-item:active {
    background: rgba(0, 184, 148, 0.1);
    transform: translateX(4px);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 6px;
}

.history-date {
    color: var(--t-green);
    font-weight: 700;
    font-size: 0.8rem;
}

.history-stats {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--t-muted);
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.history-badge {
    background: rgba(0, 184, 148, 0.2);
    border: 1px solid rgba(0, 184, 148, 0.3);
    border-radius: 60px;
    padding: 4px 12px;
    font-size: 0.65rem;
    color: var(--t-green-light);
    display: inline-block;
    margin-bottom: 8px;
}

/* ===== v3.0: HISTORY ACTION BUTTONS ROW ===== */
.history-action-row {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.view-detail-btn,
.view-route-history-btn {
    flex: 1;
    background: transparent;
    border: 1px solid var(--t-green-border);
    color: var(--t-green);
    padding: 7px 10px;
    border-radius: 60px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-detail-btn:active,
.view-route-history-btn:active {
    background: var(--t-green);
    color: black;
    transform: scale(0.97);
}

/* Route button subtle differentiation */
.view-route-history-btn {
    border-color: rgba(0, 184, 148, 0.5);
    background: rgba(0, 184, 148, 0.06);
}

.view-route-history-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== RESUME BANNER ===== */
.resume-activity-banner {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.25), rgba(0, 100, 80, 0.15));
    border: 1px solid var(--t-green-border);
    border-radius: 60px;
    padding: 12px 20px;
    margin-top: 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.resume-activity-banner:active {
    transform: scale(0.98);
    background: rgba(0, 184, 148, 0.35);
}

.resume-activity-banner i { color: var(--t-green); font-size: 1.1rem; }

.resume-activity-banner span {
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-container { background: #0a1520 !important; }

.leaflet-container.light-tiles { background: #f0ebe3 !important; }

.leaflet-control-attribution {
    background: rgba(0, 0, 0, 0.6) !important;
    font-size: 8px !important;
}

.athlete-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(6px);
    border-radius: 50%;
    border: 2px solid var(--t-green);
    box-shadow: 0 0 0 3px rgba(0, 184, 148, 0.3);
}

.athlete-marker-icon i {
    font-size: 20px;
    color: var(--t-green);
}

/* ===== RESUME INDICATOR ===== */
.resume-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 60px;
    font-size: 0.7rem;
    color: var(--t-green);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    border: 1px solid var(--t-green-border);
}

/* ===== RESPONSIVE ===== */
@media (min-width: 768px) {
    .tachydronics-tracker-section {
        max-width: 550px;
        margin: 16px auto;
    }
    .controls-buttons { flex-direction: row; }
    .active-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .tracker-popup,
    .history-content {
        max-width: calc(100% - 24px);
        border-radius: 28px;
    }
    .active-stats { grid-template-columns: repeat(2, 1fr); }
    .athlete-map-overlay .overlay-id { display: none; }
    .athlete-map-overlay { padding: 6px 12px 6px 12px !important; gap: 8px !important; }
    .popup-top-bar-device span { font-size: 0.75rem; }
    .popup-top-bar { border-radius: 28px 28px 0 0; }
    .stats-toggle-btn { width: 36px !important; height: 36px !important; font-size: 0.8rem !important; }
    .leaflet-compass-control { width: 50px; height: 50px; }
    .leaflet-compass-control svg { width: 48px; height: 48px; }
    .map-theme-toggle-btn { width: 38px !important; height: 38px !important; right: 52px !important; bottom: 16px !important; font-size: 0.9rem !important; }
}

@media (max-width: 480px) {
    .profile-stats { grid-template-columns: 1fr; }
    .history-filters { flex-direction: column; }
    .history-filters select,
    .history-filters button { width: 100%; }
    .popup-top-bar { padding: 10px 12px; }
    .popup-top-bar-device span { font-size: 0.7rem; }
    .popup-top-bar-close { width: 30px; height: 30px; font-size: 0.8rem; }
    .history-action-row { flex-direction: column; }
    .view-detail-btn,
    .view-route-history-btn { flex: unset; width: 100%; }
}

@media (max-width: 380px) {
    .active-stats { grid-template-columns: 1fr; }
    .profile-header { flex-direction: column; text-align: center; }
    .overlay-activity-type { display: none; }
    .overlay-divider { display: none; }
}

/* ===== BODY OVERFLOW FIX ===== */
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* ===== ACTIVITY END CONTROL LAYOUT ===== */
#endControl {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#endControl .activity-actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ===== PAUSE BUTTON ===== */
.control-btn.pause {
    background: linear-gradient(135deg, #6b5a1a, #4a3a0f);
}

.control-btn.pause.resume-mode {
    background: linear-gradient(135deg, #1a6b3a, #0f4a28);
}

.control-btn.export {
    background: linear-gradient(135deg, #2c5e6b, #1a3a44);
}

/* ===== FULLSCREEN BUTTON ===== */
.fullscreen-map-btn {
    position: absolute !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 600 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid var(--t-green-border) !important;
    color: var(--t-green-light) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 1.1rem !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
}

.fullscreen-map-btn:active {
    transform: scale(0.92) !important;
}

/* ===== SUMMARY CARD ===== */
.activity-summary-card {
    position: absolute !important;
    bottom: 100px !important;
    left: 12px !important;
    right: 12px !important;
    background: rgba(0, 0, 0, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border-radius: 24px !important;
    border: 1px solid var(--t-green-border) !important;
    z-index: 450 !important;
    animation: slideUp 0.3s ease-out !important;
    overflow: hidden !important;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(0, 184, 148, 0.15);
    border-bottom: 1px solid rgba(0, 184, 148, 0.3);
}

.summary-header h4 {
    margin: 0;
    color: var(--t-green-light);
    font-size: 0.9rem;
    font-weight: 700;
}

.summary-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--t-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.summary-close:active {
    background: rgba(255, 59, 59, 0.3);
    transform: scale(0.9);
}

.summary-content {
    padding: 16px;
}

.summary-points {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.summary-start, .summary-end {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 12px;
    border-radius: 16px;
    font-size: 0.7rem;
}

.summary-start i, .summary-end i {
    font-size: 1.1rem;
}

.summary-start i { color: #00ff00; }
.summary-end i { color: #ff4444; }

.summary-start strong, .summary-end strong {
    min-width: 45px;
    color: var(--t-text);
}

.summary-start span, .summary-end span {
    color: var(--t-muted);
    font-family: monospace;
    font-size: 0.65rem;
    word-break: break-all;
    flex: 1;
}

.summary-stats-mini {
    display: flex;
    gap: 16px;
    justify-content: center;
    padding: 12px;
    background: rgba(0, 184, 148, 0.1);
    border-radius: 16px;
    margin-bottom: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--t-green-light);
}

.view-route-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.25), rgba(0, 100, 80, 0.15));
    border: 1px solid var(--t-green-border);
    border-radius: 60px;
    color: var(--t-green-light);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.view-route-btn:active {
    transform: scale(0.97);
    background: rgba(0, 184, 148, 0.35);
}

/* ===== PAUSED INDICATOR ===== */
.paused-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 60px;
    font-size: 1rem;
    font-weight: 700;
    color: #ffaa44;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #ffaa44;
    animation: pulsePause 0.5s ease-out;
    pointer-events: none;
}

@keyframes pulsePause {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ===== START/END MARKER STYLES ===== */
.start-marker-icon, .end-marker-icon {
    background: transparent !important;
    border: none !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.start-marker-icon i, .end-marker-icon i {
    font-size: 24px;
}

/* ===== FULLSCREEN EXIT BUTTON ===== */
.fullscreen-exit-btn {
    position: absolute !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 601 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.9) !important;
    backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(0, 184, 148, 0.6) !important;
    color: #ffaa44 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 1.1rem !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.fullscreen-exit-btn:active {
    transform: scale(0.92) !important;
}

.map-area:fullscreen {
    background: #0a1520;
    display: flex;
    flex-direction: column;
}

.map-area:fullscreen #trackerMap {
    flex: 1;
    height: auto !important;
    min-height: 100%;
}

.map-area:fullscreen .fullscreen-map-btn {
    display: flex !important;
    background: rgba(0, 184, 148, 0.3) !important;
}

/* ===== RESPONSIVE UPDATES ===== */
@media (min-width: 768px) {
    #endControl .activity-actions-group {
        flex-direction: row;
    }
    #endControl .activity-actions-group .control-btn {
        flex: 1;
    }
    .summary-points {
        flex-direction: row;
    }
    .summary-start, .summary-end {
        flex: 1;
    }
}

@media (max-width: 600px) {
    .fullscreen-map-btn {
        width: 38px !important;
        height: 38px !important;
        bottom: 16px !important;
        right: 16px !important;
    }
    .activity-summary-card {
        bottom: 90px !important;
    }
    .summary-start span, .summary-end span {
        font-size: 0.55rem;
    }
    .fullscreen-exit-btn {
        width: 38px !important;
        height: 38px !important;
        bottom: 16px !important;
        right: 16px !important;
        font-size: 0.9rem !important;
    }
}

/* ===== v2.9: FULL ROUTE VIEW OVERLAY ===== */
#fullRouteOverlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: #060e0a !important;
    z-index: 800 !important;
    display: flex !important;
    flex-direction: column !important;
    border-radius: inherit !important;
    overflow: hidden !important;
    animation: routeOverlayIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@keyframes routeOverlayIn {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== FULL ROUTE TOP BAR ===== */
#fullRouteTopBar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 12px 16px !important;
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border-bottom: 1px solid rgba(0, 184, 148, 0.3) !important;
    flex-shrink: 0 !important;
    z-index: 10 !important;
}

#fullRouteTopBar .fr-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #00ffcc;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    letter-spacing: 0.03em;
}

#fullRouteTopBar .fr-title i {
    font-size: 1rem;
    color: #00b894;
}

#fullRouteCloseBtn {
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
}

#fullRouteCloseBtn:active {
    transform: scale(0.9) !important;
    background: rgba(255, 59, 59, 0.25) !important;
    border-color: rgba(255, 59, 59, 0.45) !important;
    color: #ff7675 !important;
}

/* ===== FULL ROUTE STATS RIBBON ===== */
#fullRouteStats {
    display: flex !important;
    align-items: stretch !important;
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border-bottom: 1px solid rgba(0, 184, 148, 0.2) !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

.fr-stat-cell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    min-width: 0;
}

.fr-stat-cell:last-child {
    border-right: none;
}

.fr-stat-icon {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 3px;
    font-family: system-ui, sans-serif;
    letter-spacing: 0.05em;
    white-space: nowrap;
    font-weight: 600;
}

.fr-stat-value {
    font-size: 0.95rem;
    font-weight: 800;
    color: #00d6a8;
    font-family: system-ui, sans-serif;
    white-space: nowrap;
}

.fr-stat-unit {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 2px;
    font-family: system-ui, sans-serif;
}

/* ===== FULL ROUTE MAP CONTAINER ===== */
#fullRouteMapWrap {
    flex: 1 !important;
    position: relative !important;
    min-height: 0 !important;
    overflow: hidden !important;
}

#fullRouteMap {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

/* ===== FULL ROUTE LEGEND BAR ===== */
#fullRouteLegend {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 20px !important;
    padding: 10px 16px !important;
    background: rgba(0, 0, 0, 0.82) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border-top: 1px solid rgba(0, 184, 148, 0.18) !important;
    flex-shrink: 0 !important;
}

.fr-legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.72rem;
    font-family: system-ui, sans-serif;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

.fr-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.fr-legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ===== FULL ROUTE LOADING STATE ===== */
#fullRouteLoading {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: #060e0a !important;
    z-index: 5 !important;
    gap: 14px !important;
    pointer-events: none !important;
    transition: opacity 0.4s ease !important;
}

#fullRouteLoading i {
    font-size: 1.6rem;
    color: #00b894;
    animation: frSpin 1s linear infinite;
}

#fullRouteLoading span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    font-family: system-ui, sans-serif;
}

@keyframes frSpin {
    to { transform: rotate(360deg); }
}

/* ===== KM MARKERS ===== */
.fr-km-marker {
    background: rgba(0, 0, 0, 0.82);
    border: 1px solid rgba(0, 184, 148, 0.55);
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 0.6rem;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    color: #00d6a8;
    white-space: nowrap;
}

/* ===== FULL ROUTE EMPTY/ERROR STATE ===== */
#fullRouteEmpty {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    background: #060e0a !important;
    z-index: 5 !important;
}

#fullRouteEmpty i {
    font-size: 2rem;
    color: rgba(0, 184, 148, 0.4);
}

#fullRouteEmpty p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.4);
    font-family: system-ui, sans-serif;
    text-align: center;
    max-width: 200px;
    line-height: 1.5;
}

/* ===== FULL ROUTE RESPONSIVE ===== */
@media (max-width: 600px) {
    .fr-stat-value   { font-size: 0.82rem; }
    .fr-stat-icon    { font-size: 0.55rem; }
    .fr-legend-item  { font-size: 0.65rem; gap: 5px; }
    #fullRouteLegend { gap: 14px; padding: 8px 12px; }
}

@media (max-width: 380px) {
    .fr-stat-cell    { padding: 8px 3px; }
    .fr-stat-value   { font-size: 0.72rem; }
    #fullRouteLegend { gap: 10px; }
    .fr-legend-line  { width: 16px; }
}

/* ===== v3.0: HISTORY ROUTE MODAL OVERLAY ===== */
#historyRouteModal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    z-index: 1000001 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    animation: t-popup-in 0.28s ease-out !important;
}

.history-route-container {
    width: 100%;
    max-width: 560px;
    height: 88vh;
    max-height: 680px;
    background: #060e0a;
    border-radius: 28px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--t-green);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
}

.history-route-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(0, 184, 148, 0.28);
    flex-shrink: 0;
}

.history-route-topbar .hr-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #00ffcc;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: system-ui, sans-serif;
    letter-spacing: 0.02em;
}

.history-route-topbar .hr-title i {
    color: var(--t-green);
    font-size: 1rem;
}

.history-route-close {
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    width: 34px !important;
    height: 34px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 0.85rem !important;
    transition: all 0.2s ease !important;
}

.history-route-close:active {
    transform: scale(0.9) !important;
    background: rgba(255, 59, 59, 0.25) !important;
    color: #ff7675 !important;
}

.history-route-stats {
    display: flex;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.72);
    border-bottom: 1px solid rgba(0, 184, 148, 0.18);
    flex-shrink: 0;
}

.history-route-map-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

#historyRouteMap {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

.history-route-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 9px 14px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(0, 184, 148, 0.16);
    flex-shrink: 0;
}

.history-route-loading {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: #060e0a !important;
    z-index: 5 !important;
    gap: 14px !important;
    pointer-events: none !important;
    transition: opacity 0.4s ease !important;
}

.history-route-loading i {
    font-size: 1.6rem;
    color: #00b894;
    animation: frSpin 1s linear infinite;
}

.history-route-loading span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.45);
    font-family: system-ui, sans-serif;
}

.history-route-empty {
    position: absolute !important;
    inset: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    background: #060e0a !important;
    z-index: 5 !important;
}

.history-route-empty i {
    font-size: 2rem;
    color: rgba(0, 184, 148, 0.35);
}

.history-route-empty p {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.38);
    text-align: center;
    max-width: 200px;
    line-height: 1.5;
    font-family: system-ui, sans-serif;
}

@media (max-width: 600px) {
    .history-route-container {
        max-width: calc(100% - 16px);
        height: 92vh;
        border-radius: 22px;
    }
}