/* ===== PALETAS ===== */
:root{
  /* Light — White Mode: limpio, aireado, cálido */
  --bg:#f8fafc;
  --surface:#ffffff;
  --surface-2:#f1f5f9;
  --surface-3:#e2e8f0;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --primary:#4f46e5;
  --primary-2:#6366f1;
  --primary-contrast:#ffffff;
  --radius:16px;
  --shadow:0 4px 20px rgba(15,23,42,.06);
  --shadow-hover:0 8px 28px rgba(15,23,42,.10);
  --sidebar-w:280px;
  --chart-grid: rgba(148,163,184,.15);
  --chart-text: #64748b;
}
/* Dark — Black Mode: profundo, noche azulada, neón suave */
[data-theme="dark"]{
  --bg:#070a13;
  --surface:#111827;
  --surface-2:#1e293b;
  --surface-3:#273549;
  --text:#f1f5f9;
  --muted:#94a3b8;
  --border:#1e2d45;
  --primary:#818cf8;
  --primary-2:#a5b4fc;
  --primary-contrast:#0f172a;
  --shadow:0 8px 30px rgba(0,0,0,.45);
  --shadow-hover:0 12px 40px rgba(0,0,0,.55);
  --chart-grid: rgba(148,163,184,.12);
  --chart-text: #94a3b8;
}
/* Transición suave al cambiar tema */
html{transition: background-color .25s, color .25s}
body, .sidebar, .header, .panel, .card, .category-hero, .hero-card, .search-wrap, .modal-content,
.kpi, .table-wrap, .ad-placeholder, .field input, .field select, .btn-ghost, .icon-btn, .nav-item a{
  transition: background-color .25s, color .25s, border-color .25s, box-shadow .25s;
}

*{box-sizing:border-box;margin:0;padding:0}
body{
  font-family:'Inter',system-ui,sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
}

/* App layout */
.app{display:flex;min-height:100vh}
.sidebar{
  width:var(--sidebar-w);
  flex-shrink:0;
  background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  position:sticky;
  top:0;
  height:100vh;
  height:100dvh;
  overflow:hidden;
  z-index:30;
}
.sidebar-header{
  padding:16px 14px 14px;
  border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:10px;
}
.brand-wrap{display:flex;align-items:center;gap:10px;flex:1;min-width:0}
.brand-icon{
  width:38px;height:38px;display:grid;place-items:center;
  background:var(--text);color:var(--surface);border-radius:10px;
  font-size:17px;font-weight:800;flex-shrink:0;
}
.sidebar-header h1{font-size:16px;font-weight:800;letter-spacing:-.02em;line-height:1}
.sidebar-header p{font-size:11px;color:var(--muted);font-weight:500}
/* Theme toggle — superior izquierdo (sidebar header) */
.theme-toggle{
  width:40px;height:40px;border-radius:999px;
  border:1px solid var(--border);background:var(--surface-2);
  display:grid;place-items:center;cursor:pointer;flex-shrink:0;
  font-size:16px;line-height:1;position:relative;overflow:hidden;
  transition:.2s;
}
.theme-toggle:hover{transform:rotate(12deg) scale(1.05);border-color:var(--primary)}
.theme-toggle .icon-sun, .theme-toggle .icon-moon{
  position:absolute;transition:.3s;
}
[data-theme="light"] .theme-toggle .icon-moon{opacity:0;transform:translateY(10px) rotate(30deg)}
[data-theme="light"] .theme-toggle .icon-sun{opacity:1;transform:none}
[data-theme="dark"] .theme-toggle .icon-sun{opacity:0;transform:translateY(-10px) rotate(-30deg)}
[data-theme="dark"] .theme-toggle .icon-moon{opacity:1;transform:none}
.theme-toggle-small{
  width:36px;height:36px;font-size:14px;
}
.sidebar-nav{
  flex:1;
  overflow:auto;
  padding:16px 12px;
  display:flex;flex-direction:column;gap:18px;
}
.nav-section-label{
  font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);padding:0 8px;margin-bottom:6px;
}
.nav-list{list-style:none;display:flex;flex-direction:column;gap:4px}
.nav-item a{
  display:flex;align-items:center;gap:10px;
  padding:10px 10px;border-radius:10px;
  text-decoration:none;color:var(--text);font-size:13.5px;font-weight:500;
  border:1px solid transparent;transition:.15s;
}
.nav-item a:hover{background:var(--surface-2);border-color:var(--border)}
.nav-item.active a{background:var(--text);color:var(--surface);border-color:var(--text)}
.nav-item .nav-icon{width:28px;height:28px;display:grid;place-items:center;background:var(--surface-2);border:1px solid var(--border);border-radius:8px;font-size:14px;flex-shrink:0}
.nav-item.active .nav-icon{background:rgba(255,255,255,.15);border-color:transparent;color:var(--surface)}
[data-theme="dark"] .nav-item.active a{background:var(--surface-2);color:var(--text);border-color:var(--border)}
[data-theme="dark"] .nav-item.active .nav-icon{background:var(--surface-3);color:var(--text)}
.nav-count{margin-left:auto;font-size:11px;font-weight:700;background:var(--surface-2);border:1px solid var(--border);padding:2px 7px;border-radius:999px;color:var(--muted)}
.nav-item.active .nav-count{background:rgba(255,255,255,.18);border-color:transparent;color:var(--surface)}
[data-theme="dark"] .nav-item.active .nav-count{background:var(--surface-3);color:var(--text)}
.sidebar-footer{
  padding:14px 12px;
  border-top:1px solid var(--border);
  display:flex;flex-direction:column;gap:10px;
}
.ad-placeholder{
  background:var(--surface-2);border:1px dashed var(--border);
  border-radius:12px;padding:18px 12px;text-align:center;
  color:var(--muted);font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;
}
.ad-placeholder span{display:block;font-size:10px;margin-top:4px;opacity:.7;text-transform:none;letter-spacing:0}
.sidebar-footer-meta{font-size:11px;color:var(--muted);text-align:center}

