@charset "UTF-8";
/* =============================================================================
   styles.css — Sistema Eléctrico RODRITEL
   Paleta: negro + verde (#16a34a) sobre blanco. Mismo lenguaje que Mi RODRITEL.
   ========================================================================== */

:root {
  --accent: #16a34a;
  --accent-dark: #15803d;
  --accent-soft: #dcfce7;
  --accent-tint: #f0fdf4;
  --accent-off: #a7d8b6;          /* botón deshabilitado */

  --ink: #0a0a0a;
  --ink-soft: #262626;
  --muted: #525252;
  --faint: #a3a3a3;

  --bg: #ffffff;
  --surface: #ffffff;
  --line: #e5e5e5;
  --line-soft: #f5f5f5;
  --field: #f5f5f5;               /* fondo de inputs */
  --field-off: #ededed;           /* input deshabilitado */

  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --glass: rgba(15, 15, 15, 0.72);
  --glass-line: rgba(255, 255, 255, 0.10);

  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.12);

  --content-max: 720px;           /* ancho de la columna de contenido */

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
a { color: inherit; }

.hidden { display: none !important; }

/* ----- Utilidades de marca ----- */
.brand-logo {
  height: 38px; width: auto; display: block; object-fit: contain; flex-shrink: 0;
}
.brand-logo-lg { height: 72px; margin: 0 auto 18px; }

/* =============================================================================
   LOGIN
   ========================================================================== */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 24px;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}
/* Fondo sin foto: brillos verde/cian (colores del logo) + retícula tenue.
   Para usar una foto, añadir como primera capa:
   url("fondo-login.jpg") center / cover no-repeat, */
