/* =====================================================================
   Grid SaaS — IT Pro Solutions Brand · Light corporate (+ dark theme)
   Paleta y componentes alineados con landing it-prosolutions.com
   ===================================================================== */
:root {
  --white: #FFFFFF;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --slate-50: #F8FAFC;
  --slate-100: #F1F5F9;
  --slate-200: #E2E8F0;
  --slate-300: #CBD5E1;
  --slate-400: #94A3B8;
  --slate-500: #64748B;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-900: #0F172A;
  --blue-50: #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-300: #93C5FD;
  --blue-500: #3B82F6;
  --blue-600: #2563EB;
  --blue-700: #1D4ED8;
  --blue-800: #1E40AF;
  --green-50: #F0FDF4;
  --green-500: #22C55E;
  --green-700: #15803D;
  --red-50: #FEF2F2;
  --red-500: #EF4444;
  --red-700: #B91C1C;
  --amber-50: #FFFBEB;
  --amber-500: #F59E0B;
  --amber-700: #B45309;

  --shadow-sm: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.02);
  --shadow:    0 4px 24px rgba(15,23,42,0.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,0.10);
  --shadow-blue: 0 4px 16px rgba(30,64,175,0.18);
  --shadow-blue-lg: 0 8px 24px rgba(30,64,175,0.28);
}

/* ── Dark theme ────────────────────────────────────────────────────────
   Activación: <html data-theme="dark">
   Mantiene el azul brand (#1E40AF) pero invierte surfaces, texto y
   tonos pastel a versiones oscuras semánticas.
   ─────────────────────────────────────────────────────────────────── */
html[data-theme="dark"] {
  color-scheme: dark;
  --white: #0F172A;
  --bg: #0B1220;
  --surface: #111827;
  --surface-2: #1F2937;

  --slate-50:  #1F2937;
  --slate-100: #1F2937;
  --slate-200: #334155;
  --slate-300: #475569;
  --slate-400: #64748B;
  --slate-500: #94A3B8;
  --slate-600: #CBD5E1;
  --slate-700: #E5E7EB;
  --slate-900: #F8FAFC;

  --blue-50:  #1E3A8A;
  --blue-100: #1E40AF;
  --blue-300: #2563EB;
  --blue-700: #93C5FD;
  --blue-800: #BFDBFE;

  --green-50:  #064E3B;
  --green-700: #6EE7B7;
  --red-50:    #3A0A0A;
  --red-700:   #FECACA;
  --amber-50:  #3D1F0A;
  --amber-700: #FDE047;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow:    0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.55);
}

/* Body en dark usa --bg directamente */
html[data-theme="dark"] body { background: var(--bg); color: var(--slate-700); }

