/* ============================================================
   IANA — Plataforma Unificada Infotek
   style.css — design system (basado en el Access Point)
   ============================================================ */

:root {
  --primary:       #1e293b;
  --primary-hover: #334155;
  --navy:          #153148;
  --navy-hover:    #1F4158;
  --navy-subtle:   rgba(21,49,72,.08);
  --accent:        #F97316;
  --accent-hover:  #fb923c;
  --accent-subtle: rgba(249,115,22,.08);
  --accent-glow:   rgba(249,115,22,.2);
  --cyan:          #06B6D4;
  --user-blue:     #1a3d7c;   /* burbuja usuario (Chat Style) */
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --bg:            #f3f5f8;
  --card-bg:       #FFFFFF;
  --border:        #cbd5e1;
  --border-light:  #f1f5f9;
  --text:          #1E293B;
  --muted:         #64748B;
  --header-bg:     #f8fafc;
  --input-border:  #cbd5e1;

  --radius-card:   12px;
  --radius-btn:    8px;
  --radius-input:  8px;
  --shadow-card:   0 1px 3px rgba(0,0,0,.04), 0 0 0 1px var(--border);
  --shadow-md:     0 4px 14px rgba(0,0,0,.06);
  --transition:    0.25s cubic-bezier(0.4, 0, 0.2, 1);

  --font: 'Inter', 'Segoe UI', 'Roboto', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
img, svg { display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 0.875rem; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 248px 1fr;
  grid-template-areas: "header header" "sidebar main";
  min-height: 100vh;
}

.app-header {
  grid-area: header;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 3px solid var(--accent);
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 18px;
  box-shadow: var(--shadow-md);
}

.header-brand { display: flex; align-items: center; gap: 0.625rem; }
.header-logo { height: 38px; width: auto; object-fit: contain; flex-shrink: 0; }
.header-brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1; }
.header-brand-name { font-size: 1rem; font-weight: 800; color: var(--text); letter-spacing: -0.01em; }
.header-brand-sub { font-size: 0.65rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.12em; }

.header-right { display: flex; align-items: center; gap: 1rem; }
.hostname-badge { font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 0.375rem; }

.connection-badge {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.25rem 0.625rem; border-radius: 999px;
  background: var(--header-bg); border: 1px solid var(--border); color: var(--muted);
}
.connection-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.connection-badge.connected { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.3); color: var(--text); }
.connection-badge.connected .dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.connection-badge.disconnected { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3); color: var(--text); }
.connection-badge.disconnected .dot { background: var(--danger); }

.hamburger { display: none; background: none; border: none; color: var(--text); padding: 0.25rem; }

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 1rem 0;
  position: sticky; top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto; z-index: 100;
  transition: transform var(--transition);
}
.sidebar-nav { flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--muted); cursor: pointer;
  font-size: 0.875rem; font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent; user-select: none;
}
.nav-item:hover { color: var(--text); background: var(--accent-subtle); }
.nav-item.active { color: var(--accent); background: var(--accent-subtle); border-left-color: var(--accent); font-weight: 600; }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.nav-item .nav-count {
  margin-left: auto; font-size: 0.68rem; font-weight: 700;
  background: var(--border-light); color: var(--muted);
  padding: 0.1rem 0.45rem; border-radius: 999px;
}
.nav-section-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); opacity: .5;
  padding: 0.5rem 1.25rem 0.25rem; margin-top: 0.5rem;
}

/* ---- Main ---- */
.main-content { grid-area: main; padding: 1.5rem; overflow-y: auto; min-width: 0; }
.section { display: none; }
.section.active { display: block; animation: fadeIn .2s ease; }
.section-title {
  font-size: 1.25rem; font-weight: 700; color: var(--navy);
  margin-bottom: 1.25rem; display: flex; align-items: center; gap: 0.5rem;
}
.section-title .section-sub { font-size: 0.78rem; font-weight: 500; color: var(--muted); margin-left: auto; }

/* ============================================================
   CARDS
   ============================================================ */
.card { background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--navy); margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.card-title small { font-size: 0.72rem; font-weight: 500; color: var(--muted); margin-left: auto; }

