:root{
  --bg-canvas:#0d1117;
  --bg-surface:#151b23;
  --bg-surface-2:#1c232d;
  --border:#2a323d;
  --text:#e6edf3;
  --text-dim:#8b98a5;
  --accent:#5b8def;
  --accent-soft:rgba(91,141,239,0.14);
  --teal:#2dd4bf;
  --teal-soft:rgba(45,212,191,0.14);
  --warn:#f0655a;
  --warn-soft:rgba(240,101,90,0.14);
  --gold:#e8a33d;
  --mono:'JetBrains Mono','SF Mono','Courier New',monospace;
  --sans:-apple-system,'Segoe UI',Roboto,Inter,Arial,sans-serif;
  --radius:12px;
}
*{ box-sizing:border-box; margin:0; padding:0; }
body{
  font-family:var(--sans); color:var(--text); background:var(--bg-canvas);
  min-height:100vh;
}
svg{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

/* ================= LOGIN ================= */
/* Fondo: degradados azul/cian que hacen eco del logo (escudo de circuito) + una textura de
   circuito muy tenue de fondo — nunca compite con la tarjeta, solo da profundidad y contexto
   ("consola de sistemas/infraestructura"), sin caer en ruido visual. */
.login-screen{
  min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;
  position:relative; overflow:hidden;
  background:
    radial-gradient(1000px 560px at 18% -5%, rgba(91,141,239,0.16), transparent 60%),
    radial-gradient(800px 560px at 88% 100%, rgba(45,212,191,0.12), transparent 55%),
    radial-gradient(1200px 800px at 50% 50%, rgba(20,30,45,0.6), transparent 70%),
    var(--bg-canvas);
}
.login-screen::before{
  content:''; position:absolute; inset:0; opacity:0.05; pointer-events:none;
  background-image:
    linear-gradient(rgba(91,141,239,0.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,141,239,0.5) 1px, transparent 1px);
  background-size:42px 42px;
  mask-image:radial-gradient(circle at 50% 40%, black, transparent 75%);
}

.login-card{
  width:100%; max-width:380px; position:relative; z-index:1;
  background:linear-gradient(180deg, #151b23, #0c1015);
  border-radius:18px; padding:34px 28px;
  border:1px solid rgba(91,141,239,0.3);
  box-shadow:0 30px 70px rgba(0,0,0,0.55), 0 0 55px -18px rgba(45,212,191,0.4), 0 0 0 1px rgba(91,141,239,0.05), inset 0 1px 0 rgba(255,255,255,0.03);
  transform:translateY(-7vh); /* sube la tarjeta del centro exacto: se veía con demasiado aire arriba en móvil */
}

.login-brand{ display:flex; flex-direction:column; align-items:center; gap:14px; margin-bottom:26px; padding-bottom:22px;
  border-bottom:1px solid var(--border); text-align:center; }
.login-subtitle{ font-size:11.5px; color:var(--text-dim); font-family:var(--mono); letter-spacing:0.4px; }

/* Halo pulsante detrás del logo — el "latido" de un sistema de monitoreo en vivo. Es la única
   animación de la pantalla (deliberada, no decorativa de sobra) y refuerza qué es Aria: algo
   que vigila sistemas de forma continua, no un logo estático más. */
.logo-halo{ position:relative; display:flex; align-items:center; justify-content:center; }
.logo-halo::before{
  content:''; position:absolute; width:196px; height:196px; border-radius:50%;
  background:radial-gradient(circle, rgba(45,212,191,0.35), rgba(91,141,239,0.18) 55%, transparent 75%);
  filter:blur(6px);
  animation:logoPulse 3.2s ease-in-out infinite;
}
@keyframes logoPulse{
  0%,100%{ transform:scale(0.92); opacity:0.55; }
  50%{ transform:scale(1.08); opacity:0.95; }
}
.logo-img{ position:relative; width:158px; height:auto; object-fit:contain; filter:drop-shadow(0 4px 20px rgba(91,141,239,0.45)); }
.sidebar-logo-img{ width:34px; height:34px; }

.login-form{ display:flex; flex-direction:column; gap:14px; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field span{ font-size:11px; color:var(--text-dim); font-family:var(--mono); }
.field input{ height:42px; border-radius:9px; border:1px solid var(--border); background:var(--bg-surface-2);
  color:var(--text); padding:0 13px; font-size:13.5px; outline:none; transition:border-color .15s ease, box-shadow .15s ease; }
.field input:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.btn-primary{ height:42px; border-radius:9px; border:none; background:linear-gradient(135deg, var(--accent), #4a9ee0); color:#fff;
  font-weight:700; font-size:13.5px; cursor:pointer; transition:filter .15s ease, transform .15s ease; }
.btn-primary:hover{ filter:brightness(1.08); transform:translateY(-1px); }
.btn-ghost{ height:38px; border-radius:9px; border:1px solid var(--border); background:transparent;
  color:var(--text-dim); font-size:12.5px; cursor:pointer; transition:all .15s ease; }
.btn-ghost:hover{ border-color:var(--warn); color:var(--warn); }
.login-error{ display:none; color:var(--warn); background:var(--warn-soft); border:1px solid rgba(240,101,90,0.3);
  border-radius:8px; padding:9px 12px; font-size:12px; text-align:center; }

@media (prefers-reduced-motion: reduce){
  .logo-halo::before{ animation:none; opacity:0.7; }
}
.login-footnote{ margin-top:20px; text-align:center; font-size:11px; color:var(--text-dim); font-family:var(--mono); }

/* ================= SHELL ================= */
.app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width:230px; flex-shrink:0; background:var(--bg-surface); border-right:1px solid var(--border);
  display:flex; flex-direction:column; padding:18px 14px; position:sticky; top:0; height:100vh;
}
.mobile-menu-toggle{
  display:none; background:none; border:none; color:var(--text); width:32px; height:32px;
  cursor:pointer; align-items:center; justify-content:center; border-radius:6px; flex-shrink:0;
}
.mobile-menu-toggle svg{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; }
.mobile-menu-toggle:hover{ background:var(--bg-surface-2); }
.sidebar-collapsible{ display:contents; }
.mobile-drawer-backdrop{ display:none; }
.sidebar-brand{ display:flex; align-items:center; gap:10px; padding:0 6px 20px; margin-bottom:14px; border-bottom:1px solid var(--border); }
.brand-text{ display:flex; flex-direction:column; line-height:1.25; }
.brand-text strong{ font-size:14.5px; letter-spacing:0.3px; }
.brand-text span{ font-size:10.5px; color:var(--text-dim); font-family:var(--mono); }

.sidebar-nav{ display:flex; flex-direction:column; gap:3px; flex:1; }
.nav-item{
  display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:8px; border:none;
  background:none; color:var(--text-dim); font-size:13px; font-weight:600; cursor:pointer;
  text-align:left; border-left:2px solid transparent; transition:all .15s ease;
}
.nav-item svg{ width:17px; height:17px; flex-shrink:0; }
.nav-item:hover{ background:var(--bg-surface-2); color:var(--text); }
.nav-item.active{ background:var(--accent-soft); color:var(--accent); border-left-color:var(--accent); }

.sidebar-footer{ display:flex; flex-direction:column; gap:10px; padding-top:14px; border-top:1px solid var(--border); }
.user-card{ display:flex; align-items:center; gap:10px; }
.user-avatar{
  width:34px; height:34px; border-radius:50%; flex-shrink:0; display:grid; place-items:center;
  background:linear-gradient(135deg,var(--teal),#1a9e8f); color:#04201c; font-weight:800; font-size:12.5px;
}
.user-meta{ display:flex; flex-direction:column; gap:3px; min-width:0; }
.user-meta strong{ font-size:12.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.role-badge{
  font-size:9.5px; font-family:var(--mono); text-transform:uppercase; letter-spacing:0.5px;
  padding:2px 7px; border-radius:999px; width:fit-content;
}
.role-badge.administrador{ background:var(--accent-soft); color:var(--accent); }
.role-badge.tecnico{ background:var(--teal-soft); color:var(--teal); }
.role-badge.consulta{ background:rgba(139,152,165,0.14); color:var(--text-dim); }

/* ================= MAIN ================= */
.main-content{ flex:1; min-width:0; padding:22px 28px 40px; max-width:980px; }
.content-topbar{ display:flex; align-items:center; justify-content:space-between; margin-bottom:22px; }
.content-topbar h2{ font-size:19px; font-weight:800; letter-spacing:0.2px; }
.topbar-status{ display:flex; align-items:center; gap:7px; font-size:11.5px; color:var(--text-dim); font-family:var(--mono); }
.status-dot{ width:7px; height:7px; border-radius:50%; background:var(--teal); box-shadow:0 0 6px var(--teal); }
.alert-badge{
  background:var(--warn-soft); color:var(--warn); border:1px solid rgba(240,101,90,0.3);
  border-radius:999px; padding:3px 10px; font-size:11px; font-weight:700;
}

.view{ display:none; }
.view.active{ display:block; }
.view-subtitle{ color:var(--text-dim); font-size:12.5px; margin-bottom:18px; }

/* ---- Chat ---- */
.quick-actions{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.chip{
  border:1px solid var(--border); background:var(--bg-surface); color:var(--text);
  font-size:12.5px; padding:8px 14px; border-radius:999px; cursor:pointer; transition:all .15s ease;
}
.chip:hover{ border-color:var(--accent); background:var(--accent-soft); }
.chip.locked{ opacity:.4; cursor:not-allowed; }
.chip.add-chip{ border-style:dashed; color:var(--teal); }

.chat-panel{ background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px; }
.messages{ min-height:320px; max-height:480px; overflow-y:auto; display:flex; flex-direction:column; gap:12px; padding:4px; }
.empty-hint{ margin:auto; color:var(--text-dim); font-size:12.5px; font-family:var(--mono); text-align:center; }

.msg-row{ display:flex; gap:10px; max-width:82%; }
.msg-row.user{ align-self:flex-end; flex-direction:row-reverse; }
.msg-avatar{
  width:26px; height:26px; border-radius:50%; flex-shrink:0; display:grid; place-items:center;
  font-size:10.5px; font-weight:800; margin-top:2px;
}
.msg-row.assistant .msg-avatar{ background:linear-gradient(135deg,var(--accent),#3a63c4); color:#fff; }
.msg-row.user .msg-avatar{ background:linear-gradient(135deg,var(--teal),#1a9e8f); color:#04201c; }
.msg-bubble{ padding:11px 14px; border-radius:12px; font-size:13.5px; line-height:1.5; word-break:break-word; }
.msg-row.assistant .msg-bubble{ background:var(--bg-surface-2); border:1px solid var(--border); }
.msg-row.user .msg-bubble{ background:var(--accent-soft); border:1px solid rgba(91,141,239,0.25); }
.msg-bubble a{ color:var(--teal); text-decoration:underline; word-break:break-all; }
.msg-bubble a:visited{ color:var(--teal); opacity:0.85; }

.confirm-bar{
  display:none; align-items:center; justify-content:space-between; gap:12px; margin-top:12px;
  background:rgba(232,163,61,0.1); border:1px solid rgba(232,163,61,0.35); border-radius:9px;
  padding:11px 14px; font-size:12.5px; color:var(--gold); font-family:var(--mono);
}
.confirm-bar button{ background:var(--teal); color:#04201c; border:none; border-radius:6px; padding:6px 13px; font-weight:700; cursor:pointer; flex-shrink:0; }

.composer{ display:flex; align-items:center; gap:9px; margin-top:14px; }
.mic-btn{
  width:40px; height:40px; border-radius:9px; border:1px solid var(--border); background:var(--bg-surface-2);
  color:var(--text-dim); display:grid; place-items:center; cursor:pointer; flex-shrink:0; transition:all .15s ease;
}
.mic-btn:hover{ border-color:var(--accent); color:var(--accent); }
.mic-btn.listening{ border-color:var(--teal); color:var(--teal); background:var(--teal-soft); animation:pulse 1.2s ease-in-out infinite; }
@keyframes pulse{ 0%,100%{box-shadow:0 0 0 0 rgba(45,212,191,0.35);} 50%{box-shadow:0 0 0 6px rgba(45,212,191,0);} }
.text-input{
  flex:1; min-width:0; height:40px; border-radius:9px; border:1px solid var(--border); background:var(--bg-surface-2);
  color:var(--text); padding:0 14px; font-size:13.5px; outline:none;
}
.text-input:focus{ border-color:var(--accent); }
.composer-send-row{ display:flex; justify-content:center; margin-top:10px; }
.btn-send{
  display:flex; align-items:center; justify-content:center; gap:8px;
  width:min(320px, 100%); height:44px; font-size:14px; font-weight:700; letter-spacing:0.2px;
  box-shadow:0 6px 18px rgba(91,141,239,0.35);
}
.btn-send svg{ width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.btn-send:hover{ box-shadow:0 8px 22px rgba(91,141,239,0.45); transform:translateY(-1px); }
.mic-status{ margin-top:8px; font-size:11px; color:var(--text-dim); font-family:var(--mono); min-height:14px; }
.attach-chip{
  display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text);
  background:var(--bg-surface-2); border:1px solid var(--border); border-radius:999px;
  padding:6px 12px; margin-bottom:8px; width:fit-content;
}
.attach-chip button{ background:none; border:none; color:var(--text-dim); cursor:pointer; font-size:14px; }

/* ---- Servicios ---- */
.services-grid-full{ display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:12px; }
.service-card-full{ background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius); padding:16px; }
.service-card-full .head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.service-card-full .name{ font-size:13.5px; font-weight:700; text-transform:capitalize; }
.service-card-full .dot{ width:8px; height:8px; border-radius:50%; background:var(--text-dim); }
.service-card-full .dot.online{ background:var(--teal); box-shadow:0 0 6px var(--teal); }
.service-card-full .dot.offline{ background:var(--warn); }
.service-card-full .status-text{ font-size:11.5px; color:var(--text-dim); font-family:var(--mono); }

/* ---- Admin / Config paneles ---- */
.panel-card{ background:var(--bg-surface); border:1px solid var(--border); border-radius:var(--radius); padding:18px; margin-bottom:16px; }
.panel-card h3{ font-size:13.5px; margin-bottom:14px; }

.admin-tabla{ display:flex; flex-direction:column; gap:8px; }
.admin-fila{ display:flex; flex-direction:column; gap:8px;
  background:var(--bg-surface-2); border:1px solid var(--border); border-radius:8px; padding:10px 13px; }
.admin-fila-top{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.admin-fila .info{ display:flex; flex-direction:column; gap:2px; }
.admin-fila .correo{ font-size:12.5px; font-family:var(--mono); }
.admin-fila .meta{ font-size:11px; color:var(--text-dim); }
.admin-fila .nc-estado{ color:var(--teal); }
.admin-fila-acciones{ display:flex; gap:8px; flex-wrap:wrap; }
.admin-fila button{ background:none; border:1px solid var(--warn); color:var(--warn); border-radius:6px;
  padding:5px 10px; font-size:11px; cursor:pointer; flex-shrink:0; }
.admin-fila .btn-nc-toggle, .admin-fila .btn-nc-quitar{ border-color:var(--teal); color:var(--teal); }
.admin-fila .nc-inline-form{ margin-top:2px; }
.admin-fila .nc-inline-form .btn-primary{ border:none; }

.admin-form{ display:flex; flex-wrap:wrap; gap:10px; }
.admin-form input, .admin-form select{
  height:38px; border-radius:8px; border:1px solid var(--border); background:var(--bg-surface-2);
  color:var(--text); padding:0 11px; font-size:12.5px; outline:none; flex:1; min-width:160px;
}
.admin-form .btn-primary{ flex-basis:100%; }
.admin-msg{ margin-top:10px; font-size:12px; font-family:var(--mono); color:var(--teal); }
.admin-msg.error{ color:var(--warn); }

.settings-row{ display:flex; align-items:center; justify-content:space-between; gap:14px; padding:11px 0;
  border-bottom:1px solid var(--border); font-size:12.5px; color:var(--text-dim); }
.settings-row:last-of-type{ border-bottom:none; }
.settings-row input[type=number]{ width:66px; background:var(--bg-surface-2); border:1px solid var(--border);
  border-radius:7px; color:var(--text); padding:5px 8px; font-size:12px; }
.settings-row input[type=checkbox]{ width:16px; height:16px; accent-color:var(--accent); }
.settings-row select{ background:var(--bg-surface-2); border:1px solid var(--border); border-radius:7px;
  color:var(--text); padding:5px 8px; font-size:12px; max-width:180px; }

/* ================= RESPONSIVE ================= */
@media (max-width:820px){
  .app-shell{ flex-direction:column; }

  /* La barra lateral pasa a ser una barra superior FINA y fija — solo botón de menú,
     logo/marca y el estado del sistema. Nada de aplastar navegación + usuario ahí
     (eso era lo que se veía roto: texto cortado, botón de salir fuera de pantalla). */
  .sidebar{
    width:100%; height:auto; position:sticky; top:0; z-index:50;
    flex-direction:row; align-items:center; padding:10px 14px; gap:10px;
    border-right:none; border-bottom:1px solid var(--border);
  }
  .mobile-menu-toggle{ display:flex; }
  .sidebar-brand{ border-bottom:none; padding:0; margin:0; flex:1; min-width:0; }
  .sidebar-brand .brand-text span{ display:none; } /* se oculta "GestionIT" para dar aire; "Aria" solo basta */

  /* Todo lo demás (navegación + cuenta + cerrar sesión) vive en un panel desplegable
     con TODO el ancho y alto que necesite — no compite por espacio con el logo. */
  .sidebar-collapsible{
    display:none;
    position:fixed; top:56px; left:0; right:0; z-index:49;
    flex-direction:column; gap:4px;
    background:var(--bg-surface); border-bottom:1px solid var(--border);
    padding:10px 14px 18px; max-height:calc(100vh - 56px); overflow-y:auto;
    box-shadow:0 16px 32px rgba(0,0,0,0.45);
  }
  .sidebar-collapsible.mobile-open{ display:flex; }

  .mobile-drawer-backdrop.mobile-open{
    display:block; position:fixed; inset:0; top:56px; z-index:48; background:rgba(0,0,0,0.55);
  }

  .sidebar-nav{ flex-direction:column; gap:2px; }
  .nav-item{ border-left:2px solid transparent; border-bottom:none; padding:13px 12px; white-space:normal; }
  .nav-item span{ display:inline; } /* etiquetas completas de vuelta: acá SÍ hay espacio */
  .nav-item.active{ border-bottom-color:transparent; }

  .sidebar-footer{
    flex-direction:column; align-items:stretch; border-top:1px solid var(--border);
    margin-top:8px; padding-top:14px; gap:10px;
  }
  .user-meta{ display:flex; max-width:none; }
  .user-meta strong{ font-size:14px; }
  .user-meta .role-badge{ display:inline-block; }
  .sidebar-footer .btn-ghost{ display:block; width:100%; text-align:center; padding:11px; font-size:13px; }

  .main-content{ padding:18px 16px 90px; max-width:100%; }
  .services-grid-full{ grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); }
  .content-topbar{ flex-wrap:wrap; gap:8px; }
}