/* Overrides puntuales que tenían colores literales fuera de las vars */
html[data-theme="dark"] .nav {
  background: rgba(11,18,32,0.92);
  border-bottom-color: var(--slate-200);
}
html[data-theme="dark"] .logo-badge { background: var(--blue-800); color: #FFFFFF; }
html[data-theme="dark"] .logo-name  { color: var(--slate-900); }
html[data-theme="dark"] .nav-user-dropdown {
  background: var(--surface) !important;
  border-color: var(--slate-200);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
html[data-theme="dark"] .nav-user-card {
  background: linear-gradient(135deg, var(--blue-50) 0%, var(--surface) 80%);
  border-bottom-color: var(--slate-100);
}
html[data-theme="dark"] .btn-primary { color: #FFFFFF; }
html[data-theme="dark"] .btn-secondary { background: var(--surface); }
html[data-theme="dark"] .btn-danger-outline { background: var(--surface); }
html[data-theme="dark"] .btn-ghost { background: transparent; }

/* Cards / paneles típicos del dashboard / apps — usamos selectores con
   specificity ≥ (0,1,0) para ganar a las reglas light que usan `background: white`.
   `:where()` no sube specificity → no sirve frente a `.kpi-card { background:white }`. */
html[data-theme="dark"] .card,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .stats-card,
html[data-theme="dark"] .app-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .info-box,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .data-table,
html[data-theme="dark"] table,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .ai-card,
html[data-theme="dark"] .ai-stat,
html[data-theme="dark"] .alert-card,
html[data-theme="dark"] .filter-chip,
html[data-theme="dark"] .action-icon,
html[data-theme="dark"] .nav-logout,
html[data-theme="dark"] .toggle-card,
html[data-theme="dark"] .collapsible-header {
  background-color: var(--surface);
  border-color: var(--slate-200);
  color: var(--slate-700);
}
/* Inputs / selects / textareas — specificity (0,0,1) basta porque la regla light
   usa selectores como `input[type="text"]` (0,1,1). Usamos selectores explícitos. */
html[data-theme="dark"] input,
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="tel"],
html[data-theme="dark"] input[type="url"],
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .input {
  background-color: var(--surface-2);
  color: var(--slate-700);
  border-color: var(--slate-200);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: var(--slate-400);
}
html[data-theme="dark"] thead,
html[data-theme="dark"] thead th,
html[data-theme="dark"] .table-head {
  background-color: var(--surface-2);
  color: var(--slate-600);
}
/* Hover de filas — la regla light usa --blue-50 (en dark = #1E3A8A), pero
   en mucho contexto queda demasiado contrastado. Usamos surface-2. */
html[data-theme="dark"] tbody tr:hover { background-color: var(--surface-2); }
html[data-theme="dark"] td { color: var(--slate-700); border-bottom-color: var(--slate-200); }

/* Botón primary en dark: --blue-800 cambia a #BFDBFE (claro), por eso el
   color: white original queda ilegible. Forzamos un azul más sólido + texto blanco. */
html[data-theme="dark"] .btn-primary {
  background: #1E40AF;
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
html[data-theme="dark"] .btn-primary:hover { background: #2563EB; }
html[data-theme="dark"] .filter-chip.active { background: #1E40AF; color: #FFFFFF; border-color: #1E40AF; }
html[data-theme="dark"] .ai-action-chip { background: #1E40AF; color: #FFFFFF; }
html[data-theme="dark"] .filter-chip { color: var(--slate-700); }
html[data-theme="dark"] .action-icon { color: var(--slate-700); }
html[data-theme="dark"] .nav-link { color: var(--slate-700); }
html[data-theme="dark"] .nav-link:hover { color: #FFFFFF; }
html[data-theme="dark"] .nav-link.active { color: #FFFFFF; border-bottom-color: #93C5FD; }

/* Login page background: el gradient usa `white` literal → en dark queda muy
   blanco. Lo reemplazamos por un gradient oscuro. */
html[data-theme="dark"] .login-page {
  background: linear-gradient(180deg, var(--bg) 0%, #1E3A8A 100%);
}

/* welcome-card de apps.html usa gradient con `white` literal */
html[data-theme="dark"] .welcome-card {
  background: linear-gradient(135deg, #1E3A8A 0%, var(--surface) 60%);
  border-color: var(--slate-200);
}

/* Modal backdrop: ya usa rgba opaca, OK. Modal interior + tab-btn (admin.html) */
html[data-theme="dark"] .modal { background: var(--surface); border-color: var(--slate-200); }
html[data-theme="dark"] .modal-close { background: var(--slate-100); color: var(--slate-600); }
html[data-theme="dark"] .modal-close:hover { background: var(--slate-200); color: var(--slate-900); }
html[data-theme="dark"] .tab-btn { color: var(--slate-500); }
html[data-theme="dark"] .tab-btn:hover { color: var(--slate-700); }
html[data-theme="dark"] .tab-btn.active { color: #93C5FD; border-bottom-color: #93C5FD; }

/* Settings footer y nav usan rgba(255,255,255,...) hardcoded */
html[data-theme="dark"] .settings-footer { background: rgba(11,18,32,0.92); border-top-color: var(--slate-200); }

/* Switch thumb: el círculo blanco se ve bien en ambos modos, lo dejamos */

/* dashboard.html: info-table */
html[data-theme="dark"] .info-table tr { border-bottom-color: var(--slate-200); }

/* warn-box / alertas amber con color hardcoded #92400E (texto marrón oscuro)
   se vuelven ilegibles sobre fondo amber-50 dark (#3D1F0A) */
html[data-theme="dark"] .warn-box { color: var(--amber-700); border-color: var(--amber-700); }

/* Code inline (settings.html, apps.html) — fondo blanco hardcoded en algunos lados;
   forzamos cuando es <code> dentro de cards en dark. */
html[data-theme="dark"] code { background: var(--surface-2); color: var(--slate-700); }

/* Welcome audio banner: usa gradient amber claro hardcoded; en dark da contraste
   amber, queda usable. Forzamos texto legible. */
html[data-theme="dark"] #welcome-audio-banner { filter: brightness(0.85); }

/* Health banner (admin) y banner warnings (dashboard) usan rojo/amber claros.
   Mantienen contraste interno aceptable, no los tocamos. */

/* Tabla en mobile: el inset shadow asume fondo claro */
@media (max-width: 768px) {
  html[data-theme="dark"] .table-wrap {
    border-color: var(--slate-200);
    box-shadow: inset -8px 0 8px -8px rgba(0,0,0,0.5);
  }
}

/* Theme toggle button (lo agregamos en base.html) */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--slate-200);
  background: transparent; color: var(--slate-700);
  cursor: pointer; transition: .15s;
}
.theme-toggle:hover { border-color: var(--blue-700); background: var(--blue-50); color: var(--blue-800); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
html[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
html[data-theme="dark"] .theme-toggle .ico-moon { display: none; }

* { box-sizing: border-box; margin: 0; padding: 0 }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--white);
  color: var(--slate-900);
  line-height: 1.6;
  font-size: 15px;
}
h1, h2, h3, h4 { font-family: 'Manrope', sans-serif; letter-spacing: -0.02em; line-height: 1.2 }
a { color: var(--blue-700); text-decoration: none }
a:hover { text-decoration: underline }
button { font-family: 'Inter', sans-serif; cursor: pointer; border: none; background: none }

/* ── Nav ─────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  height: 68px;
  display: flex; align-items: center;
  padding: 0 32px;
}
.nav-brand { display: flex; align-items: center; gap: 12px; margin-right: 36px }
.logo-badge {
  background: var(--slate-900);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1 }
.logo-name { font-weight: 700; font-size: 14px; color: var(--slate-900); letter-spacing: 0.02em }
.logo-sub  { font-size: 11px; color: var(--blue-700); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase }

.nav-links { display: flex; align-items: center; gap: 4px; flex: 1 }
.nav-link {
  font-size: 14px; font-weight: 500;
  color: var(--slate-700); padding: 8px 16px;
  border-radius: 8px; transition: all .15s;
}
.nav-link:hover { color: var(--blue-800); background: var(--blue-50); text-decoration: none }
.nav-link.active {
  color: var(--blue-800); font-weight: 600;
  border-bottom: 2px solid var(--blue-800);
  border-radius: 0; padding-bottom: 6px;
}
.nav-right { display: flex; align-items: center; gap: 12px; margin-left: auto }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--slate-700) }
.nav-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.nav-logout {
  font-size: 13px; color: var(--slate-700);
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--slate-200);
  transition: all .15s;
}
.nav-logout:hover { color: var(--blue-800); border-color: var(--blue-300); background: var(--blue-50); text-decoration: none }

/* ── Botón "← Inicio" (volver al sitio web) ────────────────────── */
.nav-home-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
  color: var(--slate-700);
  padding: 8px 12px; border-radius: 8px;
  text-decoration: none;
  transition: all .15s;
}
.nav-home-link:hover {
  color: var(--blue-800);
  background: var(--blue-50);
  text-decoration: none;
}
.nav-home-link svg { stroke-width: 2.2 }

/* ── Dropdown del usuario ──────────────────────────────────────── */
.nav-user-menu { position: relative }
.nav-user-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: all .15s;
}
.nav-user-trigger:hover {
  background: var(--blue-50);
  border-color: var(--blue-100);
}
.nav-user-trigger .nav-avatar { width: 32px; height: 32px; font-size: 13px }
.nav-user-name { font-size: 14px; font-weight: 500; color: var(--slate-900) }
.nav-user-caret { color: var(--slate-500); transition: transform .15s }
.nav-user-menu.open .nav-user-caret { transform: rotate(180deg) }

.nav-user-dropdown {
  display: none !important;
  position: absolute;
  right: 0; top: calc(100% + 10px);
  min-width: 280px;
  background: #FFFFFF !important;
  border: 1px solid var(--slate-200);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15,23,42,0.18);
  overflow: hidden;
  z-index: 9999;
  animation: ddownIn .15s ease;
}
.nav-user-menu.open .nav-user-dropdown { display: block !important }
@keyframes ddownIn {
  from { opacity: 0; transform: translateY(-6px) }
  to   { opacity: 1; transform: translateY(0) }
}

.nav-user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--blue-50) 0%, white 80%);
  border-bottom: 1px solid var(--slate-100);
}
.nav-user-card-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--blue-100); color: var(--blue-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
  flex-shrink: 0;
}
.nav-user-card-info { flex: 1; min-width: 0 }
.nav-user-card-name {
  font-weight: 700; color: var(--slate-900); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-user-card-email {
  font-size: 12px; color: var(--slate-600); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-user-card-role { margin-top: 6px }

.nav-user-section {
  padding: 6px 0;
  border-bottom: 1px solid var(--slate-100);
}
.nav-user-section:last-child { border-bottom: none }
.nav-user-item {
  display: block;
  padding: 9px 18px;
  font-size: 13.5px;
  color: var(--slate-700);
  text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-user-item:hover {
  background: var(--blue-50);
  color: var(--blue-800);
  text-decoration: none;
}
.nav-user-item-muted { color: var(--slate-600) }
.nav-user-item-danger { color: var(--red-700) }
.nav-user-item-danger:hover { background: var(--red-50); color: var(--red-700) }

@media (max-width: 768px) {
  .nav-user-name { display: none }
  .nav-user-caret { display: none }
  .nav-home-link span, .nav-home-link { font-size: 12px }
  .nav-user-dropdown { right: -4px; min-width: 260px }
}

/* ── Container ───────────────────────────────────────────────────── */
.container { max-width: 1320px; margin: 0 auto; padding: 32px 28px }

/* ── Page header / section tag ───────────────────────────────────── */
.section-tag {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 600;
  color: var(--blue-700);
  letter-spacing: 0.15em; text-transform: uppercase;
  margin-bottom: 12px;
}
.page-header { margin-bottom: 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap }
.page-title { font-size: 32px; font-weight: 800; color: var(--slate-900); margin-bottom: 4px }
.page-sub   { font-size: 16px; color: var(--slate-600); font-weight: 400 }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  transition: all .15s;
  line-height: 1; white-space: nowrap;
}
.btn:hover { text-decoration: none }
.btn-primary { background: var(--blue-800); color: white; box-shadow: var(--shadow-blue) }
.btn-primary:hover { background: var(--blue-700); transform: translateY(-1px); box-shadow: var(--shadow-blue-lg) }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none }
.btn-secondary { background: white; color: var(--blue-800); border: 1.5px solid var(--blue-800) }
.btn-secondary:hover { background: var(--blue-50) }
.btn-danger-outline { background: white; color: var(--red-700); border: 1.5px solid var(--red-500) }
.btn-danger-outline:hover { background: var(--red-50) }
.btn-ghost { color: var(--slate-700); background: transparent; border: 1px solid var(--slate-200) }
.btn-ghost:hover { background: var(--slate-50); border-color: var(--slate-300) }
.btn-sm { padding: 6px 12px; font-size: 13px }
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: 12px }

/* ── Chip ────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  background: var(--slate-100); color: var(--slate-700);
}
.chip-blue          { background: var(--blue-50); color: var(--blue-800) }
.chip-blue-outline  { background: white; border: 1px solid var(--blue-300); color: var(--blue-800) }
.chip-green         { background: var(--green-50); color: var(--green-700); font-weight: 600 }
.chip-red           { background: var(--red-50); color: var(--red-700); font-weight: 600 }
.chip-amber         { background: var(--amber-50); color: var(--amber-700); font-weight: 600 }

/* ── Dot ─────────────────────────────────────────────────────────── */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0 }
.dot-green { background: var(--green-500); box-shadow: 0 0 0 4px rgba(34,197,94,0.18) }
.dot-gray  { background: var(--slate-300) }
.dot-amber { background: var(--amber-500); box-shadow: 0 0 0 4px rgba(245,158,11,0.18) }
.dot-pulse { animation: pulse 2.4s ease-out infinite }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.5 } }

