/* ============================================================
   NetPanel — Panel ISP MikroTik
   Estilo: Profesional limpio, sidebar oscuro, contenido claro
   Fuente: DM Sans + DM Mono
   ============================================================ */

[data-theme="light"], :root {
  --overlay-bg: rgba(0,0,0,.45);
  --sidebar-bg:    #0f1623;
  --sidebar-hover: #1a2538;
  --sidebar-active:#1e6fff;
  --accent:        #1e6fff;
  --accent-soft:   #e8f0ff;
  --accent-dark:   #1458d6;

  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --surface2:      #f8fafd;
  --border:        #e2e8f0;
  --border-soft:   #edf2f7;

  --text:          #1a202c;
  --text-muted:    #718096;
  --text-light:    #a0aec0;

  --green:         #10b981;
  --green-soft:    #d1fae5;
  --green-border:  #a7f3d0;
  --green-text:    #065f46;
  --yellow:        #f59e0b;
  --yellow-soft:   #fef3c7;
  --yellow-border: #fcd34d;
  --yellow-text:   #92400e;
  --red:           #ef4444;
  --red-soft:      #fee2e2;
  --red-border:    #fca5a5;
  --red-text:      #991b1b;
  --blue-soft:     #dbeafe;
  --blue-border:   #bfdbfe;
  --blue-text:     #1e40af;
  --purple-soft:   #f3e8ff;
  --purple-border: #e9d5ff;
  --purple-text:   #6b21a8;
  --gray-soft:     #f1f5f9;
  --gray-border:   #e2e8f0;
  --gray-text:     #475569;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 16px rgba(0,0,0,.08);

  --sidebar-w:     260px;
  --font:          'Outfit', sans-serif;
  --font-mono:     'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; font-family: var(--font); font-size: 14px; background: var(--bg); color: var(--text); }

/* ── SHELL ─────────────────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon { font-size: 20px; color: var(--accent); }
.brand-name { font-size: 17px; font-weight: 600; color: #fff; letter-spacing: -.3px; }

.nav-menu { padding: 16px 10px; flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .2s ease, color .2s ease, transform .1s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,.95); transform: translateX(3px); }
.nav-item.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(30,111,255,.3); }

/* ── SUBMENUS (ACORDEON) ───────────────────── */
.nav-group { margin-bottom: 2px; }
.nav-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65); cursor: pointer;
  font-size: 14px; font-weight: 500;
  transition: background .2s ease, color .2s ease;
}
.nav-group-header:hover { background: var(--sidebar-hover); color: rgba(255,255,255,.95); }
.nav-group-header.open { color: #fff; }
.nav-group-header-left { display: flex; align-items: center; gap: 12px; }
.nav-group-header-left i { width: 18px; text-align: center; font-size: 14px; }
.nav-group-chevron { font-size: 11px; transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1); }
.nav-group-header.open .nav-group-chevron { transform: rotate(180deg); }

