/* =====================================================================================================
 * Prixma Turbo Lite · diseño común de Local Focus TL y Global Focus TL (plan de P3, §1; ADR-0002)
 *
 * Tomado del prototipo GlobalFocus/globalfocus_v2_build_063.html, la especificación de estilo: sus colores (tema
 * oscuro industrial, cian #00e5ff), sus medidas y sus componentes, con los mismos nombres de clase (card, btn,
 * badge, data-table, form-control, modal, nav-item...) para que Global Focus TL (P7) reutilice su marcado.
 * Cambios frente al prototipo:
 *   - sin fuentes ni recursos externos (el nodo trabaja sin internet): letras del sistema (Segoe UI, Cascadia);
 *   - tema claro además del oscuro: el oscuro es el de fábrica; el claro se elige con el botón de la cabecera
 *     (data-theme="claro" en <html>);
 *   - sin estilos en línea en el HTML (la política de seguridad de contenidos no los admite);
 *   - componentes nuevos de Local Focus TL: franja de identidad, avisos, insignias de severidad y diálogo de
 *     confirmación.
 * Usable a 1280 px y en un teléfono: a menos de 1100 px el menú queda en iconos; a menos de 640 px se abre con
 * el botón de la cabecera.
 * ===================================================================================================== */

/* ============================== TOKENS: TEMA OSCURO (DE FÁBRICA) ============================== */
:root {
  color-scheme: dark;
  /* superficies */
  --bg-void: #05080d; --bg-primary: #0a0e14; --bg-secondary: #0f1620;
  --bg-card: #131c28; --bg-card-hi: #182232; --bg-input: #0a1018;
  --bg-elevated: #1a2536; --bg-deep: #070b11;
  /* bordes */
  --border: #1c2a3d; --border-hi: #2a3d57; --border-cyan: #00bcd4;
  /* texto */
  --text-primary: #e8eef6; --text-secondary: #93a3b8; --text-muted: #64758a; --text-faint: #3d4a5e;
  --on-accent: #05080d;
  /* paleta */
  --cyan: #00e5ff; --cyan-2: #00bcd4; --cyan-glow: #00e5ff33;
  --blue: #3b82f6; --blue-glow: #3b82f633;
  --green: #00e676; --green-glow: #00e67633;
  --orange: #ff9100; --orange-glow: #ff910033;
  --red: #ff1744; --red-glow: #ff174433;
  --yellow: #ffd600; --yellow-glow: #ffd60033;
  --purple: #7c4dff; --purple-glow: #7c4dff33;
  /* fondos translúcidos de estado */
  --tint-cyan: rgba(0, 229, 255, 0.06); --tint-green: rgba(0, 230, 118, 0.12); --tint-orange: rgba(255, 145, 0, 0.12);
  --tint-red: rgba(255, 23, 68, 0.12); --tint-blue: rgba(59, 130, 246, 0.12); --tint-purple: rgba(124, 77, 255, 0.12);
  --tint-muted: rgba(100, 117, 138, 0.12);
  --line-green: rgba(0, 230, 118, 0.3); --line-orange: rgba(255, 145, 0, 0.3); --line-red: rgba(255, 23, 68, 0.3);
  --line-blue: rgba(59, 130, 246, 0.3); --line-cyan: rgba(0, 229, 255, 0.3); --line-purple: rgba(124, 77, 255, 0.3);
  /* gradientes */
  --grad-cyan: linear-gradient(135deg, #00e5ff 0%, #2196f3 100%);
  --grad-card: linear-gradient(180deg, rgba(0, 229, 255, 0.04) 0%, rgba(0, 229, 255, 0) 100%);
  --grad-bg: radial-gradient(circle at 15% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
             radial-gradient(circle at 85% 80%, rgba(124, 77, 255, 0.05) 0%, transparent 40%),
             linear-gradient(180deg, #05080d 0%, #0a0e14 100%);
  --grad-login: radial-gradient(circle at 30% 30%, rgba(0, 229, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(124, 77, 255, 0.08) 0%, transparent 50%);
  --login-grid: rgba(0, 229, 255, 0.05);
  --login-card: linear-gradient(180deg, rgba(19, 28, 40, 0.92) 0%, rgba(10, 14, 20, 0.92) 100%);
  --overlay: rgba(5, 8, 13, 0.75);
  --nav-active: linear-gradient(90deg, rgba(0, 229, 255, 0.1) 0%, transparent 100%);
  /* gráficas */
  --chart-grid: rgba(255, 255, 255, 0.06); --chart-fault: rgba(255, 23, 68, 0.12);
  /* sombras y halos */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3); --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5); --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.6);
  --glow-cyan: 0 0 24px rgba(0, 229, 255, 0.18); --glow-cyan-strong: 0 0 36px rgba(0, 229, 255, 0.4);
  --glow-green: 0 0 24px rgba(0, 230, 118, 0.2); --glow-red: 0 0 24px rgba(255, 23, 68, 0.22);
  /* letras (del sistema: sin descargas) */
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", Consolas, "SFMono-Regular", Menlo, "Liberation Mono", monospace;
  /* medidas */
  --sidebar-w: 248px; --topbar-h: 60px;
  --radius: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-2xl: 20px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================== TOKENS: TEMA CLARO ============================== */
:root[data-theme="claro"] {
  color-scheme: light;
  --bg-void: #e9eef3; --bg-primary: #f1f4f8; --bg-secondary: #ffffff;
  --bg-card: #ffffff; --bg-card-hi: #f1f5f9; --bg-input: #f7f9fb;
  --bg-elevated: #ffffff; --bg-deep: #e4eaf0;
  --border: #d3dbe4; --border-hi: #b4c1cf; --border-cyan: #00839a;
  --text-primary: #0f1a26; --text-secondary: #344456; --text-muted: #556477; --text-faint: #8593a3;
  --on-accent: #ffffff;
  --cyan: #007f94; --cyan-2: #006b7d; --cyan-glow: #007f9422;
  --blue: #1d4ed8; --blue-glow: #1d4ed822;
  --green: #08773f; --green-glow: #08773f22;
  --orange: #b43d00; --orange-glow: #b43d0022;
  --red: #c8102e; --red-glow: #c8102e22;
  --yellow: #8a6400; --yellow-glow: #8a640022;
  --purple: #5b21b6; --purple-glow: #5b21b622;
  --tint-cyan: rgba(0, 127, 148, 0.07); --tint-green: rgba(8, 119, 63, 0.09); --tint-orange: rgba(180, 61, 0, 0.08);
  --tint-red: rgba(200, 16, 46, 0.08); --tint-blue: rgba(29, 78, 216, 0.08); --tint-purple: rgba(91, 33, 182, 0.08);
  --tint-muted: rgba(85, 100, 119, 0.1);
  --line-green: rgba(8, 119, 63, 0.35); --line-orange: rgba(180, 61, 0, 0.35); --line-red: rgba(200, 16, 46, 0.35);
  --line-blue: rgba(29, 78, 216, 0.35); --line-cyan: rgba(0, 127, 148, 0.35); --line-purple: rgba(91, 33, 182, 0.35);
  --grad-cyan: linear-gradient(135deg, #00839a 0%, #1d5fc4 100%);
  --grad-card: none;
  --grad-bg: linear-gradient(180deg, #eef2f6 0%, #e6ecf2 100%);
  --grad-login: radial-gradient(circle at 30% 30%, rgba(0, 127, 148, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 70%, rgba(91, 33, 182, 0.06) 0%, transparent 50%);
  --login-grid: rgba(0, 127, 148, 0.07);
  --login-card: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(247, 249, 251, 0.96) 100%);
  --overlay: rgba(15, 26, 38, 0.45);
  --nav-active: linear-gradient(90deg, rgba(0, 127, 148, 0.1) 0%, transparent 100%);
  --chart-grid: rgba(15, 26, 38, 0.08); --chart-fault: rgba(200, 16, 46, 0.1);
  --shadow-sm: 0 1px 3px rgba(15, 26, 38, 0.12); --shadow-md: 0 3px 10px rgba(15, 26, 38, 0.12);
  --shadow-lg: 0 8px 24px rgba(15, 26, 38, 0.14); --shadow-xl: 0 18px 44px rgba(15, 26, 38, 0.18);
  --glow-cyan: 0 0 0 1px rgba(0, 127, 148, 0.12); --glow-cyan-strong: 0 0 0 2px rgba(0, 127, 148, 0.2);
  --glow-green: 0 0 0 1px rgba(8, 119, 63, 0.2); --glow-red: 0 0 0 1px rgba(200, 16, 46, 0.25);
}

/* ============================== BASE ============================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body); font-size: 13.5px; line-height: 1.5;
  color: var(--text-primary); background-color: var(--bg-void); background-image: var(--grad-bg);
  background-attachment: fixed; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--cyan); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hi); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============================== ACCESO ============================== */
.login-screen {
  position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background-image: var(--grad-login); overflow: hidden;
}
.login-grid-bg {
  position: absolute; inset: 0; pointer-events: none; background-size: 48px 48px;
  background-image: linear-gradient(var(--login-grid) 1px, transparent 1px), linear-gradient(90deg, var(--login-grid) 1px, transparent 1px);
  -webkit-mask-image: radial-gradient(ellipse at center, black 0%, transparent 70%); mask-image: radial-gradient(ellipse at center, black 0%, transparent 70%);
}
.login-card {
  position: relative; width: 100%; max-width: 440px; padding: 40px;
  background: var(--login-card); border: 1px solid var(--border); border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl), var(--glow-cyan);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-logo-mark, .brand-mark {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--grad-cyan); color: var(--on-accent); font-family: var(--font-display); font-weight: 800;
}
.login-logo-mark { width: 52px; height: 52px; border-radius: 12px; font-size: 26px; box-shadow: var(--glow-cyan-strong); }
.login-logo-text { font-family: var(--font-display); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.login-logo-text span, .brand-text span { color: var(--cyan); }
.login-logo-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 3px; letter-spacing: 0.05em; }
.login-card h1, .login-card h2 { font-size: 19px; margin-bottom: 6px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.login-nodo { margin-bottom: 22px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-input); }
.login-footer {
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted);
}

/* ============================== FORMULARIOS ============================== */
.form-group { margin-bottom: 16px; }
.form-group > label, .form-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 6px; font-weight: 700;
}
.form-control {
  width: 100%; padding: 11px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary); font-family: var(--font-body); font-size: 14px;
  transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-glow); }
