/* ═══════════════════════════════════════════════════════════
   DIGESETT · COMIPOL — Dashboard Styles
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #21262d;
  --border:   #30363d;
  --text:     #e6edf3;
  --muted:    #8b949e;
  --green:    #097138;
  --green-l:  #3fb950;
  --orange:   #E65100;
  --orange-l: #ff8a50;
  --purple:   #6e40c9;
  --purple-l: #bf91f3;
  --blue:     #01579B;
  --blue-l:   #4fc3f7;
  --amber:    #F9A825;
  --amber-l:  #ffd740;
  --teal:     #00897B;
  --teal-l:   #4db6ac;
  --red:      #c62828;
  --red-l:    #ef5350;
  --hh:       54px;
  --bs-peek:  78px;
}

/* ── Modo claro ──────────────────────────────────────────── */
body.light {
  --bg:       #e8e4de;
  --surface:  #f0ece6;
  --surface2: #d8d4ce;
  --border:   #bcb8b0;
  --text:     #2a2520;
  --muted:    #6a6460;
}

html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ═══ HEADER ══════════════════════════════════════════════ */

header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--hh);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; z-index: 300;
}
.hbadge { background: none; padding: 0; flex-shrink: 0; }
.hbadge img { height: 40px; width: auto; display: block; }
.htitles { flex: 1; min-width: 0; }
.htitles h1 { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.htitles p  { font-size: 11px; color: var(--muted); }
.hright { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

#last-updated { font-size: 11px; color: var(--muted); white-space: nowrap; }
#last-updated.ok  { color: var(--green-l); }
#last-updated.err { color: var(--red-l); }

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green-l);
  box-shadow: 0 0 0 3px rgba(63,185,80,.25);
  animation: pulse 2s infinite; flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(63,185,80,.25); }
  50%      { box-shadow: 0 0 0 7px rgba(63,185,80,.06); }
}
#clock { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

#btn-refresh {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 5px 10px;
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: background .12s; white-space: nowrap;
}
#btn-refresh:hover { background: var(--border); }
.ri { display: inline-block; }
#btn-refresh.spinning .ri { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#filter-clear {
  display: none; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 11px; font-size: 11px;
  cursor: pointer; color: var(--text); white-space: nowrap;
  transition: background .15s;
}
#filter-clear.show { display: inline-flex; }
#filter-clear:hover { background: var(--border); }

#btn-sidebar {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 16px; padding: 4px 10px;
  cursor: pointer; line-height: 1; margin-right: 4px;
}
#btn-sidebar:hover { background: var(--surface2); }

.btn-logout {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-size: 11px; font-weight: 600;
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red-l); }

#btn-theme {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 16px; padding: 4px 9px;
  cursor: pointer; line-height: 1; transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
#btn-theme:hover { background: var(--surface2); }

/* ═══ MAIN GRID (desktop) ════════════════════════════════ */

