/* POP Command — territorial, móvil primero, marca blanca */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&display=swap');

:root {
  --ink: #12263A;
  --ink-soft: #1E3A4F;
  --teal: #0E7C7B;
  --teal-2: #14919B;
  --signal: #E07A3D;
  --paper: #EEF1F4;
  --sheet: #FFFFFF;
  --mist: #5A6B7A;
  --line: #D5DCE3;
  --ok: #1B7F5A;
  --danger: #C44536;
  --primario: var(--teal);
  --primario-2: var(--ink);
  --acento: var(--signal);
  --fondo: var(--paper);
  --lienzo: var(--sheet);
  --tinta: var(--ink);
  --humo: var(--mist);
  --borde: var(--line);
  --radio: 16px;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Outfit', system-ui, sans-serif;
  --display: 'Source Serif 4', Georgia, serif;
  font-family: var(--font);
  color: var(--tinta);
  background: var(--fondo);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--fondo);
  background-image:
    linear-gradient(180deg, rgba(18,38,58,.04), transparent 28%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0 L60 30 L30 60 L0 30 Z' fill='none' stroke='%2312263A' stroke-opacity='.04' stroke-width='1'/%3E%3C/svg%3E");
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  -webkit-font-smoothing: antialiased;
}

h1, h2, .marca-titulo {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.oculto { display: none !important; }

/* ——— LOGIN ——— */
#vista-login {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.login-stage {
  position: relative;
  min-height: 46dvh;
  padding: 28px 22px 36px;
  background:
    linear-gradient(160deg, var(--ink) 0%, var(--ink-soft) 48%, #0A4F50 100%);
  color: #F4F7FA;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  isolation: isolate;
}
.login-stage::before {
  content: '';
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 85% 15%, rgba(14,124,123,.45), transparent 55%),
    radial-gradient(ellipse 50% 40% at 10% 80%, rgba(224,122,61,.25), transparent 50%);
  animation: pulso 8s ease-in-out infinite alternate;
}
.login-stage::after {
  content: '';
  position: absolute; inset: 0; z-index: 0; opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 40h80M40 0v80' stroke='%23fff' stroke-opacity='.08'/%3E%3Ccircle cx='40' cy='40' r='18' fill='none' stroke='%23fff' stroke-opacity='.1'/%3E%3C/svg%3E");
}
.login-stage > * { position: relative; z-index: 1; }
.brand-mark {
  display: inline-flex; align-items: center; gap: 10px;
  margin-bottom: 22px;
  animation: subir .6s cubic-bezier(.22,1,.36,1) both;
}
.brand-mark .orb {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(145deg, var(--teal-2), var(--teal));
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 15px;
  box-shadow: 0 12px 28px rgba(0,0,0,.25);
}
.brand-mark span {
  font-size: 12px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; opacity: .72;
}
.login-stage h1 {
  color: #fff; font-size: clamp(2.4rem, 9vw, 3.1rem);
  line-height: 1; margin: 0 0 12px;
  animation: subir .65s .05s cubic-bezier(.22,1,.36,1) both;
}
.login-stage .tagline {
  margin: 0; max-width: 28ch; font-size: 15px; line-height: 1.45;
  color: rgba(244,247,250,.78); font-weight: 450;
  animation: subir .65s .1s cubic-bezier(.22,1,.36,1) both;
}
.login-panel {
  margin: -28px 16px 28px;
  padding: 22px 20px 20px;
  background: var(--sheet);
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(18,38,58,.12);
  animation: subir .7s .12s cubic-bezier(.22,1,.36,1) both;
  position: relative; z-index: 2;
}
.cred-box {
  background: rgba(14,124,123,.07);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.45;
}
.cred-box strong { display: block; color: var(--ink); margin-bottom: 6px; font-size: 13px; }
.cred-line { color: var(--mist); font-size: 12px; margin-top: 2px; }
.cred-box code {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink);
  background: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ——— FORMS ——— */
