/* ============================================================
   GeoRando - Thème Randonnée / Marche Nordique
   ============================================================ */

/* -- Variables -------------------------------------------- */
:root {
    --forest-dark:    #1a3a0a;
    --forest-mid:     #2d5a1b;
    --forest-light:   #4a7c2f;
    --moss:           #7aad42;
    --moss-light:     #c8dfa4;
    --moss-pale:      #eaf4d8;
    --bark:           #7c5230;
    --earth:          #a67c52;
    --earth-light:    #d4b896;
    --parchment:      #faf6ed;
    --parchment-dark: #f0e9d6;
    --sky:            #4e91c9;
    --sky-light:      #d4e9f7;
    --trail:          #d9732a;
    --trail-light:    #f5b07e;
    --snow:           #f8fbf4;
    --text-dark:      #1c2714;
    --text-mid:       #4a5540;
    --text-light:     #7a8b6e;
    --white:          #ffffff;
    --danger:         #c0392b;
    --shadow-sm:      0 2px 6px rgba(26,58,10,.12);
    --shadow-md:      0 4px 16px rgba(26,58,10,.18);
    --shadow-lg:      0 8px 32px rgba(26,58,10,.22);
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      16px;
    --header-height:  62px;
    --sidebar-width:  320px;
    --transition:     .2s ease;
}

/* -- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text-dark);
    background: var(--parchment);
}

/* -- Header ----------------------------------------------- */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--forest-dark) 0%, var(--forest-mid) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--white);
    cursor: pointer;
    user-select: none;
}

.header-brand:hover > i,
.header-brand:hover .brand-name {
    opacity: 0.8;
}

.header-brand > i {
    font-size: 28px;
    color: var(--moss);
}

.brand-name {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--white);
}

.brand-sub {
    font-size: 11px;
    color: var(--moss-light);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
    display: block;
}

.header-brand > div {
    display: flex;
    flex-direction: column;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}

.btn-nav:hover {
    background: rgba(255,255,255,.2);
    transform: translateY(-1px);
}

.btn-nav i { font-size: 14px; }

/* Layer switcher */
.layer-switcher-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,.2);
}

.layer-switcher-icon {
    color: rgba(255,255,255,.6);
    font-size: 14px;
}

.layer-switcher {
    display: flex;
    gap: 4px;
}

.layer-btn {
    padding: 5px 11px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 14px;
    color: rgba(255,255,255,.75);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.layer-btn:hover {
    background: rgba(255,255,255,.18);
    color: var(--white);
}

.layer-btn.active {
    background: var(--moss);
    border-color: var(--moss);
    color: var(--forest-dark);
    font-weight: 700;
}

/* -- Layout ----------------------------------------------- */
.app-main {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

/* -- Sidebar ---------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--forest-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 2px 0 12px rgba(0,0,0,.25);
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: 16px 18px 12px;
    background: rgba(0,0,0,.2);
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-header h2 {
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-header h2 i { color: var(--moss); }

.sidebar-stats {
    margin-top: 6px;
    font-size: 11px;
    color: var(--moss-light);
    letter-spacing: .5px;
}

/* Search box */
.sidebar-search {
    padding: 10px 14px;
    background: rgba(0,0,0,.15);
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 7px 32px 7px 12px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 20px;
    color: var(--white);
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition), background var(--transition);
}

.search-input::placeholder { color: rgba(255,255,255,.4); }
.search-input:focus {
    border-color: var(--moss);
    background: rgba(255,255,255,.12);
}

.search-wrapper {
    position: relative;
}

.search-wrapper i {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,.35);
    font-size: 12px;
    pointer-events: none;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

/* Location list */
.location-list { padding: 8px 0; }

.location-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}

.location-item:hover {
    background: rgba(255,255,255,.07);
    border-left-color: var(--moss);
}

.location-item.active {
    background: rgba(122,173,66,.15);
    border-left-color: var(--moss);
}

.location-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--forest-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--white);
    flex-shrink: 0;
}

.location-info { flex: 1; min-width: 0; }

.location-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-count {
    font-size: 11px;
    color: var(--moss-light);
    margin-top: 1px;
}

.location-arrow {
    color: rgba(255,255,255,.3);
    font-size: 11px;
    flex-shrink: 0;
}

