/* ==========================================================
   FORMOSA SMART LIGHTING - Estilo NEUMORFISMO OSCURO AZUL
   Tonos azul marino predominantes
   ========================================================== */
:root {
  --bg: #0f1a2e;
  --bg-grad-1: rgba(126, 166, 255, 0.1);
  --bg-grad-2: rgba(46, 78, 146, 0.14);
  --shadow-dark: #080d17;
  --shadow-light: #1b2943;
  --text: #e6eefc;
  --muted: #8d9bb4;
  --blue: #7aa6ff;
  --azure: #c9d8ff;
  --navy: #2b4e9e;
  --lila: #a5adff;
  --accent: #7aa6ff;
  --accent-soft: rgba(122, 166, 255, 0.14);
  --ok: #6fbfa0;
  --off: #7f8796;
  --fail: #e07676;
  --warn: #e0a24e;
  --radius: 24px;
  --font: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-brand: "Orbitron", "Poppins", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 800px at 85% -10%, var(--bg-grad-1), transparent 55%),
    radial-gradient(1000px 700px at 0% 110%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Neumorfismo: superficies ---------- */
.neu-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
}
.neu-inset {
  background: var(--bg);
  border-radius: 14px;
  box-shadow: inset 5px 5px 10px var(--shadow-dark), inset -5px -5px 10px var(--shadow-light);
}