/* ── KPI Cards ───────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 28px }
@media(max-width: 900px){ .kpi-grid { grid-template-columns: 1fr 1fr } }
@media(max-width: 540px){ .kpi-grid { grid-template-columns: 1fr } }
.kpi-grid.cols-5 { grid-template-columns: repeat(5, 1fr) }
@media(max-width: 1100px){ .kpi-grid.cols-5 { grid-template-columns: repeat(3, 1fr) } }
@media(max-width: 700px){ .kpi-grid.cols-5 { grid-template-columns: 1fr 1fr } }

.kpi-card {
  background: white; border: 1px solid var(--slate-200);
  border-radius: 16px; padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg) }
.kpi-label {
  font-size: 11px; font-weight: 600;
  color: var(--blue-700); letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 10px;
}
.kpi-value {
  font-family: 'Manrope', sans-serif;
  font-size: 32px; font-weight: 800;
  color: var(--slate-900); letter-spacing: -0.025em; line-height: 1;
  margin-bottom: 8px;
}
.kpi-value.green { color: var(--green-700) }
.kpi-value.blue  { color: var(--blue-800) }
.kpi-value.amber { color: var(--amber-700) }
.kpi-sub { font-size: 13px; color: var(--slate-600); display: flex; align-items: center; gap: 6px; flex-wrap: wrap }
.kpi-sub .pos { color: var(--green-700); font-weight: 600 }
.kpi-sub .neg { color: var(--red-700); font-weight: 600 }

/* ── Card ────────────────────────────────────────────────────────── */
.card {
  background: white; border: 1px solid var(--slate-200);
  border-radius: 16px; box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 20px 24px; border-bottom: 1px solid var(--slate-100);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-title { font-size: 18px; font-weight: 700; color: var(--slate-900) }
.card-meta  { font-size: 13px; color: var(--slate-500) }
.card-body  { padding: 24px }

/* ── Layout grids ────────────────────────────────────────────────── */
.grid-7-3 { display: grid; grid-template-columns: 7fr 3fr; gap: 18px; margin-bottom: 28px }
@media(max-width: 1100px){ .grid-7-3 { grid-template-columns: 1fr } }
.grid-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px }
@media(max-width: 900px){ .grid-1-1 { grid-template-columns: 1fr } }
.grid-220-1 { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start }
@media(max-width: 800px){ .grid-220-1 { grid-template-columns: 1fr } }

