:root {
  --navy: #0D1B2A;
  --navy-light: #162A40;
  --cyan: #00C9D4;
  --cyan-soft: rgba(0, 201, 212, 0.14);
  --bg: #F7F9FA;
  --card: #FFFFFF;
  --ink: #0D1B2A;
  --muted: #5A6B75;
  --line: #E1E7EA;
  --brand: #0E6B7A;
  --brand-hover: #0B5561;
  --ok: #2E9E5B;
  --ok-bg: rgba(46, 158, 91, 0.12);
  --warn: #D97706;
  --warn-bg: rgba(230, 126, 34, 0.14);
  --bad: #C0392B;
  --bad-bg: rgba(192, 57, 43, 0.12);
  --info: #3B82C4;
  --shadow-sm: 0 1px 3px rgba(13, 27, 42, 0.06), 0 1px 2px rgba(13, 27, 42, 0.04);
  --shadow-md: 0 6px 18px -4px rgba(13, 27, 42, 0.08), 0 2px 6px -1px rgba(13, 27, 42, 0.04);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B131E;
    --card: #132030;
    --ink: #ECF2F6;
    --muted: #94A6B4;
    --line: #233549;
    --brand: #1793A6;
    --brand-hover: #00C9D4;
    --ok: #4ADE80;
    --ok-bg: rgba(74, 222, 128, 0.14);
    --warn: #FBBF24;
    --warn-bg: rgba(251, 191, 36, 0.15);
    --bad: #F87171;
    --bad-bg: rgba(248, 113, 113, 0.15);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.38);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ---------------- Tipografía y Marca ---------------- */
h1, h2, h3 {
  font-family: "Manrope", "Inter", system-ui, sans-serif;
  letter-spacing: -0.015em;
  color: var(--ink);
}
h1 { font-size: 22px; font-weight: 700; margin: 0 0 6px; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, var(--cyan), var(--brand));
  border-radius: 3px;
  flex-shrink: 0;
}
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--ink); }

.brand-logo {
  font-family: "Manrope", sans-serif;
  font-size: 18px;
  letter-spacing: 0.03em;
  line-height: 1;
  user-select: none;
  display: inline-flex;
  align-items: center;
}
.brand-tecno {
  font-weight: 400;
  color: var(--cyan);
}
.brand-prevenir {
  font-weight: 800;
  color: #FFFFFF;
}

/* ---------------- Header & Navegación Navy ---------------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  background: linear-gradient(135deg, #0D1B2A 0%, #14283D 100%);
  color: #FFFFFF;
  border-bottom: 2px solid rgba(0, 201, 212, 0.35);
  box-shadow: 0 4px 16px rgba(13, 27, 42, 0.18);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 4px;
}
.brand-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.18);
}
.brand-project {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-project strong {
  font-size: 12.5px;
  font-weight: 700;
  color: #FFFFFF;
}
.header-sub {
  font-size: 10.5px;
  color: #9FB3C8;
}

nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  flex: 1;
  align-items: center;
}
nav button {
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 6px;
  color: #D9E2EC;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  margin: 0;
  transition: all 0.18s ease;
}
nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
  border-color: rgba(0, 201, 212, 0.25);
}
nav button.on {
  background: var(--brand);
  color: #FFFFFF;
  font-weight: 600;
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(0, 201, 212, 0.3), 0 2px 8px rgba(0, 201, 212, 0.2);
}

.user {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}
.user-pill {
  font-size: 12.5px;
  font-weight: 500;
  color: #E2E8F0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: 999px;
}
.btn-salir {
  background: rgba(192, 57, 43, 0.22);
  color: #FCA5A5;
  border: 1px solid rgba(248, 113, 113, 0.35);
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  margin: 0;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn-salir:hover {
  background: var(--bad);
  color: #FFFFFF;
}

/* ---------------- Contenedor Principal y Tarjetas ---------------- */
main {
  padding: 12px 16px 24px;
  max-width: 1440px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* ---------------- Login Corporativo ---------------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at 15% 20%, rgba(14, 107, 122, 0.35) 0%, transparent 45%),
              radial-gradient(circle at 85% 80%, rgba(0, 201, 212, 0.2) 0%, transparent 45%),
              linear-gradient(135deg, #09131E 0%, #0D1B2A 60%, #132A3E 100%);
}
.login .login-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  border-top: 4px solid var(--cyan);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.login-brand {
  font-size: 24px;
  margin-bottom: 8px;
  background: #0D1B2A;
  padding: 8px 14px;
  border-radius: 8px;
  display: inline-flex;
}
.brand-badge {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin-bottom: 10px;
}
.btn-login {
  width: 100%;
  padding: 11px 16px;
  font-size: 14.5px;
  font-weight: 600;
  margin-top: 18px;
}
.login-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  text-align: center;
}