/* ---------- Texto con degradado azul → azul marino ---------- */
.grad {
  background: linear-gradient(90deg, var(--blue), var(--azure));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Iconos ---------- */
.icon { width: 20px; height: 20px; flex: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(135deg, #2f6ad0, #16397f);
  box-shadow: 5px 5px 10px rgba(6, 10, 18, 0.55), -5px -5px 10px var(--shadow-light);
  transition: box-shadow 0.2s ease, color 0.2s ease, filter 0.2s ease;
}
.btn:hover { filter: brightness(1.12); }
.neu-btn {
  background: var(--bg);
  box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}
.neu-btn:hover { color: var(--accent); }
.neu-btn:active { box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light); }
.neu-btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #2f6ad0, #16397f);
  box-shadow: 6px 6px 14px rgba(6, 10, 18, 0.6), -6px -6px 12px var(--shadow-light);
}
.neu-btn-primary:hover { color: #fff; filter: brightness(1.12); }
.neu-btn-primary:active {
  box-shadow: inset 4px 4px 8px rgba(5, 9, 18, 0.55), inset -4px -4px 8px rgba(255, 255, 255, 0.08);
}

/* ==========================================================
   BARRA DE SECCIONES
   ========================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 256px;
  z-index: 1000;
  background: var(--bg);
  border-right: 1px solid rgba(122, 166, 255, 0.08);
  box-shadow: 12px 0 28px rgba(5, 9, 18, 0.7);
  display: flex;
  flex-direction: column;
}
.sb-top { padding: 26px 22px 18px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.brand-logo {
  width: 62px; height: 62px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.brand-logo .icon { width: 22px; height: 22px; color: var(--blue); }
.brand-logo-img { width: 42px; height: 42px; display: block; }
a.brand:hover .brand-logo,
a.brand:focus-visible .brand-logo {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px rgba(122, 166, 255, 0.35), 0 0 26px rgba(122, 166, 255, 0.35), 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--font-brand); font-size: 18px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.brand-name em { font-style: normal; }
.brand-sub { font-size: 15px; color: var(--muted); }

.nav-links { flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; overflow-y: auto; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--muted);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.2px;
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.2s ease, box-shadow 0.2s ease;
}
.nav-icon { width: 18px; height: 18px; flex: none; opacity: 0.7; transition: opacity 0.2s ease, filter 0.2s ease; }
.nav-link:hover { color: var(--text); }
.nav-link:hover .nav-icon { opacity: 1; }
.nav-link.active {
  color: var(--blue);
  font-weight: 600;
  box-shadow: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
}
.nav-link.active .nav-icon {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(122, 166, 255, 0.55));
}

.sidebar-footer { padding: 16px 18px 24px; display: flex; flex-direction: column; gap: 12px; }
.clock { padding: 14px 16px; text-align: center; }
.clock-zone { display: block; font-size: 15px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.clock-hora {
  display: flex;
  align-items: baseline;
  justify-content: center;
  width: 100%;
  font-family: var(--font-brand);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.15;
}
.clock-hora b { font-weight: 500; }
.clock-hora i { font-style: normal; color: var(--blue); font-weight: 500; padding: 0 2px; animation: clockBlink 1s steps(1) infinite; }
@keyframes clockBlink { 50% { opacity: 0.25; } }
.clock-fecha { display: flex; align-items: center; justify-content: center; gap: 7px; font-size: 15px; letter-spacing: 0.3px; margin-top: 5px; }
.cf-sem { text-transform: capitalize; color: var(--text); font-weight: 600; }
.cf-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 6px rgba(122, 166, 255, 0.8); }
.cf-fecha { color: var(--muted); }
.fase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  letter-spacing: 0.3px;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--bg);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
}

/* ==========================================================
   CONTENIDO
   ========================================================== */
.main { margin-left: 256px; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(15, 26, 46, 0.85);
  backdrop-filter: blur(10px);
}
.topbar-title h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.topbar-sub { font-size: 15px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

/* ---------- Títulos con degradado ---------- */
.title-grad {
  background: linear-gradient(90deg, var(--blue) 0%, var(--azure) 50%, var(--lila) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.view-head h2 {
  display: inline-block;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  padding-bottom: 10px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--azure) 55%, var(--lila) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.view-head h2::after {
  content: "";
  display: block;
  width: 46px;
  height: 3px;
  border-radius: 3px;
  margin-top: 10px;
  background: linear-gradient(90deg, var(--blue), var(--lila));
}
.view-head p { color: var(--muted); font-size: 18px; max-width: 720px; margin-top: 4px; }

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: none;
  color: var(--text);
  border-radius: 12px;
  width: 42px; height: 42px;
  cursor: pointer;
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.backdrop { display: none; position: fixed; inset: 0; background: rgba(4, 8, 16, 0.55); z-index: 950; }

.views { padding: 26px 30px 60px; max-width: 1200px; }
.view { display: none; }
.view.active { display: block; animation: viewIn 0.25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Página de inicio ---------- */
.hero-card { padding: 40px 44px; margin-bottom: 26px; }
.hero-overline {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 16px;
}
.hero-title { font-size: clamp(26px, 4vw, 40px); font-weight: 700; line-height: 1.2; letter-spacing: -0.5px; max-width: 640px; }
.hero-sub { margin: 16px 0 26px; max-width: 600px; color: var(--muted); font-size: 18px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px; }
.kpi-card { padding: 24px; }
.kpi-label {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.kpi-value { font-size: 18px; color: var(--muted); margin-bottom: 12px; }
.kpi-value span { font-family: var(--font-brand); font-size: 34px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.kpi-value em { font-style: normal; font-size: 18px; font-weight: 600; color: var(--blue); }
.kpi-note { display: block; font-size: 16px; color: var(--muted); }
.kpi-note b { color: var(--text); font-weight: 600; }

/* ---------- Placeholders ---------- */
.empty-view {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
  padding: 48px;
  text-align: center;
  max-width: 560px;
  margin: 40px auto;
}
.empty-view h2 { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.empty-view p { color: var(--muted); font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .backdrop.show { display: block; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .views { padding: 18px 18px 50px; }
  .hero-card { padding: 28px 24px; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
}

/* ==========================================================
   COMPONENTES COMPLETOS · vistas, tablas, gráficos, toasts
   ========================================================== */

.view-head { margin-bottom: 24px; }
.view-head b { color: var(--text); font-weight: 600; }

/* ---------- Superficie de tarjeta ---------- */
.kpi-card, .panel-box, .chart-box, .schedule-card, .logs-table, .info-strip, .tasks-box, .mn-card, .clock {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
}
.kpi-card { padding: 24px; }
.kpi-alert { border: 1px solid rgba(224, 118, 118, 0.25); }
.kpi-value-sm span { font-size: 24px; }

.kpi-split { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 2px 0 10px; }
.ks-item { display: inline-flex; align-items: center; gap: 7px; font-size: 16px; color: var(--muted); }
.ks-item b { color: var(--text); font-weight: 600; }

.kpi-bar { height: 8px; border-radius: 999px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); margin: 6px 0 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--navy)); transition: width 0.6s ease; }

.kpi-lower { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 22px; margin-top: 24px; }
.panel-box { padding: 22px; }
.panel-title { font-size: 16px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 16px; }
.chart-wrap { position: relative; height: 240px; }
.schedule-now { display: flex; flex-direction: column; gap: 10px; }
.snow-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 18px; color: var(--muted); padding: 8px 12px; border-radius: 12px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); }
.snow-row b { color: var(--text); font-weight: 600; }
.panel-hint { font-size: 16px; color: var(--muted); line-height: 1.6; }

/* ---------- Puntos de estado ---------- */
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--off);
  flex: none;
  box-shadow: 0 0 0 3px rgba(127, 135, 150, 0.16);
}
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 191, 160, 0.2), 0 0 10px rgba(111, 191, 160, 0.45); }
.dot-off { background: var(--off); box-shadow: 0 0 0 3px rgba(127, 135, 150, 0.16); }
.dot-fail { background: var(--fail); box-shadow: 0 0 0 3px rgba(224, 118, 118, 0.22), 0 0 10px rgba(224, 118, 118, 0.45); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(224, 162, 78, 0.2), 0 0 10px rgba(224, 162, 78, 0.4); }
.dot-act { background: var(--blue); box-shadow: 0 0 0 3px rgba(122, 166, 255, 0.22), 0 0 10px rgba(122, 166, 255, 0.45); }

/* ---------- Topbar / conexión ---------- */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: var(--muted);
  background: var(--bg);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  transition: color 0.2s ease, box-shadow 0.2s ease;
}
.bell:hover { color: var(--blue); box-shadow: 0 0 0 1px rgba(122, 166, 255, 0.35), 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light); }
.bell svg { width: 21px; height: 21px; }
.bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #f43f5e, #b91c4b);
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.45);
}
.bell-badge.show { display: flex; }
.bell.shake svg { animation: bellShake 0.5s ease; }
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); }
  40% { transform: rotate(-10deg); }
  60% { transform: rotate(7deg); }
  80% { transform: rotate(-4deg); }
}
.faselive { font-weight: 600; }
.fase-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(141, 155, 180, 0.15), 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.fase-dot[data-fase="dia"] { background: #fbbf24; box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.2), 0 0 14px rgba(251, 191, 36, 0.55); }
.fase-dot[data-fase="noche"] { background: #22d3ee; box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.2), 0 0 14px rgba(34, 211, 238, 0.55); }
.fase-dot[data-fase="ahorro"] { background: #34d399; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2), 0 0 14px rgba(52, 211, 153, 0.55); }
.live-badge { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; padding: 9px 14px; border-radius: 999px; color: var(--muted); background: var(--bg); box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light); }

/* ---------- Toolbars y filtros ---------- */
.logs-toolbar, .chart-toolbar { margin-bottom: 18px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 15px; color: var(--muted); letter-spacing: 0.5px; }
.filter-input { padding: 10px 14px; border-radius: 12px; border: none; outline: none; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 18px; box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light); }
.filter-input:focus { box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light), 0 0 0 2px rgba(122, 166, 255, 0.35); }
select.filter-input option { background: var(--bg); }
.btn-ghost {
  padding: 10px 18px;
  font-size: 18px;
  font-weight: 600;
  background: var(--bg);
  color: var(--blue);
  box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light);
}
.btn-ghost:hover { color: var(--text); }