/* ── Inputs ──────────────────────────────────────────────────────── */
.field { margin-bottom: 18px }
.field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--slate-700); margin-bottom: 6px;
}
.field-hint { font-size: 12px; color: var(--slate-500); margin-top: 6px }

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; background: white;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 11px 14px; font-size: 14px;
  color: var(--slate-900);
  transition: border-color .15s, box-shadow .15s;
  outline: none; font-family: inherit;
}
.input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59,130,246,0.10);
}
input::placeholder { color: var(--slate-400) }

.field-with-icon { position: relative }
.field-with-icon input { padding-left: 40px }
.field-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--slate-400); font-size: 16px; pointer-events: none;
}
.field-with-badge { position: relative }
.field-with-badge .badge-saved {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: var(--green-50); color: var(--green-700);
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
}
.field-with-badge input { padding-right: 110px }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0 }
.switch input { opacity: 0; width: 0; height: 0 }
.switch-track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--slate-200); border-radius: 999px; transition: .2s;
}
.switch-track::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.switch input:checked + .switch-track { background: var(--blue-800) }
.switch input:checked + .switch-track::before { transform: translateX(20px) }

.toggle-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: 12px;
}
.toggle-card-content { flex: 1; display: flex; flex-direction: column; gap: 2px }
.toggle-card-title { font-size: 14px; font-weight: 600; color: var(--slate-900) }
.toggle-card-sub   { font-size: 12px; color: var(--slate-600) }