/* Main */
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.header{
  position:sticky;top:0;z-index:20;
  background:color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
}
.header-inner{
  display:flex;align-items:center;justify-content:space-between;
  gap:12px;
  padding:0 20px;
  height:60px;
  min-height:60px;
  box-sizing:border-box;
}
@media(min-width:1100px){
  .header-inner{
    padding:0 28px;
    height:60px;
    min-height:60px;
  }
}
.header-left{display:flex;align-items:center;gap:10px}
.hamburger{display:none;width:40px;height:40px;border-radius:10px;border:1px solid var(--border);background:var(--surface);font-size:18px;cursor:pointer}
@media(max-width:860px){.hamburger{display:grid;place-items:center}}
.header-actions{display:flex;align-items:center;gap:10px;flex:1;justify-content:flex-end;max-width:560px}
.search-wrap{
  position:relative;flex:1;display:flex;align-items:center;
  background:var(--surface-2);border:1px solid var(--border);
  border-radius:999px;padding:8px 14px;gap:8px;
}
.search-wrap:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent)}
.search-icon{color:var(--muted);font-size:13px}
.search-wrap input{
  flex:1;border:none;background:transparent;outline:none;
  color:var(--text);font-size:14px;font-family:inherit;
}
.search-wrap kbd{
  font-family:'JetBrains Mono',monospace;font-size:11px;
  background:var(--surface);border:1px solid var(--border);
  padding:2px 6px;border-radius:6px;color:var(--muted);
  border-bottom-width:2px;
}
@media(max-width:560px){.search-wrap kbd{display:none}}
.icon-btn{
  width:40px;height:40px;border-radius:999px;border:1px solid var(--border);
  background:var(--surface);cursor:pointer;font-size:16px;color:var(--text);flex-shrink:0;
}
.icon-btn:hover{background:var(--surface-2)}

/* Evita desplazamiento horizontal cuando aparece/desaparece la barra vertical */
html{ scrollbar-gutter: stable; }

.content{padding:22px 20px;max-width:1400px;width:100%;margin:0 auto;box-sizing:border-box}
@media(min-width:1100px){.content{padding:28px 28px}}
/* Con dashboard-shell el contenido gana ancho — MISMO valor en todas las páginas */
.content:has(.dashboard-shell){ max-width:1720px; padding-left:20px; padding-right:20px; margin:0 auto; width:100%; box-sizing:border-box; }

