@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── VARIABLES ── */
:root {
  --sp-bg: #0b1220;
  --sp-sidebar: #0e1628;
  --sp-border: rgba(255,255,255,.08);
  --sp-muted: #64748b;
}

/* ── BASE ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', Arial, sans-serif; background: var(--sp-bg); color: #e2e8f0; }

/* ── ADMIN LAYOUT ── */
.admin-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.admin-sidebar {
  width: 220px; height: 100vh; background: var(--sp-sidebar);
  border-right: 1px solid var(--sp-border);
  display: flex; flex-direction: column; padding: 20px 14px;
  overflow-y: auto; flex-shrink: 0;
}
.admin-sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; padding: 0 4px; }
.admin-sidebar-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 14px; color: #fff; flex-shrink: 0; box-shadow: none;
}
.admin-sidebar-title { font-weight: 800; font-size: 13px; line-height: 1.2; color: #fff; }
.admin-sidebar-subtitle { font-size: 11px; color: var(--sp-muted); }
.admin-sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.admin-sidebar-nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 10px; color: #94a3b8;
  font-size: 13.5px; font-weight: 500; transition: .15s;
  border: 1px solid transparent; text-decoration: none;
}
.admin-sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-sidebar-nav a.active {
  background: rgba(59,130,246,.18); border-color: rgba(59,130,246,.25);
  color: #93c5fd; font-weight: 700;
}
.admin-sidebar-nav .nav-icon { width: 18px; text-align: center; font-size: 15px; }
.admin-sidebar-nav .logout { color: #f87171; }

/* ── MAIN AREA ── */
.admin-main {
  flex: 1; min-width: 0; height: 100vh;
  overflow-y: auto; display: flex; flex-direction: column;
  background: var(--sp-bg);
}

/* ── TOP HEADER BAR ── */
.sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  background: rgba(14,22,40,.98); border-bottom: 1px solid var(--sp-border);
  flex-shrink: 0; gap: 12px;
}
.sp-header-left  { display: flex; align-items: center; gap: 14px; }
.sp-header-right { display: flex; align-items: center; gap: 10px; }
.sp-hamburger { width: 32px; height: 32px; display: flex; flex-direction: column; justify-content: center; gap: 5px; cursor: pointer; }
.sp-hamburger span { width: 18px; height: 2px; background: #94a3b8; border-radius: 2px; display: block; }
.sp-header-live { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.sp-header-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; animation: sp-blink 1.4s infinite; }
.sp-header-live .txt { color: #4ade80; font-weight: 600; }
.sp-header-live .ts  { color: var(--sp-muted); }
@keyframes sp-blink { 0%,100%{opacity:1;} 50%{opacity:.3;} }
.sp-icon-btn {
  width: 32px; height: 32px; border-radius: 9px;
  background: rgba(255,255,255,.06); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; color: #94a3b8; border: 1px solid var(--sp-border);
}
.sp-profile {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--sp-border);
  border-radius: 20px; padding: 4px 12px 4px 4px; cursor: pointer;
}
.sp-profile-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
}
.sp-profile-name { font-size: 12px; font-weight: 600; color: #e2e8f0; }
.sp-profile-role { font-size: 10px; color: var(--sp-muted); }

/* ── PAGE TOPBAR ── */
.sp-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 0; gap: 12px; flex-wrap: wrap;
}
.sp-topbar-left .breadcrumb { font-size: 12px; color: var(--sp-muted); margin-bottom: 4px; }
.sp-topbar-left h1 { font-size: 26px; font-weight: 900; margin: 0; line-height: 1.1; color: #f1f5f9; }
.sp-topbar-left h1 .pro { color: #818cf8; }
.sp-topbar-left .subtitle { font-size: 13px; color: var(--sp-muted); margin-top: 3px; }
.sp-topbar-right { display: flex; align-items: center; gap: 10px; }
.sp-range-form select {
  background: rgba(255,255,255,.07); border: 1px solid var(--sp-border);
  border-radius: 10px; color: #fff; padding: 7px 14px; font-size: 13px;
  outline: none; cursor: pointer;
}

/* ── CONTENT ── */
.sp-content { padding: 20px 28px 48px; flex: 1; }

/* ── OVERRIDE OLD .page & .hero ── */
.page { padding: 20px 28px 48px; max-width: none !important; }
.hero {
  margin-bottom: 20px; padding: 0; border: none;
  background: none !important; box-shadow: none;
}
.hero h2 { font-size: 26px; font-weight: 900; margin-bottom: 4px; color: #f1f5f9; }
.hero p  { font-size: 13px; color: var(--sp-muted); }

/* ── PRO PANELS ── */
.pro-panel {
  background: rgba(255,255,255,.035); border: 1px solid var(--sp-border);
  border-radius: 18px; overflow: hidden; margin-bottom: 20px;
}
.pro-panel:last-child { margin-bottom: 0; }
.pro-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--sp-border);
}
.pro-panel-title    { font-size: 16px; font-weight: 800; color: #f1f5f9; }
.pro-panel-subtitle { font-size: 12px; color: var(--sp-muted); margin-top: 2px; }
.pro-panel-body     { padding: 20px 22px; }

/* ── OVERRIDE OLD .panel ── */
.panel {
  background: rgba(255,255,255,.035) !important;
  border: 1px solid var(--sp-border) !important;
  border-radius: 18px !important; overflow: hidden;
  box-shadow: none !important;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px !important; border-bottom: 1px solid var(--sp-border);
}
.panel-title    { font-size: 16px !important; font-weight: 800 !important; color: #f1f5f9 !important; margin: 0; }
.panel-subtitle { font-size: 12px !important; color: var(--sp-muted) !important; margin: 0; }
.panel-body     { padding: 20px 22px !important; }

/* ── PRO KPI GRID ── */
.pro-kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.pro-kpi-card {
  background: rgba(255,255,255,.04); border: 1px solid var(--sp-border);
  border-radius: 16px; padding: 20px; position: relative; overflow: hidden;
}
.pro-kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 3px 3px 0 0;
}
.pro-kpi-card.c-blue::before   { background: linear-gradient(90deg,#3b82f6,#06b6d4); }
.pro-kpi-card.c-green::before  { background: linear-gradient(90deg,#22c55e,#16a34a); }
.pro-kpi-card.c-purple::before { background: linear-gradient(90deg,#a855f7,#7c3aed); }
.pro-kpi-card.c-pink::before   { background: linear-gradient(90deg,#ec4899,#f43f5e); }
.pro-kpi-card.c-orange::before { background: linear-gradient(90deg,#f97316,#f59e0b); }
.pro-kpi-icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.c-blue   .pro-kpi-icon { background: rgba(59,130,246,.18);  color: #60a5fa; }
.c-green  .pro-kpi-icon { background: rgba(34,197,94,.18);   color: #4ade80; }
.c-purple .pro-kpi-icon { background: rgba(168,85,247,.18);  color: #c084fc; }
.c-pink   .pro-kpi-icon { background: rgba(236,72,153,.18);  color: #f472b6; }
.c-orange .pro-kpi-icon { background: rgba(249,115,22,.18);  color: #fb923c; }
.pro-kpi-label { font-size: 12px; color: var(--sp-muted); font-weight: 500; margin-bottom: 6px; }
.pro-kpi-value { font-size: 32px; font-weight: 900; line-height: 1; margin-bottom: 4px; }
.pro-kpi-note  { font-size: 12px; color: var(--sp-muted); }
.c-blue   .pro-kpi-value { color: #60a5fa; }
.c-green  .pro-kpi-value { color: #4ade80; }
.c-purple .pro-kpi-value { color: #c084fc; }
.c-pink   .pro-kpi-value { color: #f472b6; }
.c-orange .pro-kpi-value { color: #fb923c; }

/* ── OVERRIDE OLD .stats-grid / .stat-card ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 20px; }
.stat-card  { background: rgba(255,255,255,.04) !important; border: 1px solid var(--sp-border) !important; border-radius: 16px !important; padding: 20px !important; box-shadow: none !important; }
.stat-label { color: var(--sp-muted); font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 32px !important; font-weight: 900; line-height: 1; margin-bottom: 4px; color: #60a5fa; }
.stat-note  { font-size: 12px; color: var(--sp-muted); }

/* ── GRIDS ── */
.grid-2    { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
.pro-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; }
.pro-grid-eq{ display: grid; grid-template-columns: 1fr 1fr;   gap: 20px; margin-bottom: 20px; }
.pro-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* ── FORMS ── */
.form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; }
.form-group.full { grid-column: 1/-1; }
label { margin-bottom: 7px; color: #cbd5e1; font-size: 13px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--sp-border); background: rgba(255,255,255,.05);
  color: #fff; outline: none; font-size: 13.5px; font-family: 'Inter', Arial, sans-serif;
}
input::placeholder, textarea::placeholder { color: var(--sp-muted); }
input:focus, select:focus, textarea:focus {
  border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.14);
}
select option { background: #1e293b; }

/* ── BUTTONS ── */
.btn, .pro-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 10px 16px; border-radius: 11px; border: none;
  cursor: pointer; color: #fff; font-size: 13.5px; font-weight: 700;
  transition: .15s; font-family: 'Inter', Arial, sans-serif; text-decoration: none;
}
.btn:hover, .pro-btn:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary,   .pro-btn-primary   { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.btn-success,   .pro-btn-success   { background: linear-gradient(135deg,#22c55e,#16a34a); }
.btn-secondary, .pro-btn-secondary { background: rgba(255,255,255,.08); border: 1px solid var(--sp-border); }
.btn-danger,    .pro-btn-danger    { background: linear-gradient(135deg,#ef4444,#dc2626); }
.btn-soft-blue  { background: linear-gradient(135deg,#2563eb,#1d4ed8); color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 700; cursor: pointer; border: none; font-family: 'Inter', Arial, sans-serif; }
.btn-soft-gray  { background: linear-gradient(135deg,#475569,#334155); color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 700; cursor: pointer; border: none; font-family: 'Inter', Arial, sans-serif; }
.btn-soft-red   { background: linear-gradient(135deg,#b91c1c,#7f1d1d); color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; border-radius: 11px; font-size: 13.5px; font-weight: 700; cursor: pointer; border: none; font-family: 'Inter', Arial, sans-serif; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
th { color: var(--sp-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
td { color: #e2e8f0; font-size: 13.5px; }
tr:hover td { background: rgba(255,255,255,.02); }
.actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ── BADGES ── */
.badge, .pro-badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-success, .pro-badge-success { background: rgba(34,197,94,.14);  color: #86efac; }
.badge-danger,  .pro-badge-danger  { background: rgba(239,68,68,.14);  color: #fecaca; }
.badge-info     { background: rgba(59,130,246,.14); color: #93c5fd; }

/* ── ALERT ── */
.alert, .pro-alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--sp-border); font-size: 13.5px; }
.alert-error, .pro-alert-error { background: rgba(239,68,68,.12); color: #fecaca; }
.alert-success                 { background: rgba(34,197,94,.12); color: #bbf7d0; }

/* ── TOAST ── */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast { min-width: 290px; padding: 15px 17px; border-radius: 14px; border: 1px solid var(--sp-border); box-shadow: 0 20px 50px rgba(0,0,0,.3); color: #fff; backdrop-filter: blur(8px); }
.toast-success { background: linear-gradient(135deg,rgba(34,197,94,.92),rgba(22,163,74,.92)); }
.toast-info    { background: linear-gradient(135deg,rgba(59,130,246,.92),rgba(37,99,235,.92)); }
.toast-error   { background: linear-gradient(135deg,rgba(239,68,68,.92),rgba(220,38,38,.92)); }
.toast-title   { font-weight: 800; margin-bottom: 3px; }
.toast-text    { font-size: 12.5px; line-height: 1.5; }

/* ── UTILS ── */
.small        { font-size: 12px; color: var(--sp-muted); }
.preview-link { word-break: break-all; color: #93c5fd; font-size: 12px; }
.empty        { text-align: center; color: var(--sp-muted); padding: 28px; font-size: 14px; }
.kpi-list     { display: flex; flex-direction: column; gap: 12px; }
.kpi-item     { padding: 16px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--sp-border); }

/* ── RANGE BUTTONS (monetizacion) ── */
.range-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.range-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 12px; text-decoration: none;
  color: #94a3b8; background: rgba(255,255,255,.04); border: 1px solid var(--sp-border);
  font-weight: 700; font-size: 13px; transition: .15s;
}
.range-btn.active { background: linear-gradient(135deg,#2563eb,#1d4ed8); color: #fff; border-color: transparent; }

/* ── LOGIN ── */
body.pro-login {
  background: var(--sp-bg); display: flex; align-items: center;
  justify-content: center; min-height: 100vh; height: auto; overflow: auto;
}
.pro-login-wrap { width: 100%; max-width: 420px; padding: 20px; margin: auto; }
.pro-login-card {
  background: rgba(255,255,255,.05); border: 1px solid var(--sp-border);
  border-radius: 24px; padding: 36px; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.pro-login-brand    { text-align: center; margin-bottom: 28px; }
.pro-login-logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg,#3b82f6,#7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 20px; color: #fff; margin: 0 auto 12px;
}
.pro-login-title    { font-size: 22px; font-weight: 900; color: #f1f5f9; }
.pro-login-subtitle { font-size: 13px; color: var(--sp-muted); margin-top: 4px; }
.pro-login-group    { margin-bottom: 16px; }
.pro-login-group label { display: block; margin-bottom: 7px; color: #cbd5e1; font-size: 13px; font-weight: 600; }
.pro-login-group input {
  width: 100%; padding: 12px 15px; border-radius: 12px;
  border: 1px solid var(--sp-border); background: rgba(255,255,255,.05);
  color: #fff; font-size: 14px; outline: none; font-family: 'Inter', Arial, sans-serif;
}
.pro-login-group input:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.14); }
.pro-login-btn {
  width: 100%; padding: 13px; border: none; border-radius: 13px;
  background: linear-gradient(135deg,#22c55e,#16a34a); color: #fff;
  font-size: 15px; font-weight: 800; cursor: pointer; font-family: 'Inter', Arial, sans-serif; margin-top: 6px;
}
.pro-login-btn:hover { opacity: .9; }
.pro-login-alert { padding: 12px 14px; border-radius: 11px; margin-bottom: 16px; text-align: center; font-size: 13px; }
.pro-login-alert.success { background: rgba(34,197,94,.14); color: #bbf7d0; }
.pro-login-alert.error   { background: rgba(239,68,68,.14);  color: #fecaca; }

/* ── RESPONSIVE ── */
.sp-hamburger { display: none; }

@media(max-width: 1100px) {
  .pro-kpi-grid, .stats-grid { grid-template-columns: repeat(2,1fr); }
  .pro-grid-2, .grid-2 { grid-template-columns: 1fr; }
}

@media(max-width: 760px) {
  /* Hamburger visible */
  .sp-hamburger { display: flex; }

  /* Sidebar oculto por defecto, aparece como drawer */
  .admin-sidebar {
    display: none !important;
    position: fixed; top: 0; left: 0; z-index: 10000;
    height: 100vh; width: 260px !important;
    overflow-y: auto; background: #0e1628 !important;
    box-shadow: 4px 0 32px rgba(0,0,0,.6);
  }
  .admin-sidebar.sidebar-open { display: flex !important; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 9999; }
  .sidebar-overlay.show { display: block; }

  /* Layout principal */
  .admin-layout { height: auto; min-height: 100vh; overflow: visible; }
  .admin-main   { width: 100%; height: auto; min-height: 100vh; overflow-y: visible; }

  /* Header */
  .sp-header { padding: 0 14px; }
  .sp-profile-name, .sp-profile-role, .sp-icon-btn { display: none; }
  .sp-profile { padding: 4px 8px 4px 4px; }

  /* Topbar */
  .sp-topbar { padding: 14px 14px 0; flex-direction: column; align-items: flex-start; gap: 10px; }
  .sp-topbar-left h1 { font-size: 20px; }
  .sp-topbar-right { width: 100%; flex-wrap: wrap; gap: 8px; }
  .sp-range-form select { width: 100%; }

  /* Contenido */
  .sp-content, .page { padding: 12px 12px 40px; }

  /* KPI grids — 2 columnas en móvil */
  .pro-kpi-grid, .stats-grid { grid-template-columns: repeat(2,1fr); gap: 10px; }
  .pro-kpi-value, .stat-value { font-size: 22px !important; }
  .pro-kpi-card, .stat-card   { padding: 14px !important; }

  /* Grids de contenido — 1 columna */
  .pro-grid-2, .pro-grid-eq, .pro-grid-3, .grid-2, .sp-grid-2 { grid-template-columns: 1fr !important; }

  /* Formularios */
  .form-grid { grid-template-columns: 1fr; }

  /* Tablas */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 500px; }
  th, td { padding: 10px 10px; font-size: 12px; }

  /* Botones de acción en tablas */
  .actions { flex-wrap: wrap; gap: 5px; }
  .btn, .pro-btn { padding: 7px 11px; font-size: 12px; }

  /* Paneles */
  .pro-panel-header, .panel-header { padding: 14px 16px 12px !important; flex-wrap: wrap; gap: 8px; }
  .pro-panel-body,   .panel-body   { padding: 14px 16px !important; }

  /* Mapas y charts — altura reducida */
  #sp-world-map { height: 220px !important; }
  .chart-main-wrap { height: 180px !important; }
  canvas { max-height: 200px; }

  /* Tarjetas de dashboard */
  .pro-panel { margin-bottom: 12px; }
}

@media(max-width: 420px) {
  .pro-kpi-grid, .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sp-topbar-left h1 { font-size: 18px; }
  .sp-header-live .txt { display: none; }
}
