/* ====================================================================
   DURAV — CLICKHOUSE-INSPIRED TACTICAL COMMAND
   Design System — Neutral Monochrome + Dark Canvas
   Dark · Glass · Monospaced · Semantic Colors Only
   ==================================================================== */

/* === DESIGN TOKENS (CSS Custom Properties) === */
/* === LOCAL FONTS === */
@font-face {
  font-family: "Phosphor-Fill";
  src: url("/fonts/Phosphor-Fill.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}
/* Font Awesome 6 Free — solid (SIL OFL 1.1). Segunda familia de iconos: SOLO los
   glifos operativos del mapa (marcadores + celda GPS de la grilla) usan FA; el
   resto de la app sigue en Phosphor. Peso 900 OBLIGATORIO (canvas y DOM). */
@font-face {
  font-family: "Font Awesome 6 Free";
  src: url("/fonts/fa-solid-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: block;
}
/* Celda GPS de la grilla: mismos glifos FA que los marcadores del mapa */
.fam { font-family: "Font Awesome 6 Free"; font-weight: 900; font-style: normal; line-height: 1; display: inline-flex; -moz-osx-font-smoothing: grayscale; -webkit-font-smoothing: antialiased; }
.fam-location-arrow:before { content: "\f124"; }
.fam-pause:before { content: "\f04c"; }
.fam-stop:before { content: "\f04d"; }
.fam-square-parking:before { content: "\f540"; }
.fam-eye-slash:before { content: "\f070"; }

:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Surface — blue-tinted terminal ramp */
  --surface: #06080c;
  --surface-dim: #06080c;
  --surface-bright: #121822;
  --surface-container-lowest: #040608;
  --surface-container-low: #0d1118;
  --surface-container: #090d14;
  --surface-container-high: #121822;
  --surface-container-highest: #18202d;
  --surface-hover: #18202d;
  --surface-active: #1f2a3a;
  --on-surface: #f8fafc;
  --on-surface-variant: #c5d4e6;
  --outline: #8498b0;
  --outline-variant: #1e2838;

  /* Borders — machined hairlines */
  --border-subtle: #1e2838;
  --border-medium: #2a3a50;
  --border-bright: #3f5575;

  /* Neutral Primary — Blanco Señal stays the action accent */
  --primary: #ffffff;
  --on-primary: #06080c;
  --primary-container: #ffffff;
  --on-primary-container: #06080c;
  --primary-fixed: #c5d4e6;

  /* Secondary */
  --secondary: #c5d4e6;
  --secondary-container: #18202d;

  /* Status — semantic colors re-tuned to the terminal palette */
  --error: #ff3355;
  --error-container: rgba(255, 51, 85, 0.14);
  --on-error-container: #ffb3c0;
  --warning: #ffaa00;
  --tertiary: #60a5fa;
  --tertiary-container: #60a5fa;
  --color-success: #00f076;
  --color-danger: #ff3355;
  --color-info: #60a5fa;
  --color-orange: #f97316;
  --color-transit: #00f076;
  --color-ralenti: #c6ce00;
  --color-idle: #ffaa00;
  --color-lila: #a855f7;
  --color-teal: #14b8a6;
  --color-parked: #2f9bff;
  --color-arrived: #818cf8;
  --color-done: #64748b;
  --color-cancelled: #47546a;
  --color-pending: #8498b0;

  /* Tints — state fills at low alpha (badges, cells, washes) */
  --tint-success: rgba(0, 240, 118, 0.12);
  --tint-danger: rgba(255, 51, 85, 0.12);
  --tint-idle: rgba(255, 170, 0, 0.12);
  --tint-info: rgba(96, 165, 250, 0.12);
  --tint-orange: rgba(249, 115, 22, 0.14);
  --row-hover: rgba(255, 255, 255, 0.03);

  /* Glass defaults */
  --glass-bg: rgba(9, 12, 18, 0.60);
  --glass-border: rgba(63, 85, 117, 0.45);
  --glass-blur: 12px;
  --glass-saturate: 1.15;

  /* Sidebar */
  --sidebar-bg: rgba(9, 12, 18, 0.88);

  /* Layout */
  --sidebar-width: 64px;
  --panel-right: 420px;
  --gutter: 16px;
  --margin-page: 24px;

  /* Derived aliases */
  --color-base: #06080c;
  --color-panel: #0d1118;
  --color-panel-alt: #121822;
  --color-border: #1e2838;
  --color-border-light: rgba(63, 85, 117, 0.35);
  --color-text: #f8fafc;
  --color-text-secondary: #c5d4e6;
  --color-text-muted: #9bb0c9;
  --color-text-dim: #8498b0;
  --color-accent: #ffffff;
  --color-accent-dim: #c5d4e6;
  --color-accent-bg: rgba(255, 255, 255, 0.05);
  --color-accent-glow: rgba(255, 255, 255, 0.12);
  --color-glass: rgba(9, 12, 18, 0.60);
  --color-glass-border: rgba(63, 85, 117, 0.45);
  --map-glass: rgba(9,12,18,0.66);
  --map-border: rgba(63,85,117,0.55);
  --map-btn-color: rgba(197, 212, 230, 0.45);
  --map-btn-hover: rgba(248, 250, 252, 0.9);
  --marker-border: #040608;

  /* ── Escala de capas (stacking) — única fuente de verdad del z-index ──
     nav-sidebar 200 < detail-panel 1000 < tour 100000 < alert-popup 1000001
     < modal 2000000 < toast 10000000. Los modales SIEMPRE por encima de los
     paneles de detalle; los toasts SIEMPRE por encima de los modales. */
  --z-nav-sidebar: 200;
  --z-detail-panel: 1000;
  --z-tour: 100000;
  --z-alert-popup: 1000001;
  --z-modal: 2000000;
  --z-toast: 10000000;
}

/* === LIGHT THEME OVERRIDES — Daylight Terminal ===
   Same world, inverted: cool blue-tinted paper grounds, ink-navy text,
   accents darkened for contrast. Blue remains the undertone; nothing
   drifts back to neutral gray. */
:root:not(.dark) {
  --surface: #f0f4f9;
  --surface-dim: #e4eaf2;
  --surface-bright: #ffffff;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #e9eef6;
  --surface-container: #e2e9f3;
  --surface-container-high: #d9e2ee;
  --surface-container-highest: #cfd9e8;
  --surface-hover: #d9e2ee;
  --surface-active: #c8d3e4;
  --on-surface: #101828;
  --on-surface-variant: #3d4d63;
  --outline: #5b6d85;
  --outline-variant: #d4dce9;
  --border-subtle: #dbe2ec;
  --border-medium: #b6c4d9;
  --border-bright: #8fa2bf;
  --primary: #101828;
  --on-primary: #f8fafc;
  --primary-container: #101828;
  --on-primary-container: #f8fafc;
  --primary-fixed: #3d4d63;
  --secondary: #3d4d63;
  --secondary-container: #d9e2ee;
  --error: #d91f3f;
  --error-container: rgba(217, 31, 63, 0.10);
  --on-error-container: #d91f3f;
  --warning: #9a6a00;
  --tertiary: #2563eb;
  --tertiary-container: #2563eb;
  --color-success: #00874f;
  --color-danger: #d91f3f;
  --color-info: #2563eb;
  --color-orange: #c2410c;
  --color-transit: #00874f;
  --color-ralenti: #7d8800;
  --color-idle: #9a6a00;
  --color-lila: #7c3aed;
  --color-teal: #0f766e;
  --color-parked: #2563eb;
  --color-arrived: #4f46e5;
  --color-done: #526175;
  --color-cancelled: #47526a;
  --color-pending: #5b6d85;
  --tint-success: rgba(0, 135, 79, 0.10);
  --tint-danger: rgba(217, 31, 63, 0.10);
  --tint-idle: rgba(154, 106, 0, 0.12);
  --tint-info: rgba(37, 99, 235, 0.10);
  --tint-orange: rgba(194, 65, 12, 0.10);
  --row-hover: rgba(16, 24, 40, 0.04);
  --glass-bg: rgba(240, 244, 249, 0.60);
  --glass-border: rgba(16, 24, 40, 0.10);
  --glass-blur: 12px;
  --glass-saturate: 1.15;
  --sidebar-bg: rgba(240, 244, 249, 0.90);
  --color-base: #f0f4f9;
  --color-panel: #e9eef6;
  --color-panel-alt: #e2e9f3;
  --color-border: #d4dce9;
  --color-border-light: rgba(16, 24, 40, 0.07);
  --color-text: #101828;
  --color-text-secondary: #3d4d63;
  --color-text-muted: #5b6d85;
  --color-text-dim: #5b6d85;
  --color-accent: #101828;
  --color-accent-dim: #3d4d63;
  --color-accent-bg: rgba(16, 24, 40, 0.05);
  --color-accent-glow: rgba(16, 24, 40, 0.10);
  --color-glass: rgba(240, 244, 249, 0.60);
  --color-glass-border: rgba(16, 24, 40, 0.10);
  --map-glass: rgba(240,244,249,0.9);
  --map-border: rgba(16,24,40,0.12);
  --map-btn-color: rgba(16,24,40,0.5);
  --map-btn-hover: rgba(16,24,40,0.85);
}

/* === BASE RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root { --theme-transition: 0.25s; }
html { transition: background var(--theme-transition) ease; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  letter-spacing: -0.01em;
  background: var(--surface);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Browser surfaces carry the design: selection, focus, caret, scrollbars */
::selection { background: var(--primary); color: var(--on-primary); }
:focus-visible { outline: 2px solid var(--color-info); outline-offset: 1px; }
input, select, textarea { caret-color: var(--color-info); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }
* { scrollbar-width: thin; scrollbar-color: var(--border-medium) transparent; }

/* remove scrollbars on body */
body::-webkit-scrollbar { display: none; }
body { -ms-overflow-style: none; scrollbar-width: none; }

#app-splash {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background: var(--surface);
  transition: opacity 0.5s ease;
}

.app-splash-hidden { opacity: 0; pointer-events: none; }

.splash-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.splash-shield {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(255, 255, 255, 0.08);
}

.splash-brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.splash-wordmark {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.35em;
  margin-right: -0.35em;
  text-transform: uppercase;
  color: var(--color-text);
}

.splash-tagline {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.splash-ring {
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ffffff;
  animation: splashSpin 1.2s cubic-bezier(0.6, 0, 0.4, 1) infinite;
}

.splash-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #ffffff, transparent);
  animation: splashScan 2.5s ease-in-out infinite;
}

.splash-dots {
  display: flex;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-text-muted);
}