/* Warning box */
.warn-box {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--amber-50);
  border: 1px solid #FCD34D;
  border-left: 4px solid var(--amber-500);
  border-radius: 12px;
  font-size: 13px; color: #92400E; line-height: 1.5;
  margin-bottom: 18px;
}

/* Alert */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  margin-bottom: 20px;
}
.alert-success { background: var(--green-50); color: var(--green-700); border: 1px solid #BBF7D0 }
.alert-error   { background: var(--red-50); color: var(--red-700); border: 1px solid #FECACA }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto }
table { width: 100%; border-collapse: collapse }
thead { background: var(--slate-50); border-bottom: 1px solid var(--slate-200) }
th {
  padding: 12px 18px; text-align: left;
  font-size: 11px; font-weight: 600;
  color: var(--slate-600); letter-spacing: 0.12em; text-transform: uppercase;
  white-space: nowrap;
}
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-900); font-size: 14px;
  vertical-align: middle;
}
tbody tr { transition: background .12s }
tbody tr:hover { background: var(--blue-50) }
tbody tr:last-child td { border-bottom: none }
td.num { font-family: 'Manrope', sans-serif; font-weight: 600; font-variant-numeric: tabular-nums }
td .pos { color: var(--green-700); font-weight: 700 }
td .neg { color: var(--red-700); font-weight: 700 }

/* User cell con avatar + email */
.user-cell { display: flex; align-items: center; gap: 10px }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-100); color: var(--blue-800);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; line-height: 1.2 }
.user-name  { font-weight: 600; color: var(--slate-900); font-size: 14px }
.user-email { font-size: 12px; color: var(--slate-500) }

/* Action icon buttons */
.action-icons { display: inline-flex; gap: 6px }
.action-icon {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: white; border: 1px solid var(--slate-200);
  border-radius: 8px; color: var(--slate-700);
  cursor: pointer; transition: all .12s;
  font-size: 14px;
}
.action-icon:hover { border-color: var(--blue-300); color: var(--blue-800); background: var(--blue-50) }
.action-icon.danger:hover { border-color: var(--red-500); color: var(--red-700); background: var(--red-50) }

/* Filter chips */
.filter-row { display: flex; flex-wrap: wrap; gap: 8px }
.filter-chip {
  padding: 6px 14px; border-radius: 999px;
  background: white; border: 1px solid var(--slate-200);
  color: var(--slate-700); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .12s;
}
.filter-chip:hover { border-color: var(--blue-300); color: var(--blue-800) }
.filter-chip.active { background: var(--blue-800); color: white; border-color: var(--blue-800) }

/* ── Settings nav ────────────────────────────────────────────────── */
.settings-nav { position: sticky; top: 88px }
.settings-nav-title {
  font-size: 11px; font-weight: 700;
  color: var(--blue-700); letter-spacing: 0.12em; text-transform: uppercase;
  margin-bottom: 10px; padding: 0 10px;
}
.settings-nav-item {
  display: block; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--slate-700);
  transition: all .15s; margin-bottom: 2px;
  text-decoration: none;
}
.settings-nav-item:hover { color: var(--blue-800); background: var(--blue-50); text-decoration: none }
.settings-nav-item.active { color: var(--blue-800); background: var(--blue-50); font-weight: 700 }