label {
  display: block; font-size: 11px; font-weight: 650;
  color: var(--mist); margin: 14px 0 6px;
  text-transform: uppercase; letter-spacing: .06em;
}
label:first-of-type { margin-top: 0; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; font-weight: 500;
  padding: 13px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #F8FAFB; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal); background: #fff;
  box-shadow: 0 0 0 4px rgba(14,124,123,.14);
}
textarea { resize: vertical; min-height: 88px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; font: inherit; font-weight: 700; font-size: 15px;
  padding: 14px 16px; border-radius: 12px; border: none; cursor: pointer;
  margin-top: 16px; transition: transform .12s, filter .12s, background .15s;
}
.btn:active { transform: scale(.985); }
.btn-primario { background: var(--ink); color: #fff; }
.btn-primario:hover { filter: brightness(1.08); }
.btn-acento { background: var(--signal); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-suave {
  background: transparent; border: 1.5px solid var(--line);
  color: var(--ink); margin-top: 10px;
}
.btn-mini {
  width: auto; padding: 8px 12px; font-size: 12px; margin: 0;
  border-radius: 10px;
}
.msg { margin-top: 12px; font-size: 13px; color: var(--danger); min-height: 1.2em; font-weight: 500; }
.msg.ok { color: var(--ok); }

.check-row {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 14px; padding: 12px 14px;
  background: rgba(14,124,123,.06); border-radius: 12px; border: 1px solid var(--line);
}
.check-row input { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--teal); }
.check-row label {
  margin: 0; text-transform: none; letter-spacing: 0;
  font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1.4; cursor: pointer;
}
.check-row a { color: var(--teal); font-weight: 650; }

/* ——— APP SHELL ——— */
#app-shell { max-width: 560px; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(213,220,227,.65);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .orb {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--teal-2), var(--ink));
  color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-size: 11px; font-weight: 700;
}
.topbar .brand strong {
  font-family: var(--display); font-size: 1.05rem;
  display: block; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .brand span { font-size: 11px; color: var(--mist); font-weight: 500; }
.chips { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.chip {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 5px 9px; border-radius: 8px; text-transform: uppercase;
  background: rgba(14,124,123,.12); color: var(--teal);
}
.chip.warn { background: #F8E8D8; color: #9A4E18; }
.chip.danger { background: #F8E0DC; color: var(--danger); }

.contenido { padding: 14px 16px 28px; }
.vista-head { margin-bottom: 16px; animation: subir .4s ease both; }
.vista-head h2 { font-size: 1.55rem; margin: 0 0 6px; }
.vista-head .lead { margin: 0; color: var(--mist); font-size: 14px; line-height: 1.45; }

.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  padding: 16px;
  margin-bottom: 12px;
  animation: subir .45s ease both;
}
.panel-ink {
  background: linear-gradient(145deg, var(--ink), var(--ink-soft));
  color: #fff; border: none;
}
.panel-ink .label { font-size: 12px; opacity: .75; font-weight: 500; }
.panel-ink .big {
  font-family: var(--display); font-size: 1.7rem; margin-top: 4px;
}
.barra {
  height: 7px; background: rgba(255,255,255,.18);
  border-radius: 99px; margin-top: 14px; overflow: hidden;
}
.barra i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--signal), #F0B27A);
  border-radius: 99px; transition: width .5s cubic-bezier(.22,1,.36,1);
}

.kpis {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px;
}
.kpi {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 14px 12px;
  animation: subir .4s ease both;
}
.kpi .n {
  font-family: var(--display); font-size: 1.85rem; line-height: 1;
  color: var(--ink); font-feature-settings: 'tnum';
}
.kpi .t { font-size: 11px; color: var(--mist); margin-top: 6px; font-weight: 600; letter-spacing: .02em; }

.sec-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--mist); margin: 18px 0 10px;
}

.lista { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 14px; padding: 13px 14px;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  transition: border-color .15s, transform .12s;
}
.item:active { transform: scale(.99); }
.item .tit { font-weight: 650; font-size: 14px; color: var(--ink); }
.item .sub { font-size: 12px; color: var(--mist); margin-top: 3px; line-height: 1.35; }
.item .badge {
  font-size: 13px; font-weight: 800; color: var(--teal);
  font-variant-numeric: tabular-nums; min-width: 2.2rem; text-align: right;
}
.item.alerta-alta { border-left: 3px solid var(--danger); }
.item.alerta-media { border-left: 3px solid var(--signal); }