.nav-submenu {
  overflow: hidden; max-height: 0;
  transition: max-height .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-submenu.open { max-height: 500px; }
.nav-submenu .nav-item {
  padding: 10px 14px 10px 36px;
  font-size: 14px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-submenu .nav-item i {
  width: 16px;
  text-align: center;
  font-size: 14px;
}
.nav-submenu .nav-item:hover { opacity: 1; transform: translateX(3px); }
.nav-submenu .nav-item.active { background: transparent; color: var(--accent); box-shadow: none; font-weight: 600; opacity: 1; }
.nav-submenu .nav-item.active::before {
  content: ''; position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.nav-divider { height: 1px; background: rgba(255,255,255,.07); margin: 12px 0; }
.nav-label { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: 1px; padding: 6px 14px 4px; }

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-chip { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}
.user-name { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.35); }
.btn-logout {
  color: rgba(255,255,255,.35);
  font-size: 14px;
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ── MAIN CONTENT ──────────────────────────── */
.main-content { flex: 1; overflow-y: auto; }
.page-container { padding: 28px 32px; max-width: 1280px; }

/* ── PAGE HEADER ───────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -.4px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── CARDS ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── STAT CARDS ────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue  { background: var(--blue-soft);   color: var(--accent); }
.stat-icon.green { background: var(--green-soft);  color: var(--green); }
.stat-icon.yellow{ background: var(--yellow-soft); color: var(--yellow); }
.stat-icon.red   { background: var(--red-soft);    color: var(--red); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ── TABLA ─────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 14px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); background: var(--surface2); border-bottom: 1px solid var(--border); text-align: left; }
a.sort-hdr { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
a.sort-hdr:hover { color: var(--accent); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── BADGES ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green  { background: var(--green-soft);  color: var(--green-text); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow-text); }
.badge-red    { background: var(--red-soft);    color: var(--red-text); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue-text); }
.badge-purple { background: var(--purple-soft); color: var(--purple-text); }
.badge-gray   { background: var(--gray-soft);   color: var(--gray-text); }

/* ── BOTONES ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 4px 12px rgba(30,111,255,.25); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); box-shadow: 0 6px 16px rgba(30,111,255,.4); transform: translateY(-1px); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface2); border-color: var(--text-muted); }
.btn-danger  { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 4px 12px rgba(239,68,68,.25); }
.btn-danger:hover { background: #dc2626; box-shadow: 0 6px 16px rgba(239,68,68,.4); transform: translateY(-1px); }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ── FORMULARIOS ───────────────────────────── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,111,255,.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── MODAL ─────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  transform: translateY(10px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { padding: 20px 24px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── ALERTAS ───────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.alert-success { background: var(--green-soft); color: var(--green-text); border: 1px solid var(--green-border); }
.alert-error,
.alert-danger   { background: var(--red-soft);   color: var(--red-text); border: 1px solid var(--red-border); }
.alert-warning { background: var(--yellow-soft); color: var(--yellow-text); border: 1px solid var(--yellow-border); }

/* ── FILTROS ───────────────────────────────── */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; }

/* ── ESTADO CONEXION ───────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot-green  { background: var(--green);  box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.dot-yellow { background: var(--yellow); }
.dot-red    { background: var(--red);    }
.dot-gray   { background: #cbd5e0; }

/* ── LOGIN ─────────────────────────────────── */
.login-page { 
  min-height: 100vh; 
  background: var(--bg); 
  display: flex; 
}
.login-left {
  flex: 1;
  background: linear-gradient(135deg, var(--sidebar-bg), #0b1a2e);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(34, 211, 238, 0.08) 0%, transparent 60%);
}
.login-left img {
  max-width: 75%;
  max-height: 400px;
  object-fit: contain;
  z-index: 1;
  filter: drop-shadow(0 15px 35px rgba(0,0,0,0.4));
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}
.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: 16px; 
  padding: 50px 40px; 
  width: 100%; 
  max-width: 420px; 
  box-shadow: 0 20px 40px rgba(0,0,0,0.2); 
}
.login-logo { text-align: center; margin-bottom: 32px; display: none; }
.login-logo i { font-size: 36px; color: var(--accent); }
.login-logo h1 { font-size: 24px; font-weight: 700; margin-top: 8px; }
.login-logo p  { font-size: 14px; color: var(--text-muted); }

@media (max-width: 900px) {
  .login-left { display: none; }
  .login-logo { display: block; }
}

/* ── MONO FONT para IPs, tokens ────────────── */
.mono { font-family: var(--font-mono); font-size: 12.5px; }

/* ── EMPTY STATE ───────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: 14px; }

/* ── PROGRESS BAR ──────────────────────────── */
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; transition: width .3s; }
.progress-bar.blue   { background: var(--accent); }
.progress-bar.green  { background: var(--green); }
.progress-bar.yellow { background: var(--yellow); }
.progress-bar.red    { background: var(--red); }

/* ── SITIO CARD (dashboard) ─────────────────── */
.sitios-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sitio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.sitio-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.sitio-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sitio-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.sitio-ip { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.sitio-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sitio-stat-item { background: var(--surface2); border-radius: 6px; padding: 8px 10px; overflow: hidden; }
.sitio-stat-val { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sitio-stat-lbl { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .page-container { padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── RESPONSIVE BREAKPOINTS ────────────────────────── */
@media (max-width: 1024px) {
  [data-theme="light"], :root {
  --overlay-bg: rgba(0,0,0,.45); --sidebar-w: 200px; }
  .page-container { padding: 20px 20px; }
}

@media (max-width: 768px) {
  [data-theme="light"], :root {
  --overlay-bg: rgba(0,0,0,.45); --sidebar-w: 0px; }
  .sidebar {
    position: fixed; left: -240px; top: 0; height: 100vh;
    width: 240px; z-index: 100;
    transition: left .25s ease;
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,.3); }
  .main-content { margin-left: 0 !important; }
  .shell { flex-direction: column; }
  .page-container { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal { width: 95vw !important; }
  .sitios-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 18px; }
}

/* Hamburger menu button (mobile) */
.menu-toggle {
  display: none;
  background: transparent; border: 1px solid var(--border); color: var(--text);
  
  z-index: 200; background: var(--sidebar-bg);
  border: none; border-radius: 8px;
  color: #fff; padding: 8px 10px;
  cursor: pointer; font-size: 16px;
}
@media (max-width: 768px) {
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .page-container { padding: 16px; }
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--overlay-bg); z-index: 99;
}
.sidebar-overlay.open { display: block; }


/* ── THEMES ────────────────────────────────── */
:root[data-theme="dark"] {
  --sidebar-bg:    #0b0f19;
  --sidebar-hover: #151e32;
  --sidebar-active:#3b82f6;
  --accent:        #3b82f6;
  --accent-soft:   #1e3a8a;
  --accent-dark:   #60a5fa;

  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface2:      #334155;
  --border:        #334155;
  --border-soft:   #1e293b;

  --text:          #f8fafc;
  --text-muted:    #94a3b8;
  --text-light:    #cbd5e1;

  --green:         #10b981;
  --green-soft:    rgba(16, 185, 129, 0.15);
  --green-border:  rgba(16, 185, 129, 0.3);
  --green-text:    #34d399;
  --yellow:        #f59e0b;
  --yellow-soft:   rgba(245, 158, 11, 0.15);
  --yellow-border: rgba(245, 158, 11, 0.3);
  --yellow-text:   #fbbf24;
  --red:           #ef4444;
  --red-soft:      rgba(239, 68, 68, 0.15);
  --red-border:    rgba(239, 68, 68, 0.3);
  --red-text:      #fca5a5;
  --blue-soft:     rgba(59, 130, 246, 0.15);
  --blue-border:   rgba(59, 130, 246, 0.3);
  --blue-text:     #93c5fd;
  --purple-soft:   rgba(168, 85, 247, 0.15);
  --purple-border: rgba(168, 85, 247, 0.3);
  --purple-text:   #d8b4fe;
  --gray-soft:     rgba(148, 163, 184, 0.15);
  --gray-border:   rgba(148, 163, 184, 0.3);
  --gray-text:     #cbd5e1;

  --shadow:        0 4px 6px -1px rgba(0,0,0,.3), 0 2px 4px -1px rgba(0,0,0,.2);
  --shadow-md:     0 10px 25px -5px rgba(0,0,0,.5), 0 8px 10px -6px rgba(0,0,0,.3);
  --overlay-bg:    rgba(0,0,0,.7);
}

:root[data-theme="ocean"] {
  --sidebar-bg:    #021220;
  --sidebar-hover: #072640;
  --sidebar-active:#0ea5e9;
  --accent:        #0ea5e9;
  --accent-soft:   #082f49;
  --accent-dark:   #38bdf8;

  --bg:            #061a2f;
  --surface:       #0b2948;
  --surface2:      #123e6b;
  --border:        #123e6b;
  --border-soft:   #0b2948;

  --text:          #f0f9ff;
  --text-muted:    #7dd3fc;
  --text-light:    #bae6fd;

  --green:         #10b981;
  --green-soft:    rgba(16, 185, 129, 0.15);
  --green-border:  rgba(16, 185, 129, 0.3);
  --green-text:    #34d399;
  --yellow:        #f59e0b;
  --yellow-soft:   rgba(245, 158, 11, 0.15);
  --yellow-border: rgba(245, 158, 11, 0.3);
  --yellow-text:   #fbbf24;
  --red:           #f43f5e;
  --red-soft:      rgba(244, 63, 94, 0.15);
  --red-border:    rgba(244, 63, 94, 0.3);
  --red-text:      #fda4af;
  --blue-soft:     #0c4a6e;
  --blue-border:   rgba(14, 165, 233, 0.3);
  --blue-text:     #7dd3fc;
  --purple-soft:   rgba(168, 85, 247, 0.15);
  --purple-border: rgba(168, 85, 247, 0.3);
  --purple-text:   #d8b4fe;
  --gray-soft:     rgba(125, 211, 252, 0.15);
  --gray-border:   rgba(125, 211, 252, 0.3);
  --gray-text:     #bae6fd;
  
  --shadow:        0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:     0 4px 16px rgba(0,0,0,.4);
  --overlay-bg:    rgba(0,0,0,.65);
}

:root[data-theme="night"] {
  --sidebar-bg:    #1e1e2e;
  --sidebar-hover: #313244;
  --sidebar-active:#cba6f7;
  --accent:        #cba6f7;
  --accent-soft:   #45475a;
  --accent-dark:   #b4befe;

  --bg:            #11111b;
  --surface:       #181825;
  --surface2:      #313244;
  --border:        #313244;
  --border-soft:   #1e1e2e;

  --text:          #cdd6f4;
  --text-muted:    #a6adc8;
  --text-light:    #bac2de;

  --green:         #a6e3a1;
  --green-soft:    rgba(166, 227, 161, 0.15);
  --green-border:  rgba(166, 227, 161, 0.3);
  --green-text:    #a6e3a1;
  --yellow:        #f9e2af;
  --yellow-soft:   rgba(249, 226, 175, 0.15);
  --yellow-border: rgba(249, 226, 175, 0.3);
  --yellow-text:   #f9e2af;
  --red:           #f38ba8;
  --red-soft:      rgba(243, 139, 168, 0.15);
  --red-border:    rgba(243, 139, 168, 0.3);
  --red-text:      #f38ba8;
  --blue-soft:     #313244;
  --blue-border:   rgba(203, 166, 247, 0.3);
  --blue-text:     #cba6f7;
  --purple-soft:   rgba(203, 166, 247, 0.15);
  --purple-border: rgba(203, 166, 247, 0.3);
  --purple-text:   #cba6f7;
  --gray-soft:     rgba(166, 173, 200, 0.15);
  --gray-border:   rgba(166, 173, 200, 0.3);
  --gray-text:     #cdd6f4;
  
  --shadow:        0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow-md:     0 4px 16px rgba(0,0,0,.4);
  --overlay-bg:    rgba(0,0,0,.65);
}

/* ── TOP NAVBAR ── */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(var(--surface-rgb, 255, 255, 255), 0.85); /* fallback */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background .3s ease;
}
[data-theme="light"] .top-navbar { background: rgba(255, 255, 255, 0.85); }
[data-theme="dark"] .top-navbar { background: rgba(30, 41, 59, 0.85); }
[data-theme="ocean"] .top-navbar { background: rgba(11, 41, 72, 0.85); }
[data-theme="night"] .top-navbar { background: rgba(24, 24, 37, 0.85); }

.top-navbar-left, .top-navbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* â”€â”€ DROPDOWNS â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.dropdown-toggle:hover {
  background: var(--surface2);
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 8px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 100;
}
.dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
}
.dropdown-item:hover, .dropdown-item.active {
  background: var(--surface2);
  color: var(--accent);
}
.dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 0;
}