.settings-section { margin-bottom: 28px; scroll-margin-top: 88px }
.settings-section-header { margin-bottom: 14px }
.settings-section-title { font-size: 22px; font-weight: 700; color: var(--slate-900); letter-spacing: -0.01em }
.settings-section-desc  { font-size: 14px; color: var(--slate-600); margin-top: 4px }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px }
@media(max-width: 600px){ .field-row { grid-template-columns: 1fr } }

.settings-footer {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--slate-200);
  padding: 16px 0; margin-top: 24px;
  display: flex; gap: 10px; align-items: center;
}

/* ── AI Recommendation ────────────────────────────────────────────── */
.ai-card {
  background: white; border: 1px solid var(--slate-200);
  border-left: 4px solid var(--blue-800);
  border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow);
}
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px }
.ai-action-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue-800); color: white;
  padding: 8px 16px; border-radius: 8px;
  font-weight: 700; font-size: 14px; margin-bottom: 16px;
}
.ai-body { color: var(--slate-700); font-size: 15px; line-height: 1.6; margin-bottom: 20px }
.ai-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px }
@media(max-width: 600px){ .ai-stats { grid-template-columns: 1fr } }
.ai-stat {
  background: var(--slate-50); border: 1px solid var(--slate-200);
  border-radius: 12px; padding: 14px 16px;
}
.ai-stat-label { font-size: 11px; font-weight: 600; color: var(--slate-600); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px }
.ai-stat-value { font-family: 'Manrope', sans-serif; font-size: 20px; font-weight: 700; color: var(--blue-800) }

/* ── Activity timeline ───────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 14px; padding-left: 20px; position: relative }
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--blue-200, #BFDBFE);
}
.timeline-item { position: relative }
.timeline-item::before {
  content: ''; position: absolute; left: -20px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue-800); border: 2px solid white;
  box-shadow: 0 0 0 2px var(--blue-200, #BFDBFE);
}
.timeline-time { font-size: 12px; color: var(--slate-500); margin-bottom: 2px }
.timeline-user { font-weight: 600; color: var(--blue-800); font-size: 14px }
.timeline-msg  { color: var(--slate-700); font-size: 14px; line-height: 1.5 }

/* ── Alert with side border ──────────────────────────────────────── */
.alert-card {
  background: white; border-radius: 12px;
  padding: 14px 16px; margin-bottom: 12px;
  border: 1px solid var(--slate-200);
  display: flex; align-items: flex-start; gap: 12px;
}
.alert-card.danger { border-left: 4px solid var(--red-500) }
.alert-card.warn   { border-left: 4px solid var(--amber-500) }
.alert-card-content { flex: 1 }
.alert-card-title { font-weight: 700; color: var(--slate-900); font-size: 15px; margin-bottom: 4px }
.alert-card-sub   { font-size: 13px; color: var(--slate-600); line-height: 1.5 }

/* ── Login ───────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, white 0%, var(--blue-50) 100%);
  padding: 40px 20px;
}
.login-wrap { width: 100%; max-width: 440px }
.login-brand { text-align: center; margin-bottom: 32px }
.login-logo {
  display: inline-flex; gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.login-logo .logo-badge { font-size: 16px; padding: 8px 12px }
.login-logo-text { display: flex; flex-direction: column; line-height: 1.1; text-align: left }
.login-logo-text .logo-name { font-size: 16px }
.login-logo-text .logo-sub { font-size: 12px }
.login-title { font-size: 30px; font-weight: 800; color: var(--slate-900); margin-top: 28px; margin-bottom: 6px }
.login-sub   { font-size: 15px; color: var(--slate-600) }

.login-card {
  background: white; border: 1px solid var(--slate-200);
  border-radius: 20px; padding: 32px;
  box-shadow: var(--shadow-lg);
}
.login-footer {
  text-align: center; margin-top: 24px;
  font-size: 13px; color: var(--slate-600);
}
.login-version {
  text-align: center; margin-top: 16px;
  font-size: 11px; color: var(--slate-400); letter-spacing: 0.05em;
}

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--slate-700);
  margin-bottom: 18px;
}
.checkbox-row input[type=checkbox] {
  width: 18px; height: 18px; accent-color: var(--blue-800); cursor: pointer;
}

.eye-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--slate-400); font-size: 16px; cursor: pointer;
}
.eye-btn:hover { color: var(--blue-800) }

/* ── Info tooltips ─────────────────────────────────────────────── */
.info-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--slate-200);
  color: var(--slate-700);
  font-size: 11px; font-weight: 700;
  cursor: help; margin-left: 6px;
  position: relative;
  transition: all .15s;
  vertical-align: middle;
  font-style: italic;
}
.info-tip:hover { background: var(--blue-100); color: var(--blue-800) }
/* Tooltip con position: fixed para que se salga de cualquier overflow:auto/hidden
   del padre (modales, cards, formularios). El JS setea --tip-x y --tip-y en
   coordenadas absolutas del viewport en cada hover/focus. */