/* Track panel */
.track-panel {
    position: absolute;
    inset: 0;
    background: var(--forest-dark);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.track-panel-header {
    padding: 12px 16px;
    background: rgba(0,0,0,.2);
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--moss-light);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition);
    margin-bottom: 8px;
}

.btn-back:hover { color: var(--white); }

.track-panel-header h3 {
    color: var(--white);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.track-panel-header h3 i { color: var(--moss); }

.track-count-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--forest-dark);
    background: var(--moss);
    padding: 2px 8px;
    border-radius: 10px;
}

.track-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}

.track-list::-webkit-scrollbar { width: 4px; }
.track-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

.track-item {
    padding: 12px 16px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.track-item:hover {
    background: rgba(255,255,255,.07);
}

.track-item.active {
    background: rgba(122,173,66,.15);
    border-left-color: var(--trail);
}

.track-item-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.track-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
    box-shadow: 0 0 0 2px rgba(255,255,255,.2);
}

.track-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
    line-height: 1.3;
    flex: 1;
}

.track-date {
    font-size: 10px;
    color: var(--moss-light);
    margin-top: 2px;
    white-space: nowrap;
}

.track-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-left: 22px;
}

.stat-box {
    background: rgba(0,0,0,.2);
    border-radius: var(--radius-sm);
    padding: 5px 6px;
    text-align: center;
}

.stat-value {
    font-size: 12px;
    font-weight: 700;
    color: var(--moss);
    line-height: 1;
}

.stat-label {
    font-size: 9px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    color: var(--moss-light);
    font-size: 11px;
    flex-shrink: 0;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.btn-download:hover {
    background: var(--moss);
    color: var(--forest-dark);
    transform: translateY(-1px);
}

.track-stats-row {
    display: flex;
    gap: 12px;
    margin-left: 22px;
    margin-top: 4px;
}

.track-stat-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--moss-light);
}

.track-stat-inline i { font-size: 10px; color: var(--moss); }
.track-stat-inline strong { color: var(--white); font-weight: 600; }

/* -- Map -------------------------------------------------- */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    background: var(--sky-light);
}

/* Custom Leaflet marker */
.location-marker {
    background: var(--forest-mid);
    border: 2px solid var(--moss);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform .15s ease, background .15s ease;
    position: relative;
}

.location-marker:hover,
.location-marker.hovered {
    background: var(--forest-light);
    transform: scale(1.15);
}

.location-marker.active-marker {
    background: var(--trail);
    border-color: var(--trail-light);
    transform: scale(1.2);
}

.marker-count {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    line-height: 1;
}

.marker-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--moss);
    animation: pulse 2s infinite;
    pointer-events: none;
}

@keyframes pulse {
    0%   { transform: scale(1); opacity: .6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Map overlays */
.map-info {
    position: absolute;
    bottom: 30px;
    right: 14px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    max-width: 300px;
    z-index: 500;
    overflow: hidden;
    border-top: 3px solid var(--forest-mid);
}

.map-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--forest-mid);
    color: var(--white);
    font-size: 13px;
    font-weight: 600;
}

.btn-close-info {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
    transition: color var(--transition);
}
.btn-close-info:hover { color: var(--white); }

.map-info-content { padding: 12px 14px; font-size: 12px; color: var(--text-mid); }

/* Legend */
.map-legend {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 10px 14px;
    z-index: 500;
    min-width: 180px;
    border-left: 3px solid var(--forest-mid);
}

.legend-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--forest-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    cursor: pointer;
    border-radius: 4px;
    padding: 4px 6px;
    transition: background var(--transition);
}

.legend-item:hover { background: var(--parchment); }

