/* --- ESTILOS GENERALES --- */
        * {
            box-sizing: border-box;
        }

        html {
            font-size: 16px;
        }

        body {
            font-family: 'Inter', sans-serif;
            background: var(--bg);
            color: var(--text-main);
            margin: 0;
            padding: 15px;
            transition: background 0.3s;
            font-size: 0.95rem;
            overflow-x: hidden;
        }

        .hidden {
            display: none !important;
        }

        :root {
            --bg: #0b0d11;
            --card: #15171e;
            --border: #2a2d36;
            --brand-blue: #3b82f6;
            --brand-green: #10b981;
            --brand-gradient: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
            --text-main: #ffffff;
            --text-muted: #9ca3af;
            --cal-red: #ef4444;
            --speed-green: #10b981;
            --elev-gold: #f59e0b;
            --strava-orange: #fc4c02;
        }

        body.light-mode {
            --bg: #f3f4f6;
            --card: #ffffff;
            --border: #d1d5db;
            --text-main: #1f2937;
            --text-muted: #6b7280;
        }

        /* LOGIN */
        #login-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1000;
            background: #fff;
            display: flex;
            padding: 0;
            margin: 0;
        }

        .split-wrapper {
            display: flex;
            width: 100%;
            height: 100%;
        }

        .info-section {
            flex: 1.2;
            background: linear-gradient(135deg, rgba(11, 13, 17, 0.9), rgba(59, 130, 246, 0.8)), url('https://images.unsplash.com/photo-1517649763962-0c623066013b?q=80&w=2070&auto=format&fit=crop');
            background-size: cover;
            background-position: center;
            display: flex;
            flex-direction: column;
            justify-content: center;
            padding: 80px;
            color: white;
        }

        .info-content {
            max-width: 600px;
            margin: 0 auto;
            width: 100%;
        }

        .brand-title {
            font-size: 4rem;
            margin: 0 0 10px;
            font-weight: 900;
            letter-spacing: -2px;
            background: -webkit-linear-gradient(0deg, #fff, #a5f3fc);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
        }

        .brand-subtitle {
            font-size: 1.2rem;
            opacity: 0.9;
            margin-bottom: 40px;
            line-height: 1.6;
            font-weight: 300;
        }

        .features-list {
            list-style: none;
            padding: 0;
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-bottom: 40px;
        }

        .features-list li {
            background: rgba(255, 255, 255, 0.1);
            padding: 18px 25px;
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.15);
            backdrop-filter: blur(12px);
            font-size: 1rem;
            font-weight: 500;
            display: flex;
            align-items: center;
            gap: 15px;
            transition: transform 0.2s;
        }

        .pricing-mini {
            display: flex;
            gap: 20px;
            margin-top: 20px;
        }

        .p-card {
            flex: 1;
            background: rgba(0, 0, 0, 0.3);
            padding: 20px;
            border-radius: 12px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            text-align: center;
        }

        .p-title {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 1px;
            opacity: 0.7;
            display: block;
            margin-bottom: 5px;
        }

        .p-price {
            font-size: 1.5rem;
            font-weight: 800;
        }

        .login-section {
            flex: 0.8;
            background: var(--bg);
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 40px;
            border-left: 1px solid var(--border);
        }

        .login-box {
            width: 100%;
            max-width: 380px;
        }

        .login-header h2 {
            font-size: 2rem;
            color: var(--text-main);
            margin-bottom: 10px;
            font-weight: 800;
            letter-spacing: -1px;
        }

        .login-header p {
            color: var(--text-muted);
            margin-bottom: 30px;
        }

        .login-input-group input {
            width: 100%;
            padding: 16px;
            margin-bottom: 15px;
            border: 2px solid var(--border);
            border-radius: 12px;
            background: var(--card);
            color: var(--text-main);
            outline: none;
            transition: all 0.3s;
            font-size: 1rem;
        }

        .btn-modern {
            width: 100%;
            padding: 16px;
            border-radius: 12px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.2s;
            border: none;
            font-size: 1rem;
        }

        .btn-primary {
            background: var(--brand-gradient);
            color: white;
            margin-top: 10px;
            box-shadow: 0 10px 25px -5px rgba(59, 130, 246, 0.5);
        }
        
        .btn-primary:hover {
            transform: translateY(-3px);
            box-shadow: 0 15px 30px -5px rgba(59, 130, 246, 0.6);
        }

        .btn-google {
            background: white;
            color: #333;
            margin-bottom: 25px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            border: 1px solid #ddd;
        }

        .divider {
            text-align: center;
            margin: 30px 0;
            color: var(--text-muted);
            font-size: 0.8rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 1px;
            position: relative;
        }

        .divider::before,
        .divider::after {
            content: "";
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background: var(--border);
        }

        .divider::before {
            left: 0;
        }

        .divider::after {
            right: 0;
        }

        @media (max-width: 1000px) {
            .info-section {
                display: none;
            }

            .login-section {
                flex: 1;
            }
        }

        /* DASHBOARD */
        #app-container {
            display: none;
            width: 99%;
            max-width: 1800px;
            margin: 0 auto;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--border);
        }

        h1 {
            margin: 0;
            font-size: 1.4rem;
            font-weight: 800;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header-tools {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .btn-circle {
            background: var(--card);
            color: var(--text-main);
            border: 1px solid var(--border);
            width: 36px;
            height: 36px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.1rem;
            transition: all 0.2s;
        }

        .btn-pill {
            border: none;
            padding: 0 15px;
            height: 36px;
            border-radius: 50px;
            font-weight: 700;
            cursor: pointer;
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            gap: 5px;
            transition: transform 0.2s;
        }

        .kpi-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
            gap: 15px;
            margin-bottom: 15px;
        }

        .kpi-card {
            background: var(--card);
            padding: 15px 20px;
            border-radius: 20px;
            border: 1px solid var(--border);
            position: relative;
            overflow: hidden;
        }

        .kpi-card::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 4px;
            background: var(--border);
        }

        .kpi-card:nth-child(1)::after {
            background: var(--brand-blue);
        }

        .kpi-val {
            font-size: 1.8rem;
            font-weight: 800;
            color: var(--brand-blue);
            line-height: 1.1;
        }

        .kpi-lbl {
            font-size: 0.75rem;
            color: var(--text-muted);
            font-weight: 700;
            text-transform: uppercase;
            margin-top: 5px;
        }

        .kpi-card:nth-child(2) .kpi-val {
            color: var(--cal-red);
        }

        .kpi-card:nth-child(3) .kpi-val {
            color: var(--elev-gold);
        }

        .kpi-card:nth-child(4) .kpi-val {
            color: var(--speed-green);
        }

        .pr-row {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }

        .pr-card {
            background: linear-gradient(145deg, var(--card) 0%, rgba(59, 130, 246, 0.05) 100%);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 12px 15px;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: transform 0.2s;
        }

        .pr-card:hover {
            transform: translateY(-3px);
            border-color: rgba(59, 130, 246, 0.4);
        }

        .pr-icon {
            font-size: 1.6rem;
        }

        .pr-info h4 {
            margin: 0;
            font-size: 0.7rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .pr-info .val {
            display: block;
            font-size: 1.2rem;
            font-weight: 800;
            color: var(--text-main);
            margin: 0;
            line-height: 1.2;
        }

        .pr-info .date {
            font-size: 0.7rem;
            color: var(--brand-blue);
            font-weight: 600;
        }

        .tab-bar {
            display: flex;
            gap: 10px;
            margin-bottom: 20px;
            overflow-x: auto;
            padding-bottom: 5px;
        }

        .tab-button {
            background: var(--card);
            color: var(--text-muted);
            border: 1px solid var(--border);
            padding: 10px 18px;
            border-radius: 12px;
            cursor: pointer;
            white-space: nowrap;
            font-weight: 600;
            transition: all 0.2s;
            font-size: 0.9rem;
        }

        .tab-button.active {
            background: var(--brand-gradient);
            color: white;
            border-color: transparent;
        }

        .mid-section {
            display: grid;
            grid-template-columns: 280px 1fr;
            gap: 20px;
            margin-bottom: 25px;
            align-items: stretch;
        }

        @media (max-width:1000px) {
            .mid-section {
                grid-template-columns: 1fr;
            }
        }

        .card {
            background: var(--card);
            padding: 20px;
            border-radius: 24px;
            border: 1px solid var(--border);
            height: fit-content;
        }

        .chart-card {
            background: var(--card);
            padding: 20px;
            border-radius: 24px;
            border: 1px solid var(--border);
            height: 100%;
            min-height: 400px;
            display: flex;
            flex-direction: column;
        }

        .chart-controls {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 15px;
            font-size: 0.75rem;
            color: var(--text-muted);
            margin-bottom: 10px;
            background: var(--bg);
            padding: 5px 10px;
            border-radius: 8px;
            width: fit-content;
            align-self: flex-end;
            border: 1px solid var(--border);
        }

        .btn-reset-zoom {
            background: var(--border);
            color: var(--text-muted);
            border: none;
            padding: 5px 10px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.7rem;
            font-weight: 700;
            text-transform: uppercase;
            transition: all 0.2s;
        }

        .btn-reset-zoom:hover {
            background: var(--brand-blue);
            color: white;
        }

        .chart-select {
            background: transparent;
            color: var(--text-main);
            border: 1px solid var(--border);
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 0.75rem;
            font-weight: 600;
            outline: none;
            cursor: pointer;
        }

        .card input,
        .card select,
        .modal-input {
            width: 100%;
            padding: 10px;
            background: #0b0d11;
            border: 1px solid var(--border);
            color: white;
            border-radius: 10px;
            margin-bottom: 10px;
            font-size: 0.9rem;
            outline: none;
        }

        body.light-mode .card input,
        body.light-mode .card select,
        body.light-mode .filter-card input,
        body.light-mode .filter-card select,
        body.light-mode .modal-input,
        body.light-mode .chart-select {
            background: white;
            color: var(--text-main);
        }

        select option {
            background-color: #0b0d11;
            color: white;
        }

        body.light-mode select option {
            background-color: white;
            color: #333;
        }

        ::-webkit-calendar-picker-indicator {
            filter: invert(1);
            cursor: pointer;
        }

        body.light-mode ::-webkit-calendar-picker-indicator {
            filter: invert(0);
        }

        .btn-save {
            width: 100%;
            padding: 12px;
            border: none;
            border-radius: 12px;
            font-weight: 800;
            cursor: pointer;
            background: var(--brand-gradient);
            color: white;
            margin-top: 5px;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-size: 0.85rem;
            transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
        }

        .btn-save:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
        }

        .btn-save:active {
            transform: translateY(0);
        }

        .btn-save.secondary {
            background: var(--border);
            color: var(--text-muted);
        }

        .gpx-upload-box {
            border: 1px dashed var(--border);
            padding: 10px;
            border-radius: 12px;
            text-align: center;
            margin-bottom: 15px;
            cursor: pointer;
            transition: background 0.2s;
        }

        .table-container {
            background: var(--card);
            border-radius: 24px;
            border: 1px solid var(--border);
            padding: 20px;
        }

        .activity-table-container {
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            min-width: 900px;
        }

        th {
            text-align: left;
            padding: 15px;
            font-size: 0.75rem;
            color: var(--text-muted);
            border-bottom: 1px solid var(--border);
            text-transform: uppercase;
        }

        td {
            padding: 12px 15px;
            border-bottom: 1px solid var(--border);
            font-size: 0.9rem;
        }

        .btn-action {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 1.1rem;
            margin-right: 5px;
            transition: transform 0.2s;
        }

        .filter-card {
            background: var(--card);
            padding: 20px;
            border-radius: 24px;
            border: 1px solid var(--border);
            margin-bottom: 20px;
        }

        .filter-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
            gap: 15px;
            align-items: end;
        }

        .filter-card input,
        .filter-card select {
            width: 100%;
            padding: 12px;
            background: #0b0d11;
            border: 1px solid var(--border);
            color: white;
            border-radius: 10px;
            font-size: 0.9rem;
            outline: none;
            margin-bottom: 0 !important;
        }

        .filter-grid .btn-save {
            margin-top: 0 !important;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .filter-card label {
            display: block;
            margin-bottom: 6px;
            font-size: 0.7rem;
            color: var(--text-muted);
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* MULTI-SELECT */
        .multiselect {
            position: relative;
            width: 100%;
        }

        .selectBox {
            position: relative;
            cursor: pointer;
        }

        .selectBox select {
            width: 100%;
            padding: 12px;
            background: #0b0d11;
            border: 1px solid var(--border);
            color: white;
            border-radius: 10px;
            font-size: 0.9rem;
            appearance: none;
            -webkit-appearance: none;
            cursor: pointer;
        }

        .overSelect {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
        }

        #checkboxes {
            display: none;
            border: 1px solid var(--border);
            border-radius: 12px;
            background-color: var(--card);
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            z-index: 500;
            max-height: 250px;
            overflow-y: auto;
            padding: 5px;
            margin-top: 5px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
        }

        #checkboxes label {
            display: flex;
            align-items: center;
            padding: 8px 10px;
            color: var(--text-main);
            cursor: pointer;
            border-radius: 6px;
            font-size: 0.85rem;
            transition: background 0.2s;
            margin: 2px 0;
        }

        #checkboxes label:hover {
            background-color: rgba(59, 130, 246, 0.2);
        }

        #checkboxes input {
            width: 16px !important;
            height: 16px !important;
            margin-right: 10px !important;
            margin-bottom: 0 !important;
            accent-color: var(--brand-blue);
            cursor: pointer;
        }

        .arrow-down {
            position: absolute;
            right: 15px;
            top: 18px;
            pointer-events: none;
            font-size: 0.7rem;
            color: var(--text-muted);
        }

        #bulkActionsContainer {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1000;
            display: flex;
            gap: 20px;
            align-items: center;
            background: var(--card);
            padding: 15px 25px;
            border-radius: 50px;
            border: 1px solid var(--brand-blue);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
            transition: all 0.3s;
        }

        #bulkActionsContainer.hidden {
            bottom: -100px;
            opacity: 0;
            pointer-events: none;
            display: flex !important;
        }

        .btn-close-bulk {
            background: var(--bg);
            border: 1px solid var(--border);
            color: var(--text-muted);
            width: 30px;
            height: 30px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
        }

        .pricing-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.85);
            z-index: 2000;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .pricing-card {
            background: var(--card);
            border-radius: 24px;
            width: 90%;
            max-width: 900px;
            border: 1px solid var(--border);
            position: relative;
            overflow: hidden;
            box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
        }

        .close-modal {
            position: absolute;
            top: 15px;
            right: 20px;
            font-size: 1.5rem;
            cursor: pointer;
            z-index: 999;
            color: black;
            background: white;
            border-radius: 50%;
            width: 30px;
            height: 30px;
            text-align: center;
            line-height: 30px;
        }

        .nav-icon {
            width: 20px;
            height: 20px;
            stroke: var(--text-muted);
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
            transition: stroke 0.3s;
        }

        /* =========================================================
           TEMPLATES PARA COMPARTIR (CANVAS NATIVO PREMIUM)
           ========================================================= */
        #shareTemplate {
            position: fixed;
            top: -9999px;
            left: -9999px;
            width: 1080px;
            height: 1920px;
            background: #0b0d11;
            color: white;
            display: flex;
            flex-direction: column;
            font-family: 'Inter', sans-serif;
            z-index: -10;
            overflow: hidden;
            justify-content: space-between;
        }

        /* Capa 0: El fondo brillante 100% nativo */
        #shareBgCanvas {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 0;
        }

        /* Capa 1: El mapa de Leaflet (si aplica) */
        #shareMapElement {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }

        /* Capa 2: Oscurecedor central para que resalte la ruta y los textos */
        .share-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(180deg, rgba(11, 13, 17, 0.7) 0%, rgba(11, 13, 17, 0.1) 40%, rgba(11, 13, 17, 0.8) 80%, rgba(11, 13, 17, 1) 100%);
            z-index: 2;
        }

        /* Capa 3: Contenido visual */
        .share-content {
            z-index: 3;
            position: relative;
            display: flex;
            flex-direction: column;
            height: 100%;
            justify-content: space-between;
            padding: 80px;
        }

        .share-header {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
        }

        .share-brand {
            font-size: 3.5rem;
            font-weight: 900;
            background: -webkit-linear-gradient(0deg, #fff, #a5f3fc);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: -2px;
            text-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
        }

        .share-badge {
            display: inline-block;
            background: rgba(0, 0, 0, 0.5);
            padding: 15px 30px;
            border-radius: 40px;
            font-size: 1.6rem;
            font-weight: 800;
            color: #fff;
            margin-bottom: 15px;
            border: 1px solid rgba(255, 255, 255, 0.3);
            text-transform: uppercase;
            letter-spacing: 1.5px;
            backdrop-filter: blur(20px);
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
        }

        .share-date {
            font-size: 2rem;
            color: #cbd5e1;
            font-weight: 600;
            text-align: right;
            text-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
        }

        .share-footer {
            padding-bottom: 40px;
        }

        .share-route-name {
            font-size: 5.5rem;
            font-weight: 900;
            margin-bottom: 50px;
            line-height: 1.1;
            letter-spacing: -1px;
            text-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
        }

        /* Tarjetas Glassmorphism */
        .share-stats-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 30px;
        }

        .share-stat {
            background: linear-gradient(145deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%);
            padding: 45px 40px;
            border-radius: 35px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-top: 3px solid #3b82f6;
            /* Se cambia dinámicamente con JS */
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
            backdrop-filter: blur(20px);
        }

        .share-stat-lbl {
            font-size: 1.5rem;
            color: #9ca3af;
            text-transform: uppercase;
            font-weight: 700;
            margin-bottom: 10px;
            display: block;
            letter-spacing: 1px;
        }

        .share-stat-val {
            font-size: 4.2rem;
            font-weight: 800;
            color: #fff;
            line-height: 1;
        }

        .share-stat-val span {
            font-size: 2rem;
            color: #cbd5e1;
            font-weight: 600;
        }