.user-dropdown-header {
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}
.user-dropdown-header .user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.user-dropdown-header .user-role {
  font-size: 11.5px;
  color: var(--text-muted);
}

.stat-card {
  position: relative;
  transition: all 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card.selected-site {
  border-color: var(--accent) !important;
  background: var(--accent-soft) !important;
  box-shadow: 0 0 0 1px var(--accent), var(--shadow) !important;
}
.site-eye-link {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: all 0.15s ease;
  z-index: 10;
  text-decoration: none;
}
.site-eye-link:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(1.1);
}

/* Multi-select dropdown styles */
.dropdown-multiselect-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.15s ease;
}
.dropdown-multiselect-btn:hover {
  border-color: var(--text-muted);
}
.chk-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
  transition: background 0.1s ease;
}
.chk-label:hover {
  background: var(--surface2);
}

@media print {
  /* Ocultar barra lateral, botones y controles de filtro */
  .sidebar, .top-navbar, .menu-toggle, .sidebar-overlay, .page-header button, .page-header .btn, 
  .card:has(form), .dropdown-multiselect, form, .btn-logout, .btn-outline,
  .no-print {
    display: none !important;
  }
  
  /* Ajustar contenedor principal */
  .shell {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    overflow: visible !important;
  }
  .page-container {
    padding: 0 !important;
    max-width: 100% !important;
  }
  
  /* Tarjetas y layouts */
  .metrics-grid, .charts-row, .tables-row {
    display: grid !important;
    grid-template-columns: 1fr !important; /* Full width items on print */
    gap: 20px !important;
    page-break-inside: avoid;
  }
  
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #fff !important;
    page-break-inside: avoid;
    height: auto !important;
    max-height: none !important;
  }

  /* Asegurar que las tablas muestren todo el contenido y sin scrollbars */
  .table-wrap, .card > div {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
  }
  table {
    page-break-inside: auto;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  
  /* Evitar saltos de página huérfanos */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
}