.form-control:disabled { opacity: 0.6; cursor: not-allowed; }
.form-control[aria-invalid="true"] { border-color: var(--red); }
select.form-control {
  appearance: none; padding-right: 36px; background-repeat: no-repeat; background-position: right 14px center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%2364758a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.checkbox-label input { accent-color: var(--cyan); width: 16px; height: 16px; }
/* Un número dentro de una opción, como «Cerrar tras [N] minutos sin uso» (ADR-TL-0004, punto 4.3). */
.checkbox-label .form-control.input-inline { width: 96px; height: auto; padding: 6px 10px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--cyan); }

/* ============================== BOTONES ============================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px;
  border-radius: var(--radius); border: 1px solid transparent; font-family: var(--font-body); font-weight: 600;
  font-size: 13px; cursor: pointer; transition: var(--transition); text-decoration: none; white-space: nowrap;
  user-select: none; min-height: 40px;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--grad-cyan); color: var(--on-accent); border-color: var(--cyan); }
.btn-primary:hover:not(:disabled) { box-shadow: var(--glow-cyan); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-hi); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hi); border-color: var(--cyan); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { color: var(--cyan); background: var(--bg-card); }
.btn-danger { background: var(--tint-red); color: var(--red); border-color: var(--line-red); }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; box-shadow: var(--glow-red); }
.btn-warning { background: var(--tint-orange); color: var(--orange); border-color: var(--line-orange); }
.btn-warning:hover:not(:disabled) { background: var(--orange); color: var(--on-accent); }
.btn-success { background: var(--tint-green); color: var(--green); border-color: var(--line-green); }
.btn-success:hover:not(:disabled) { background: var(--green); color: var(--on-accent); }
.btn-sm { padding: 6px 12px; font-size: 12px; min-height: 32px; }
.btn-lg { padding: 13px 22px; font-size: 14px; min-height: 46px; }
.btn-block { width: 100%; }
.btn-icon-only { padding: 8px; width: 38px; height: 38px; min-height: 0; }
.inline-form { display: inline; }

/* ============================== ESTRUCTURA DE LA APLICACIÓN ============================== */
.app-shell {
  display: grid; height: 100vh; height: 100dvh; overflow: hidden;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}