/* ---------------- Textos y Estados ---------------- */
.muted { color: var(--muted); }
.error { color: var(--bad); font-weight: 500; }

p.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-left: 4px solid var(--warn);
  padding: 10px 14px;
  border-radius: 6px;
  font-weight: 500;
  margin: 10px 0;
}

/* ---------------- Formularios y Botones ---------------- */
label {
  display: block;
  margin: 10px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  margin-top: 4px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(0, 201, 212, 0.2);
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  vertical-align: middle;
  margin-right: 6px;
  cursor: pointer;
}

button {
  background: var(--brand);
  color: #FFFFFF;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 15px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  margin-top: 12px;
  transition: all 0.16s ease;
  box-shadow: 0 1px 2px rgba(13, 27, 42, 0.1);
}
button:hover {
  background: var(--brand-hover);
  box-shadow: 0 3px 8px rgba(14, 107, 122, 0.25);
  transform: translateY(-1px);
}
button:active {
  transform: translateY(0);
}
button.sec {
  background: var(--card);
  color: var(--brand);
  border: 1px solid var(--brand);
  box-shadow: none;
}
button.sec:hover {
  background: rgba(14, 107, 122, 0.08);
  border-color: var(--cyan);
}
button.link {
  background: none;
  color: var(--brand);
  border: 0;
  box-shadow: none;
  margin: 0;
  padding: 2px 4px;
  font-weight: 600;
}
button.link:hover {
  color: var(--cyan);
  text-decoration: underline;
  transform: none;
}
button.link.del, button.link.bd, button.link.bor {
  color: var(--bad);
}
button.small {
  padding: 5px 11px;
  margin: 0;
  font-size: 12.5px;
  border-radius: 6px;
}

/* ---------------- Tablas con Números Tabulares ---------------- */
.scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--line);
}
tbody tr:hover {
  background: rgba(14, 107, 122, 0.035);
}
tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------------- Tarjetas KPI ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.kpi b {
  display: block;
  font-family: "Manrope", sans-serif;
  font-size: 28px;
  font-weight: 800;
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi b.bad {
  color: var(--bad);
}

/* ---------------- Etiquetas / Badges ---------------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--bg);
}
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.tag.ok { background: var(--ok-bg); border-color: rgba(46, 158, 91, 0.3); color: var(--ok); }
.tag.warn { background: var(--warn-bg); border-color: rgba(230, 126, 34, 0.35); color: var(--warn); }
.tag.bad { background: var(--bad-bg); border-color: rgba(192, 57, 43, 0.3); color: var(--bad); }

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 180px;
}

/* ---------------- Visor Geográfico 3D / 2D ---------------- */
.card-map {
  padding: 12px 16px;
  margin-bottom: 6px;
}
.map-header-compact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.map-controls-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.map-badge-3d {
  background: linear-gradient(135deg, #0D1B2A, #0E6B7A);
  color: var(--cyan);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 5px;
  letter-spacing: 0.04em;
}
.map-body {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 10px;
  align-items: stretch;
}
.map-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: calc(100vh - 185px);
  min-height: 440px;
  max-height: 780px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}
.map-side-section {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.map-side-title {
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--cyan);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.layers {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
}
.layers label {
  display: flex;
  align-items: flex-start;
  margin: 0;
  font-size: 11.8px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.3;
}
.layers input[type="checkbox"] {
  margin-top: 1px;
  flex-shrink: 0;
}
.map-wrap {
  position: relative;
}
#map {
  height: calc(100vh - 185px);
  min-height: 440px;
  max-height: 780px;
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 11.5px;
}
.map-legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  line-height: 1.3;
}
@media (max-width: 1050px) {
  .map-body {
    grid-template-columns: 1fr;
  }
  .map-sidebar {
    height: auto;
    max-height: none;
  }
}
.map-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.map-coords {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
}
.maplibregl-popup-content {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #0D1B2A;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(13, 27, 42, 0.22);
  border-left: 4px solid #0E6B7A;
}

/* ---------------- Galería y Barras de Progreso ---------------- */
.gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.gal .it {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gal .it:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.gal img {
  width: 100%;
  height: 185px;
  object-fit: contain;
  background: #FFFFFF;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 6px;
  cursor: zoom-in;
}

.bar {
  height: 9px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--ok));
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------------- Responsivo ---------------- */
@media (max-width: 1000px) {
  header {
    gap: 8px;
    position: static;
    padding: 10px 14px;
  }
  nav {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  nav button {
    white-space: nowrap;
  }
  th, td {
    padding: 7px 6px;
  }
}

td input:not([type="checkbox"]) {
  min-width: 86px;
}

nav {
  scrollbar-width: thin;
}