.splash-dot {
  animation: splashDot 1.4s steps(4) infinite;
}

@keyframes splashSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes splashScan { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); }}

@keyframes splashDot { 0% { opacity: 0.2; } 50% { opacity: 1; } 100% { opacity: 0.2; }}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
ul, ol { list-style: none; }

/* === FONT UTILITIES === */
.font-mono { font-family: var(--font-mono) !important; }
.font-sans { font-family: var(--font-body) !important; }

/* === TEXT CLASSES === */
.text-body { font-family: var(--font-body); font-size: 16px; line-height: 24px; }
.text-data-lg { font-family: var(--font-mono); font-size: 32px; font-weight: 700; line-height: 40px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.text-data-sm { font-family: var(--font-mono); font-size: 14px; font-weight: 500; line-height: 20px; font-variant-numeric: tabular-nums; }
.text-label { font-family: var(--font-mono); font-size: 14px; font-weight: 600; line-height: 16px; letter-spacing: 0.05em; text-transform: uppercase; }
.nowrap { white-space: nowrap !important; }

/* === TABLE GRID (no word-wrap) === */
#ops-table th,
#ops-table td { white-space: nowrap; }

/* === SCROLLBAR === */
.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 2px;
  transition: background 0.2s;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* === GLASS PANELS === */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
}
.glass-strong {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(16px) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
}
.glass-dark {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
}
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
}

/* Sidebars + grillas de Operaciones, Alertas y Sedes/Monitor:
   más opacas para legibilidad de datos */
#ops-side-panel,
#alerts-side-panel,
#mnt-side-panel {
  background: rgba(9, 12, 18, 0.82);
}
#ops-side-panel thead,
#alerts-side-panel thead,
#mnt-side-panel thead {
  background: rgba(9, 12, 18, 0.82) !important;
}
:root:not(.dark) #ops-side-panel,
:root:not(.dark) #alerts-side-panel,
:root:not(.dark) #mnt-side-panel {
  background: rgba(240, 244, 249, 0.86);
}
:root:not(.dark) #ops-side-panel thead,
:root:not(.dark) #alerts-side-panel thead,
:root:not(.dark) #mnt-side-panel thead {
  background: rgba(240, 244, 249, 0.86) !important;
}

/* === CARDS === */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: var(--gutter);
  transition: all 0.15s ease;
}
.card:hover {
  border-color: var(--border-bright);
}
.card-accent {
  border-color: var(--primary-container);
  background: var(--color-accent-bg);
}
.clickable {
  cursor: pointer;
  transition: all 0.15s ease;
}
.clickable:hover {
  border-color: var(--border-bright) !important;
  background: var(--row-hover) !important;
}
.clickable-result {
  cursor: pointer;
  transition: background 0.12s ease;
}
.clickable-result:hover {
  background: var(--row-hover) !important;
}
.stat-card-dash {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 10px 14px;
  transition: all 0.15s ease;
  cursor: pointer;
}
.stat-card-dash:hover {
  border-color: var(--border-bright) !important;
}

/* === METRIC CARDS === */
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 4px;
  padding: 12px 16px;
  transition: all 0.15s ease;
}
.stat-card:hover {
  border-color: var(--border-bright);
}
#ops-metrics .stat-card {
  padding: 8px 12px;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  line-height: 40px;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* === STATUS CHIPS / BADGES — machined rectangles, tint fills === */