.legend-color {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-label {
    font-size: 11px;
    color: var(--text-dark);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

/* -- Modals ----------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(3px);
}

.modal {
    background: var(--parchment);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    animation: modalIn .2s ease;
}

@keyframes modalIn {
    from { transform: scale(.95) translateY(-10px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--forest-mid);
    color: var(--white);
}

.modal-header h3 {
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i { color: var(--moss-light); }

.modal-close {
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--white); background: rgba(255,255,255,.1); }

.modal-body { padding: 20px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    background: var(--parchment-dark);
    border-top: 1px solid var(--earth-light);
}

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--forest-dark);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--earth-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-dark);
    background: var(--white);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
    border-color: var(--forest-light);
    box-shadow: 0 0 0 3px rgba(74,124,47,.15);
}

.form-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    background: var(--moss-pale);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--forest-mid);
    border-left: 3px solid var(--moss);
    margin-top: 12px;
}

.form-hint i { color: var(--forest-light); margin-top: 1px; flex-shrink: 0; }

/* File drop zone */
.file-drop-zone {
    border: 2px dashed var(--earth-light);
    border-radius: var(--radius-md);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--white);
}

.file-drop-zone:hover,
.file-drop-zone.dragover {
    border-color: var(--forest-light);
    background: var(--moss-pale);
}

.file-drop-zone i {
    font-size: 32px;
    color: var(--earth);
    margin-bottom: 8px;
    display: block;
}

.file-drop-zone p {
    font-size: 13px;
    color: var(--text-mid);
    line-height: 1.5;
}

.file-drop-zone small { font-size: 11px; color: var(--text-light); }

.file-selected {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--moss-pale);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    font-size: 12px;
    color: var(--forest-mid);
    font-weight: 600;
    border: 1px solid var(--moss-light);
}

.file-selected i { color: var(--forest-light); font-size: 16px; }

/* Buttons */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: var(--forest-mid);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
}

.btn-primary:hover {
    background: var(--forest-light);
    transform: translateY(-1px);
}

.btn-cancel {
    padding: 9px 16px;
    background: transparent;
    border: 1.5px solid var(--earth-light);
    border-radius: var(--radius-sm);
    color: var(--text-mid);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.btn-cancel:hover {
    background: var(--parchment-dark);
    border-color: var(--earth);
}

/* -- Toast ------------------------------------------------ */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--forest-dark);
    color: var(--white);
    padding: 12px 22px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 4px solid var(--moss);
}

.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--moss); }

/* -- Loading / Empty states ------------------------------ */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px 20px;
    color: rgba(255,255,255,.5);
    font-size: 13px;
}

.loading i { font-size: 22px; color: var(--moss); }

.empty-state {
    padding: 24px 18px;
    text-align: center;
    color: rgba(255,255,255,.4);
    font-size: 12px;
    line-height: 1.6;
}

.empty-state i {
    display: block;
    font-size: 28px;
    margin-bottom: 8px;
    color: rgba(255,255,255,.2);
}

/* -- Leaflet overrides ----------------------------------- */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow-sm) !important;
}

.leaflet-control-zoom a {
    background: var(--white) !important;
    color: var(--forest-dark) !important;
    border-color: var(--parchment-dark) !important;
    font-weight: 700;
    transition: background var(--transition);
}

.leaflet-control-zoom a:hover {
    background: var(--moss-pale) !important;
}

.leaflet-popup-content-wrapper {
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-md) !important;
    border-top: 3px solid var(--forest-mid);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 180px;
}

.popup-inner {
    padding: 12px 14px;
}

.popup-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--forest-dark);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.popup-title i { color: var(--forest-light); }

.popup-count {
    font-size: 11px;
    color: var(--text-mid);
    margin-bottom: 10px;
}

.popup-btn {
    display: block;
    width: 100%;
    padding: 8px;
    background: var(--forest-mid);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background var(--transition);
}

.popup-btn:hover { background: var(--forest-light); }

.leaflet-popup-tip { background: var(--white) !important; }

/* -- Compare button --------------------------------------- */
.btn-nav-compare {
    background: rgba(217,115,42,.2);
    border-color: rgba(217,115,42,.5);
}
.btn-nav-compare:hover { background: rgba(217,115,42,.35); }