.main {
  position: fixed;
  top: var(--hh); left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: 270px 1fr;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
.main.sidebar-hidden { grid-template-columns: 0 1fr; }
.main.sidebar-hidden .sidebar { width: 0; padding: 0; overflow: hidden; border: none; }
.sidebar { transition: width .22s ease, padding .22s ease; }

/* ═══ STATS ROW ══════════════════════════════════════════ */

.stats-row {
  grid-column: 1 / -1;
  display: flex; gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-row::-webkit-scrollbar { height: 0; }

.stat-card {
  flex: 1; min-width: 118px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: relative; overflow: hidden;
  transition: transform .12s, box-shadow .12s;
  cursor: pointer;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px #00000066; }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent, #444);
  border-radius: 8px 8px 0 0;
}
.sc-lbl { font-size: 9px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.sc-val { font-size: 26px; font-weight: 800; line-height: 1; color: var(--text); }
.sc-sub { font-size: 10px; color: var(--muted); }
.sc-ico { position: absolute; right: -6px; bottom: 0; height: 62px; opacity: .4; pointer-events: none; display: flex; align-items: flex-end; }
.sc-ico img { height: 62px; width: auto; object-fit: contain; display: block; mix-blend-mode: multiply; }

.stat-card.card-on  { box-shadow: 0 0 0 2px var(--accent), 0 8px 24px rgba(0,0,0,.55); transform: translateY(-3px); z-index: 2; }
.stat-card.card-off { opacity: .28; filter: grayscale(.4); transform: none !important; box-shadow: none !important; }

/* ── Compound accidents card ─────────────────────────── */
.acc-compound { min-width: 170px; }
.acc-sub-row  { display: flex; gap: 12px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--border); }
.acc-sub-item { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.acc-sub-lbl  { font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.acc-sub-val  { font-size: 18px; font-weight: 800; line-height: 1; }

.lyr.lyr-hl { background: var(--surface2); border-radius: 5px; }

/* ═══ SIDEBAR ════════════════════════════════════════════ */

.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
.sec h3 {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 8px; padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.lyr { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; margin-bottom: 3px; cursor: pointer; transition: background .12s; }
.lyr:hover { background: var(--surface2); }
.lyr-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.lyr-ico { height: 22px; width: auto; flex-shrink: 0; opacity: .85; }
.lyr-nm  { font-size: 12px; flex: 1; }
.lyr-ct  { font-size: 11px; font-weight: 700; background: var(--surface2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 20px; min-width: 34px; text-align: center; }
.lyr-toggle { position: relative; display: inline-block; width: 32px; height: 18px; flex-shrink: 0; cursor: pointer; }
.lyr-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.lyr-track { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 18px; transition: background .2s; }
.lyr-track::after { content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s; }
.lyr-toggle input:checked + .lyr-track { background: var(--tc, var(--accent)); }
.lyr-toggle input:checked + .lyr-track::after { transform: translateX(14px); }

#lyr-all, #lyr-none {
  float: right; font-size: 10px; padding: 2px 7px;
  border-radius: 4px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  cursor: pointer; margin-left: 4px;
}

.alrt { display: flex; gap: 8px; padding: 7px 9px; background: var(--surface2); border-radius: 6px; margin-bottom: 5px; border-left: 3px solid transparent; }
.alrt-ico { font-size: 14px; flex-shrink: 0; }
.alrt-txt { font-size: 11px; line-height: 1.4; }
.alrt-sub { font-size: 10px; color: var(--muted); margin-top: 1px; }

/* ═══ MAP PANEL ══════════════════════════════════════════ */

.map-panel { position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; }

.map-badge {
  position: absolute; bottom: 14px; left: 14px;
  background: rgba(13,17,23,.88); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 11px; font-size: 11px; font-weight: 600;
  color: var(--text); pointer-events: none; z-index: 10;
}
.map-badge span { color: var(--green-l); }

.map-logo {
  position: absolute; bottom: 0; right: 0;
  height: 60px; width: auto;
  z-index: 10; pointer-events: none;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.55));
}



/* ═══ MAPBOX POPUP DARK ══════════════════════════════════ */

.mapboxgl-popup-content {
  background: #161b22; border: 1px solid #30363d;
  border-radius: 8px; padding: 10px 13px;
  min-width: 200px; box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.mapboxgl-popup-tip { border-top-color: #161b22 !important; border-bottom-color: #161b22 !important; }
.mapboxgl-popup-close-button { color: #8b949e; font-size: 16px; right: 6px; top: 4px; }
.mapboxgl-popup-close-button:hover { color: #fff; }
.mp-type { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; margin-bottom: 5px; opacity: .9; }
.mp-name { font-size: 12px; font-weight: 600; color: #e6edf3; line-height: 1.4; margin-bottom: 4px; }
.mp-desc { font-size: 11px; color: #8b949e; line-height: 1.5; }
.mp-desc b { color: #c9d1d9; }
.mp-coords { font-size: 10px; color: #484f58; margin-top: 6px; font-family: monospace; }

/* ── Leyenda de tráfico (sidebar desktop) ───────────────────────────────────── */
.traffic-legend { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.tl-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #c9d1d9; padding: 3px 0; }
.tl-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

/* ── Leyenda de tráfico (bottom sheet mobile) ──────────────────────────────── */
.bs-traffic-legend { margin: 12px 12px 4px; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; }
.btl-title { font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.btl-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #c9d1d9; margin-bottom: 6px; }
.btl-row:last-child { margin-bottom: 0; }
.btl-dot { display: block; width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.mp-nav { margin-top: 12px; }
.nav-btn { width: 100%; padding: 11px; background: #1f6feb; color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nav-btn:active { opacity: .8; }

/* ── Nav modal ───────────────────────────────────────────────────── */
#nav-modal { position: fixed; inset: 0; z-index: 9999; }
#nav-modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
#nav-modal-sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: #161b22; border-radius: 18px 18px 0 0;
  border-top: 1px solid #30363d;
  padding: 20px 16px 40px;
  animation: slideup .25s cubic-bezier(.32,.72,0,1);
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.nm-label  { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #8b949e; margin-bottom: 3px; }
.nm-name   { font-size: 15px; font-weight: 700; color: #e6edf3; margin-bottom: 2px; }
.nm-coords { font-size: 11px; color: #484f58; font-family: monospace; margin-bottom: 16px; }
.nm-btns   { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.nmbtn { padding: 13px 16px; border: none; border-radius: 10px; font-size: 14px; font-weight: 700; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
.nmbtn:active { opacity: .8; }
.nmgm  { background: #1a73e8; color: #fff; }
.nmwz  { background: #33ccff; color: #000; }
.nmgeo { background: #21262d; color: #e6edf3; border: 1px solid #30363d; }
.nm-cancel { width: 100%; padding: 13px; background: #0d1117; border: 1px solid #30363d; border-radius: 10px; color: #8b949e; font-size: 14px; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; margin-top: 2px; }

.pin-label {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  font-size: 7px; font-weight: 800; letter-spacing: .4px;
  color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.9);
  white-space: nowrap; pointer-events: none; line-height: 1;
}

/* ═══ SCROLLBARS ═════════════════════════════════════════ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ═════════════════════════════════════════════════════════
   BOTTOM SHEET (mobile)
   3 snap states: peek (chips visible) → half → full
   ═════════════════════════════════════════════════════════ */

#bs {
  display: none;                          /* visible only on mobile */
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 88vh;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  z-index: 400;
  transform: translateY(calc(88vh - var(--bs-peek)));
  transition: transform .38s cubic-bezier(.32,.72,0,1);
  will-change: transform;
  overflow: hidden;
}
#bs.bs-half { transform: translateY(44vh); }
#bs.bs-full { transform: translateY(0); }
#bs.bs-dragging { transition: none; }

#bs-handle-area {
  cursor: grab;
  padding-bottom: 2px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#bs-handle-area:active { cursor: grabbing; }

.bs-handle {
  width: 36px; height: 4px;
  background: var(--border); border-radius: 2px;
  margin: 10px auto 6px;
}

/* Chips row — always visible in peek state */
.bs-chips {
  display: flex; gap: 6px;
  padding: 0 12px 8px;
  overflow-x: auto; align-items: center;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bs-chips::-webkit-scrollbar { display: none; }

.bschip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 5px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 10px 5px 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity .15s, border-color .15s;
  user-select: none;
}
.bschip img { height: 28px; width: auto; flex-shrink: 0; }
.bschip span { font-size: 18px; font-weight: 800; color: var(--cc, var(--text)); min-width: 26px; text-align: right; }
.bschip.active { border-color: var(--cc, var(--border)); }
.bschip.off { opacity: .3; }

.bschip-refresh { flex-shrink: 0; margin-left: auto; }
.bschip-refresh button {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 17px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
}
.bschip-refresh button.spinning { animation: spin .7s linear infinite; }

/* Revealed body */
.bs-body {
  display: flex; flex-direction: column;
  height: calc(88vh - var(--bs-peek));
  overflow: hidden;
}
.bs-tabbar {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 6px; flex-shrink: 0; gap: 2px;
}
.bs-tab {
  flex: 1; background: none; border: none;
  color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 9px 4px; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.bs-tab.active { color: var(--green-l); border-bottom-color: var(--green-l); }
.bs-minimize-bar {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 6px 0; border-top: 1px solid var(--border);
  background: var(--surface2);
  font-size: 11px; font-weight: 600; color: var(--muted);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.bs-minimize-bar:active { background: var(--border); color: var(--text); }

.bs-panel {
  flex: 1; overflow-y: auto; padding: 12px 14px 32px;
  -webkit-overflow-scrolling: touch;
}
.bs-panel.hidden { display: none; }

/* Stats 2×4 grid */
.bs-statsgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bssc {
  background: var(--surface2); border: 1px solid var(--border);
  border-top: 3px solid var(--a, #444);
  border-radius: 8px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.bssc img { height: 36px; width: auto; opacity: .65; }
.bssc-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); text-align: center; }
.bssc-val { font-size: 34px; font-weight: 800; line-height: 1; }

/* Compound accident card (full-width in grid) */
.bssc-acc-compound { grid-column: 1 / -1; align-items: center; }
.bssc-acc-subrow   { display: flex; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); width: 100%; justify-content: center; }
.bssc-acc-item     { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bssc-acc-lbl      { font-size: 9px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.bssc-acc-val      { font-size: 22px; font-weight: 800; line-height: 1; }

/* Layers 2-column grid */
.bs-lyr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.bslyr {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 10px;
  background: var(--surface2); border-radius: 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .12s;
  user-select: none;
}
.bslyr:active { background: var(--border); }
.bslyr-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bslyr-ico { height: 24px; width: auto; flex-shrink: 0; opacity: .85; }
.bslyr-nm { font-size: 11px; flex: 1; line-height: 1.3; }

.bs-lyr-actions { display: flex; gap: 8px; margin-top: 4px; }
.bs-lyr-actions button {
  flex: 1; padding: 9px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.bs-lyr-actions button:active { background: var(--border); }

.bs-panel .alrt { background: var(--surface); }

/* ═════════════════════════════════════════════════════════
   UNIT CARD — slides up from bottom when marker tapped (mobile)
   ═════════════════════════════════════════════════════════ */

#unit-card {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--border);
  z-index: 500;
  padding: 16px 18px 36px;
  max-height: 70vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.32,.72,0,1);
  will-change: transform;
  pointer-events: none;
}
#unit-card.open { transform: translateY(0); pointer-events: auto; }

#unit-card .uc-handle {
  width: 36px; height: 4px;
  background: var(--border); border-radius: 2px;
  margin: 0 auto 14px;
}
#uc-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

/* ════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  /* Compact header */
  .htitles p    { display: none; }
  .htitles h1   { font-size: 12px; }
  #clock        { display: none; }
  #last-updated { display: none; }
  #btn-refresh .rl { display: none; }
  #btn-sidebar  { display: none; }
  #btn-logout   { display: none; }
  #filter-clear { display: none !important; }

  /* Main becomes a simple block — map fills it */
  .main { display: block; }

  /* Stats row + sidebar hidden — bottom sheet replaces them */
  .stats-row { display: none !important; }
  .sidebar   { display: none !important; }

  /* Map panel fills the full area under the header */
  .map-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
  }

  /* Badge sits above the peek strip */
  .map-badge { bottom: calc(var(--bs-peek) + 14px); }
  .map-logo  { display: none; }

  /* Show bottom sheet */
  #bs         { display: block; }

  /* Disable floating popups — unit card replaces them */
  .mapboxgl-popup { display: none !important; }
}

@media (max-width: 480px) {
  .hbadge img { height: 34px; }
  .htitles h1 { font-size: 11px; }
}
.uc-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 14px; }
#uc-close {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
#uc-close:hover { color: var(--text); }

/* ═════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 900px)
   ═════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  /* Compact header */
  .htitles p   { display: none; }
  .htitles h1  { font-size: 12px; }
  #clock       { display: none; }
  #last-updated { display: none; }
  #btn-refresh .rl { display: none; }
  #btn-sidebar { display: none; }
  #btn-logout  { display: none; }
  #filter-clear { display: none !important; }

  /* Main: one block, full screen */
  .main {
    bottom: 0 !important;
    display: block;
    overflow: hidden;
  }

  /* Stats row + sidebar replaced by bottom sheet */
  .stats-row { display: none !important; }
  .sidebar   { display: none !important; }

  /* Map fills everything */
  .map-panel { position: absolute; inset: 0; display: block; }

  /* Map badge shifts up above chips */
  .map-badge { bottom: calc(var(--bs-peek) + 14px); left: 14px; }
  .map-logo  { display: none; }

  /* Activate bottom sheet */
  #bs         { display: block; }

  /* Suppress Mapbox popups (unit card replaces them) */
  .mapboxgl-popup { display: none !important; }
}

@media (max-width: 480px) {
  .hbadge img { height: 34px; }
  .htitles h1 { font-size: 11px; }
}

/* ── Accident toast notifications ──────────────────────────────────────── */
#acc-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}
.acc-toast {
  pointer-events: all;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 280px;
  max-width: 360px;
  background: var(--surface2);
  border: 1px solid #f4a200;
  border-left: 4px solid #f4a200;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,.55);
  animation: toast-in .3s ease;
  cursor: pointer;
}
.acc-toast.toast-out { animation: toast-out .3s ease forwards; }
.acc-toast-ico  { font-size: 26px; line-height: 1; flex-shrink: 0; }
.acc-toast-body { flex: 1; min-width: 0; }
.acc-toast-ttl  { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: #f4a200; margin-bottom: 3px; }
.acc-toast-tipo { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-toast-dir  { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-toast-hora { font-size: 10px; color: var(--muted); margin-top: 4px; }
.acc-toast-close { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0; align-self: flex-start; }
.acc-toast-close:hover { color: var(--text); }
@keyframes toast-in  { from { opacity:0; transform: translateX(40px); } to { opacity:1; transform: translateX(0); } }
@keyframes toast-out { to   { opacity:0; transform: translateX(40px); } }
@media (max-width: 900px) {
  #acc-toast-stack { bottom: calc(var(--bs-peek) + 20px); right: 14px; left: 14px; }
  .acc-toast { max-width: 100%; }
}

/* ── Accident feed (sidebar) ───────────────────────────────────────────── */
.acc-feed-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--muted);
  margin: 8px 0 4px;
}
.acc-feed-badge {
  background: #f4a200; color: #000;
  font-size: 10px; font-weight: 800;
  border-radius: 10px; padding: 1px 6px;
  min-width: 18px; text-align: center;
}
.acc-feed-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 240px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.acc-feed-empty { font-size: 11px; color: var(--muted); padding: 6px 2px; }
.acc-feed-item {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--surface2); border-left: 3px solid #f4a200;
  border-radius: 5px; padding: 6px 8px;
  cursor: pointer; transition: background .15s;
  animation: feed-in .3s ease;
}
.acc-feed-item.acc-feed-new { border-left-color: #ff4444; animation: feed-pulse .5s ease; }
.acc-feed-item:hover { background: var(--border); }
.acc-feed-item-ico { font-size: 18px; flex-shrink: 0; line-height: 1.2; }
.acc-feed-item-body { flex: 1; min-width: 0; }
.acc-feed-item-tipo { font-size: 11px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-feed-item-dir  { font-size: 10px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-feed-item-hora { font-size: 10px; color: #f4a200; margin-top: 2px; }
.acc-feed-item-cas  { font-size: 10px; color: #ef5350; margin-top: 1px; }
@keyframes feed-in    { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: none; } }
@keyframes feed-pulse { 0%,100% { border-left-color:#ff4444; } 50% { border-left-color:#ffcc00; } }

/* ═══ MODAL: Accidentes Diarios ══════════════════════════════════════════ */
.adm-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: adm-fadein .2s ease;
}
@keyframes adm-fadein { from { opacity:0 } to { opacity:1 } }
.adm-sheet {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px 24px;
  width: 94vw; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,.55);
  animation: adm-slideup .25s cubic-bezier(.32,.72,0,1);
}
@keyframes adm-slideup { from { transform: translateY(30px); opacity:0 } to { transform: none; opacity:1 } }
.adm-close {
  position: absolute; top: 12px; right: 14px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 18px; width: 30px; height: 30px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: color .12s, background .12s;
}
.adm-close:hover { color: var(--text); background: var(--border); }
.adm-title { font-size: 16px; font-weight: 800; color: #f4a200; margin-bottom: 2px; }
.adm-subtitle { font-size: 11px; color: var(--muted); margin-bottom: 16px; }

.adm-grid { display: flex; flex-direction: column; gap: 6px; }
.adm-row {
  display: grid; grid-template-columns: 1fr 80px;
  align-items: center; gap: 6px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  transition: background .12s;
}
.adm-row:hover { background: var(--border); }
.adm-row.adm-today { border-left: 3px solid #f4a200; }
.adm-day { font-size: 13px; font-weight: 700; color: var(--text); }
.adm-day small { font-size: 10px; font-weight: 400; color: var(--muted); display: block; margin-top: 1px; }
.adm-num { font-size: 20px; font-weight: 800; text-align: center; }
.adm-num-lbl { font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); text-align: center; display: block; margin-top: 1px; }
.adm-acc { color: #f4a200; }
.adm-les { color: #ff7043; }
.adm-fal { color: #ef5350; }

.adm-totals {
  display: grid; grid-template-columns: 1fr;
  gap: 8px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.adm-tot-card {
  text-align: center; padding: 10px 6px;
  background: var(--surface2); border-radius: 8px;
  border: 1px solid var(--border);
}
.adm-tot-val { font-size: 28px; font-weight: 800; line-height: 1; }
.adm-tot-lbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 4px; }

@media (max-width: 480px) {
  .adm-sheet { padding: 22px 14px 18px; border-radius: 18px 18px 0 0; max-width: 100%; width: 100%; position: fixed; bottom: 0; left: 0; right: 0; max-height: 85vh; }
  .adm-row { grid-template-columns: 1fr 70px; padding: 8px 10px; }
  .adm-num { font-size: 17px; }
  .adm-tot-val { font-size: 24px; }
}