.login-wrap::before {
  content: "";
  position: absolute;
  inset: -6%;
  background:
    radial-gradient(circle at 20% 30%, rgba(22,163,74,.38), transparent 45%),
    radial-gradient(circle at 78% 80%, rgba(34,211,238,.20), transparent 48%),
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 44px 44px,
    #0a0a0a;
  z-index: 0;
  opacity: 0;
  transform: scale(1.08);
  animation: bgIntro 2.2s ease-out forwards, bgDrift 40s ease-in-out 2.2s infinite alternate;
  will-change: transform, opacity;
}
@keyframes bgIntro {
  from { opacity: 0; transform: scale(1.14); }
  to   { opacity: 1; transform: scale(1.08); }
}
@keyframes bgDrift {
  0%   { transform: scale(1.08) translate(0, 0); }
  100% { transform: scale(1.12) translate(-1.5%, -1%); }
}
.login-col {
  width: 100%; max-width: 400px;
  margin-right: clamp(16px, 6vw, 90px);
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}
.login-card {
  width: 100%;
  background: rgba(15, 15, 15, 0.62);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-radius: 22px;
  padding: 40px 32px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  border: 1px solid var(--glass-line);
  animation: cardIn .8s cubic-bezier(.16,1,.3,1) .3s both;
  will-change: transform, opacity;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-brand { text-align: center; margin-bottom: 30px; }
.login-title { font-size: 26px; font-weight: 700; color: #fff; }
.login-title b { color: var(--accent); font-weight: 800; }
.login-sub { color: #a3a3a3; font-size: 14.5px; margin-top: 5px; }

.login-card .field label { color: #d4d4d4; }
.login-card .input-shell {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
}
.login-card .input-shell:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
}
.login-card .input-shell input { color: #fff; }
.login-card .input-shell input::placeholder { color: rgba(255,255,255,0.45); }
.login-card .form-msg.error { color: #f87171; }

.login-demo {
  margin-top: 18px; padding: 9px 12px;
  border-radius: 10px; text-align: center;
  background: rgba(22,163,74,.14); border: 1px solid rgba(22,163,74,.35);
  color: #bbf7d0; font-size: 12.5px;
}
.login-demo b { color: #fff; }
.login-foot {
  text-align: center; color: #8a8a8a; font-size: 12.5px;
  margin-top: 22px; line-height: 1.55;
}
.login-foot b { color: var(--accent); font-weight: 700; }

/* ----- Campos ----- */
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 7px;
}
.input-shell {
  display: flex; align-items: center;
  background: var(--field);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color .15s, background .15s;
}
.input-shell:focus-within { border-color: var(--accent); background: #fff; }
.input-shell input {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  height: 50px; font-size: 16px; color: var(--ink);
}
.input-shell .toggle {
  font-size: 13px; font-weight: 600; color: var(--accent); padding-left: 8px;
}

/* ----- Botones ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; padding: 0 22px;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700;
  transition: background .15s, transform .05s, box-shadow .15s;
  box-shadow: 0 6px 18px rgba(22,163,74,.26);
}
.btn:hover { background: var(--accent-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--accent-off); box-shadow: none; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost {
  background: var(--surface); color: var(--ink-soft);
  border: 1.5px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: var(--line-soft); }
.btn-danger { background: var(--danger); box-shadow: 0 6px 18px rgba(220,38,38,.22); }
.btn-danger:hover { background: #b91c1c; }
.btn-soft-danger { background: var(--danger-soft); color: var(--danger); box-shadow: none; }
.btn-soft-danger:hover { background: #fee2e2; }
.btn-sm { height: 40px; font-size: 14px; padding: 0 16px; border-radius: 9px; }

.form-msg { font-size: 13.5px; margin-top: 12px; min-height: 18px; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

/* =============================================================================
   APP SHELL
   ========================================================================== */
.app { min-height: 100vh; padding-bottom: 24px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  border-bottom: 1px solid var(--glass-line);
  padding: 12px 18px 0;
}
.topbar-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-bottom: 10px;
}
/* En pantallas anchas, logo, usuario y pestañas se alinean con la columna
   de contenido (la barra de cristal sigue ocupando todo el ancho) */
.topbar-row, .top-nav { max-width: calc(var(--content-max) - 40px); margin: 0 auto; }
.topbar .brand { display: flex; align-items: center; }
.topbar .user {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font-size: 13px; color: rgba(255,255,255,0.75);
}
.topbar .user .name {
  font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.topbar .user .role { font-size: 11.5px; color: rgba(255,255,255,0.55); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* ----- Navegación (dentro de la barra superior cristal) ----- */
.top-nav {
  display: flex; gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: 1 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 9px 14px 11px;
  color: rgba(255,255,255,0.55);
  font-size: 12px; font-weight: 600;
  border-radius: 12px 12px 0 0;
  position: relative;
  transition: color .18s, background .18s;
  white-space: nowrap;
}
.nav-item svg { width: 21px; height: 21px; }
.nav-item:hover { color: rgba(255,255,255,0.85); }
.nav-item.active {
  color: #fff;
  background: rgba(22,163,74,0.18);
}
.nav-item.active::after {
  content: "";
  position: absolute; left: 12px; right: 12px; bottom: 0; height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
/* Cerrar sesión es una acción, no una vista: se tiñe de rojo al pasar */
.nav-item.nav-logout:hover { color: #fca5a5; background: rgba(220,38,38,0.12); }

.container { max-width: var(--content-max); margin: 0 auto; padding: 22px 20px; }

.view-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.view-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 16px; font-weight: 700; }
.card-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--faint);
}

/* ----- Hero: la firma visual ----- */
.hero {
  background: linear-gradient(135deg, #111827, #16a34a);
  color: #fff;
  border-radius: 20px;
  padding: 26px 24px;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
  position: relative; overflow: hidden;
  margin-bottom: 16px;
}
.hero::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,.10);
}
.hero .label {
  font-size: 13px; font-weight: 600; opacity: .9;
  text-transform: uppercase; letter-spacing: .05em;
}
.hero .big { font-size: 34px; font-weight: 800; margin: 6px 0 2px; letter-spacing: -.5px; }
.hero .meta { font-size: 13.5px; opacity: .92; position: relative; z-index: 1; }
.hero .btn { margin-top: 18px; position: relative; z-index: 1; }
.btn-white { background: #fff; color: var(--accent); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.btn-white:hover { background: var(--accent-tint); }

/* ----- Estadísticas (números grandes en columnas) ----- */
.stats { display: flex; text-align: center; }
.stat { flex: 1; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .num.ok { color: var(--ok); }
.stat .num.warn { color: var(--warn); }
.stat .num.danger { color: var(--danger); }

/* ----- Listas / filas ----- */
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }
.row .main { min-width: 0; }
.row .t { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.row .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row .v { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* ----- Grid de detalles (etiqueta / valor) ----- */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-top: 1px solid var(--line-soft);
}
.detail { padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.detail:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.detail-wide { grid-column: 1 / -1; border-right: none; }
.dl {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--faint); margin-bottom: 4px;
}
.dv { font-size: 15px; font-weight: 600; color: var(--ink); }

/* ----- Acordeón ----- */
.acc { padding: 0; overflow: hidden; }
.acc-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 20px; text-align: left;
}
.acc-head .t { font-weight: 700; font-size: 16px; color: var(--ink); }
.acc-head .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.acc-head .chev { color: var(--faint); transition: transform .25s ease; }
.acc-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s ease; }
.acc-body.open { grid-template-rows: 1fr; }
.acc-body > * { overflow: hidden; min-height: 0; }

/* ----- Chips de estado ----- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.ok .dot { background: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.warn .dot { background: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.danger .dot { background: var(--danger); }
.chip.muted { background: var(--line-soft); color: var(--muted); }
.chip.muted .dot { background: var(--faint); }

/* ----- Lista de opciones grandes (icono + título + descripción) ----- */
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--accent); background: var(--accent-tint); }
.opt-icon {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.opt-text { flex: 1; min-width: 0; }
.opt-title { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.opt-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.opt-arrow { color: var(--faint); flex-shrink: 0; }

/* ----- Buscador y paginado ----- */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--line-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 12px;
  color: var(--faint);
}
.search input {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  font-size: 14.5px; color: var(--ink);
}
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.page-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--line-soft); color: var(--ink);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.page-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 13.5px; font-weight: 600; color: var(--muted); }

/* ----- Forms genéricos en vistas ----- */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px;
}
.form-row input, .form-row select, .form-row textarea {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: 15.5px; color: var(--ink); background: var(--field);
  outline: none; transition: border-color .15s, background .15s;
}
.form-row textarea { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--accent); background: #fff;
}
.form-row input:disabled, .form-row select:disabled, .form-row textarea:disabled {
  background: var(--field-off); color: var(--faint); cursor: not-allowed;
}
.form-row input[readonly] { background: var(--field-off); color: var(--ink-soft); }