.badge, .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
  border: 1px solid var(--border-subtle);
}
.badge-success, .chip-success { background: var(--tint-success); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 30%, transparent); }
.badge-danger, .chip-danger { background: var(--tint-danger); color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 30%, transparent); }
.badge-warning, .chip-warning { background: var(--tint-idle); color: var(--color-idle); border-color: color-mix(in srgb, var(--color-idle) 30%, transparent); }
.badge-info, .chip-info { background: var(--tint-info); color: var(--color-info); border-color: color-mix(in srgb, var(--color-info) 30%, transparent); }

/* === PRIORITY BADGES === */
.prio-1 { background: var(--tint-danger); color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 32%, transparent); }
.prio-2 { background: var(--tint-orange); color: var(--color-orange); border-color: color-mix(in srgb, var(--color-orange) 32%, transparent); }
.prio-3 { background: var(--tint-idle); color: var(--color-idle); border-color: color-mix(in srgb, var(--color-idle) 32%, transparent); }
.prio-4 { background: var(--tint-info); color: var(--color-info); border-color: color-mix(in srgb, var(--color-info) 32%, transparent); }
.prio-5 { background: var(--row-hover); color: var(--color-pending); border-color: color-mix(in srgb, var(--color-pending) 30%, transparent); }

/* === ACCENT UTILITY CLASSES === */
.badge-accent {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent);
}
.badge-accent-dim {
  background: var(--color-accent-bg);
  color: var(--color-accent-dim);
}
.fleet-card-active {
  background: var(--color-accent-bg) !important;
  border-color: var(--primary-container) !important;
}
.timeline-dot-active {
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent);
}
.timeline-dot-inactive {
  background: var(--surface);
  border: 1px solid var(--outline-variant);
}
.timeline-ping {
  background: var(--color-accent-glow);
  opacity: 0.6;
  margin: -1px;
}
/* Sonar de ALERTA ABIERTA en el timeline: rojo (intensidad plena). Cerrada → gris sin sonar. */
.timeline-dot-danger {
  background: var(--tint-danger);
  border: 1px solid var(--color-danger);
}
.timeline-ping-danger {
  background: rgba(255, 51, 85, 0.85);
  opacity: 0.6;
  margin: -1px;
}
/* Sonar de REPORTE de integraciones (DPort/APM): purple permanente, MITAD de intensidad. */
.timeline-dot-purple {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid #a855f7;
}
.timeline-ping-purple {
  background: rgba(168, 85, 247, 0.85);
  opacity: 0.3;
  margin: -1px;
}
.amt-token-active {
  background: var(--color-accent-bg);
  border: 1px dashed var(--color-success);
  padding: 12px;
  border-radius: 2px;
  text-align: center;
  margin-bottom: 12px;
}

/* === HUD BADGES === */
.hud-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--on-surface);
  height: 32px;
  padding: 0 14px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary-container);
  color: var(--on-primary);
}
.btn-primary:hover {
  background: var(--primary);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-secondary {
  background: transparent;
  color: var(--on-surface-variant);
  border: 1px solid var(--border-bright);
}
.btn-secondary:hover {
  background: var(--row-hover);
  color: var(--on-surface);
  border-color: var(--on-surface-variant);
}
.btn-ghost {
  background: transparent;
  color: var(--on-surface-variant);
  border: none;
}
.btn-ghost:hover {
  background: var(--row-hover);
  color: var(--on-surface);
}
.btn-accent {
  background: var(--color-accent-bg);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--color-accent) 20%, transparent);
}
.btn-accent:hover {
  background: var(--color-accent-glow);
  transform: translateY(-1px);
}
.btn-danger {
  background: var(--tint-danger);
  color: var(--color-danger);
  border: 1px solid color-mix(in srgb, var(--color-danger) 30%, transparent);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--color-danger) 20%, transparent);
}
.btn-sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 2px; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }

/* === FILTER PILLS — machined toggles === */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 12px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--on-surface-variant);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.filter-pill:hover {
  background: var(--surface-hover);
  color: var(--on-surface);
}
.filter-pill.active {
  background: var(--surface-active);
  color: var(--on-surface);
  border-color: var(--border-medium);
}

/* === TOP HEADER BAR === */
.top-header {
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 var(--margin-page);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--glass-border);
  gap: var(--gutter);
  flex-shrink: 0;
  z-index: 30;
}
.top-header-left {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
}
.top-header-center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.top-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
}
#offline-dot i {
  font-size: 16px;
  transition: color 0.3s;
}

/* === TOP HEADER UI COMPONENTS === */
.th-btn-icon {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--on-surface-variant);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.th-btn-icon:hover {
  background: var(--row-hover);
  color: var(--on-surface);
}
.th-user-menu {
  position: relative;
}
.th-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.2s;
}
.th-user-avatar:hover {
  box-shadow: 0 0 0 2px var(--primary-container);
}
.th-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  z-index: 50;
  min-width: 200px;
}
.th-dropdown-card {
  background: var(--surface-container-high);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.th-dropdown-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--on-surface);
  margin: 0 0 2px;
}
.th-dropdown-role {
  color: var(--on-surface-variant);
  margin: 0 0 2px;
}
.th-dropdown-rol {
  margin: 0;
}
.th-dropdown-rol-badge {
  color: var(--primary);
}
.th-dropdown-divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 8px 0;
}
.th-btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: transparent;
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.th-btn-logout:hover {
  background: var(--tint-danger);
  color: var(--color-danger);
  border-color: color-mix(in srgb, var(--color-danger) 30%, transparent);
}

/* === OFFLINE BANNER === */
.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  background: #9a6a00;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}
:root:not(.light) .offline-banner { background: #ffaa00; color: #06080c; }

/* ─── Sync Queue Panel ──────────────────────────── */
#sync-queue-panel {
  animation: slide-up 0.2s ease-out;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 5px 1px rgba(255, 170, 0, 0.35); }
  50% { box-shadow: 0 0 8px 2px rgba(255, 170, 0, 0.15); }
}
.top-header-brand {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.top-header-brand-icon {
  color: var(--primary);
  font-size: 16px;
}
.top-header-brand em {
  font-style: normal;
  color: var(--on-surface);
}

/* === NAVIGATION === */
.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  color: var(--on-surface-variant);
  transition: all 0.15s ease;
  position: relative;
}
.nav-link:hover {
  background: var(--row-hover);
  color: var(--primary);
}
.nav-link.active-nav {
  background: var(--color-accent-bg);
  color: var(--primary);
}
.nav-link.active-nav::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-link svg, .nav-link img { width: 24px; height: 24px; }

/* Fix icon size inside sidebar buttons (enlarge without changing button) */
.ph-fix-size {
  font-size: 18px !important;
}