/* -- Compare modal ---------------------------------------- */
.modal-xl {
    max-width: 820px;
    width: 95vw;
    height: 85vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-body-compare {
    display: flex;
    flex-direction: column;
    padding: 0;
    flex: 1;
    min-height: 0;
}

/* Summary bar */
.compare-summary {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 20px;
    background: var(--parchment-dark);
    border-bottom: 1px solid var(--earth-light);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.compare-stat { text-align: center; }

.compare-stat-value {
    display: block;
    font-size: 22px;
    font-weight: 700;
    color: var(--forest-dark);
    line-height: 1;
}

.compare-stat-label {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.cmp-highlight .compare-stat-value { color: var(--trail); }

.compare-threshold-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    font-size: 12px;
    color: var(--text-mid);
}

.compare-threshold-wrap input[type=range] {
    width: 100px;
    accent-color: var(--forest-mid);
}

#cmp-threshold-val {
    font-weight: 700;
    color: var(--forest-dark);
    min-width: 36px;
}

/* Compare status */
.compare-status { padding: 30px 20px; }

/* Compare list */
.compare-list {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    max-height: calc(85vh - 130px);
}

.compare-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.compare-empty i { font-size: 30px; color: var(--moss); }

/* Compare card */
.compare-card {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0;
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--parchment-dark);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.compare-card:hover { box-shadow: var(--shadow-sm); }

.compare-track {
    padding: 12px 14px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.compare-track:first-child { border-right: 1px solid var(--parchment-dark); }
.compare-track:last-child  { border-left: 1px solid var(--parchment-dark); }

.compare-loc {
    font-size: 11px;
    font-weight: 700;
    color: var(--forest-mid);
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.compare-title {
    font-size: 12px;
    color: var(--text-dark);
    font-weight: 500;
    line-height: 1.3;
}

.compare-dl {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--parchment);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.compare-dl:hover { background: var(--moss); color: var(--white); }

/* Similarity badge */
.compare-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    gap: 2px;
    min-width: 72px;
}

.compare-badge span {
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
}

.compare-badge small {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: .5px;
    opacity: .7;
}

.sim-high { background: #e8f5e0; color: #2d6a10; }
.sim-mid  { background: #fff8e0; color: #7a5a00; }
.sim-low  { background: #fef0e0; color: #8a4500; }

.same-loc-tag {
    margin-top: 4px;
    font-size: 8px;
    background: var(--moss-light);
    color: var(--forest-dark);
    border-radius: 8px;
    padding: 1px 6px;
    text-transform: uppercase;
    letter-spacing: .3px;
    font-weight: 700;
}

/* -- Auth modal ------------------------------------------ */
.modal-sm { max-width: 360px; }

#modal-auth { z-index: 3000; }

.auth-input-wrap {
    display: flex;
    gap: 8px;
}

.auth-input-wrap .form-input { flex: 1; }

.btn-auth-submit {
    width: 42px;
    flex-shrink: 0;
    background: var(--forest-mid);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 16px;
    cursor: pointer;
    transition: background var(--transition);
}

.btn-auth-submit:hover { background: var(--forest-light); }

.auth-error {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    background: #fdecea;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--danger);
    color: var(--danger);
    font-size: 12px;
    font-weight: 500;
}

/* -- Cases à cocher de visibilité des parcours ----------- */

/* Label cliquable autour du checkbox */
.track-vis-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 4px;
}

/* On masque le vrai <input> natif */
.track-vis-label input[type="checkbox"] {
    display: none;
}

/* Carré personnalisé qui remplace la case native */
.track-vis-custom {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid rgba(255,255,255,.25);
    background: rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
    position: relative;
}

/* Coche (chevron) — masquée par défaut */
.track-vis-custom::after {
    content: '';
    width: 4px;
    height: 7px;
    border: 2px solid transparent;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px, -1px);
    display: none;
}

/* État coché : fond = couleur du parcours, coche visible */
.track-vis-label input:checked + .track-vis-custom {
    background: var(--track-color, var(--moss));
    border-color: var(--track-color, var(--moss));
}

.track-vis-label input:checked + .track-vis-custom::after {
    display: block;
    border-color: rgba(0,0,0,.55);
}

/* Item atténué quand son parcours est masqué */
.track-item.track-hidden {
    opacity: 0.42;
}

.track-item.track-hidden .track-color-dot {
    background: rgba(255,255,255,.2) !important;
}

/* -- btn-info -------------------------------------------- */
.btn-info {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    border: none;
    color: var(--sky);
    font-size: 11px;
    flex-shrink: 0;
    cursor: pointer;
    margin-right: 2px;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.btn-info:hover {
    background: var(--sky);
    color: var(--white);
    transform: translateY(-1px);
}

/* -- Info modal ------------------------------------------ */
.modal-info {
    max-width: 780px;
    width: 95vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
}

.modal-body-info {
    overflow-y: auto;
    padding: 20px 22px;
    flex: 1;
    min-height: 0;
    background: var(--parchment);
}

.info-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.info-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}

.info-badge-date {
    background: var(--parchment-dark);
    color: var(--text-mid);
    border: 1px solid var(--earth-light);
}

.info-badge-activity {
    background: var(--moss-pale);
    color: var(--forest-mid);
    border: 1px solid var(--moss-light);
}

/* Stats grids */
.info-stats-primary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.info-stats-secondary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 22px;
}

.info-stat-card {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 12px 10px;
    text-align: center;
    border: 1px solid var(--earth-light);
    transition: box-shadow var(--transition);
}

.info-stat-card:hover { box-shadow: var(--shadow-sm); }

.info-stat-card.highlight {
    background: var(--moss-pale);
    border-color: var(--moss-light);
}

.info-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--forest-dark);
    line-height: 1;
    margin-bottom: 5px;
}