/* Breadcrumb */
.breadcrumb{display:flex;gap:6px;align-items:center;font-size:13px;color:var(--muted);margin-bottom:16px;flex-wrap:wrap}
.breadcrumb a{color:var(--muted);text-decoration:none;font-weight:500}
.breadcrumb a:hover{color:var(--text);text-decoration:underline}
.breadcrumb .sep{opacity:.4}

/* Hero */
.hero{
  display:grid;grid-template-columns:1.7fr .9fr;gap:18px;
  margin-bottom:22px;
}
@media(max-width:980px){.hero{grid-template-columns:1fr}}
.hero-text h2{font-size:32px;font-weight:800;letter-spacing:-.03em;line-height:1.1}
@media(max-width:560px){.hero-text h2{font-size:26px}}
.hero-text h2 span{color:var(--primary)}
.hero-text p{color:var(--muted);margin:10px 0 14px;font-size:14px;max-width:560px}
.hero-stats{display:flex;gap:10px;font-size:13px;color:var(--muted);align-items:center;flex-wrap:wrap}
.hero-stats b{color:var(--text)}
.dot{opacity:.5}
.hero-card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);
}
.hero-card-header{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-bottom:12px}
.popular-list{list-style:none;display:flex;flex-direction:column;gap:8px}
.popular-list li{
  display:flex;align-items:center;gap:10px;
  padding:10px 12px;border-radius:12px;background:var(--surface-2);
  cursor:pointer;border:1px solid transparent;transition:.15s;
}
.popular-list li:hover{border-color:var(--border);transform:translateY(-1px)}
.popular-list .pi{
  width:32px;height:32px;display:grid;place-items:center;
  background:var(--surface);border-radius:8px;font-size:16px;border:1px solid var(--border);
}