/* === SIDEBAR === */
.sidebar {
  position: fixed;
  left: -280px;
  top: 0;
  bottom: 0;
  width: 220px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--gutter);
  z-index: var(--z-nav-sidebar);
  gap: 4px;
  transition: left 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
}
.sidebar.open {
  left: 0;
}
.sidebar.open ~ .sidebar-overlay {
  display: block;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  flex: 1;
}
.nav-link {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 4px;
}
.nav-label {
  display: inline;
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 600;
  white-space: nowrap;
}
.sidebar-nav-spacer {
  flex: 1;
}
.sidebar-credit-nav {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--on-surface-variant);
  opacity: 0.4;
  text-align: center;
  line-height: 1.4;
  padding: 8px 0;
  width: 100%;
  user-select: none;
  letter-spacing: 0.05em;
}
.sidebar-credit-nav strong {
  color: var(--primary);
  opacity: 0.7;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}
.sidebar-overlay.visible {
  display: block;
}
/* === SIDEBAR BRAND === */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0 12px;
  margin-bottom: 4px;
}
.sidebar-brand-icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 10px;
  position: relative;
}
.sidebar-brand-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px var(--primary)) drop-shadow(0 0 2px var(--primary));
  opacity: 0.92;
}
:root.light .sidebar-brand-img {
  filter: drop-shadow(0 0 5px rgba(0,0,0,0.3)) drop-shadow(0 0 2px rgba(0,0,0,0.15));
}
.sidebar-brand-title {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--on-surface);
  text-align: center;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sidebar-brand-subtitle {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  color: var(--on-surface-variant);
  text-align: center;
  letter-spacing: 0.08em;
  opacity: 0.6;
  margin-bottom: 12px;
}
.sidebar-brand-divider {
  width: 80%;
  height: 1px;
  background: var(--glass-border);
  margin-bottom: 8px;
  align-self: center;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--outline-variant);
  overflow: hidden;
}

/* === SIDEBAR SUB-NAV === */
.nav-group {
  width: 100%;
}
.nav-sub {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding-left: 8px;
  margin-top: 2px;
}
.sidebar.open .nav-sub {
  display: flex;
}
.nav-sub-link {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px 0 28px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--on-surface-variant);
  border-radius: 2px;
  transition: all 0.12s ease;
  text-decoration: none;
  white-space: nowrap;
}
.nav-sub-link:hover {
  color: var(--primary);
  background: var(--row-hover);
}
.nav-sub-link.active {
  color: var(--primary);
  background: var(--color-accent-bg);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  background: var(--color-danger);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: default;
  user-select: none;
}

/* Alert police flash */
.alert-flash {
  background: var(--color-danger) !important;
  border-color: var(--color-danger) !important;
  color: #fff !important;
  animation: alertPulse 1.2s ease-in-out infinite;
}
.alert-flash i,
.alert-flash strong {
  color: #fff !important;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 51, 85, 0.6); }
  50% { box-shadow: 0 0 12px 4px rgba(255, 51, 85, 0.4); }
}

/* Sirena policial del icono de criticidad CRITICO en la grilla de Operaciones */
@keyframes crit-siren-glyph { 0%,100% { color: var(--color-danger); } 50% { color: var(--color-info); } }
.crit-siren-glyph { animation: crit-siren-glyph 0.55s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .crit-siren-glyph { animation: none; } }
.position-relative { position: relative; }

/* === OPS PANEL COLLAPSED === */
#ops-side-panel.ops-collapsed {
  width: 0 !important;
  min-width: 0 !important;
  overflow: visible !important;
  border: none !important;
}
#ops-side-panel.ops-collapsed > :not(.ops-panel-tab) {
  display: none !important;
}
#ops-side-panel.ops-collapsed > .ops-panel-tab {
  display: flex !important;
}
.ops-panel-tab {
  display: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 60px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--color-text-muted);
  cursor: pointer;
  z-index: 25;
  border: 1px solid var(--border-subtle);
  background: var(--surface-container-low);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0;
  margin: 0;
  border-radius: 0 4px 4px 0;
  transition: color 0.15s;
}
.ops-panel-tab:hover {
  color: var(--color-accent);
  background: var(--surface-hover);
}

/* === OPS CANDADOS POPOVER (QUICK OPEN) === */
.ops-candados-pop {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal);
  width: min(460px, calc(100vw - 24px));
  background: var(--surface-container-high);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  padding: 18px;
  animation: opsCandadosIn 0.18s ease-out;
  font-family: var(--font-mono);
}
@keyframes opsCandadosIn {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.ops-candados-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.ops-candados-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.02em;
}
.ops-candados-sub {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ops-candados-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--outline-variant);
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.ops-candados-close:hover {
  background: var(--surface-variant);
  color: var(--color-text);
}
.ops-candados-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.ops-candados-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 2px;
  background: var(--surface-container-low);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.ops-candados-item i {
  font-size: 16px;
  color: var(--color-accent);
  transition: transform 0.12s ease;
}
.ops-candados-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-bright);
  background: var(--surface-hover);
}
.ops-candados-item.is-activo {
  border-color: color-mix(in srgb, var(--color-danger) 40%, transparent);
  color: var(--color-danger);
  background: var(--tint-danger);
}
.ops-candados-item.is-activo i {
  color: var(--color-danger);
}
.ops-candados-item.is-jumping {
  animation: opsCandadoJump 0.36s ease;
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
}
.ops-candados-item.is-jumping i {
  color: var(--color-accent);
}
@keyframes opsCandadoJump {
  0% { transform: translateY(0); }
  25% { transform: translateY(-8px); }
  50% { transform: translateY(0); }
  70% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .ops-candados-pop,
  .ops-candados-item.is-jumping { animation: none; }
}

/* === APP CONTAINER === */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#app-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* === DETAIL SLIDE-OVER PANEL === */
.detail-panel {
  width: var(--panel-right);
  flex-shrink: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-left: 1px solid var(--glass-border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 25;
}

/* El sidebar de detalle de transporte ocupa SIEMPRE el alto completo de pantalla
   (top:0) y se desliza POR ENCIMA del topbar (z-index alto). El scroll va al contenido
   interno (timeline), no al panel. */
#detail-sidebar {
  top: 0;
  right: 0;
  bottom: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-detail-panel);
}
#detail-sidebar::-webkit-scrollbar { display: none; }

/* ── OPERACIONES: detalle como navegación drill-down (dock IZQUIERDO sobre la grilla).
   Scope exclusivo de la vista Operaciones: solo SU #detail-sidebar lleva .detail-dock-left;
   Monitoreo/Containers conservan el slide-over derecho clásico. El ancho lo fija
   OperationsView._applyDetailDock() (mismo ancho exacto de la grilla). */
#detail-sidebar.detail-dock-left {
  left: 0;
  right: auto;
  border-left: 0;
  border-right: 1px solid var(--glass-border);
}
#detail-sidebar.detail-dock-left.is-hidden { transform: translateX(-100%); }
/* Detalle flotante: grilla expandida al 100%, compacta u oculta (full tracking / trace) —
   el detalle no puede heredar un ancho pantalla completa: flota al ancho normal guardado
   con elevación de modal (lo que se despega del plano del mapa). */