/* ============================================================
   STAT GRID
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.375rem; }
.stat-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--navy); line-height: 1.2; word-break: break-all; }
.stat-sub { font-size: 0.75rem; color: var(--muted); }

/* ============================================================
   BADGES
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.7rem; font-weight: 700; padding: 0.2rem 0.5rem; border-radius: 999px; }
.badge-success { background: rgba(16,185,129,.12); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-cyan    { background: rgba(6,182,212,.12);  color: var(--cyan); }
.badge-gray    { background: var(--border-light);  color: var(--muted); }
.badge-primary { background: var(--accent-subtle); color: var(--accent); }
.badge-info    { background: rgba(21,49,72,.12);   color: #153148; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 1.1rem; border-radius: var(--radius-btn);
  font-size: 0.875rem; font-weight: 600; border: 2px solid transparent;
  transition: all var(--transition); cursor: pointer; white-space: nowrap;
  position: relative; overflow: hidden; outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--accent-glow); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--header-bg); }
.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.btn.loading { pointer-events: none; opacity: .8; }
.btn-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.loading .btn-spinner { display: inline-block; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 0.375rem; }
.form-hint { display: block; font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; }
.form-control {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--input-border); border-radius: var(--radius-input);
  background: #fff; color: var(--text); font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition); outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-input) 0 0 var(--radius-input); flex: 1; }
.input-group .btn-addon {
  border-radius: 0 var(--radius-input) var(--radius-input) 0;
  border: 1px solid var(--input-border); border-left: none;
  background: var(--header-bg); color: var(--muted);
  padding: 0.5rem 0.75rem; font-size: 0.78rem; font-weight: 600;
}
.input-group .btn-addon:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-group { margin-bottom: 1rem; }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.375rem; }
.progress-label { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.progress-value { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.progress-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--navy); transition: width 0.5s ease; }
.progress-bar.warn { background: var(--warning); }
.progress-bar.crit { background: var(--danger); }
.progress-bar.cyan { background: var(--cyan); }

/* ============================================================
   QUICK ACCESS TILES (dashboard)
   ============================================================ */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.tile-grid-big { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.tile {
  background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem;
  cursor: pointer; transition: all var(--transition); border: 1px solid transparent;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent-subtle); color: var(--accent); }