.topbar {
  grid-column: 1 / 3; grid-row: 1; display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border); z-index: 100; min-width: 0;
}
.brand {
  display: flex; align-items: center; gap: 12px; width: calc(var(--sidebar-w) - 20px); padding-right: 20px;
  border-right: 1px solid var(--border); height: 100%; color: var(--text-primary); text-decoration: none; flex-shrink: 0;
}
.brand-mark { width: 32px; height: 32px; border-radius: 8px; font-size: 16px; box-shadow: var(--glow-cyan); }
.brand-text { font-family: var(--font-display); font-size: 16px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-nodo { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.topbar-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.topbar-nodo-nombre { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-nodo-codigo { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-shrink: 0; }
.topbar-hora {
  display: flex; flex-direction: column; align-items: flex-end; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card); line-height: 1.25;
}
.topbar-hora-valor { font-family: var(--font-mono); font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.topbar-icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: var(--radius); background: var(--bg-card);
  border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: var(--transition); text-decoration: none; flex-shrink: 0;
}
.topbar-icon-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.topbar-icon-btn svg { width: 18px; height: 18px; }
.topbar-icon-btn .contador {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--bg-secondary);
}
.topbar-icon-btn.con-alarmas { color: var(--red); border-color: var(--line-red); }
.topbar-user {
  display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 24px; transition: var(--transition); color: var(--text-primary);
  text-decoration: none; min-width: 0;
}
.topbar-user:hover { border-color: var(--cyan); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--grad-cyan); color: var(--on-accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 12px;
}
.topbar-user-name { font-weight: 600; font-size: 13px; white-space: nowrap; }
.topbar-user-role { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.topbar-mobile-toggle {
  display: none; align-items: center; justify-content: center; width: 38px; height: 38px; flex-shrink: 0;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-secondary);
}
.topbar-mobile-toggle:hover { color: var(--cyan); border-color: var(--cyan); }
.topbar-mobile-toggle svg { width: 20px; height: 20px; }

.sidebar {
  grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; padding: 14px 0;
  background: var(--bg-secondary); border-right: 1px solid var(--border); -webkit-overflow-scrolling: touch;
}
.sidebar-section { margin-bottom: 14px; }
.sidebar-label { padding: 6px 22px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 22px; color: var(--text-secondary); text-decoration: none;
  border-left: 3px solid transparent; font-size: 13.5px; font-weight: 500; transition: var(--transition);
  background: none; border-top: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active { color: var(--cyan); background: var(--nav-active); border-left-color: var(--cyan); font-weight: 600; }
.nav-item .icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .icon svg { width: 100%; height: 100%; }
.nav-item .nav-badge {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px;
  border-radius: 10px; font-family: var(--font-mono);
}
.sidebar-footer { margin-top: auto; padding: 14px 0 4px; border-top: 1px solid var(--border); }
.sidebar-version { padding: 8px 22px 0; font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
.sidebar-overlay {
  display: none; position: fixed; top: var(--topbar-h); left: 0; width: 100vw; height: calc(100dvh - var(--topbar-h));
  background: var(--overlay); z-index: 150;
}
.sidebar-overlay.is-visible { display: block; }

.content { grid-column: 2; grid-row: 2; overflow-y: auto; overflow-x: hidden; min-height: 0; -webkit-overflow-scrolling: touch; }
/* Sin la animación de entrada del prototipo: en una pestaña en segundo plano dejaba la página en blanco un momento. */
.view { padding: 24px 30px 40px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; max-width: 760px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--cyan); }

/* ============================== FRANJA DE IDENTIDAD Y AVISOS ============================== */
.franja-identidad {
  display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; padding: 16px 18px;
  border: 2px solid var(--orange); border-radius: var(--radius-lg); background: var(--tint-orange); color: var(--text-primary);
}
.franja-identidad svg { width: 28px; height: 28px; color: var(--orange); flex-shrink: 0; margin-top: 2px; }
.franja-identidad strong { display: block; font-family: var(--font-display); font-size: 16px; color: var(--orange); margin-bottom: 2px; }
.aviso {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 14px; padding: 12px 14px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text-primary);
}
.aviso::before { content: ""; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--text-muted); }
.aviso-exito { border-color: var(--line-green); background: var(--tint-green); }
.aviso-exito::before { background: var(--green); }
.aviso-info { border-color: var(--line-cyan); background: var(--tint-cyan); }
.aviso-info::before { background: var(--cyan); }
.aviso-advertencia { border-color: var(--line-orange); background: var(--tint-orange); }
.aviso-advertencia::before { background: var(--orange); }
.aviso-error { border-color: var(--line-red); background: var(--tint-red); }
.aviso-error::before { background: var(--red); }