#detail-sidebar.detail-dock-left.detail-floating {
  top: 12px;
  bottom: 12px;
  height: auto;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}
/* Botón VOLVER (drill-down): mono uppercase, hairline maquinado. */
.sb-btn-volver {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 2px;
  border: 1px solid var(--outline-variant);
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.sb-btn-volver:hover {
background: var(--row-hover);
border-color: var(--border-bright);
color: var(--on-surface);
}
/* PLACA-BOTÓN del header del detalle: copia la ALERTA DE SALIDA para WhatsApp.
   Mismo look de la placa (18px mono 800); el icono ph-copy se revela con hover. */
.sb-placa-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.sb-placa-copy:hover {
  background: var(--color-accent-bg);
  border-color: color-mix(in srgb, var(--color-accent) 25%, transparent);
}
.sb-placa-copy:active { transform: translateY(1px); }
.sb-placa-copy-icon {
  font-size: 11px;
  color: var(--color-text-muted);
  opacity: 0;
  transform: translateX(-2px);
  transition: all 0.15s ease;
}
.sb-placa-copy:hover .sb-placa-copy-icon {
  opacity: 1;
  transform: translateX(0);
  color: var(--color-accent);
}

/* Menú ACCIONES del header de detalle — dropdown machined + glass del sistema */
.sb-acciones-wrap { position: relative; flex-shrink: 0; margin-left: auto; }
.sb-btn-acciones {
display: inline-flex;
align-items: center;
gap: 6px;
height: 28px;
padding: 0 10px;
border-radius: 2px;
border: 1px solid var(--outline-variant);
background: transparent;
color: var(--color-text);
font-family: var(--font-mono);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
cursor: pointer;
transition: all 0.15s ease;
white-space: nowrap;
}
.sb-btn-acciones:hover { background: var(--row-hover); border-color: var(--border-bright); color: var(--on-surface); }
.sb-acciones-caret { font-size: 10px; color: var(--color-text-muted); transition: transform 0.15s ease; }
.sb-btn-acciones.abierto .sb-acciones-caret { transform: rotate(180deg); }
.sb-acciones-menu {
position: absolute;
top: calc(100% + 6px);
right: 0;
min-width: 200px;
z-index: 60;
background: var(--map-glass);
backdrop-filter: blur(24px);
-webkit-backdrop-filter: blur(24px);
border: 1px solid var(--border-bright);
border-radius: 4px;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
padding: 4px;
display: flex;
flex-direction: column;
}
.sb-accion-item {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
padding: 7px 10px;
background: transparent;
border: none;
border-radius: 2px;
color: var(--on-surface-variant);
font-family: var(--font-mono);
font-size: 11px;
font-weight: 700;
letter-spacing: 0.05em;
cursor: pointer;
text-align: left;
white-space: nowrap;
}
.sb-accion-item i { font-size: 14px; color: var(--color-text-muted); }
.sb-accion-item:hover { background: var(--row-hover); color: var(--on-surface); }
.sb-accion-item:hover i { color: var(--on-surface); }
.sb-accion-item.danger { color: var(--color-danger); }
.sb-accion-item.danger i { color: var(--color-danger); }
.sb-accion-item.danger:hover { background: var(--tint-danger); }
.sb-acciones-sep { height: 1px; background: var(--glass-border); margin: 4px 2px; }

.detail-panel::-webkit-scrollbar { width: 4px; }
.detail-panel::-webkit-scrollbar-track { background: transparent; }
.detail-panel::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 10px;
}
.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gutter);
  border-bottom: 1px solid var(--glass-border);
  gap: 8px;
}
.detail-panel-body {
  padding: var(--gutter);
}

/* === TABLES === */
table { border-collapse: collapse; width: 100%; }
th {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  user-select: none;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-container-low);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 5;
}
td {
  padding: 8px 12px;
  vertical-align: middle;
  font-size: 14px;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-subtle);
  line-height: 20px;
}
tr {
  transition: background 0.12s ease;
}
tr:hover { background: var(--row-hover); }
tr:last-child td { border-bottom: none; }

/* Operaciones - fila seleccionada */
.ops-row-selected {
  background: var(--color-accent-bg) !important;
  border-left: 3px solid var(--primary) !important;
}
.ops-row-selected td:first-child {
  padding-left: 5px;
}

/* === DATA GRID === */
.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}
.data-grid th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-container-low);
  padding: 8px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.data-grid td {
  padding: 6px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--on-surface);
  font-size: 13px;
}
.data-grid tr:hover {
  background: var(--row-hover);
}
.data-grid .row-num {
  width: 32px;
  min-width: 32px;
  text-align: center;
  color: var(--on-surface-variant);
  font-size: 12px;
  opacity: 0.5;
}

/* === MASTERS TABS === */
.masters-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  cursor: pointer;
  border-radius: 2px 2px 0 0;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  margin: 0 2px;
}
.masters-tab:hover {
  color: var(--on-surface);
}
.masters-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.masters-module-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--on-surface-variant);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}
.masters-module-item:hover {
  background: var(--row-hover);
}
.masters-module-item.active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--color-accent-bg);
  font-weight: 600;
}

/* === FORM ELEMENTS === */
input, select, textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  background: var(--surface-container-low);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-radius: 2px;
  padding: 6px 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-container) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-info) 25%, transparent) !important;
  outline: none !important;
}
input::placeholder, textarea::placeholder { color: var(--color-text-dim); }

/* === MAP CONTAINER === */
.map-container {
  background: var(--surface);
  position: relative;
  flex: 1;
  min-height: 0;
}
.map-container::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--primary-container), transparent);
  opacity: 0.5;
}

/* === MAPBOX OVERRIDES === */
.mapboxgl-ctrl-attrib { display: none !important; }
.mapboxgl-ctrl-bottom-right { display: none !important; }
.mapboxgl-popup-content {
  background: var(--color-glass) !important;
  backdrop-filter: blur(var(--glass-blur)) !important;
  color: var(--on-surface) !important;
  font-family: var(--font-mono) !important;
  font-size: 13px !important;
  border: none !important;
  border-radius: 6px !important;
  padding: 4px 8px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.mapboxgl-popup-tip {
  border-top-color: var(--color-glass) !important;
  border-bottom-color: var(--color-glass) !important;
}

/* === TABS === */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-container);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 14px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.tab:hover {
  color: var(--on-surface);
  background: var(--surface-hover);
}
.tab.active {
  background: var(--surface-active);
  color: var(--on-surface);
}

/* === PAGINATION === */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.page-btn:hover {
  background: var(--row-hover);
  color: var(--on-surface);
}
.page-btn.active {
  background: var(--primary-container);
  color: var(--on-primary);
  border-color: var(--primary-container);
}
.page-btn.arrow {
  font-size: 14px;
}