/* Category page header */
.category-hero{
  background:var(--surface);border:1px solid var(--border);border-radius:20px;
  padding:22px;display:flex;align-items:center;gap:16px;margin-bottom:20px;box-shadow:var(--shadow);
}
.category-hero-icon{width:56px;height:56px;border-radius:14px;display:grid;place-items:center;font-size:26px;color:#fff;flex-shrink:0}
.category-hero h1{font-size:22px;font-weight:800;letter-spacing:-.02em}
.category-hero p{font-size:13px;color:var(--muted);margin-top:4px}
.category-hero-meta{margin-left:auto;text-align:right}
.category-hero-meta strong{font-size:22px;display:block;line-height:1}
.category-hero-meta span{font-size:11px;color:var(--muted);font-weight:600;letter-spacing:.06em;text-transform:uppercase}
@media(max-width:560px){.category-hero{flex-direction:column;align-items:flex-start}.category-hero-meta{margin-left:0;text-align:left}}

/* Dashboard */
#dashboard{display:flex;flex-direction:column;gap:26px}
.category{}
.cat-head{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.cat-head a{margin-left:auto;font-size:12px;font-weight:700;color:var(--primary);text-decoration:none;background:var(--surface);border:1px solid var(--border);padding:6px 10px;border-radius:999px;transition:.15s}
.cat-head a:hover{background:var(--primary);color:var(--primary-contrast);border-color:var(--primary)}
.cat-icon{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;font-size:16px;color:#fff}
.cat-title{font-size:15px;font-weight:700;letter-spacing:-.02em}
.cat-count{font-size:11px;font-weight:700;color:var(--muted);background:var(--surface);border:1px solid var(--border);padding:2px 8px;border-radius:999px}
.grid{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;
}
@media(max-width:1280px){ .grid{grid-template-columns:repeat(3,minmax(0,1fr));} }
@media(max-width:900px){ .grid{grid-template-columns:repeat(2,minmax(0,1fr));} }
@media(max-width:560px){ .grid{grid-template-columns:1fr;} }
.card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:16px;padding:16px;cursor:pointer;
  transition:.15s;box-shadow:var(--shadow);position:relative;
  display:flex;flex-direction:column;gap:10px;min-height:132px;
}
.card:hover{transform:translateY(-3px);box-shadow:var(--shadow-hover);border-color:color-mix(in srgb, var(--border) 60%, var(--primary) 40%)}
.card-top{display:flex;justify-content:space-between;align-items:flex-start}
.card-icon{width:40px;height:40px;border-radius:12px;display:grid;place-items:center;font-size:20px;background:var(--surface-2);border:1px solid var(--border)}
.card-arrow{width:28px;height:28px;border-radius:999px;display:grid;place-items:center;background:var(--surface-2);border:1px solid var(--border);font-size:12px;color:var(--muted);opacity:0;transform:translateX(-4px);transition:.15s}
.card:hover .card-arrow{opacity:1;transform:translateX(0)}
.card h3{font-size:14px;font-weight:700;line-height:1.2}
.card p{font-size:12.5px;color:var(--muted);line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.card-tag{margin-top:auto;font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);display:flex;align-items:center;gap:6px}
.card-tag::before{content:"";width:6px;height:6px;border-radius:999px;background:currentColor;opacity:.6}

/* Empty */
.empty{padding:40px;text-align:center;color:var(--muted);background:var(--surface);border:1px dashed var(--border);border-radius:16px}

/* Footer */
.footer{padding:28px 0 40px;text-align:center;color:var(--muted);font-size:12px;border-top:1px solid var(--border);margin-top:32px}
.footer code{font-family:'JetBrains Mono',monospace;background:var(--surface-2);padding:2px 6px;border-radius:6px;border:1px solid var(--border)}

/* Modal */
.modal{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:20px}
.modal.hidden{display:none}
.modal-backdrop{position:absolute;inset:0;background:rgba(2,6,23,.55);backdrop-filter:blur(4px)}
[data-theme="dark"] .modal-backdrop{background:rgba(0,0,0,.65)}
.modal-content{
  position:relative;background:var(--surface);border:1px solid var(--border);
  border-radius:20px;max-width:560px;width:100%;max-height:90vh;overflow:auto;
  padding:24px;box-shadow:0 20px 60px rgba(0,0,0,.25);animation:pop .18s ease;
}
@keyframes pop{from{transform:scale(.96) translateY(6px);opacity:0}to{transform:none;opacity:1}}
.modal-close{
  position:absolute;top:14px;right:14px;width:32px;height:32px;border-radius:999px;
  border:1px solid var(--border);background:var(--surface-2);cursor:pointer;color:var(--text);
}
.modal h2{font-size:20px;font-weight:800;letter-spacing:-.02em;margin-bottom:6px;display:flex;gap:10px;align-items:center}
.modal .subtitle{color:var(--muted);font-size:13px;margin-bottom:18px}
.calc-form{display:flex;flex-direction:column;gap:12px}
.field{display:flex;flex-direction:column;gap:6px}
.field label{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.field input, .field select{
  padding:10px 12px;border-radius:10px;border:1px solid var(--border);
  background:var(--surface-2);color:var(--text);font-size:14px;font-family:inherit;outline:none;
}
.field input:focus, .field select:focus{border-color:var(--primary);box-shadow:0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent)}
.field.hidden{display:none}
.btn-primary{
  padding:12px 16px;border-radius:12px;border:none;background:var(--primary);color:var(--primary-contrast);
  font-weight:700;font-size:14px;cursor:pointer;transition:.15s;
}
.btn-primary:hover{background:var(--primary-2);transform:translateY(-1px)}
.result{
  margin-top:14px;padding:16px;border-radius:14px;background:var(--surface-2);border:1px solid var(--border);
  text-align:center;
}
.result.hidden{display:none}
.result strong{font-size:22px;display:block}
.result span{font-size:12px;color:var(--muted)}
.badge-soon{display:inline-flex;padding:4px 8px;border-radius:999px;background:#fef3c7;color:#92400e;font-size:11px;font-weight:700;border:1px solid #fde68a}
[data-theme="dark"] .badge-soon{background:#422006;color:#fde68a;border-color:#78350f}

/* ============================================= */
/* LAYOUT CENTRADO PERFECTO — 3 columnas fijas   */
/* Izquierda 240 | gap 20 | centro 1fr | gap 20 | derecha 240 */
/* Simétrico en TODAS las páginas (index, categorías, calculadoras) */
/* ============================================= */

.dashboard-shell{
  display:grid;
  grid-template-columns:240px minmax(0,1fr) 240px;
  gap:20px;
  align-items:start;
  justify-content:center;
  justify-items:stretch;
  max-width:1720px;
  margin:0 auto;
  padding:0 16px;
  width:100%;
  min-width:0;
  box-sizing:border-box;
}

/* Marcos — columnas fijas simétricas, sin líneas nombradas complejas */
.frame--left{ grid-column:1; }
.frame--center{
  grid-column:2;
  min-width:0;
  width:100%;
  max-width:100%;
  padding:0;
  box-sizing:border-box;
  justify-self:stretch;
  position:relative;
  z-index:1;
  background:transparent;
}
.frame--right{ grid-column:3; }

/* Laterales: sticky, ancho fijo 240, centrados dentro de su celda */
.frame--left,
.frame--right{
  position:sticky;
  top:72px;
  align-self:start;
  justify-self:center;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  width:100%;
  max-width:240px;
  box-sizing:border-box;
}

.frame__content{
  width:100%;
  max-width:240px;
  min-height:600px;
  margin:0 auto;
  box-sizing:border-box;
  flex-shrink:0;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  padding:24px 22px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  text-align:center;
  box-shadow:var(--shadow);
  position:relative;
  overflow:hidden;
}

/* Etiqueta "ADSENSE" en la esquina (opcional) */
.frame__content::before {
  content: "ADSENSE";
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--muted);
}

.ad-rail__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .9;
  margin-bottom: 8px;
}

.frame__content small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  opacity: .6;
  margin-top: 4px;
}

.ad-placeholder-demo {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  opacity: .55;
}

/* El contenedor del anuncio en sí mismo ocupa todo el espacio disponible */
.frame__content ins.adsbygoogle {
  display: block;
  width: 100%;
  min-height: 600px;
}

/* Banner horizontal (visible solo en tablet/móvil) */
.ad-slot--horizontal {
  display: none;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
}
.ad-slot--horizontal small {
  display: block;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  opacity: .6;
  margin-top: 4px;
}

/* Asegura que el contenido interno nunca fuerce overflow del grid */
.calc-layout,
.stack,
.info-grid,
.panel,
.category-hero,
.hero,
.grid{
  min-width:0;
  max-width:100%;
  box-sizing:border-box;
}

/* Intermedios: laterales idénticos en TODAS las páginas — sin :has para evitar conflictos de especificidad */
@media (max-width:1400px){
  .dashboard-shell{
    grid-template-columns:200px minmax(0,1fr) 200px;
    gap:16px;
  }
  .frame--left, .frame--right{ max-width:200px; }
  .frame__content{ max-width:200px; }
}
@media (max-width:1220px){
  .dashboard-shell{
    grid-template-columns:160px minmax(0,1fr) 160px;
    gap:12px;
  }
  .frame--left, .frame--right{ max-width:160px; }
  .frame__content{ max-width:160px; padding:16px 12px; }
}

/* RESPONSIVE: en pantallas menores a 1100px ocultamos los laterales y mostramos banners horizontales */
@media (max-width: 1100px) {
  .ad-slot--horizontal {
    display: block;
  }
  .frame--left,
  .frame--right {
    display: none !important;
  }
  .dashboard-shell {
    grid-template-columns: 1fr !important; /* Una sola columna para el centro */
    gap: 0 !important;
    width: 100%;
  }
  .frame--center {
    grid-column: 1 / -1 !important;
    min-width: 0;
    width: 100%;
    padding: 0;
  }
}

/* Ajuste fino para móviles pequeños */
@media (max-width: 768px) {
  .dashboard-shell {
    padding: 0 8px;
    grid-template-columns: 1fr !important;
  }
  .frame--left,
  .frame--right {
    display: none !important;
  }
  .frame--center {
    grid-column: 1 / -1 !important;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-text h2 {
    font-size: 24px;
  }
}