:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --radius: 6px;
    --success: #10b981;
}
[data-theme="dark"] {
    --primary: #94a3b8;
    --primary-dark: #64748b;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #cbd5e1;
    --border: #334155;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

#loader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; }
.progress-bar { width: 60%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.progress-bar::after { content: ''; display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.3s; }
#loader p { font-weight: 500; }

#header { background: var(--card); padding: 10px 16px; box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#title { font-size: 1.1rem; font-weight: 600; color: var(--primary); }
#last-pos { font-size: 0.82rem; color: var(--text); }

.theme-switch { position: relative; display: inline-block; width: 48px; height: 24px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ccc; border-radius: 34px; transition: .3s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background: white; border-radius: 50%; transition: .3s; }
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }
.sun, .moon { position: absolute; top: 50%; transform: translateY(-50%); font-size: 14px; }
.sun { left: 6px; } .moon { right: 6px; }

#main { flex: 1; display: flex; overflow: hidden; }
#map { flex: 1; min-width: 0; }
#sidebar { width: 380px; max-width: 100%; background: var(--card); padding: 14px; overflow-y: auto; border-left: 1px solid var(--border); }

h3 { font-size: 0.95rem; color: var(--primary); margin: 0 0 10px; font-weight: 600; border-bottom: 1px solid var(--primary); padding-bottom: 4px; }

#preset-filter, #date-range { width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; font-size: 0.9rem; background: var(--card); color: var(--text); }
.input-icon { position: relative; margin-bottom: 8px; }
.input-icon .icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--primary); pointer-events: none; }

/* BOUTONS UNIFORMES */
.btn-group { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.action-btn {
    flex: 1;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow);
    position: relative;
}
.action-btn iconify-icon { font-size: 1.3rem; }

#loadBtn { background: var(--primary); color: white; }
#loadBtn:hover { background: var(--primary-dark); transform: translateY(-1px); }

.export-btn { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.export-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

#info { font-size: 0.82rem; text-align: center; margin: 8px 0; color: var(--primary); font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 0.8rem; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { background: var(--primary); color: white; padding: 6px 4px; font-size: 0.75rem; }
td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.day-link { color: var(--primary); text-decoration: underline; cursor: pointer; }

#playback-controls { display: flex; gap: 4px; align-items: center; margin: 8px 0; }
#playback-controls button { padding: 6px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; }
#speed-control { flex: 1; height: 32px; }
#speed-label { font-size: 0.8rem; white-space: nowrap; }

/* MODE COMPACT MOBILE */
@media (max-width: 480px) {
    #sidebar { width: 100%; height: 52vh; border-left: none; border-top: 1px solid var(--border); padding: 10px; }
    #main { flex-direction: column; }
    #map { height: 48vh; }

    .btn-group { gap: 6px; }
    .action-btn { height: 40px; min-width: 40px; }
    .action-btn iconify-icon { font-size: 1.1rem; }

    table { font-size: 0.75rem; }
    #table-details thead { display: none; }
    #table-details td { display: block; text-align: right; padding: 3px 0; padding-left: 45%; position: relative; }
    #table-details td::before { content: attr(data-label); position: absolute; left: 8px; width: 40%; font-weight: 600; color: var(--primary); text-align: left; font-size: 0.78rem; }
}