/* ---------- Tablas ---------- */
.logs-table { padding: 8px 6px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 18px; }
.data-table th { text-align: left; padding: 12px 14px; color: var(--muted); font-size: 15px; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; border-bottom: 1px solid rgba(122, 166, 255, 0.1); white-space: nowrap; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid rgba(122, 166, 255, 0.06); white-space: nowrap; }
.data-table td .btn { padding: 6px 12px; font-size: 15px; margin-right: 4px; }
.data-table tbody tr:hover { background: rgba(122, 166, 255, 0.04); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 18px; }

.st-badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: 999px; font-size: 16px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); }
.st-badge[data-est="online"] .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 191, 160, 0.2), 0 0 10px rgba(111, 191, 160, 0.45); }
.st-badge[data-est="actuando"] .dot { background: var(--blue); box-shadow: 0 0 0 3px rgba(122, 166, 255, 0.22), 0 0 10px rgba(122, 166, 255, 0.45); }
.st-badge[data-est="apagada"] .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(224, 162, 78, 0.2), 0 0 10px rgba(224, 162, 78, 0.4); }
.st-badge[data-est="offline"] .dot { background: var(--off); box-shadow: 0 0 0 3px rgba(127, 135, 150, 0.16); }
.st-badge[data-est="falla"] .dot { background: var(--fail); box-shadow: 0 0 0 3px rgba(224, 118, 118, 0.22), 0 0 10px rgba(224, 118, 118, 0.45); }
.st-txt { color: var(--text); }

.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 16px; }
.pg-info { font-size: 16px; color: var(--muted); margin-right: 8px; }
.pg-btn { padding: 8px 16px; border-radius: 10px; border: none; cursor: pointer; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 18px; box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light); }
.pg-btn:hover:not(:disabled) { color: var(--blue); }
.pg-btn:disabled { opacity: 0.45; cursor: default; }
.pg-cur { font-size: 18px; color: var(--muted); }