/* ============================== TARJETAS Y CIFRAS ============================== */
.card { background: var(--bg-card); background-image: var(--grad-card); border: 1px solid var(--border); border-radius: var(--radius-lg); transition: var(--transition); }
.card + .card { margin-top: 16px; }
.card-padded { padding: 22px; }
.card-padded-sm { padding: 16px; }
.card-seleccionada { border-color: var(--line-cyan); box-shadow: 0 0 0 1px var(--line-cyan); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-header h2, .card-header h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); font-weight: 700; }
.card-header .sub { color: var(--text-muted); font-size: 11px; font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-2 > .card + .card { margin-top: 0; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  position: relative; overflow: hidden; padding: 18px 20px; background: var(--bg-card); background-image: var(--grad-card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.kpi-card.online { border-color: var(--line-green); }
.kpi-card.warn { border-color: var(--line-orange); }
.kpi-card.danger { border-color: var(--line-red); }
.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.kpi-value { font-family: var(--font-display); font-size: 34px; font-weight: 800; margin: 6px 0; line-height: 1.1; }
.kpi-value .sub { font-size: 16px; color: var(--text-muted); font-weight: 500; }
.kpi-foot { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kv-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.kv-table td { padding: 7px 0; vertical-align: top; }
.kv-table td:first-child { color: var(--text-muted); padding-right: 14px; width: 40%; max-width: 220px; }
.en-construccion { text-align: center; padding: 48px 24px; }
.en-construccion svg { width: 46px; height: 46px; color: var(--text-muted); margin-bottom: 12px; }
.en-construccion h2 { font-size: 18px; margin-bottom: 8px; }
.en-construccion p { color: var(--text-muted); max-width: 620px; margin: 0 auto 6px; }

/* ============================== TABLAS ============================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 11px 14px; background: var(--bg-secondary); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--bg-card-hi); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.data-table a.link { color: var(--cyan); text-decoration: none; font-weight: 600; }
.data-table a.link:hover { text-decoration: underline; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 13px; }

/* ============================== INSIGNIAS ============================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 11px; font-size: 10.5px;
  font-weight: 700; font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-muted);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* en una tarjeta estrecha (el panel en un teléfono), el texto largo del estado parte en dos líneas */
.kpi-card .badge, .tabla-reglas .badge { white-space: normal; max-width: 100%; line-height: 1.35; }
.tabla-reglas td:nth-child(2), .tabla-reglas td:nth-child(3) { min-width: 160px; }
/* estado de módulos, servicios y relés */
.badge.online, .badge.success { background: var(--tint-green); color: var(--green); border-color: var(--line-green); }
.badge.online .dot { box-shadow: 0 0 6px var(--green); animation: pulse 2s infinite; }
.badge.stale, .badge.warning { background: var(--tint-orange); color: var(--orange); border-color: var(--line-orange); }
.badge.offline, .badge.error { background: var(--tint-red); color: var(--red); border-color: var(--line-red); }
.badge.unknown, .badge.muted { background: var(--tint-muted); color: var(--text-muted); border-color: var(--border); }
.badge.info { background: var(--tint-blue); color: var(--blue); border-color: var(--line-blue); }
.badge.cyan { background: var(--tint-cyan); color: var(--cyan); border-color: var(--line-cyan); }
.badge.purple { background: var(--tint-purple); color: var(--purple); border-color: var(--line-purple); }
/* severidad de las alarmas (RF-L-013, RF-L-018): Crítica, Alta, Advertencia, Informativa */
.badge.sev-critica { background: var(--red); color: #fff; border-color: var(--red); animation: pulse 2s infinite; }
.badge.sev-alta { background: var(--tint-red); color: var(--red); border-color: var(--line-red); }
.badge.sev-advertencia { background: var(--tint-orange); color: var(--orange); border-color: var(--line-orange); }
.badge.sev-informativa { background: var(--tint-blue); color: var(--blue); border-color: var(--line-blue); }
/* roles */
.role-badge { padding: 2px 9px; border-radius: 11px; font-size: 11px; font-weight: 700; font-family: var(--font-mono); text-transform: uppercase; white-space: nowrap; }
.role-badge.admin { background: var(--tint-cyan); color: var(--cyan); }
.role-badge.operator { background: var(--tint-green); color: var(--green); }
.role-badge.viewer { background: var(--tint-muted); color: var(--text-muted); }
.role-badge.maxadmin { background: var(--tint-purple); color: var(--purple); }

/* ============================== PESTAÑAS, FILTROS Y PAGINACIÓN ============================== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 11px 18px; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary);
  font-family: var(--font-body); font-size: 13px; font-weight: 500; transition: var(--transition); white-space: nowrap; text-decoration: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); font-weight: 600; }
.tab .count { font-family: var(--font-mono); font-size: 11px; margin-left: 6px; opacity: 0.8; }
.filters-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-end; }
.filters-bar .form-group { margin-bottom: 0; }
.filters-bar .form-control { padding: 8px 12px; font-size: 13px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; font-size: 12px; color: var(--text-muted); }
.pager-controls { display: flex; gap: 8px; align-items: center; }

/* ============================== DIÁLOGOS ============================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9998; display: none; align-items: center; justify-content: center; padding: 16px;
  background: var(--overlay); animation: fadeIn 0.2s ease-out;
}
.modal-backdrop.active { display: flex; }
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 28px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius-2xl); box-shadow: var(--shadow-xl);
  animation: modalIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal.peligro { border-color: var(--line-red); }
.modal h2, .modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal-desc { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 4px; white-space: pre-line; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ============================== VIVO, PROGRESO Y RELÉS ============================== */
.live-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 13px; font-size: 11px; font-family: var(--font-mono); color: var(--text-muted);
}
.live-pill .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.5s infinite; }
.live-pill.paused .pulse { background: var(--text-muted); box-shadow: none; animation: none; }
.progress { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--grad-cyan); transition: width 0.5s ease; }
.progress-fill.warn { background: var(--orange); }
.progress-fill.danger { background: var(--red); }
.relay-toggle {
  width: 44px; height: 24px; background: var(--bg-input); border-radius: 12px; position: relative; border: 1px solid var(--border);
  transition: var(--transition); flex-shrink: 0;
}
.relay-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: var(--text-muted); border-radius: 50%; transition: var(--transition); }
.relay-toggle.is-on { background: var(--green); border-color: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.relay-toggle.is-on::after { left: 22px; background: #fff; }

/* ============================== TARJETAS DE SENSORES Y DE RELÉS (del prototipo) ============================== */
.channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.channel-card, .relay-card {
  position: relative; overflow: hidden; padding: 16px; background: var(--bg-card-hi); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.chan-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.chan-name { font-weight: 600; font-size: 13.5px; }
.chan-name a { color: var(--text-primary); text-decoration: none; }
.chan-name a:hover { color: var(--cyan); }
.chan-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.chan-value { font-family: var(--font-display); font-size: 28px; font-weight: 800; color: var(--cyan); line-height: 1.1; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.chan-value.estado-falla, .chan-value.estado-invalida { color: var(--red); font-size: 17px; }
.chan-value.estado-sin_lectura, .chan-value.estado-deshabilitado { color: var(--text-muted); font-size: 17px; }
.chan-value.estado-saturado { color: var(--orange); }
.chan-meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.relay-acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.codigo-etiqueta { font-size: 30px; font-weight: 800; letter-spacing: 0.06em; color: var(--cyan); overflow-wrap: anywhere; }
.ficha-estado { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ficha-estado .badge { font-size: 13px; padding: 6px 14px; white-space: normal; max-width: 100%; line-height: 1.35; }
.lista-simple { list-style: none; }
.lista-simple li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.lista-simple li:last-child { border-bottom: 0; }

/* ============================== GRÁFICAS SVG (prixma.js, PTL.grafica) ============================== */
.chart-wrap { position: relative; width: 100%; height: 260px; }
.chart-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-grid line { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-family: var(--font-mono); font-size: 10px; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-fault { fill: var(--chart-fault); }
.chart-line.serie-0, .chart-dot.serie-0 { stroke: var(--cyan); }
.chart-line.serie-1, .chart-dot.serie-1 { stroke: var(--orange); }
.chart-line.serie-2, .chart-dot.serie-2 { stroke: var(--green); }
.chart-line.serie-3, .chart-dot.serie-3 { stroke: var(--purple); }
.chart-line.serie-4, .chart-dot.serie-4 { stroke: var(--yellow); }
.chart-line.serie-5, .chart-dot.serie-5 { stroke: var(--blue); }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-cursor { stroke: var(--cyan); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-dot { fill: var(--bg-card); stroke-width: 2; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 8px 12px; font-size: 12px;
  background: var(--bg-elevated); border: 1px solid var(--cyan); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.chart-tooltip .mono { display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.chart-legend span::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--serie, var(--cyan)); }
.chart-legend .serie-0 { --serie: var(--cyan); }
.chart-legend .serie-1 { --serie: var(--orange); }
.chart-legend .serie-2 { --serie: var(--green); }
.chart-legend .serie-3 { --serie: var(--purple); }
.chart-legend .serie-4 { --serie: var(--yellow); }
.chart-legend .serie-5 { --serie: var(--blue); }
.chart-legend .falla::before { height: 10px; width: 12px; background: var(--chart-fault); border: 1px solid var(--line-red); }
/* El detalle que muestra la gráfica (ADR-TL-0004, punto 4.9): texto, sin la marca de una serie. */
.chart-legend .detalle { color: var(--text-muted); }
.chart-legend .detalle::before { display: none; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-muted); font-size: 13px; }

/* ============================== UTILIDADES ============================== */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); } .text-cyan { color: var(--cyan); } .text-green { color: var(--green); }
.text-orange { color: var(--orange); } .text-red { color: var(--red); }
.text-xs { font-size: 11px; } .text-sm { font-size: 12px; } .fw-700 { font-weight: 700; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; margin: 18px 0 10px; }
.code-block { background: var(--bg-deep); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); overflow-x: auto; }
.max-480 { max-width: 480px; } .max-720 { max-width: 720px; }

/* ============================== PANTALLAS MEDIANAS Y PEQUEÑAS ============================== */
@media (max-width: 1100px) {
  :root { --sidebar-w: 64px; }
  .sidebar .nav-item .nav-text, .sidebar .nav-item .nav-badge, .sidebar-label, .sidebar-version { display: none; }
  .nav-item { padding: 10px 0; justify-content: center; }
  .nav-item.active { border-left-width: 2px; }
  .brand { width: auto; padding-right: 14px; }
  .brand-text { display: none; }
  .topbar-user-name, .topbar-user-role { display: none; }
  .topbar-user { padding: 4px; }
  .view { padding: 18px; }
}
@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-actions { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .card-padded { padding: 14px; }
  .topbar-hora .topbar-label { display: none; }
}
@media (max-width: 640px) {
  :root { --sidebar-w: 0px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .topbar, .content { grid-column: 1; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: -260px; width: 240px; height: calc(100dvh - var(--topbar-h));
    z-index: 200; transition: left 0.25s ease; box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
  }
  .sidebar.is-mobile-open { left: 0; }
  .sidebar .nav-item .nav-text, .sidebar .nav-item .nav-badge, .sidebar-label, .sidebar-version { display: initial; }
  .sidebar-label, .sidebar-version { display: block; }
  .nav-item { padding: 11px 22px; justify-content: flex-start; }
  .topbar-mobile-toggle { display: inline-flex; }
  .brand { border-right: 0; padding-right: 0; }
  .topbar-nodo-codigo { display: none; }
  .topbar-hora { padding: 4px 8px; }
  .topbar-hora-valor { font-size: 13px; }
  .topbar-tema { display: none; }
  .view { padding: 14px 12px 32px; }
  .page-title { font-size: 21px; }
  .login-card { padding: 26px 20px; }
  .modal { padding: 20px; }
  .modal-footer .btn { flex: 1 1 auto; }
  .data-table th, .data-table td { padding: 9px 10px; }
}
@media print {
  .sidebar, .topbar, .sidebar-overlay { display: none !important; }
  .app-shell { display: block; height: auto; }
  .content { overflow: visible; }
  body { background: #fff; color: #000; }
}

/* ===== Global Focus TL, P7-c: búsqueda global, mapa de la flota, mapa de calor y arquitectura (sin nada de fuera) ===== */
.topbar-buscar { flex: 1 1 260px; max-width: 360px; margin-left: 18px; }
.topbar-buscar input { width: 100%; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; color: var(--text-primary); padding: 7px 11px; font: inherit; font-size: 13px; }
.topbar-buscar input:focus { outline: none; border-color: var(--border-cyan); box-shadow: 0 0 0 3px var(--cyan-glow); }
.mapa-wrap { width: 100%; overflow-x: auto; }
.mapa-svg { width: 100%; height: auto; min-width: 560px; display: block; }
.mapa-fondo { fill: var(--bg-deep); stroke: var(--border); }
.mapa-rejilla { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.mapa-rotulo { fill: var(--text-faint); font-size: 11px; font-family: var(--font-mono); }
.mapa-punto { stroke: var(--bg-card); stroke-width: 3; }
.mapa-punto.online, .mapa-marca.online { fill: var(--green); background: var(--green); }
.mapa-punto.stale, .mapa-marca.stale { fill: var(--orange); background: var(--orange); }
.mapa-punto.offline, .mapa-marca.offline { fill: var(--red); background: var(--red); }
.mapa-punto.unknown, .mapa-marca.unknown, .mapa-punto.muted, .mapa-marca.muted { fill: var(--text-muted); background: var(--text-muted); }
.mapa-nombre { fill: var(--text-secondary); font-size: 13px; }
.mapa-svg a:hover .mapa-nombre, .mapa-svg a:focus .mapa-nombre { fill: var(--cyan); }
.mapa-leyenda { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 12px; font-size: 13px; color: var(--text-secondary); }
.mapa-marca { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.calor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.calor-celda { display: flex; align-items: center; justify-content: center; height: 42px; border-radius: 7px; font-weight: 700; font-size: 13px; text-decoration: none; border: 1px solid var(--border); }
.calor-celda.bien { background: var(--tint-green); color: var(--green); border-color: var(--line-green); }
.calor-celda.media { background: var(--tint-orange); color: var(--orange); border-color: var(--line-orange); }
.calor-celda.mala { background: var(--tint-red); color: var(--red); border-color: var(--line-red); }
.calor-celda.sin { background: var(--tint-muted); color: var(--text-muted); }
.arq-zona { fill: var(--bg-deep); stroke: var(--border); }
.arq-caja { fill: var(--bg-card); stroke: var(--border-hi); }
.arq-base { stroke: var(--cyan); }
.arq-hw { stroke: var(--orange); }
.arq-titulo { fill: var(--text-primary); font-size: 15px; font-weight: 700; }
.arq-texto { fill: var(--text-primary); font-size: 15px; font-weight: 600; text-anchor: middle; }
.arq-sub { fill: var(--text-muted); font-size: 12px; text-anchor: middle; }
.arq-linea { stroke: var(--text-faint); stroke-width: 1.5; }
.arq-https { stroke: var(--cyan); stroke-width: 2.5; stroke-dasharray: 8 5; }
.tab[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
@media (max-width: 900px) { .topbar-buscar { display: none; } }

/* ===== Global Focus TL, P7-f3: el calendario de las reglas programadas (SVG propio) y los reportes impresos ===== */
.cal-svg { width: 100%; height: auto; min-width: 760px; display: block; }
.cal-fondo { fill: var(--bg-deep); stroke: var(--border); }
.cal-hoy { fill: var(--tint-cyan); }
.cal-linea { stroke: var(--border); stroke-width: 1; }
.cal-rejilla { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 6; }
.cal-dia { fill: var(--text-primary); font-size: 13px; font-weight: 700; }
.cal-fecha { fill: var(--text-muted); font-size: 11px; font-family: var(--font-mono); }
.cal-hora { fill: var(--text-faint); font-size: 10px; font-family: var(--font-mono); }
.cal-franja { stroke-width: 1; }
.cal-franja.horario, .cal-marca.horario { fill: var(--tint-cyan); stroke: var(--cyan); background: var(--cyan); }
.cal-franja.fecha, .cal-marca.fecha { fill: var(--tint-purple); stroke: var(--purple); background: var(--purple); }
.cal-franja.pendiente, .cal-marca.pendiente { fill: var(--tint-orange); stroke: var(--orange); background: var(--orange); }
.cal-franja.apagada, .cal-marca.apagada { fill: var(--tint-muted); stroke: var(--text-faint); background: var(--text-faint); }
.cal-texto { fill: var(--text-primary); font-size: 11px; pointer-events: none; }
.cal-svg a:hover .cal-franja, .cal-svg a:focus .cal-franja { stroke-width: 2.5; }
.cal-marca { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.reporte-seccion { break-inside: avoid; }
@media print {
  .solo-pantalla, .reporte-pagina .filters-bar, .reporte-pagina .page-actions { display: none !important; }
  .reporte-pagina .card { box-shadow: none; border-color: #999; }
  .reporte-seccion { page-break-inside: avoid; }
}

/* ===== Global Focus TL, P7-g2: las pantallas SCADA (el dibujo de web/comun/hmi.js, sus temas, el editor y la vista en vivo) =====
 * Los temas del documento son clases en el <svg> (hmi-tema-<clave>, Pantallas::TEMAS) con sus variables; cada pieza del
 * dibujo toma su color de una clase (sin estilos en línea: la política de seguridad de contenidos no los admite). */
.hmi-tema-cian   { --hmi-fondo: #081019; --hmi-panel: #0e1a26; --hmi-borde: #1f4a66; --hmi-texto: #cfe8f5; --hmi-texto-2: #7fa3b8; --hmi-acento: #00e5ff; --hmi-tubo: #1f4a66; --hmi-flujo: #22d3ee; --hmi-on: #00e676; --hmi-off: #5b6b7d; --hmi-aviso: #ff9100; --hmi-peligro: #ff1744; --hmi-rejilla: #1e3a4a; --hmi-liquido: #22d3ee; }
.hmi-tema-verde  { --hmi-fondo: #08160f; --hmi-panel: #0d2219; --hmi-borde: #1a4a3a; --hmi-texto: #cdf5e4; --hmi-texto-2: #7fb39c; --hmi-acento: #34d399; --hmi-tubo: #1a4a3a; --hmi-flujo: #6ee7b7; --hmi-on: #00e676; --hmi-off: #5b6b7d; --hmi-aviso: #ff9100; --hmi-peligro: #ff1744; --hmi-rejilla: #183d2e; --hmi-liquido: #6ee7b7; }
.hmi-tema-ambar  { --hmi-fondo: #14120a; --hmi-panel: #221d10; --hmi-borde: #5a4a1a; --hmi-texto: #f8eecd; --hmi-texto-2: #b8a77a; --hmi-acento: #fbbf24; --hmi-tubo: #5a4a1a; --hmi-flujo: #fde68a; --hmi-on: #00e676; --hmi-off: #6b6656; --hmi-aviso: #ff9100; --hmi-peligro: #ff1744; --hmi-rejilla: #3d3418; --hmi-liquido: #38bdf8; }
.hmi-tema-neutro { --hmi-fondo: #0b0f14; --hmi-panel: #141a22; --hmi-borde: #334155; --hmi-texto: #e2e8f0; --hmi-texto-2: #94a3b8; --hmi-acento: #94a3b8; --hmi-tubo: #334155; --hmi-flujo: #cbd5e1; --hmi-on: #00e676; --hmi-off: #475569; --hmi-aviso: #ff9100; --hmi-peligro: #ff1744; --hmi-rejilla: #263241; --hmi-liquido: #60a5fa; }
.hmi-tema-claro  { --hmi-fondo: #f4f7fa; --hmi-panel: #ffffff; --hmi-borde: #9fb3c8; --hmi-texto: #1b2a3a; --hmi-texto-2: #52667a; --hmi-acento: #0284c7; --hmi-tubo: #b6c6d6; --hmi-flujo: #0284c7; --hmi-on: #059669; --hmi-off: #94a3b8; --hmi-aviso: #d97706; --hmi-peligro: #dc2626; --hmi-rejilla: #d5dee8; --hmi-liquido: #38bdf8; }
.hmi-lienzo { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.hmi-lienzo text { font-family: var(--font-body); }
.hmi-fondo { fill: var(--hmi-fondo); }
.hmi-punto-rejilla { fill: var(--hmi-rejilla); }
.hmi-panel { fill: var(--hmi-panel); stroke: var(--hmi-borde); stroke-width: 1.5; }
.hmi-trazo { fill: none; stroke: var(--hmi-borde); stroke-width: 2; }
.hmi-trazo-acento { fill: none; stroke: var(--hmi-acento); stroke-width: 2; }
.hmi-relleno-acento { fill: var(--hmi-acento); }
.hmi-texto { fill: var(--hmi-texto); }
.hmi-texto-2 { fill: var(--hmi-texto-2); }
.hmi-valor { fill: var(--hmi-texto); font-family: var(--font-mono) !important; font-weight: 600; font-variant-numeric: tabular-nums; }
.hmi-texto-falla { fill: var(--hmi-peligro); }
.hmi-texto-aviso { fill: var(--hmi-aviso); }
.hmi-on { fill: var(--hmi-on); }
.hmi-off { fill: var(--hmi-off); }
.hmi-sin-dato { fill: var(--hmi-panel); stroke: var(--hmi-borde); stroke-dasharray: 4 3; }
.hmi-falla { fill: var(--hmi-peligro); }
.hmi-liquido { fill: var(--hmi-liquido); opacity: 0.8; }
.hmi-barra-fondo { fill: var(--hmi-fondo); stroke: var(--hmi-borde); stroke-width: 1.5; }
.hmi-barra { fill: var(--hmi-acento); }
.hmi-aguja { stroke: var(--hmi-acento); stroke-width: 3; stroke-linecap: round; }
.hmi-serie { fill: none; stroke: var(--hmi-acento); stroke-width: 2; stroke-linejoin: round; }
.hmi-tubo { fill: var(--hmi-tubo); }
.hmi-flujo { fill: none; stroke: var(--hmi-flujo); stroke-width: 3; stroke-dasharray: 10 8; opacity: 0; }
.hmi-flujo.activo { opacity: 1; animation: hmi-flujo 0.9s linear infinite; }
.hmi-gira { transform-box: fill-box; transform-origin: center; }
.hmi-gira.activo { animation: hmi-gira 1.6s linear infinite; }
.hmi-halo { fill: var(--hmi-on); opacity: 0; }
.hmi-halo.activo { opacity: 0.25; }
.hmi-alarma-sin { fill: var(--hmi-off); }
.hmi-alarma-con { fill: var(--hmi-peligro); animation: hmi-parpadeo 1.2s steps(2, jump-none) infinite; }
.hmi-marco { fill: none; stroke: var(--hmi-borde); stroke-width: 1.5; stroke-dasharray: 6 4; }
.hmi-flecha { fill: var(--hmi-acento); }
.hmi-oculto { display: none; }
.hmi-pulsable { cursor: pointer; }
.hmi-pulsable:hover .hmi-caja-pulsable, .hmi-pulsable:focus .hmi-caja-pulsable { stroke: var(--hmi-acento); stroke-width: 2; }
.hmi-pulsable:focus { outline: none; }
.hmi-caja-pulsable { fill: transparent; stroke: transparent; }
@keyframes hmi-flujo { to { stroke-dashoffset: -18; } }
@keyframes hmi-gira { to { transform: rotate(360deg); } }
@keyframes hmi-parpadeo { 50% { opacity: 0.35; } }
/* El editor */
.hmi-editor { display: grid; grid-template-columns: 190px minmax(0, 1fr) 290px; gap: 14px; align-items: start; margin-bottom: 14px; }
.hmi-barra-herramientas { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hmi-barra-herramientas .separador { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.hmi-paleta { display: flex; flex-direction: column; gap: 4px; max-height: 76vh; overflow-y: auto; }
.hmi-paleta h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin: 10px 0 2px; }
.hmi-paleta button { text-align: left; justify-content: flex-start; }
.hmi-envoltura { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-deep); overflow: auto; max-height: 76vh; }
.hmi-envoltura .hmi-lienzo { min-width: 560px; }
.hmi-seleccion { fill: none; stroke: var(--cyan); stroke-width: 1.5; stroke-dasharray: 5 4; pointer-events: none; }
.hmi-asa { fill: var(--cyan); stroke: var(--bg-deep); stroke-width: 1; }
.hmi-asa.nw, .hmi-asa.se { cursor: nwse-resize; }
.hmi-asa.ne, .hmi-asa.sw { cursor: nesw-resize; }
.hmi-arrastrable { cursor: move; }
.hmi-aviso-enlace { fill: none; stroke: var(--orange); stroke-width: 2; stroke-dasharray: 3 3; pointer-events: none; }
.hmi-inspector .form-group { margin-bottom: 10px; }
.hmi-inspector .hmi-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hmi-inspector .hmi-nota { font-size: 12px; color: var(--text-muted); }
.hmi-inspector .hmi-nota.aviso-enlace { color: var(--orange); }
.hmi-guardar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
/* La pantalla en vivo, las miniaturas y el panel de un relé */
.hmi-vivo { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--bg-deep); margin-bottom: 8px; }
.hmi-vivo:fullscreen { background: var(--bg-void); padding: 12px; border: 0; }
.hmi-vivo:fullscreen .hmi-lienzo { max-height: calc(100vh - 24px); }
.hmi-ayuda { margin-bottom: 14px; }
.hmi-alarmas { list-style: none; margin: 0; padding: 0 20px 14px; }
.hmi-alarmas li { padding: 7px 0; border-top: 1px solid var(--border); }
.hmi-col-miniatura { width: 132px; }
.hmi-miniatura { display: block; width: 120px; height: 76px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--bg-deep); }
.hmi-miniatura .hmi-lienzo { width: 100%; height: 100%; }
.hmi-panel-rele .kv-table { margin: 8px 0 4px; }
.hmi-panel-rele .form-actions { margin-top: 12px; }
@media (max-width: 1100px) {
  .hmi-editor { grid-template-columns: 1fr; }
  .hmi-paleta { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .hmi-paleta h3 { width: 100%; }
}

/* ===== Global Focus TL, P8-c: el consumo de los últimos días de una SIM (SVG propio) ===== */
.sim-svg { width: 100%; height: auto; min-width: 560px; display: block; margin-bottom: 12px; }
.sim-dia { fill: var(--cyan-2); }
.sim-dia.hoy { fill: var(--cyan); }
.sim-eje { stroke: var(--border); stroke-width: 1; }
.sim-etiqueta { fill: var(--text-muted); font-size: 9px; font-family: var(--font-mono); }