.info-tip::before {
  content: attr(data-tip);
  position: fixed;
  left: var(--tip-x, 0); top: var(--tip-y, 0);
  background: var(--slate-900); color: white;
  padding: 10px 14px; border-radius: 10px;
  font-size: 12px; font-weight: 400; font-style: normal;
  letter-spacing: 0; line-height: 1.55;
  white-space: normal;
  width: 280px;
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .12s, visibility .12s;
  text-align: left;
  box-shadow: 0 12px 32px rgba(15,23,42,0.22);
  z-index: 99999;
}
.info-tip::after {
  /* Flecha: usa --tip-arrow-x/y para posicionar y rota según side */
  content: '';
  position: fixed;
  left: var(--tip-arrow-x, 0); top: var(--tip-arrow-y, 0);
  border: 6px solid transparent;
  border-right-color: var(--slate-900);
  pointer-events: none;
  opacity: 0; visibility: hidden;
  transition: opacity .12s, visibility .12s;
  z-index: 99999;
}
.info-tip:hover::before,
.info-tip:hover::after,
.info-tip:focus::before,
.info-tip:focus::after { opacity: 1; visibility: visible }

/* Side variants (set por JS): determina hacia qué lado apunta la flecha */
.info-tip.tip-side-right::after { border-right-color: var(--slate-900); border-left-color: transparent; }
.info-tip.tip-side-left::after  { border-left-color:  var(--slate-900); border-right-color: transparent; }
.info-tip.tip-side-up::after    { border-bottom-color: var(--slate-900); border-right-color: transparent; }
.info-tip.tip-side-down::after  { border-top-color:    var(--slate-900); border-right-color: transparent; }

/* Compat: clases viejas (no se usan ya, el JS calcula side-* automáticamente) */
.info-tip.tip-flip, .info-tip.tip-flip-up, .info-tip.tip-flip-down, .info-tip.tip-left {}

/* ── Responsive global / mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .nav { padding: 0 14px; height: 56px }
  .nav-brand .logo-text .logo-sub { display: none }
  .nav-links .nav-link { padding: 6px 10px; font-size: 13px }
  .nav-user span { display: none }
  .nav-logout { padding: 6px 10px; font-size: 12px }

  .container { padding: 18px 14px }

  .page-header { flex-direction: column; align-items: flex-start; gap: 14px }
  .page-title { font-size: 24px }
  .page-sub { font-size: 14px }

  .card-head { flex-direction: column; align-items: flex-start; gap: 8px }
  .card-body { padding: 16px }

  .kpi-card { padding: 16px 18px }
  .kpi-value { font-size: 24px }

  .filter-row { gap: 6px }
  .filter-chip { padding: 5px 10px; font-size: 12px }

  /* Tabla en mobile: scroll horizontal mantenido, pero más visible */
  .table-wrap {
    border-radius: 12px;
    border: 1px solid var(--slate-200);
    box-shadow: inset -8px 0 8px -8px rgba(15,23,42,0.12);
  }
  th, td { padding: 10px 12px; font-size: 13px }
  th { font-size: 10px }

  .btn { padding: 8px 14px; font-size: 13px }
  .btn-lg { padding: 12px 20px; font-size: 14px }

  /* Mobile: ocultar columnas REDUNDANTES (símbolo, modo, totales históricos).
     Mantener visibles: Estado, Usuario, PNL hoy, Trades hoy, Órdenes,
     AI calls (control de gasto Claude), Activa (switch on/off), Acciones. */
  table th:nth-child(3), table td:nth-child(3),    /* Símbolo */
  table th:nth-child(4), table td:nth-child(4),    /* Modo */
  table th:nth-child(6), table td:nth-child(6),    /* PNL total */
  table th:nth-child(8), table td:nth-child(8),    /* Trades total */
  table th:nth-child(9), table td:nth-child(9) {   /* Win rate */
    display: none;
  }

  /* Settings: en mobile, sidebar y form van apilados */
  .grid-220-1 { grid-template-columns: 1fr; gap: 16px }
  .settings-nav { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px }
  .settings-nav-title { display: none }
  .settings-nav-item { white-space: nowrap; flex-shrink: 0; margin-bottom: 0 }

  /* Tooltip más compacto en mobile */
  .info-tip::before { width: 220px; font-size: 11px; padding: 8px 10px }

  /* AI stats grid en mobile: 1 col */
  .ai-stats { grid-template-columns: 1fr }

  /* Modal admin: padding reducido */
  .modal { padding: 20px; max-width: calc(100vw - 32px) }
}