/* ---------- Gráficos / período ---------- */
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.tabs { display: inline-flex; gap: 8px; background: var(--bg); padding: 5px; border-radius: 14px; box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light); }
.tab { padding: 8px 18px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-family: var(--font); font-size: 18px; font-weight: 500; cursor: pointer; }
.tab.active { color: var(--blue); background: var(--bg); box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light); }
.export-btns { display: flex; gap: 10px; }
.charts-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 22px; }
.charts-grid-sensores { margin-top: 22px; }
.chart-box { padding: 22px; }
.chart-box h4 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.chart-large .chart-wrap, .chart-small .chart-wrap { height: 320px; }
.analytics-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.s-item { padding: 12px 14px; border-radius: 12px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); }
.s-item span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.s-item b { font-size: 18px; font-weight: 600; color: var(--text); }

/* ---------- Ahorro / sensores ---------- */
.schedule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; margin-bottom: 22px; }
.schedule-card { padding: 22px; border: 1px solid transparent; }
.schedule-card.active { border-color: rgba(122, 166, 255, 0.4); }
.schedule-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.schedule-time { display: inline-block; font-family: var(--font-brand); font-size: 16px; letter-spacing: 1px; color: var(--blue); margin-bottom: 0; }
.sched-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--muted);
}
.schedule-card[data-fase="dia"] .sched-dot { background: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.6); }
.schedule-card[data-fase="noche"] .sched-dot { background: #22d3ee; box-shadow: 0 0 10px rgba(34, 211, 238, 0.6); }
.schedule-card[data-fase="ahorro"] .sched-dot { background: #34d399; box-shadow: 0 0 10px rgba(52, 211, 153, 0.6); }
.schedule-card h4 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.schedule-card p { font-size: 18px; color: var(--muted); }
.maint-cols { display: grid; grid-template-columns: 1.7fr 1fr; gap: 22px; align-items: start; }

/* ---------- Alertas ---------- */
.info-strip { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; margin-bottom: 18px; }
.info-badge { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; color: var(--muted); padding: 8px 14px; border-radius: 12px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); }
.info-badge b { color: var(--text); }
.sev { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 16px; font-weight: 600; }
.sev-crit { color: var(--fail); background: rgba(224, 118, 118, 0.12); }
.sev-warn { color: var(--warn); background: rgba(224, 162, 78, 0.12); }
.sev-info { color: var(--blue); background: rgba(122, 166, 255, 0.12); }
.btn-mini { padding: 6px 12px; border-radius: 9px; border: none; cursor: pointer; background: var(--bg); color: var(--blue); font-family: var(--font); font-size: 16px; font-weight: 500; box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light); }
.btn-mini:hover { color: var(--text); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 12px; z-index: 2000; max-width: 340px; }
.toast { background: var(--bg); border-radius: 16px; padding: 14px 18px; box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light); border-left: 3px solid var(--blue); animation: toastIn 0.25s ease; }
.toast b { display: block; font-size: 18px; margin-bottom: 2px; }
.toast span { font-size: 16px; color: var(--muted); }
.toast-crit { border-left-color: var(--fail); }
.toast-ok { border-left-color: var(--ok); }
.toast-warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------- Control manual ---------- */
.ctl-list { display: block; }
.ctl-detail {
  display: none;
  align-items: center;
  gap: 16px;
  position: fixed;
  right: 22px;
  bottom: 20px;
  z-index: 1200;
  max-width: 560px;
  width: auto;
  padding: 20px 24px;
  border-radius: 18px;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(122, 166, 255, 0.35), 0 0 34px rgba(122, 166, 255, 0.2), 10px 10px 22px var(--shadow-dark), -10px -10px 22px var(--shadow-light);
  animation: ctlIn 0.25s ease;
}
.ctl-d-label { font-size: 18px; font-weight: 500; color: var(--blue); margin-bottom: 10px; }
.ctl-d-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ctl-d-cap { font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.ctl-d-info b { font-family: var(--brand); font-size: 18px; color: var(--text); line-height: 1.15; }
.ctl-d-info b .ctl-tag { vertical-align: middle; margin-left: 4px; }
.ctl-d-info > span {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctl-d-actions { display: flex; align-items: center; gap: 10px; }
.ctl-d-actions .btn { padding: 12px 18px; white-space: nowrap; }
@keyframes ctlIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
body.ctl-open .toasts { bottom: 150px; }
.ctl-d-info { flex: 1; min-width: 0; }
.ctl-d-info b { display: block; font-size: 18px; color: var(--text); }
.ctl-d-info span { display: block; font-size: 15px; color: var(--muted); }
.ctl-d-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.ctl-av { margin-bottom: 20px; }
.ctl-av-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.ctl-av-head b { font-family: var(--font-brand); font-size: 18px; letter-spacing: 1px; text-transform: uppercase; color: var(--text); }
.ctl-av-count { font-size: 16px; color: var(--muted); margin-right: auto; }
.ctl-av-acc { display: flex; gap: 8px; }
.ctl-sm { padding: 7px 12px !important; font-size: 16px !important; }
.ctl-cardgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.ctl-tipos { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.ctl-tipo { margin: 4px 0 6px; }
.ctl-tipo-head { display: flex; align-items: center; gap: 8px; margin: 10px 2px 8px; }
.ctl-tipo-head span { font-size: 15px; color: var(--muted); letter-spacing: 0.5px; }
.ctl-card { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px; background: var(--bg); box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light); cursor: pointer; }
.ctl-card.sel { box-shadow: 0 0 0 2px var(--blue), 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light); }
.ctl-lamp { width: 38px; height: 52px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.ctl-lamp svg { width: 30px; height: 46px; display: block; }
.ctl-lamp-sm { width: 20px; height: 30px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.ctl-lamp-sm svg { display: block; }
.ctl-info { min-width: 0; flex: 1; }
.ctl-info b { display: block; font-size: 18px; color: var(--text); letter-spacing: 0.3px; }
.ctl-info span { display: block; font-size: 15px; color: var(--muted); }
.ctl-tag { display: inline-block; font-size: 15px; font-weight: 700; letter-spacing: 0.8px; padding: 2px 7px; border-radius: 999px; margin-right: 6px; }
.ctl-tag-lum { color: #8fd0c2; background: rgba(143, 208, 194, 0.12); }
.ctl-tag-act { color: #c4b5fd; background: rgba(124, 58, 237, 0.14); }
.ctl-switch { width: 46px; height: 24px; border-radius: 999px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); position: relative; cursor: pointer; flex: 0 0 auto; }
.ctl-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.15s ease, background 0.15s ease; }
.ctl-switch[aria-checked="true"] .ctl-knob { transform: translateX(22px); background: var(--ok); box-shadow: 0 0 10px rgba(111, 191, 160, 0.7); }

/* ---------- Red por avenida ---------- */
.ave-list { display: flex; flex-direction: column; gap: 10px; }
.ave-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: 16px; }
.ave-name { color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ave-bar { height: 8px; border-radius: 999px; background: var(--bg); box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); overflow: hidden; }
.ave-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--lila)); }
.ave-nums { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Vista de mapa (iframe) ---------- */
.map-frame {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 8px 8px 18px var(--shadow-dark), -8px -8px 18px var(--shadow-light);
  overflow: hidden;
  height: calc(100vh - 190px);
  min-height: 460px;
}
.map-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Responsive extendido ---------- */
@media (max-width: 1000px) {
  .kpi-lower, .charts-grid, .analytics-strip, .maint-cols { grid-template-columns: 1fr; }
  .schedule-grid { grid-template-columns: 1fr; }
  .map-frame { height: 68vh; min-height: 380px; }
}

/* ==========================================================
   PULIDO · detalles de calidad
   ========================================================== */
::selection { background: rgba(122, 166, 255, 0.3); color: #fff; }

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: rgba(122, 166, 255, 0.16); border-radius: 8px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: rgba(122, 166, 255, 0.3); }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-corner { background: transparent; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid rgba(122, 166, 255, 0.6);
  outline-offset: 2px;
}

.kpi-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.kpi-card:hover { transform: translateY(-2px); }

.data-table b { color: var(--text); font-weight: 600; }
.mn-item b.em { color: var(--blue); }

@media (max-width: 900px) {
  .ctl-tipos { grid-template-columns: 1fr; }
  .ctl-cardgrid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .ctl-detail { left: 14px; right: 14px; max-width: none; }
  body.ctl-open .toasts { bottom: 96px; }
}
/* ============ LOGIN MODAL ============ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 3rem;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.login-logo {
  width: 60px;
  margin-bottom: 1rem;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.form-group {
  text-align: left;
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.form-input {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.8rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

.form-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.login-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--c-accent), #2b6cb0);
  color: #fff;
  border: none;
  padding: 1rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.3s;
}

.login-btn:hover {
  opacity: 0.9;
}