/* ── SETTINGS DRAWER ── */
.settings-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 9900;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.settings-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 9910;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.settings-drawer.open {
  transform: translateX(0);
}

.settings-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.settings-drawer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-drawer-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: background 0.2s, color 0.2s;
}
.settings-drawer-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.settings-drawer-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
}
.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}
.avatar-large {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}
.user-fullname {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.user-email {
  margin: 2px 0 6px 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.section-title {
  margin: 0 0 16px 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.theme-palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.theme-palette-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}
.theme-palette-btn:hover {
  border-color: var(--accent);
  background: var(--surface3, var(--surface2));
}
.theme-palette-btn.active {
  border-color: var(--accent);
  background: var(--surface3, var(--surface2));
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.theme-palette-lbl {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.theme-color-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
  display: inline-block;
}
.light-circle { background: #ffffff; }
.dark-circle { background: #0f172a; }
.ocean-circle { background: #075985; }
.night-circle { background: #030712; }

.pref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.pref-item-vertical {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pref-info {
  flex: 1;
}
.pref-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: block;
}
.pref-desc {
  margin: 2px 0 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.35;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: .2s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .2s;
}
input:checked + .slider {
  background-color: var(--accent);
}
input:checked + .slider:before {
  transform: translateX(20px);
}
.slider.round {
  border-radius: 24px;
}
.slider.round:before {
  border-radius: 50%;
}

.admin-pref-card {
  background: var(--surface2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.admin-pref-card-header {
  margin-bottom: 8px;
}
.admin-pref-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.admin-pref-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}
.admin-pref-roles {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.admin-role-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-light);
  cursor: pointer;
}

/* ── CUSTOM SCROLLBARS ── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  border: 1px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Firefox standard scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

/* site status dot in cards */
.site-status-dot {
  position: absolute;
  top: 14px;
  left: 14px;
  margin-right: 0 !important;
  pointer-events: none;
}
.dot-red {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .2);
}
.dot-yellow {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, .2);
}
.dot-gray {
  box-shadow: 0 0 0 3px rgba(156, 163, 175, .2);
}

/* ── Ojito de contraseña ──────────────────────────────────────────────── */
input[type="password"],
input[data-eye-init] { padding-right: 32px !important; }

.password-eye-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    font-size: 14px;
    color: var(--text-secondary, #888);
    opacity: .85;
    transition: opacity .15s, color .15s;
}
.password-eye-btn:hover { opacity: 1; color: var(--accent); }
[data-theme="dark"] .password-eye-btn,
.dark .password-eye-btn { color: #aaa; }