@media (max-width: 480px) {
  .container { padding: 14px 10px }
  .nav { padding: 0 10px }

  /* Pantallas muy pequeñas: solo lo más crítico
     [Estado] [Usuario] [PNL hoy] [PNL total] [Trades hoy] [AI calls] [Acciones] */
  table th:nth-child(7), table td:nth-child(7) { /* Trades hoy: ocultar también si no cabe */
    /* Lo dejamos visible — es info clave del día */
  }
  /* La regla de 768px ya oculta columnas 3, 4, 8, 9, 10, 12.
     En 480px no agregamos más para mantener AI calls visible (col 11). */

  /* Toolbar: stack todo */
  .field-with-icon { max-width: 100% !important }

  /* KPI cards más compactas */
  .kpi-value { font-size: 20px }
  .kpi-card { padding: 14px 16px }
  /* Cells más compactas en pantalla muy chica */
  th, td { padding: 8px 8px; font-size: 12px }
  th { font-size: 9px }
}

/* ── Sección colapsable (parámetros avanzados) ─────────────────── */
.collapsible-header {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 14px 18px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  transition: all .15s;
  user-select: none;
}
.collapsible-header:hover { background: var(--blue-50); border-color: var(--blue-300) }
.collapsible-title { font-weight: 700; color: var(--slate-900); font-size: 15px; display: flex; align-items: center; gap: 8px }
.collapsible-toggle { color: var(--slate-500); transition: transform .2s; font-size: 18px; font-weight: 600 }
.collapsible.open .collapsible-toggle { transform: rotate(180deg) }
.collapsible-body { display: none; padding: 20px 4px 4px }
.collapsible.open .collapsible-body { display: block }

/* ═══════════════════════════════════════════════════════════════════════
   Dark mode P2 — armonización de banners/chips con paleta amber/red
   hardcoded inline en dashboard.html, admin.html y settings.html.
   Capturados por attribute selector [style*="..."] para no tocar plantillas.
   ═══════════════════════════════════════════════════════════════════════ */

/* Fondos amber claro → versión oscura semántica */
html[data-theme="dark"] [style*="background:#fef3c7"],
html[data-theme="dark"] [style*="background: #fef3c7"],
html[data-theme="dark"] [style*="background:#FEF3C7"],
html[data-theme="dark"] [style*="background-color:#fef3c7"],
html[data-theme="dark"] [style*="background:#fffbeb"],
html[data-theme="dark"] [style*="background: #fffbeb"],
html[data-theme="dark"] [style*="background:#FFFBEB"] {
  background-color: #3D1F0A !important;
  border-color: #92400E !important;
}

/* Fondos red claro → versión oscura semántica */
html[data-theme="dark"] [style*="background:#fef2f2"],
html[data-theme="dark"] [style*="background: #fef2f2"],
html[data-theme="dark"] [style*="background:#FEF2F2"],
html[data-theme="dark"] [style*="background-color:#fef2f2"],
html[data-theme="dark"] [style*="background:#fee2e2"],
html[data-theme="dark"] [style*="background: #fee2e2"] {
  background-color: #3A0A0A !important;
  border-color: #991B1B !important;
}

/* Texto amber oscuro (#92400e) → claro legible sobre fondo amber dark */
html[data-theme="dark"] [style*="color:#92400e"],
html[data-theme="dark"] [style*="color: #92400e"],
html[data-theme="dark"] [style*="color:#92400E"] {
  color: #FDE047 !important;
}

/* Texto red oscuro (#991b1b, #7f1d1d) → claro sobre fondo red dark */
html[data-theme="dark"] [style*="color:#991b1b"],
html[data-theme="dark"] [style*="color: #991b1b"],
html[data-theme="dark"] [style*="color:#991B1B"],
html[data-theme="dark"] [style*="color:#7f1d1d"],
html[data-theme="dark"] [style*="color: #7f1d1d"],
html[data-theme="dark"] [style*="color:#7F1D1D"] {
  color: #FECACA !important;
}

/* Border amber-200 (#fde68a) → amber-700 visible en dark */
html[data-theme="dark"] [style*="border:1px solid #fde68a"],
html[data-theme="dark"] [style*="border: 1px solid #fde68a"],
html[data-theme="dark"] [style*="border-color:#fde68a"] {
  border-color: #92400E !important;
}

/* Border red-300 (#ef4444 como border-left accent) — mantener (es semántico) */
/* Borders left-accent en banners se mantienen — son la "barra" semántica */

/* Specific: timeline-tbody row selected (background:#fef3c7 con !important) */
html[data-theme="dark"] #timeline-tbody tr.selected {
  background-color: #3D1F0A !important;
  box-shadow: inset 3px 0 0 #FDE047 !important;
}

/* Chart.js tooltips si los hay — color de fondo y texto */
html[data-theme="dark"] .chartjs-tooltip {
  background-color: var(--surface-2) !important;
  color: var(--slate-700) !important;
  border-color: var(--slate-200) !important;
}