/* === MODAL / DIALOG === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  animation: fadeIn 0.2s ease-out;
}
.modal-card {
  background: var(--surface-container);
  color: var(--on-surface);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 24px;
  min-width: 360px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease-out;
  font-size: 13px;
}
@media (max-width:768px) {
  .modal-card { min-width:100vw; max-width:100vw; width:100vw; max-height:100vh; height:100vh; border-radius:0!important; border:none; margin:0; }
}
.modal-card label,
.modal-card .block {
  font-size: 13px !important;
}
.modal-card input,
.modal-card select,
.modal-card textarea {
  font-size: 14px !important;
}
.modal-card .cliente-option,
.modal-card .switch-btn {
  font-size: 13px !important;
}
.modal-card::-webkit-scrollbar { width: 4px; }
.modal-card::-webkit-scrollbar-track { background: transparent; }
.modal-card::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: 10px;
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.2s ease;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--on-surface);
}
.modal-container {
  background: var(--surface-container);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease-out;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.modal-body {
  flex: 1;
  overflow-y: auto;
}

/* === MAP TOOLTIP — callout de instrumento: cuadrado, borde y ángulos gruesos
   en el COLOR DEL ESTADO (--tt-color, inyectada por el builder del tooltip;
   fallback: border-bright). Lenguaje maquinado — nada de esquinas redondas. */
.um-tooltip {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  padding: 9px 11px;
  border-radius: 0;
  background: rgba(9, 12, 18, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--on-surface);
  border: 1px solid var(--tt-color, var(--border-bright));
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 140px;
  position: relative;
}
/* Ángulos gruesos (2px × 8px) en las 4 esquinas — mismo color del estado */
.um-tooltip::before {
  content: '';
  position: absolute;
  inset: -2px;
  pointer-events: none;
  --brc: var(--tt-color, var(--border-bright));
  background:
    linear-gradient(var(--brc), var(--brc)) left top / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left top / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right top / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right top / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left bottom / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left bottom / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right bottom / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right bottom / 2px 8px no-repeat;
}
.um-tooltip-title {
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 2px;
}
.um-tooltip-row {
  color: var(--on-surface-variant);
  font-size: 11px;
}
.um-tooltip-footer {
  color: var(--outline);
  font-size: 10px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid color-mix(in srgb, var(--tt-color, var(--border-bright)) 45%, transparent);
}
/* Modo light: papel translúcido — el borde y los ángulos siguen al color del estado */
:root:not(.dark) .um-tooltip {
  background: rgba(240, 244, 249, 0.90);
  border-color: var(--tt-color, var(--border-medium));
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.12);
}
:root:not(.dark) .um-tooltip::before {
  --brc: var(--tt-color, var(--border-medium));
}
.mapboxgl-popup-content {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.mapboxgl-popup-tip {
  border-top-color: var(--surface) !important;
  border-bottom-color: var(--surface) !important;
}

/* === TOOLTIP DE MARCADOR (diseño 5 filas) + HUD ANCLADO === */
/* Apilado garantizado: tooltip de marcador SIEMPRE sobre los tooltips de
   geocercas/POIs (ambos son .mapboxgl-popup hermanos — sin z-index el orden
   de apilado sería el orden DOM, no determinista). */
.mapboxgl-popup { z-index: 4; }
.mapboxgl-popup.um-mtt { z-index: 6; }

.umtt {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.35;
  padding: 9px 11px 8px;
  border-radius: 0;
  background: rgba(9, 12, 18, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: var(--on-surface);
  border: 1px solid var(--tt-color, var(--border-bright));
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  min-width: 250px;
  max-width: 320px;
  position: relative;
  cursor: default;
}
/* Ángulos gruesos en las 4 esquinas — mismo color del estado (identidad de
   los tooltips de la plataforma) */
.umtt::before {
  content: '';
  position: absolute;
  inset: -2px;
  pointer-events: none;
  --brc: var(--tt-color, var(--border-bright));
  background:
    linear-gradient(var(--brc), var(--brc)) left top / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left top / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right top / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right top / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left bottom / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) left bottom / 2px 8px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right bottom / 8px 2px no-repeat,
    linear-gradient(var(--brc), var(--brc)) right bottom / 2px 8px no-repeat;
}
/* 1ER ROW: placa (tipografía del HUD velocímetro) + badge estado (grilla) */
.umtt-row { display: flex; align-items: center; }
.umtt-head { justify-content: space-between; gap: 10px; }
.umtt-placa {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--color-text);
  line-height: 1;
  white-space: nowrap;
}
.umtt-badge { font-size: 10px; padding: 1px 7px; white-space: nowrap; flex-shrink: 0; }
/* 2DO ROW: franja HUD velocímetro (velocidad → motor → satélite) */
.umtt-strip {
  margin-top: 7px;
  padding: 6px 9px 5px;
  gap: 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--glass-border);
  justify-content: space-between;
}
.umtt-sep { width: 1px; height: 24px; background: var(--glass-border); flex-shrink: 0; }
.umtt-speed { display: flex; flex-direction: column; min-width: 92px; }
.umtt-speed-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.umtt-speed-val {
  font-size: 27px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  text-shadow: 0 0 10px currentColor;
}
.umtt-speed-lim { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.umtt-speed-limit { font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.umtt-speed-lim::after { content: 'LÍM'; font-size: 7px; text-transform: uppercase; color: var(--color-text-muted); letter-spacing: 0.08em; }
.umtt-speed-unit { font-size: 7px; text-transform: uppercase; color: var(--color-text-muted); letter-spacing: 0.1em; margin-top: 1px; }
.umtt-speed-barwrap { margin-top: 3px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.07); overflow: hidden; }
.umtt-speed-bar { height: 100%; border-radius: 2px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1), background 0.3s ease; box-shadow: 0 0 3px currentColor; }
.umtt-engine { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.umtt-engine i { font-size: 15px; }
.umtt-engine span { font-size: 7px; text-transform: uppercase; color: var(--color-text-muted); letter-spacing: 0.08em; font-weight: 700; }
.umtt-sat { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.umtt-sat-left { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.umtt-sat-left i { font-size: 15px; }
.umtt-sat-left span { font-size: 7px; text-transform: uppercase; color: var(--color-text-muted); letter-spacing: 0.08em; }
.umtt-sat-right { display: flex; align-items: center; gap: 4px; }
.umtt-sat-count { font-size: 11px; font-weight: 700; min-width: 14px; text-align: center; }
.umtt-sat-bar {
  width: 3px; height: 26px; border-radius: 2px;
  background: linear-gradient(to top, #ef4444, #eab308, #22c55e);
  position: relative; overflow: hidden;
}
.umtt-sat-mask {
  position: absolute; top: 0; left: 0; right: 0;
  background: var(--surface);
  border-radius: 2px;
  transition: height 0.5s cubic-bezier(0.4,0,0.2,1);
}
/* 3ER/4TO ROW: coordenadas + dirección */
.umtt-coords, .umtt-addrrow { gap: 6px; margin-top: 6px; align-items: flex-start; }
.umtt-coords i, .umtt-addrrow i { font-size: 12px; color: var(--color-text-muted); margin-top: 1px; }
.umtt-mono { font-size: 11px; color: var(--on-surface-variant); letter-spacing: 0.02em; }
/* Coordenadas clicables → Google Maps: mismo look mono (sin subrayado de link),
   hover a acento + icono de link externo resaltado como affordance */
a.umtt-coords-link { text-decoration: none; color: inherit; }
a.umtt-coords-link:hover, a.umtt-coords-link:hover .umtt-mono { color: var(--color-accent); }
a.umtt-coords-link:hover i { color: var(--color-accent); }
.umtt-coords-ext { font-size: 10px; margin-left: 4px; opacity: 0.65; }
a.umtt-coords-link:hover .umtt-coords-ext { opacity: 1; }
.umtt-addr { font-size: 11px; color: var(--on-surface-variant); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.umtt-addr i { font-size: 10px; margin-right: 2px; }
.umtt-addr-loading { color: var(--color-text-muted); }
.umtt-addr-loading i { animation: umtt-spin 1s linear infinite; display: inline-block; }
@keyframes umtt-spin { to { transform: rotate(360deg); } }
/* Divisoria tenue en función al color del estado */
.umtt-divider {
  height: 1px;
  margin: 7px 0 6px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--tt-color, var(--border-bright)) 45%, transparent), transparent);
}
/* 5TO ROW: última actualización │ fuente │ anclar + copiar */
.umtt-foot { gap: 6px; flex-wrap: wrap; }
.umtt-uptd { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; color: var(--color-text-muted); white-space: nowrap; }
.umtt-uptd i, .umtt-source i { font-size: 10px; }
.umtt-vsep { width: 1px; height: 12px; background: var(--glass-border); flex-shrink: 0; }
.umtt-source { display: inline-flex; align-items: center; gap: 4px; font-size: 9px; font-weight: 700; color: var(--on-surface-variant); white-space: nowrap; }
.umtt-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; }
.umtt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 21px; height: 21px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.umtt-btn i { font-size: 12px; }
.umtt-btn:hover { background: var(--color-accent-bg); color: var(--color-accent); border-color: color-mix(in srgb, var(--color-accent) 30%, transparent); }
/* Toggle ANCLAR presionado (y X de desanclar del panel) */
.umtt-btn-active {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.35);
}
.umtt-btn-active:active { transform: translateY(1px); }