.info-stat-value.sm { font-size: 15px; }

.info-stat-unit {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-light);
}

.info-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Chart sections */
.info-chart-section { margin-bottom: 20px; }

.info-chart-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--forest-dark);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.info-chart-title i { color: var(--forest-light); }

.info-chart-title::before {
    content: '';
    display: block;
    width: 3px;
    height: 13px;
    background: var(--forest-mid);
    border-radius: 2px;
}

.info-chart-wrap {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--earth-light);
    padding: 10px 10px 6px;
    overflow: hidden;
}

/* Footer details */
.info-footer-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--earth-light);
    margin-top: 4px;
}

.info-detail-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    color: var(--text-mid);
    line-height: 1.4;
}

.info-detail-item i {
    color: var(--forest-light);
    width: 14px;
    text-align: center;
    font-size: 11px;
    margin-top: 1px;
    flex-shrink: 0;
}

.info-detail-item strong { color: var(--text-dark); font-weight: 600; }

/* HR zone bar */
.info-hr-zones {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.hr-zone-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* -- Bouton Aide ----------------------------------------- */
.btn-nav-help {
    background: rgba(78,145,201,.25);
    border-color: rgba(78,145,201,.6);
    animation: helpPulseBtn 3s ease-in-out 2s 3;
}
.btn-nav-help:hover {
    background: rgba(78,145,201,.45);
}
.btn-nav-help i { color: var(--sky); }

@keyframes helpPulseBtn {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 0 4px rgba(78,145,201,.35); }
}

/* -- Modal Aide ------------------------------------------ */
.modal-help {
    max-width: 700px;
    width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-body-help {
    overflow-y: auto;
    padding: 20px 24px;
    flex: 1;
    min-height: 0;
    background: var(--parchment);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-intro {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    background: var(--moss-pale);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--moss);
    font-size: 13px;
    color: var(--forest-dark);
    line-height: 1.6;
    margin-bottom: 8px;
}

.help-intro-icon {
    font-size: 28px;
    color: var(--forest-light);
    flex-shrink: 0;
    margin-top: 2px;
}

.help-section {
    background: var(--white);
    border-radius: var(--radius-md);
    border: 1px solid var(--earth-light);
    margin-bottom: 10px;
}

.help-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 16px;
    background: var(--forest-mid);
    color: var(--white);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .3px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.help-section-title i { color: var(--moss-light); }

.help-badge-admin {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 9px;
    background: rgba(217,115,42,.35);
    border: 1px solid rgba(217,115,42,.6);
    border-radius: 10px;
    color: var(--trail-light);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.help-steps {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.help-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 12.5px;
    color: var(--text-mid);
    line-height: 1.55;
}

.help-step-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--moss-pale);
    border: 1.5px solid var(--moss-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--forest-mid);
    margin-top: 1px;
}

.help-step strong { color: var(--text-dark); }

.help-step kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    border-radius: 4px;
    border: 1.5px solid var(--earth-light);
    background: var(--parchment-dark);
    font-family: inherit;
    font-size: 11px;
    color: var(--text-dark);
    font-weight: 600;
    line-height: 1.4;
}

.help-step code {
    background: var(--parchment-dark);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--forest-mid);
    border: 1px solid var(--earth-light);
}

/* -- Scrollbar global ------------------------------------ */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--earth-light) transparent;
}

*::-webkit-scrollbar { width: 5px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--earth-light); border-radius: 3px; }

/* ============================================================
   RESPONSIVE — Bouton hamburger sidebar (masqué sur desktop)
   ============================================================ */
.btn-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 16px;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}
.btn-sidebar-toggle:hover { background: rgba(255,255,255,.2); }

/* Layer switcher flottant sur la carte (mobile uniquement) */
.map-layer-switcher-mobile {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 10px;
    z-index: 500;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 6px 8px;
    gap: 4px;
    flex-direction: column;
}

