:root {
  --bg-page: #f1f5f9;
  --bg-sidebar: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --accent-blue: #2563eb;
  --accent-green: #16a34a;
  --accent-red: #dc2626;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --card-bg: #f8fafc;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

.hidden { display: none !important; }

/* ── SCREENS ── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
  z-index: 10;
}


/* ── MAIN DASHBOARD ── */
#map-screen {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-header { display: flex; justify-content: space-between; align-items: flex-start; }
.sidebar-title { font-size: 18px; font-weight: 800; }
.sidebar-sub { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; padding-top: 2px; }


.sidebar-section { display: flex; flex-direction: column; gap: 10px; }
.section-label { font-size: 10px; font-weight: 800; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.day-filter-list { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; }
.day-pill {
  flex: 0 0 auto;
  padding: 6px 14px;
  background: #f1f5f9;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.day-pill.active { background: var(--accent-blue); color: white; }

.playback-controls { display: flex; gap: 8px; }
.pb-btn {
  flex: 1;
  height: 38px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pb-btn.primary { background: var(--accent-blue); color: white; border: none; }
#pb-speed { font-size: 11px; font-weight: 800; }

.progress-bar {
  width: 100%;
  height: 5px;
  -webkit-appearance: none;
  background: #e2e8f0;
  border-radius: 3px;
  outline: none;
}
.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent-blue);
  border-radius: 50%;
  cursor: pointer;
}

.location-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.location-item {
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  font-size: 11px;
}
.loc-time { font-weight: 700; color: var(--accent-blue); width: 60px; flex-shrink: 0; }
.loc-info { display: flex; flex-direction: column; gap: 2px; }
.loc-name { color: var(--text-primary); font-weight: 600; }
.loc-meta { color: var(--text-secondary); font-size: 10px; font-weight: 500; }

/* ── CURRENT MARKER ── */
.current-marker {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-dot {
  width: 24px;
  height: 24px;
  background: var(--accent-blue);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(0,0,0,0.4);
  z-index: 2;
}

.pulse-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  background: rgba(37, 99, 235, 0.25);
  border: 2px solid rgba(37, 99, 235, 0.5);
  border-radius: 50%;
  animation: pulse 2s infinite ease-out;
  z-index: 1;
}

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

/* ── MAP & OVERLAY ── */
.main-workspace { position: relative; }
#map { width: 100%; height: 100%; z-index: 1; }

.dashboard-container {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.panel-slice {
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  pointer-events: all;
  padding: 12px;
}

.info-slice {
  display: flex;
  gap: 20px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 6px 16px;
}
.info-item { display: flex; align-items: center; gap: 6px; }
.info-item .val { color: var(--text-primary); }

.metrics-panel { display: flex; flex-direction: column; }
.status-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.device-identity { display: flex; align-items: center; gap: 8px; }
.device-name { font-weight: 800; font-size: 14px; }

.badge {
  padding: 3px 8px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #dcfce7;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
}
.pulse { width: 6px; height: 6px; background: #22c55e; border-radius: 50%; }
.status-dot { width: 6px; height: 6px; background: #22c55e; border-radius: 50%; }
.badge.offline { background: #fef2f2; color: #991b1b; border-color: #fee2e2; }
.badge.offline .status-dot { background: #ef4444; }

.metrics-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metric-card {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.metric-value { font-size: 16px; font-weight: 800; margin-bottom: 2px; }
.metric-label { font-size: 8px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; }

.signal-container { display: flex; align-items: flex-end; gap: 1.5px; height: 14px; margin-bottom: 3px; }
.sig-bar { width: 2.5px; background: #e2e8f0; border-radius: 1px; }
.sig-bar.active { background: var(--accent-green); }

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 15px;
  right: 15px;
  width: 40px;
  height: 40px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 1001;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  #map-screen { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    transform: translateY(100%);
    transition: transform 0.3s;
    border-top: 1px solid var(--border);
    z-index: 1000;
  }
  .sidebar.open { transform: translateY(0); }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .dashboard-container { bottom: 60px; }
}