/* Modo light: papel translúcido del tema (blanco humo #f0f4f9) */
:root:not(.dark) .umtt {
  background: rgba(240, 244, 249, 0.90);
  border-color: var(--tt-color, var(--border-medium));
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.12);
}
:root:not(.dark) .umtt::before { --brc: var(--tt-color, var(--border-medium)); }
:root:not(.dark) .umtt-strip { background: rgba(16, 24, 40, 0.04); }
:root:not(.dark) .umtt-speed-barwrap { background: rgba(16, 24, 40, 0.08); }

/* HUD ANCLADO (Operaciones): el velocímetro con el diseño del tooltip, pegado
   arriba a la izquierda de la barra vertical de botones. Solo visible por pineo. */
#ops-hud-anchor {
  position: absolute;
  z-index: 15;
  width: 310px;
  cursor: pointer;
}
#ops-hud-anchor .umtt { min-width: 0; max-width: none; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }

/* Toast de copiado (botón COPIAR del tooltip/panel) */
.umtt-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 3000000;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-success);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid color-mix(in srgb, var(--color-success) 35%, transparent);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  animation: umtt-toast-in 0.18s ease;
  pointer-events: none;
}
@keyframes umtt-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === COMPACT VIEW === */
.ops-compact-row:hover {
  background: var(--surface-hover) !important;
}
.ops-compact-row:active {
  background: var(--surface-active) !important;
}

/* === MONITOREO VIEW === */
.mv-row:hover {
  background: var(--surface-hover) !important;
}

/* === SUBTLE DIVIDER === */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-border), transparent);
  margin: var(--gutter) 0;
}

/* === GLOW EFFECTS === */
.glow-accent {
  box-shadow: 0 0 20px var(--color-accent-glow);
}
.glow-text {
  text-shadow: 0 0 20px var(--color-accent-glow);
}

/* === STATUS DOTS === */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot.active { background: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.status-dot.inactive { background: var(--outline); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.danger { background: var(--color-danger); box-shadow: 0 0 6px var(--color-danger); }
.status-dot.info { background: var(--color-info); box-shadow: 0 0 6px var(--color-info); }

/* === STATS / METRIC CARDS (Legacy/Extended) === */
/* Keep for backwards compat with existing components */
.stat-card-legacy {
  background: var(--surface-container-low);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px 16px;
  transition: all 0.15s ease;
}
.stat-card-legacy:hover {
  border-color: var(--border-bright);
}

/* === ANIMATIONS === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeIn 0.3s ease-out; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-slide-up { animation: slideUp 0.4s ease-out; }

@keyframes pulse-dot {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}
.animate-pulse-dot { animation: pulse-dot 2s ease-in-out infinite; }

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}
.shimmer {
  background: linear-gradient(90deg, var(--surface-container-low) 25%, var(--surface-container) 50%, var(--surface-container-low) 75%);
  background-size: 200px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

/* === SPLASH LOADING ANIMATION === */
@keyframes splashSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes splashDot {
  0%, 75% { opacity: 0.2; }
  25% { opacity: 1; }
}
@keyframes splashScan {
  0% { left: -50%; width: 50%; }
  50% { width: 80%; }
  100% { left: 100%; width: 50%; }
}
#app-splash.splash-hidden {
  opacity: 0;
  pointer-events: none;
}
.splash-shield {
  background: var(--color-accent-bg);
  border: 1px solid var(--color-accent-glow);
  animation: splashPulse 2s ease-in-out infinite;
}
@keyframes splashPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--color-accent-bg); }
  50% { box-shadow: 0 0 12px 2px var(--color-accent-glow); }
}

/* === LOADING BAR === */
#app-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--primary);
  z-index: 9999;
  display: none;
}
#app-loader::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  animation: loaderShimmer 1.5s ease-in-out infinite;
}
@keyframes loaderShimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.animate-slide-in-right { animation: slideInRight 0.3s ease-out; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
  #detail-sidebar, #geo-sidebar, .detail-panel { width: 100% !important; max-width: 100% !important; }
}
@media (max-width: 768px) {
  body { overflow: auto !important; }
  #geo-counters { display: none; }
  .table-responsive { overflow-x: auto; }
  .top-header { height: 44px; padding: 0 12px; }
  .top-header-center { display: none; }
}