/* ----- Estados vacíos ----- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .icon {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.empty .icon svg { width: 26px; height: 26px; }
.empty h4 { color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.empty p { font-size: 13.5px; }

/* ----- Skeleton / loading ----- */
.skeleton {
  background: linear-gradient(90deg, #efefef 25%, #f7f7f7 50%, #efefef 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 8px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner.dark { border-color: var(--accent-soft); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Modal ----- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,10,10,.45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s;
}
@media (min-width: 540px) { .modal-backdrop { align-items: center; padding: 20px; } }
.modal {
  background: var(--surface);
  width: 100%; max-width: 460px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp .25s;
  overflow: hidden;
}
@media (min-width: 540px) { .modal { border-radius: 22px; max-height: 85vh; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 22px 14px; flex-shrink: 0;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 18px; font-weight: 700; }
.modal-close { font-size: 26px; color: var(--faint); line-height: 1; flex-shrink: 0; padding: 0 4px; }
.modal-close:hover { color: var(--ink); }
.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 22px calc(22px + env(safe-area-inset-bottom, 0px));
}
.sys-icon {
  width: 60px; height: 60px; margin: 4px auto 18px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
}
.sys-text { font-size: 14.5px; color: var(--ink-soft); line-height: 1.6; margin-bottom: 22px; }
.btn-pair { display: flex; gap: 10px; }
.btn-pair .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } }

/* ----- Toast ----- */
.toast-wrap {
  position: fixed; left: 0; right: 0; bottom: 28px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s;
  transition: opacity .25s;
  max-width: 90%;
}
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } }

/* =============================================================================
   PIEZAS COMPARTIDAS POR LOS MÓDULOS
   ========================================================================== */
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, 'Courier New', monospace; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 4px 0; margin-bottom: 12px;
}
.back-link:hover { color: var(--accent); }

.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }

/* Avisos dentro de vistas y modales */
.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.55; margin-bottom: 14px;
  background: var(--accent-tint); color: var(--accent-dark); border: 1px solid var(--accent-soft);
}
.notice svg { flex-shrink: 0; margin-top: 2px; }
.notice.warn { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.notice.danger { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.notice .btn { margin-top: 10px; }

/* Etiqueta pequeña en mayúsculas (OVPN, V7...) */
.tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-dark);
}
.tag.muted { background: var(--line-soft); color: var(--muted); }