.tile-icon svg { width: 22px; height: 22px; }
.tile-name { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.tile-desc { font-size: 0.75rem; color: var(--muted); }

/* Big tiles for Inicio */
.tile.tile-big {
  padding: 1.5rem 1.75rem; gap: 0.65rem;
  background: linear-gradient(135deg, var(--card-bg) 0%, rgba(245,250,255,1) 100%);
  border: 1px solid var(--border-light);
}
.tile.tile-big:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(21,49,72,0.12);
  background: linear-gradient(135deg, #fff 0%, rgba(240,248,255,1) 100%);
}
.tile.tile-big .tile-icon {
  width: 48px; height: 48px; border-radius: 12px;
}
.tile.tile-big .tile-icon svg { width: 26px; height: 26px; }
.tile.tile-big .tile-name { font-size: 1.1rem; font-weight: 800; }
.tile.tile-big .tile-desc {
  font-size: 0.82rem; line-height: 1.45; color: var(--text);
  opacity: 0.75;
}

/* ============================================================
   SERVICES & NODES
   ============================================================ */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.entity-card {
  background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem;
  border-left: 3px solid var(--border);
}
.entity-card.online { border-left-color: var(--success); }
.entity-card.offline { border-left-color: var(--danger); }
.entity-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.entity-name { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.entity-meta { font-size: 0.72rem; color: var(--muted); font-family: 'Courier New', monospace; }
.entity-desc { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.entity-foot { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }

/* ============================================================
   DASHBOARD CHART PANELS
   ============================================================ */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.chart-panel { background: var(--card-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1.25rem; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.75rem; }
.chart-title { font-size: 0.9rem; font-weight: 700; color: var(--navy); }
.chart-current { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.chart-current small { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.chart-svg { width: 100%; height: 120px; display: block; }

/* ============================================================
   CHAT IANA
   ============================================================ */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 56px - 3rem);
  background: var(--card-bg); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.chat-head {
  background: var(--navy); color: #fff;
  padding: 0.75rem 1.25rem; display: flex; align-items: center; gap: 0.75rem;
}
.chat-head-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; flex-shrink: 0; }
.chat-head-info { display: flex; flex-direction: column; line-height: 1.2; }
.chat-head-title { font-size: 0.95rem; font-weight: 700; }
.chat-head-sub { font-size: 0.72rem; opacity: .8; }
.chat-head-status { margin-left: auto; font-size: 0.72rem; display: flex; align-items: center; gap: 0.35rem; }
.chat-head-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 6px var(--success); }
.chat-head-status.off .dot { background: var(--danger); box-shadow: none; }

.chat-body { flex: 1; overflow-y: auto; padding: 1.25rem; background: #edf1f5; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg { max-width: 78%; border-radius: 14px; padding: 0.6rem 0.9rem; line-height: 1.45; font-size: 0.9rem; box-shadow: 0 2px 6px rgba(0,0,0,.05); white-space: pre-wrap; word-wrap: break-word; }
.chat-msg.user { background: var(--user-blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg.bot { background: var(--accent); color: #fff; align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.error { background: #fff; color: var(--danger); border: 1px solid rgba(239,68,68,.3); align-self: flex-start; }
.chat-msg-time { display: block; font-size: 0.62rem; opacity: .7; margin-top: 0.25rem; }

.chat-typing { align-self: flex-start; background: var(--accent); border-radius: 14px; padding: 0.7rem 0.95rem; display: inline-flex; gap: 4px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: .6; animation: typing 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing { 0%,60%,100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-5px); opacity:1; } }

.chat-input-bar { display: flex; gap: 0.5rem; padding: 0.75rem; background: #fff; border-top: 1px solid var(--border-light); }
.chat-input-bar textarea {
  flex: 1; resize: none; max-height: 120px;
  padding: 0.6rem 0.9rem; border: 1px solid var(--input-border); border-radius: 12px;
  font-size: 0.9rem; line-height: 1.4; outline: none; transition: border-color var(--transition);
}
.chat-input-bar textarea:focus { border-color: var(--accent); }
.chat-send {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 12px; border: none;
  background: var(--user-blue); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.chat-send:hover { background: #14306a; }
.chat-send:disabled { opacity: .5; pointer-events: none; }

/* ============================================================
   LOG / TERMINAL
   ============================================================ */
.log-box { background: #0f1923; border-radius: 8px; padding: 1rem; font-family: 'Courier New', monospace; font-size: 0.78rem; color: #a8c4d4; max-height: 240px; overflow-y: auto; line-height: 1.6; }
.log-box .log-line { display: flex; gap: 0.75rem; }
.log-box .log-time { color: #4a6b80; flex-shrink: 0; }
.log-box .log-ok { color: var(--success); }
.log-box .log-err { color: var(--danger); }
.log-box .log-warn { color: var(--warning); }
.log-box .log-info { color: var(--cyan); }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container { position: fixed; top: 68px; right: 1rem; z-index: 10001; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; max-width: 340px; width: 100%; }
.toast { display: flex; align-items: flex-start; gap: 0.625rem; background: #fff; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15); padding: 0.75rem 1rem; pointer-events: all; animation: toastIn .25s ease forwards; border-left: 4px solid var(--accent); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 0.82rem; font-weight: 700; color: var(--text); }
.toast-msg { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; line-height: 1.4; }
.toast-close { background: none; border: none; color: var(--muted); font-size: 1rem; flex-shrink: 0; }
.toast.removing { animation: toastOut .2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,25,35,.65); backdrop-filter: blur(3px); z-index: 8000; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; animation: fadeIn .18s ease; }
.modal { background: var(--card-bg); border-radius: var(--radius-card); box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 1.75rem; max-width: 440px; width: 100%; }
.modal-icon { font-size: 2.5rem; text-align: center; margin-bottom: 0.75rem; }
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text); text-align: center; margin-bottom: 0.5rem; }
.modal-body { font-size: 0.875rem; color: var(--muted); text-align: center; line-height: 1.55; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ============================================================
   HELPERS
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
.loading-row { display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 2rem; color: var(--muted); font-size: 0.875rem; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3rem 1rem; color: var(--muted); text-align: center; gap: 0.75rem; }
.empty-state-text { font-size: 0.875rem; font-weight: 600; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.82rem; }
.font-mono { font-family: 'Courier New', monospace; }
.dot-online { color: var(--success); }
.dot-offline { color: var(--danger); }

/* ============================================================
   RESPONSIVE (PC horizontal / teléfono vertical)
   ============================================================ */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .sidebar { position: fixed; left: 0; top: 56px; bottom: 0; width: 248px; transform: translateX(-100%); z-index: 150; }
  .sidebar.open { transform: none; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; top: 56px; background: rgba(0,0,0,.4); z-index: 140; }
  .sidebar-overlay.visible { display: block; }
  .hamburger { display: flex; }
  .main-content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hostname-badge { display: none; }
  .chat-wrap { height: calc(100vh - 56px - 2rem); }
  .chat-msg { max-width: 88%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.1rem; }
  .header-brand-sub { display: none; }
}

/* ============================================================
   SUB-TABS & NETWORKING STYLES (FUSION)
   ============================================================ */
.tabs-nav {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 0.5rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: var(--radius-btn);
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn:hover {
  color: var(--text);
  background: var(--border-light);
}
.tab-btn.active {
  color: var(--accent);
  background: var(--accent-subtle);
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

.wifi-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--header-bg);
}
.wifi-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.wifi-item:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.wifi-item.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  font-weight: 600;
}
.wifi-signal {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dns-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
  background: var(--accent-subtle);
  border: 1px solid rgba(249,115,22,.2);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.dns-link-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy);
}
.dns-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.seg-nav {
  display: flex;
  gap: 0.25rem;
  background: var(--border-light);
  padding: 0.25rem;
  border-radius: var(--radius-btn);
  width: fit-content;
  margin-bottom: 1rem;
}
.seg-btn {
  background: transparent;
  border: none;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  transition: all var(--transition);
}
.seg-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ============================================================
   INICIO PILLARS & NAV ARROWS & PLANTA ANIMATION
   ============================================================ */

/* ---- Navigation Arrows ---- */
.header-nav-arrows {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.75rem;
}
.nav-arrow-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-arrow-btn:hover:not(:disabled) {
  background: var(--border-light);
  color: var(--text);
}
.nav-arrow-btn:disabled {
  color: var(--border);
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Inicio Pillars ---- */
.inicio-pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.pillar-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.pillar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.mini-status-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.mini-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-light);
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 0.82rem;
}
.mini-status-name {
  font-weight: 600;
  color: var(--navy);
}

/* ---- Mechanical Press Animation ---- */
.press-anim-container {
  background: var(--bg-light);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  border: 1px solid var(--border-light);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1rem;
}
.press-frame {
  width: 140px;
  height: 160px;
  background: #334155;
  border-radius: 8px;
  position: relative;
  border: 4px solid #1e293b;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
}
.press-bed {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: #475569;
  border-top: 4px solid #1e293b;
}
.press-die-bottom {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 15px;
  background: #64748b;
  border: 2px solid #1e293b;
  border-bottom: none;
}
.press-ram {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 70px;
  background: #94a3b8;
  border: 3px solid #1e293b;
  border-radius: 4px;
  transition: top 0.08s linear;
}
.press-die-top {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 10px;
  background: #64748b;
  border: 2px solid #1e293b;
}
.sparkle-hit {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 50px;
  height: 50px;
  background: radial-gradient(circle, rgba(239,68,68,0.8) 0%, rgba(245,158,11,0) 70%);
  border-radius: 50%;
  pointer-events: none;
  transition: transform 0.05s ease;
}
.sparkle-hit.active {
  transform: translateX(-50%) scale(1.4);
}
.press-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 1rem;
  font-size: 0.825rem;
  color: var(--text);
  border-top: 1px solid var(--border-light);
  padding-top: 0.75rem;
}

/* LED Indicators */
.led-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-weight: 500;
}
.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
  display: inline-block;
  transition: all var(--transition);
}
.led-indicator.on .led-dot {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}
.led-indicator.off .led-dot {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}
.led-indicator.warning .led-dot {
  background: var(--warning);
  box-shadow: 0 0 6px var(--warning);
}

/* ============================================================
   SEGURIDAD: LOGIN OVERLAY
   ============================================================ */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at top right, #0f172a, #020617);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.login-card {
  background: rgba(30, 41, 59, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2.5rem;
  border-radius: 16px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.login-logo {
  max-height: 50px;
  width: auto;
  object-fit: contain;
}
.login-title {
  margin: 0.5rem 0 0 0;
  font-size: 1.25rem;
  color: #f8fafc;
  font-weight: 700;
}
.login-subtitle {
  margin: 0 0 1.5rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* utilidades de ocultar/mostrar */
.hidden {
  display: none !important;
}

/* Sub-pestañas de Sistema */
.sys-tab-content {
  animation: fadeIn 0.25s ease;
}
#sys-tabs-nav .tab-btn.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}
.db-table-item {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  transition: all var(--transition);
  text-align: left;
  border: none;
  background: transparent;
}
.db-table-item:hover {
  background: var(--border-light);
  color: var(--text);
}
.db-table-item.active {
  background: var(--navy-subtle);
  color: var(--navy);
  font-weight: 600;
}

/* ── Planta: KPI tiles en la tarjeta resumen ── */
.planta-kpi-tile {
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 7px;
  padding: 0.45rem 0.25rem;
  text-align: center;
}
.planta-kpi-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}
.planta-kpi-lbl {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ── Planta: pills de fase del ciclo ── */
.fase-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-light);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s;
}
.fase-pill.active {
  background: rgba(249, 115, 22, 0.1);
  border-color: rgba(249, 115, 22, 0.4);
  color: #92400e;
}

/* ── Planta: LEDs del grid E/S (io-blocks-grid) ── */
.io-led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.2s;
  background: #e2e8f0;
}
.io-led.led-on    { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,.5); }
.io-led.led-off   { background: #e2e8f0; }
.io-led.led-alarm { background: var(--danger); box-shadow: 0 0 7px rgba(239,68,68,.6); animation: blink-led .5s step-start infinite; }

/* ── Planta: sub-tabs del detalle ── */
.btab-pane.hidden { display: none; }

@keyframes blink-led { 50% { opacity: 0; } }

/* ── Planta: responsive mobile ── */
@media (max-width: 600px) {
  #planta-machines-grid { grid-template-columns: 1fr !important; }
  #horno-io-grid        { grid-template-columns: 1fr !important; }
  #htab-estado > div:first-child { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 380px) {
  .planta-kpi-tile { padding: 0.35rem 0.15rem; }
  .planta-kpi-val  { font-size: 0.95rem; }
  .planta-kpi-lbl  { font-size: 0.55rem; }
}



/* ── Indicadores minimalistas de alarmas activas ── */
.alarma-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.4;
  padding: .26rem .55rem;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 0 0 0 rgba(239,68,68,.5);
  animation: alarma-pulse 1.8s ease-out infinite;
}
.alarma-badge::before {
  content: "▲";
  font-size: .62rem;
}
.nav-item .alarma-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger, #ef4444);
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(239,68,68,.6);
  animation: alarma-pulse 1.8s ease-out infinite;
}
.alarma-badge.hidden,
.alarma-dot.hidden { display: none; }
@keyframes alarma-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
}

/* ── Base de datos: responsive y uso de espacio ── */
.db-grid-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1.5rem;
}
.db-sidebar {
  border-right: 1px solid var(--border-light);
  padding-right: 1rem;
}
.db-tables-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 400px;
  overflow-y: auto;
}
.db-table-responsive {
  max-height: calc(100vh - 340px);
  min-height: 350px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
}
.db-table-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid transparent;
  background: var(--bg-light);
  border-radius: 6px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  transition: all 0.2s;
}
.db-table-item:hover, .db-table-item.active {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

@media (max-width: 860px) {
  .db-grid-container {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  .db-sidebar {
    border-right: none !important;
    border-bottom: 1px solid var(--border-light) !important;
    padding-right: 0 !important;
    padding-bottom: 1.25rem !important;
    margin-bottom: 0.5rem;
  }
  .db-tables-list {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.4rem !important;
    max-height: 200px;
  }
  .db-table-item {
    width: calc(50% - 0.25rem) !important;
    justify-content: flex-start;
  }
  .db-table-responsive {
    max-height: 55vh !important;
  }
}