/* Backdrop de la sidebar (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 550;
    opacity: 0;
    transition: opacity .3s ease;
}
.sidebar-backdrop.visible {
    display: block;
    opacity: 1;
}

/* ============================================================
   RESPONSIVE — Tablette (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
    /* Masque les libellés texte des boutons du header */
    .btn-nav span { display: none; }
    .btn-nav { padding: 8px 10px; gap: 0; }
    .btn-nav i { font-size: 15px; }

    /* Icône du layer switcher inutile sans les libellés */
    .layer-switcher-icon { display: none; }
    .layer-switcher-wrap { padding-left: 8px; }

    /* Sidebar légèrement moins large */
    :root { --sidebar-width: 280px; }

    /* Stats info parcours : 2 colonnes */
    .info-stats-primary,
    .info-stats-secondary { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   RESPONSIVE — Mobile (≤ 640px)
   ============================================================ */
@media (max-width: 640px) {
    :root { --header-height: 52px; --sidebar-width: 290px; }

    /* Header : compact */
    .brand-sub { display: none; }
    .brand-name { font-size: 18px; }
    .header-brand > i { font-size: 22px; }
    .header-brand { gap: 8px; }
    .header-nav { gap: 6px; }

    /* Layer switcher header : masqué, remplacé par le flottant carte */
    .layer-switcher-wrap { display: none; }

    /* Bouton hamburger : visible */
    .btn-sidebar-toggle { display: flex; }

    /* Sidebar : panneau latéral en overlay glissant */
    .sidebar {
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: 0;
        z-index: 600;
        transform: translateX(-100%);
        transition: transform .3s cubic-bezier(.4,0,.2,1);
        min-width: unset;
        box-shadow: none;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.45);
    }

    /* Map pleine largeur / pleine hauteur */
    .app-main { display: block; }
    .map-container {
        height: calc(100vh - var(--header-height));
        width: 100%;
    }

    /* Layer switcher flottant sur la carte */
    .map-layer-switcher-mobile { display: flex; }
    .map-layer-switcher-mobile .layer-btn {
        padding: 5px 10px;
        background: rgba(45,90,27,.08);
        border: 1px solid var(--earth-light);
        border-radius: 12px;
        color: var(--text-dark);
        font-family: inherit;
        font-size: 11px;
        font-weight: 500;
        cursor: pointer;
        white-space: nowrap;
        transition: background var(--transition), color var(--transition);
    }
    .map-layer-switcher-mobile .layer-btn:hover { background: var(--moss-pale); }
    .map-layer-switcher-mobile .layer-btn.active {
        background: var(--forest-mid);
        border-color: var(--forest-mid);
        color: var(--white);
        font-weight: 700;
    }

    /* Info overlay : pleine largeur */
    .map-info {
        bottom: 16px;
        right: 8px;
        left: 8px;
        min-width: unset;
        max-width: unset;
    }

    /* Légende : compacte */
    .map-legend {
        top: 8px;
        right: 8px;
        min-width: 140px;
        padding: 8px 10px;
    }
    .legend-label { max-width: 100px; }

    /* Carte de comparaison : empilement vertical */
    .compare-card { grid-template-columns: 1fr; }
    .compare-track:first-child {
        border-right: none;
        border-bottom: 1px solid var(--parchment-dark);
    }
    .compare-track:last-child { border-left: none; }
    .compare-badge { padding: 8px 14px; flex-direction: row; gap: 8px; }

    /* Résumé comparaison */
    .compare-threshold-wrap { margin-left: 0; width: 100%; }
    .compare-summary { gap: 14px; }

    /* Stats info parcours : 2 colonnes */
    .info-stats-primary,
    .info-stats-secondary { grid-template-columns: repeat(2, 1fr); }

    /* Détails footer : 1 colonne */
    .info-footer-details { grid-template-columns: 1fr; }

    /* Modals : marges réduites */
    .modal-overlay { padding: 8px; }
    .modal-body { padding: 14px 16px; }
    .modal-footer { padding: 10px 16px; }

    /* Toast : largeur adaptée */
    .toast {
        width: calc(100% - 32px);
        text-align: center;
        justify-content: center;
        left: 16px;
        transform: translateY(100px);
        bottom: 16px;
    }
    .toast.visible { transform: translateY(0); }
}