/* === MAPBOX DARK CONTROLS === */
.mapboxgl-ctrl-group {
  background: rgba(9,12,18,0.88) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(63,85,117,0.55) !important;
  border-radius: 4px !important;
  overflow: hidden;
  box-shadow: none !important;
}
.mapboxgl-ctrl-group button {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  width: 30px !important;
  height: 30px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.mapboxgl-ctrl-group button+button {
  border-top: 1px solid rgba(63,85,117,0.35) !important;
}
.mapboxgl-ctrl-group button:hover {
  background: rgba(255,255,255,0.06) !important;
}
.mapboxgl-ctrl-group button span {
  filter: brightness(0) invert(0.75) !important;
}
.mapboxgl-ctrl-group button:hover span {
  filter: brightness(0) invert(1) !important;
}
.mapboxgl-ctrl-group .mapboxgl-ctrl-icon {
  background-size: 16px !important;
}
.mapboxgl-ctrl-compass {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.mapboxgl-ctrl-compass .mapboxgl-ctrl-icon {
  filter: brightness(0) invert(0.75) !important;
}
.mapboxgl-ctrl-compass:hover .mapboxgl-ctrl-icon {
  filter: brightness(0) invert(1) !important;
}

/* Light mode map controls for masters geo-modal (NavigationControl) */
:root:not(.dark) .mapboxgl-ctrl-group {
  background: rgba(240, 244, 249, 0.92) !important;
  border-color: rgba(16,24,40,0.14) !important;
}
:root:not(.dark) .mapboxgl-ctrl-group button {
  border-color: rgba(16,24,40,0.08) !important;
}
:root:not(.dark) .mapboxgl-ctrl-group button span {
  filter: brightness(0.3) !important;
}

/* Custom floating map controls */
.custom-map-controls {
  pointer-events: none;
}
.custom-map-controls button {
  font-family: var(--font-mono);
}

/* === FULL TRACKING PANEL TRANSITIONS === */
#ops-side-panel {
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* (El HUD velocímetro legado #ops-hud-* fue reemplazado por el HUD anclado
   #ops-hud-anchor — ver estilos .umtt arriba) */

/* === SSE SHIELD GLOW === */
@keyframes sse-glow {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(249,115,22,0.4)); }
  50% { filter: drop-shadow(0 0 10px rgba(249,115,22,0.8)); }
}

/* === DPW TAB HEARTBEAT (pestaña PUERTO con cambio de evaluación de cita) === */
/* Latido ámbar en el contorno del tab: avisa al operador que hay un cambio nuevo
   en el puerto; se apaga al abrir la pestaña (Sidebar.setTab('puerto')). Las
   animaciones CSS prevalecen sobre el borderColor inline que setTab aplica, así el
   latido es visible aunque la pestaña esté activa o inactiva. */
@keyframes dpwTabPulse {
  0%, 100% {
    border-color: rgba(255, 170, 0, 0.25);
    color: var(--color-text-muted);
    text-shadow: none;
    box-shadow: none;
  }
  50% {
    border-color: var(--color-idle);
    color: var(--color-idle);
    text-shadow: 0 0 8px rgba(255, 170, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 170, 0, 0.35);
  }
}
.dpw-tab-alert {
  animation: dpwTabPulse 1.6s ease-in-out infinite;
}

/* === CHECKBOX CUSTOM === */
.custom-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--outline);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.custom-checkbox:hover {
  border-color: var(--primary);
}

.custom-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.custom-checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--surface);
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
}

.custom-checkbox:focus {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-info) 35%, transparent);
}

/* === ALERTS CENTER === */
.alert-filter {
  padding: 3px 8px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.12s ease;
}
.alert-filter:hover { background: var(--surface-hover); color: var(--on-surface); }
.alert-filter.active { background: var(--color-accent); color: var(--on-primary); border-color: var(--color-accent); }

.alert-card {
  padding: 6px 10px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--surface-container-high);
  transition: all 0.12s ease;
}
.alert-card:hover { background: var(--surface-hover); border-color: var(--border-medium); }
.alert-card-selected { border-color: var(--border-bright); background: var(--surface-active); }
.alert-card-urgent { border-color: color-mix(in srgb, var(--color-danger) 45%, transparent); background: var(--tint-danger); animation: alert-pulse 2s ease-in-out infinite; }
.alert-card-focused { outline: 2px solid var(--color-info); outline-offset: 1px; }
@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 51, 85, 0.25); }
  50% { box-shadow: 0 0 8px 2px rgba(255, 51, 85, 0.12); }
}

.alert-take-control {
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: var(--on-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.alert-take-control:hover {
  background: var(--color-accent-bright, var(--color-accent));
  box-shadow: 0 0 6px var(--color-accent-glow);
}

/* Intervention panel tabs */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--glass-border);
  background: var(--surface-container);
  padding: 0 12px;
  flex-shrink: 0;
}
.tab-btn {
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}
.tab-btn:hover { color: var(--on-surface); background: var(--surface-container-high); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); }

.tab-content { overflow-y: auto; }
.tab-content.hidden { display: none; }
.tab-inner { padding: 10px 12px; }

.intervention-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--surface-container);
  flex-shrink: 0;
}

.sticky-resolver {
  position: sticky;
  bottom: 0;
  background: var(--surface-container-low);
  padding-top: 8px;
  border-top: 1px solid var(--glass-border);
}

/* Export button */
.export-btn {
  padding: 3px 10px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  transition: all 0.15s ease;
}
.export-btn:hover { background: var(--color-accent); color: #fff; }

/* Sidebar Alert Attention */
.alert-attention-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--surface-container);
  flex-shrink: 0;
}
.alert-attention-map {
  padding: 8px 12px;
  flex-shrink: 0;
  background: var(--surface-container-low);
  border-bottom: 1px solid var(--glass-border);
}
.alert-attention-resolver {
  padding: 10px 12px;
  border-top: 1px solid var(--glass-border);
  background: var(--surface-container-low);
  flex-shrink: 0;
}
.protocol-step-completed span {
  color: var(--color-success);
  font-weight: 600;
}
.protocol-step-completed input {
  accent-color: var(--color-success);
}

/* === MONITOREO MOBILE === */
@media (max-width: 820px) {
  #mv-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 138px;
    min-height: 138px;
    border-radius: 12px 12px 0 0 !important;
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 20 !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
  }
  #mv-panel.expanded {
    max-height: 50vh;
  }
  #mv-panel #mv-list {
    max-height: calc(50vh - 100px);
  }
  #mv-panel:not(.expanded) #mv-search-wrap {
    display: none !important;
  }
  #mv-hud {
    top: 8px !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translateX(-50%) !important;
  }
}

/* === OPERACIONES MOBILE === */
@media (max-width: 820px) {
  #ops-side-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 140px;
    min-height: 100px;
    border-radius: 12px 12px 0 0 !important;
    transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 20 !important;
    border: 1px solid var(--glass-border) !important;
    border-bottom: none !important;
  }
  #ops-side-panel.ops-expanded {
    max-height: 50vh;
  }
  #ops-panel-resizer {
    display: none !important;
  }
  #ops-side-panel .pagination,
  #ops-side-panel #ops-pagination-info {
    display: none !important;
  }
  #ops-actions-normal {
    flex-wrap: wrap;
  }
}