/* Botones píldora para acciones secundarias */
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  padding: 7px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-dark);
  transition: background .15s, color .15s;
}
.pill-btn:hover { background: #bbf7d0; }
.pill-btn:disabled { opacity: .55; cursor: not-allowed; }
.pill-btn.muted { background: var(--line-soft); color: var(--ink-soft); }
.pill-btn.muted:hover { background: var(--line); }
.pill-btn.warn { background: var(--warn-soft); color: var(--warn); }
.pill-btn.warn:hover { background: #fef3c7; }
.pill-btn.danger { background: transparent; color: var(--faint); padding: 7px 9px; }
.pill-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px; color: var(--faint); flex-shrink: 0;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.tun-head .icon-btn { margin: -1px -6px 0 -2px; }

/* Caja de código (scripts, certificados, logs) */
.code-box {
  position: relative;
  background: #0f0f0f; color: #d1fae5;
  border-radius: var(--radius-sm);
  padding: 14px 16px; padding-right: 44px;
  font-size: 12px; line-height: 1.55;
  max-height: 340px; overflow: auto;
  white-space: pre-wrap; word-break: break-all;
}
.code-box .copy {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.10); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.code-box .copy:hover { background: rgba(255,255,255,.22); }
.code-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 8px; }

/* Casilla con texto */
.check {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; color: var(--ink-soft);
  margin-bottom: 14px; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.check small { font-weight: 400; color: var(--muted); }

/* Opciones de radio en tarjetas */
.radio-opts { display: flex; flex-direction: column; gap: 8px; }
/* .radio-opts delante para ganarle a ".form-row label" (display:block) */
.radio-opts .radio-opt {
  display: flex; align-items: center; gap: 12px; margin: 0;
  padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.radio-opt:hover { border-color: var(--accent); }
.radio-opts .radio-opt input {
  width: 18px; height: 18px; padding: 0; border: none; background: none;
  accent-color: var(--accent); flex-shrink: 0;
}
.radio-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.radio-opt .t { font-size: 14.5px; font-weight: 700; }
.radio-opt .s { font-size: 12.5px; color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 10px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.modal.wide { max-width: 680px; }

/* =============================================================================
   TÚNELES VPN
   ========================================================================== */
.tun { padding: 0; overflow: hidden; }
.tun.on { border-color: #86efac; }
.tun-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; }
.tun-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 7px;
  background: #d4d4d4;
}
.tun.on .tun-dot { background: var(--ok); animation: livePulse 2s infinite; }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.45); }
  50%      { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}
.tun-main { flex: 1; min-width: 0; }
.tun-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 700; font-size: 16px; }
.tun-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tun-sub > span { white-space: nowrap; }   /* corta entre bloques, nunca dentro de una IP */
.tun .detail { min-width: 0; }
.tun .dv.mono { font-size: 14px; }
.tun .dv { display: flex; align-items: center; gap: 4px; min-width: 0; }
.tun .dv > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tun-routes { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 12px 20px 0; }
.tun-routes .lbl { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.tun-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 14px 20px 16px;
}
.tun-actions .spacer { flex: 1; }

.route-row .t { font-size: 14.5px; }
.route-form { grid-template-columns: 1.3fr 1fr auto; align-items: end; }
.route-form .btn { height: 48px; }
.api-ok { text-align: center; }
.api-ok .big { font-size: 20px; font-weight: 800; margin-top: 4px; }

/* =============================================================================
   INICIO: un cuadro por equipo (túnel VPN / MikroTik) con su voltaje DC y sus
   pings. Los pings los hace el MikroTik del equipo por el API.
   ========================================================================== */
.home-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 14px; }
.home-hora { font-size: 13px; color: var(--muted); min-width: 0; }