.modulos-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.mod-card {
  background: var(--sheet); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 14px; text-align: left;
  cursor: pointer; font: inherit; color: inherit;
  transition: transform .14s, border-color .14s, box-shadow .14s;
  animation: subir .4s ease both;
}
.mod-card:nth-child(2) { animation-delay: .04s; }
.mod-card:nth-child(3) { animation-delay: .08s; }
.mod-card:nth-child(4) { animation-delay: .12s; }
.mod-card:hover { border-color: color-mix(in srgb, var(--teal) 40%, var(--line)); }
.mod-card:active { transform: scale(.97); }
.mod-card .ico {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(145deg, rgba(14,124,123,.14), rgba(18,38,58,.06));
  display: grid; place-items: center; margin-bottom: 12px;
  font-size: 17px;
}
.mod-card strong { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.mod-card span { font-size: 12px; color: var(--mist); line-height: 1.35; display: block; margin-top: 4px; }
.mod-card.locked { opacity: .48; filter: grayscale(.3); }
.mod-card.locked::after {
  content: 'Switch requerido';
  display: block; font-size: 10px; font-weight: 750;
  color: var(--danger); margin-top: 10px;
  text-transform: uppercase; letter-spacing: .05em;
}

#map-gis {
  height: 280px; border-radius: 14px; border: 1px solid var(--line);
  overflow: hidden; background: #DDE5EC; margin-bottom: 12px;
  z-index: 1;
}

/* Bottom dock */
.nav-inf {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 0 12px calc(10px + var(--safe-b));
  pointer-events: none;
}
.nav-inf .dock {
  pointer-events: auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
  width: min(520px, 100%);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(18px) saturate(1.3);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(18,38,58,.14);
  overflow: hidden;
}
.nav-inf button {
  appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 10px; font-weight: 650;
  color: var(--mist); padding: 11px 2px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: color .15s;
}
.nav-inf button .ni {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-inf button.activo { color: var(--ink); }
.nav-inf button.activo .ni {
  background: rgba(14,124,123,.14); color: var(--teal);
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 28px + var(--safe-b));
  transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 650;
  opacity: 0; pointer-events: none; transition: .28s cubic-bezier(.22,1,.36,1);
  z-index: 50; max-width: 90vw;
  box-shadow: 0 12px 32px rgba(18,38,58,.28);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-fondo {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(18,38,58,.5); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.modal {
  background: var(--sheet); border-radius: 20px;
  padding: 22px; max-width: 480px; width: 100%;
  max-height: 80vh; overflow: auto;
  animation: subir .3s ease both;
}

.delta-pos { color: var(--ok); font-weight: 700; }
.delta-neg { color: var(--danger); font-weight: 700; }

@keyframes subir {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulso {
  from { opacity: .85; }
  to { opacity: 1; }
}

@media (min-width: 768px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .modulos-grid { grid-template-columns: repeat(3, 1fr); }
  #map-gis { height: 360px; }
}

/* Master overrides */
.master-body { padding-bottom: 24px; }
.master-layout { max-width: 1120px; margin: 0 auto; padding: 20px 16px 40px; }
.master-hero {
  background: linear-gradient(135deg, var(--ink), #0A4F50);
  color: #fff; border-radius: 20px; padding: 28px 24px;
  margin-bottom: 20px; position: relative; overflow: hidden;
}
.master-hero::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(14,124,123,.35);
}
.master-hero h1 { color: #fff; margin: 0 0 6px; font-size: 1.8rem; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th {
  text-align: left; font-size: 10px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--mist); padding: 10px 8px;
  border-bottom: 1px solid var(--line); font-weight: 700;
}
.tabla td { padding: 12px 8px; border-bottom: 1px solid #E8EEF2; vertical-align: middle; }
.acciones { display: flex; flex-wrap: wrap; gap: 6px; }
.modo-civ { color: var(--ok); font-weight: 750; font-size: 11px; letter-spacing: .04em; }
.modo-ele { color: var(--danger); font-weight: 750; font-size: 11px; letter-spacing: .04em; }