.dev .card-head { margin-bottom: 4px; }
.dev-name { min-width: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev .chip { flex-shrink: 0; }
.dev.ok  { border-color: #86efac; }
.dev.err { border-color: #fecaca; }
.dev.off { background: var(--line-soft); }
.dev-volt { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.dev-volt-num {
  display: inline-flex; align-items: center; min-height: 52px;
  font-size: 44px; font-weight: 800; letter-spacing: -1px; color: var(--faint);
}
.dev.ok .dev-volt-num { color: var(--ink); }
.dev-volt-lbl { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.dev-msg { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.dev-msg:empty { display: none; }
.dev.err .dev-msg { color: var(--danger); }
.dev-edad { font-size: 12px; color: var(--faint); margin-top: 4px; }
.dev-edad:empty { display: none; }
.dev-edad.vieja, .home-hora.warn { color: var(--warn); font-weight: 600; }   /* el cron no está leyendo */

.ping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 10px; margin-top: 16px; }
.ping {
  display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  padding: 10px 12px; font: inherit; color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s;
  touch-action: manipulation; user-select: none;   /* doble toque para editar, sin zoom */
}
.ping:hover { border-color: #d4d4d4; }
.ping-ic {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--line-soft); color: var(--faint);
}
.ping-txt { min-width: 0; display: flex; flex-direction: column; }
.ping-name { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* «Hace 13 horas»: tiempo en el estado actual (se reinicia al cambiar) */
.ping-desde { font-size: 11.5px; font-weight: 600; color: var(--faint); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ping-desde:empty { display: none; }
/* Responde: verde con ✓ */
.ping.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.ping.ok .ping-ic { background: rgba(255,255,255,.22); color: #fff; }
.ping.ok .ping-desde { color: rgba(255,255,255,.85); }
/* No responde: gris con ✗ */
.ping.no { background: #e5e5e5; border-color: #d4d4d4; color: var(--muted); }
.ping.no .ping-ic { background: #a3a3a3; color: #fff; }
.ping.no .ping-desde { color: var(--muted); }
/* Agregar un ping */
.ping.add { justify-content: center; border-style: dashed; background: transparent; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.ping.add:hover { border-color: var(--accent); color: var(--accent); }

/* Comando de la planta: el PoE del ether5 del MikroTik */
.planta {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px;
  margin-top: 14px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--line-soft);
}
.planta-txt { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; font-weight: 700; }
.planta .pill-btn.apagar { background: var(--danger-soft); color: var(--danger); }
.planta .pill-btn.apagar:hover { background: #fee2e2; }

@media (max-width: 600px) {
  .dev-volt-num { font-size: 38px; min-height: 46px; }
}

/* =============================================================================
   TAREAS PROGRAMADAS
   ========================================================================== */
/* Interruptor: un checkbox con aspecto de palanca */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: #d4d4d4;
  pointer-events: none; transition: background .2s;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:has(input:disabled) { cursor: not-allowed; opacity: .55; }

/* Opciones en línea (30 s | 1 min | 5 min) */
.seg {
  display: inline-flex; gap: 2px; padding: 3px; flex-shrink: 0;
  border-radius: 10px; background: var(--line-soft); border: 1px solid var(--line);
}
.seg button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 60px; height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background .15s, color .15s;
}
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--accent-dark); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button:disabled { cursor: not-allowed; }

.tarea-head { display: flex; align-items: center; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.tarea-tit { flex: 1; min-width: 0; }
.tarea-tit h3 { font-size: 16px; font-weight: 700; }
.tarea-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tarea .notice { margin: 14px 0 0; }
.tarea-aviso { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tarea-aviso-btn:empty { display: none; }
.tarea-aviso .btn { margin-top: 0; }
.tarea-error { font-size: 12.5px; overflow-wrap: anywhere; }
.tarea-acciones { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; }
.cmd { white-space: nowrap; }   /* un comando no se parte en el guion de «-e» */

@media (max-width: 600px) {
  .tarea-frec { flex-direction: column; align-items: stretch; }
  .tarea-frec .seg { display: flex; }
  .tarea-frec .seg button { flex: 1; }
}
@media (max-width: 360px) {
  .cmd { white-space: normal; }   /* en pantallas muy angostas no cabe entero */
}

/* ----- Responsivo: tablets y móviles ----- */
@media (max-width: 600px) {
  .container { padding: 18px 14px; }

  /* Login centrado en móvil */
  .login-wrap { justify-content: center; }
  .login-col { margin-right: 0; max-width: 100%; }
  .login-card { padding: 34px 22px 26px; }

  /* Barra superior: solo avatar, sin nombre */
  .topbar { padding: 10px 12px 0; }
  .topbar .brand-logo { height: 34px; }
  .topbar .user .info { display: none; }

  /* Navegación: ítems repartidos a lo ancho */
  .top-nav { gap: 2px; }
  .nav-item { flex: 1 1 0; min-width: 0; padding: 8px 4px 9px; font-size: 10.5px; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-item.active::after { left: 6px; right: 6px; }

  .view-title { font-size: 20px; }
  .view-sub { font-size: 13.5px; }

  .card { padding: 16px; }
  .hero { padding: 22px 20px; }
  .hero .big { font-size: 28px; }

  .detail-grid { grid-template-columns: 1fr; }
  .detail:nth-child(odd) { border-right: none; }

  /* Formularios y túneles */
  .form-grid, .route-form { grid-template-columns: 1fr; }
  .route-form .btn { width: 100%; }
  .tun-head { padding: 16px 16px 12px; }
  .tun-routes { padding: 12px 16px 0; }
  .tun-actions { padding: 12px 16px 14px; }
  .tun .detail { padding: 12px 16px; }
  .tun .detail-grid { grid-template-columns: 1fr 1fr; }
  .tun .detail:nth-child(odd) { border-right: 1px solid var(--line-soft); }
}

/* Teléfonos: usuario y contraseña del túnel en una columna para que quepan */
@media (max-width: 420px) {
  .tun .detail-grid { grid-template-columns: 1fr; }
  .tun .detail:nth-child(odd) { border-right: none; }
}

@media (max-width: 380px) {
  .container { padding: 16px 12px; }
  .nav-item { font-size: 10px; padding: 8px 2px 9px; }
  .nav-item svg { width: 19px; height: 19px; }
  .hero .big { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .login-wrap::before { opacity: 1; }
}
