/* ================================================================
   MYCONNECT ADMIN PANEL — Design System v2
   Inspired by: Linear, Stripe, Vercel
   Aesthetic: Refined Dark SaaS — premium, precise, minimal
   Fonts: Geist (display) + JetBrains Mono (code)
   ================================================================ */

/* ──────────────────────────────────────────────────────────────────
   01. GOOGLE FONTS IMPORT
   ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ──────────────────────────────────────────────────────────────────
   02. DESIGN TOKENS — Variables CSS
   Sistema de tokens semánticos en dos capas:
   primitivos (valores puros) → semánticos (uso contextual)
   ────────────────────────────────────────────────────────────────── */
:root {
  /* — Paleta primitiva — */
  --slate-950: #030712;
  --slate-900: #0A0F1E;
  --slate-850: #0D1526;
  --slate-800: #111827;
  --slate-750: #161f35;
  --slate-700: #1e2d45;
  --slate-600: #253352;
  --slate-400: #64748b;
  --slate-300: #94a3b8;
  --slate-200: #cbd5e1;
  --slate-100: #e2e8f0;

  --crimson-600: #C41230;
  --crimson-500: #DC1A3C;
  --crimson-400: #E63946;
  --crimson-300: #F05C67;
  --crimson-100: rgba(220,26,60,0.10);
  --crimson-050: rgba(220,26,60,0.05);

  --emerald-500: #10B981;
  --emerald-400: #34D399;
  --emerald-100: rgba(16,185,129,0.10);

  --amber-500:   #F59E0B;
  --amber-400:   #FBB53E;
  --amber-100:   rgba(245,158,11,0.10);

  --sky-500:     #0EA5E9;
  --sky-400:     #38BDF8;
  --sky-100:     rgba(14,165,233,0.10);

  --orange-400:  #FB923C;
  --orange-100:  rgba(251,146,60,0.10);

  /* — Tokens semánticos — */
  --bg:          var(--slate-950);
  --bg-subtle:   var(--slate-900);
  --surface:     var(--slate-850);
  --surface-2:   var(--slate-800);
  --surface-3:   var(--slate-750);

  --border:      rgba(255,255,255,0.055);
  --border-2:    rgba(255,255,255,0.095);
  --border-3:    rgba(255,255,255,0.145);

  --text:        rgba(255,255,255,0.92);
  --text-2:      rgba(255,255,255,0.60);
  --text-3:      rgba(255,255,255,0.35);

  --accent:      var(--crimson-400);
  --accent-dim:  var(--crimson-100);
  --accent-hover:var(--crimson-500);

  --success:     var(--emerald-400);
  --success-dim: var(--emerald-100);
  --warning:     var(--amber-400);
  --warning-dim: var(--amber-100);
  --info:        var(--sky-400);
  --info-dim:    var(--sky-100);
  --orange:      var(--orange-400);
  --orange-dim:  var(--orange-100);

  /* — Tipografía — */
  --font-sans:   'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  /* — Radios — */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* — Sombras — */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
  --shadow-lg:  0 16px 48px rgba(0,0,0,0.5), 0 6px 16px rgba(0,0,0,0.3);
  --shadow-xl:  0 32px 80px rgba(0,0,0,0.6), 0 12px 32px rgba(0,0,0,0.35);
  --shadow-glow:0 0 20px rgba(220,26,60,0.18);

  /* — Transiciones — */
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.0, 0.0, 0.2, 1);
  --t-fast:   120ms;
  --t-base:   200ms;
  --t-slow:   350ms;

  /* — Espaciado base — */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10:40px;
  --space-12:48px;
}

/* ──────────────────────────────────────────────────────────────────
   03. RESET & BASE
   ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  /* Textura sutil de fondo — grain premium */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(220,26,60,0.06) 0%, transparent 65%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.022'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar personalizado */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-3);
  border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* Selección de texto */
::selection {
  background: rgba(220,26,60,0.25);
  color: var(--text);
}

/* ──────────────────────────────────────────────────────────────────
   04. TIPOGRAFÍA — escala visual
   ────────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

code, kbd, pre {
  font-family: var(--font-mono);
}

/* ──────────────────────────────────────────────────────────────────
   05. INPUTS & FORMULARIOS
   ────────────────────────────────────────────────────────────────── */
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  width: 100%;
  outline: none;
  transition:
    border-color var(--t-base) var(--ease),
    box-shadow   var(--t-base) var(--ease),
    background   var(--t-base) var(--ease);
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface-3);
  box-shadow: 0 0 0 3px rgba(220,26,60,0.12), 0 1px 4px rgba(0,0,0,0.2);
}

input[readonly] {
  opacity: 0.45;
  cursor: default;
  background: var(--surface);
}

input::placeholder,
textarea::placeholder { color: var(--text-3); }

select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

select option {
  background: var(--surface-2);
  color: var(--text);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field-group label {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}

/* ──────────────────────────────────────────────────────────────────
   06. BOTONES
   Cada botón tiene: estado normal, hover (con shimmer), active, disabled
   ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition:
    background    var(--t-base) var(--ease),
    border-color  var(--t-base) var(--ease),
    box-shadow    var(--t-base) var(--ease),
    transform     var(--t-fast) var(--ease),
    color         var(--t-base) var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* Efecto shimmer en hover */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.45s var(--ease);
}
.btn:hover::after { transform: translateX(100%); }

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none !important;
  pointer-events: none;
}

/* — Variantes — */
.btn-primary {
  background: var(--crimson-500);
  color: #fff;
  border-color: var(--crimson-600);
  box-shadow: 0 1px 3px rgba(220,26,60,0.3), inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-primary:hover {
  background: var(--crimson-400);
  box-shadow: 0 4px 12px rgba(220,26,60,0.4), inset 0 1px 0 rgba(255,255,255,0.1);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-3);
}

.btn-success {
  background: rgba(16,185,129,0.15);
  color: var(--emerald-400);
  border-color: rgba(16,185,129,0.25);
}
.btn-success:hover {
  background: rgba(16,185,129,0.22);
  border-color: rgba(16,185,129,0.4);
  box-shadow: 0 4px 12px rgba(16,185,129,0.15);
}

.btn-danger {
  background: var(--crimson-100);
  color: var(--crimson-400);
  border-color: rgba(220,26,60,0.2);
}
.btn-danger:hover {
  background: var(--crimson-500);
  color: #fff;
  border-color: var(--crimson-600);
  box-shadow: 0 4px 12px rgba(220,26,60,0.3);
}

.btn-full { width: 100%; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--r-sm);
  gap: 5px;
}

/* SVG dentro de botones */
.btn svg { flex-shrink: 0; }

/* ──────────────────────────────────────────────────────────────────
   07. PANTALLA DE LOGIN
   ────────────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-6);
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%,   rgba(220,26,60,0.09)  0%, transparent 70%),
    radial-gradient(ellipse 50% 35% at 80% 90%,   rgba(14,165,233,0.04) 0%, transparent 60%),
    var(--bg);
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2xl);
  padding: var(--space-12) var(--space-10);
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.025) inset;
  animation: loginReveal 0.5s var(--ease) both;
}

@keyframes loginReveal {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.login-logo .brand {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--text);
  position: relative;
}

/* Línea decorativa bajo el logo */
.login-logo .brand::after {
  content: '';
  display: block;
  width: 28px;
  height: 2px;
  background: var(--accent);
  border-radius: var(--r-full);
  margin: 6px auto 0;
}

.login-logo .sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  margin-top: var(--space-1);
}

/* ──────────────────────────────────────────────────────────────────
   08. DASHBOARD — Layout principal
   ────────────────────────────────────────────────────────────────── */
#dashboard {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.3s var(--ease) both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ──────────────────────────────────────────────────────────────────
   09. TOPBAR
   ────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: rgba(3,7,18,0.82);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-8);
  transition: background var(--t-base) var(--ease);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-brand .dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(220,26,60,0.15), 0 0 10px rgba(220,26,60,0.4);
  animation: dotPulse 2.5s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(220,26,60,0.15), 0 0 10px rgba(220,26,60,0.4); }
  50%       { box-shadow: 0 0 0 4px rgba(220,26,60,0.08), 0 0 18px rgba(220,26,60,0.2); }
}

.topbar-brand span {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  padding: 5px 12px 5px 6px;
  font-size: 12px;
  color: var(--text-2);
  transition: border-color var(--t-base) var(--ease);
}

.admin-badge:hover { border-color: var(--border-3); }

.admin-badge .av {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, rgba(220,26,60,0.3), rgba(220,26,60,0.1));
  border: 1px solid rgba(220,26,60,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-sans);
}

/* ──────────────────────────────────────────────────────────────────
   10. CONTENIDO PRINCIPAL
   ────────────────────────────────────────────────────────────────── */
.main {
  max-width: 1340px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

/* ──────────────────────────────────────────────────────────────────
   11. STATS CARDS
   Diseño con borde superior de color + gradiente interior sutil
   ────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5) var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--t-base) var(--ease),
    transform    var(--t-base) var(--ease),
    box-shadow   var(--t-base) var(--ease);
  cursor: default;
}

.stat-card:hover {
  border-color: var(--border-3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Borde superior de color */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1.5px;
  border-radius: var(--r-full);
}

/* Brillo de fondo sutil */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60%;
  opacity: 0.03;
  pointer-events: none;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.stat-card.red::before  { background: linear-gradient(90deg, transparent, var(--crimson-400), transparent); }
.stat-card.green::before{ background: linear-gradient(90deg, transparent, var(--emerald-400), transparent); }
.stat-card.amber::before{ background: linear-gradient(90deg, transparent, var(--amber-400),   transparent); }
.stat-card.blue::before { background: linear-gradient(90deg, transparent, var(--sky-400),     transparent); }

.stat-card.red::after   { background: var(--crimson-400); }
.stat-card.green::after { background: var(--emerald-400); }
.stat-card.amber::after { background: var(--amber-400); }
.stat-card.blue::after  { background: var(--sky-400); }

.stat-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  font-family: var(--font-mono);
  letter-spacing: -0.03em;
  transition: color var(--t-base) var(--ease);
}

.stat-card.red   .stat-value { color: var(--crimson-300); }
.stat-card.green .stat-value { color: var(--emerald-400); }
.stat-card.amber .stat-value { color: var(--amber-400); }
.stat-card.blue  .stat-value { color: var(--sky-400); }

/* ──────────────────────────────────────────────────────────────────
   12. TABS DE NAVEGACIÓN
   ────────────────────────────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.dash-tab {
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-3);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
  font-family: var(--font-sans);
  text-transform: uppercase;
  position: relative;
}

.dash-tab:hover { color: var(--text-2); }

.dash-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.dash-panel { display: none; }
.dash-panel.active {
  display: block;
  animation: panelIn 0.2s var(--ease) both;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ──────────────────────────────────────────────────────────────────
   13. TOOLBAR
   ────────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.toolbar h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.toolbar-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap { position: relative; }

.search-wrap input {
  padding-left: 36px;
  width: 220px;
  height: 34px;
  font-size: 12px;
  padding-top: 0;
  padding-bottom: 0;
  border-radius: var(--r-md);
  transition: width var(--t-slow) var(--ease), border-color var(--t-base) var(--ease);
}

.search-wrap input:focus { width: 280px; }

.search-wrap svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* ──────────────────────────────────────────────────────────────────
   14. TABLA DE CLIENTES
   ────────────────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

thead th {
  padding: 12px 18px;
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  font-family: var(--font-sans);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition:
    background var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover {
  background: rgba(255,255,255,0.025);
}


tbody tr:hover::before { transform: scaleY(1); }

tbody td {
  padding: 13px 18px;
  vertical-align: middle;
  white-space: nowrap;
}

.td-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.td-email {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-top: 2px;
}

.td-mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
}

.empty-row td {
  text-align: center;
  padding: 64px 20px !important;
  color: var(--text-3);
  font-size: 13px;
  cursor: default;
}

/* ──────────────────────────────────────────────────────────────────
   15. BADGES — Sistema de etiquetas
   ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.badge-active {
  background: var(--emerald-100);
  color: var(--emerald-400);
  border: 1px solid rgba(52,211,153,0.18);
}
.badge-active .badge-dot { background: var(--emerald-400); }

.badge-expired {
  background: var(--crimson-100);
  color: var(--crimson-300);
  border: 1px solid rgba(220,26,60,0.18);
}
.badge-expired .badge-dot { background: var(--crimson-300); }

.badge-pending {
  background: var(--amber-100);
  color: var(--amber-400);
  border: 1px solid rgba(245,158,11,0.18);
}
.badge-pending .badge-dot { background: var(--amber-400); }

.badge-cancelled {
  background: rgba(255,255,255,0.04);
  color: var(--text-3);
  border: 1px solid var(--border);
}
.badge-cancelled .badge-dot { background: var(--text-3); }

.badge-vip {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(251,146,60,0.2);
}

.badge-mensual {
  background: var(--sky-100);
  color: var(--sky-400);
  border: 1px solid rgba(14,165,233,0.18);
}

.badge-trimestral {
  background: rgba(99,102,241,0.10);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,0.2);
}

.badge-anual {
  background: var(--emerald-100);
  color: var(--emerald-400);
  border: 1px solid rgba(52,211,153,0.18);
}

/* ──────────────────────────────────────────────────────────────────
   16. MODALES
   Frosted glass effect + animación de entrada suave
   ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-backdrop.open {
  display: flex;
  animation: backdropIn 0.2s var(--ease) both;
}

@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-2xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.03) inset;
  animation: modalIn 0.28s var(--ease) both;
  position: relative;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.modal-close {
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  transition:
    background     var(--t-base) var(--ease),
    border-color   var(--t-base) var(--ease),
    color          var(--t-base) var(--ease),
    transform      var(--t-fast) var(--ease);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--crimson-100);
  border-color: rgba(220,26,60,0.25);
  color: var(--accent);
  transform: rotate(90deg);
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-section-title {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-group label {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ──────────────────────────────────────────────────────────────────
   17. LOADER & TOAST
   ────────────────────────────────────────────────────────────────── */
.loader {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-top-color: currentColor;
  border-radius: var(--r-full);
  animation: spin 0.55s linear infinite;
  vertical-align: middle;
  margin-right: var(--space-1);
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  padding: 13px 18px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: 360px;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#toast.ok   { border-color: rgba(52,211,153,0.3);  }
#toast.err  { border-color: rgba(220,26,60,0.35);  }
#toast.warn { border-color: rgba(245,158,11,0.3);  }

/* ──────────────────────────────────────────────────────────────────
   18. SECCIÓN DE LISTAS M3U
   ────────────────────────────────────────────────────────────────── */
.listas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.lista-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}

.lista-card:hover {
  border-color: var(--border-3);
  box-shadow: var(--shadow-md);
}

.lista-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.lista-card-header .tipo-badge {
  font-size: 9px;
  letter-spacing: 0.12em;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  text-transform: uppercase;
  font-family: var(--font-sans);
}

.tipo-canales   { background: var(--crimson-100); color: var(--crimson-300); border: 1px solid rgba(220,26,60,0.2); }
.tipo-peliculas { background: var(--amber-100);   color: var(--amber-400);   border: 1px solid rgba(245,158,11,0.2); }
.tipo-series    { background: var(--sky-100);     color: var(--sky-400);     border: 1px solid rgba(14,165,233,0.2); }

.lista-card-header h4 {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  letter-spacing: -0.01em;
}

.lista-add-form {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.lista-add-form input {
  font-size: 12px;
  padding: 8px 12px;
  height: 34px;
}

.lista-add-form .input-row {
  display: flex;
  gap: var(--space-2);
}

.lista-add-form .btn {
  flex-shrink: 0;
  height: 34px;
}

.lista-items {
  padding: var(--space-3) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
  flex: 1;
}

.lista-empty {
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: var(--space-6) 0;
}

.lista-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition:
    border-color var(--t-fast) var(--ease),
    background   var(--t-fast) var(--ease);
}

.lista-item:hover {
  border-color: var(--border-3);
  background: var(--surface-3);
}

.lista-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.lista-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-item-url {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ──────────────────────────────────────────────────────────────────
   19. URL FIELD — selector + input apilados
   ────────────────────────────────────────────────────────────────── */
.url-field-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.url-field-group label {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.url-field-group select {
  border-radius: var(--r-md) var(--r-md) 0 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.url-field-group select:focus {
  z-index: 1;
  position: relative;
  border-bottom-color: var(--accent);
}

.url-field-group input {
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-size: 12px;
  border-top: none;
}

.url-field-group input:focus {
  z-index: 1;
  position: relative;
}

/* ──────────────────────────────────────────────────────────────────
   20. MODAL BORRAR — zona de peligro
   ────────────────────────────────────────────────────────────────── */
.delete-warning {
  background: var(--crimson-050);
  border: 1px solid rgba(220,26,60,0.18);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.delete-warning svg { flex-shrink: 0; margin-top: 2px; }

.delete-warning-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.delete-warning-text strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--crimson-300);
}

.delete-warning-text p {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}

.delete-confirm-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: var(--space-2);
  display: block;
  line-height: 1.6;
}

.delete-confirm-label code {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 1px 7px;
  font-family: var(--font-mono);
  color: var(--crimson-300);
  font-size: 12px;
}

#deleteConfirmInput {
  border-color: rgba(220,26,60,0.2);
}
#deleteConfirmInput:focus {
  border-color: var(--crimson-400);
  box-shadow: 0 0 0 3px rgba(220,26,60,0.10);
}

#confirmDeleteBtn {
  background: var(--crimson-500);
  color: #fff;
  border-color: var(--crimson-600);
}
#confirmDeleteBtn:hover:not(:disabled) {
  background: var(--crimson-400);
  box-shadow: 0 4px 12px rgba(220,26,60,0.35);
}
#confirmDeleteBtn:disabled {
  background: rgba(220,26,60,0.08);
  color: rgba(220,26,60,0.25);
  border-color: rgba(220,26,60,0.12);
}

/* ──────────────────────────────────────────────────────────────────
   21. TOGGLE MODO — nuevo vs existente
   ────────────────────────────────────────────────────────────────── */
.modo-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 4px;
}

.modo-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: none;
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition:
    background    var(--t-base) var(--ease),
    color         var(--t-base) var(--ease),
    border-color  var(--t-base) var(--ease),
    box-shadow    var(--t-base) var(--ease);
}

.modo-btn:hover { color: var(--text-2); }

.modo-btn.active {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
}

/* ──────────────────────────────────────────────────────────────────
   22. CAJAS INFORMATIVAS
   ────────────────────────────────────────────────────────────────── */
.info-box {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: var(--sky-100);
  border: 1px solid rgba(14,165,233,0.18);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}

.info-box svg { flex-shrink: 0; margin-top: 1px; color: var(--sky-400); }
.info-box strong { color: var(--sky-400); font-weight: 600; }

/* ──────────────────────────────────────────────────────────────────
   23. UID DISPLAY
   ────────────────────────────────────────────────────────────────── */
.uid-display {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 10px 14px;
}

.uid-display-label {
  font-size: 10px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  flex-shrink: 0;
}

.uid-display-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--sky-400);
  word-break: break-all;
  line-height: 1.4;
}

/* ──────────────────────────────────────────────────────────────────
   24. RESPONSIVE — Mobile first
   ────────────────────────────────────────────────────────────────── */

/* — 480px y menos (teléfonos pequeños) — */
@media (max-width: 480px) {
  :root {
    --space-8: 20px;
    --space-10: 24px;
    --space-12: 32px;
  }

  .topbar {
    height: 50px;
    padding: 0 var(--space-4);
  }

  .topbar-brand span { font-size: 12px; letter-spacing: 0.12em; }

  .admin-badge { display: none; }

  .main { padding: var(--space-4) var(--space-4); }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .stat-value { font-size: 26px; }

  .login-box { padding: var(--space-8) var(--space-5); }

  .dash-tabs { gap: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-tab  { padding: 8px 14px; font-size: 11px; flex-shrink: 0; }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-actions {
    justify-content: space-between;
    width: 100%;
  }
  .search-wrap input { width: 100% !important; }
  .search-wrap { flex: 1; }

  /* Tabla responsive — scroll horizontal */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--r-lg);
  }
  table { min-width: 560px; }

  /* Botones acción en tabla */
  .btn-sm { padding: 5px 10px; font-size: 11px; }

  .modal-box {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--r-xl);
    max-height: 95vh;
  }

  .form-row { grid-template-columns: 1fr; gap: var(--space-3); }

  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn { width: 100%; justify-content: center; }

  .listas-grid { grid-template-columns: 1fr; }

  .modo-toggle { flex-direction: column; }
  .modo-btn    { justify-content: flex-start; padding: 10px 14px; }

  #toast {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
    max-width: none;
  }
}

/* — 481px – 768px (teléfonos grandes y tablets pequeñas) — */
@media (min-width: 481px) and (max-width: 768px) {
  .main { padding: var(--space-5) var(--space-5); }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 620px; }

  .listas-grid { grid-template-columns: 1fr; }

  .form-row { grid-template-columns: 1fr; }

  .modal-box { padding: var(--space-6) var(--space-5); }

  .search-wrap input { width: 180px; }
  .search-wrap input:focus { width: 200px; }
}

/* — 769px – 1024px (tablets grandes, laptops pequeñas) — */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .listas-grid { grid-template-columns: 1fr 1fr; }
  .main { padding: var(--space-6) var(--space-6); }

  .search-wrap input { width: 180px; }
  .search-wrap input:focus { width: 220px; }
}

/* — 1025px – 1440px (laptops estándar) — */
@media (min-width: 1025px) and (max-width: 1440px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .listas-grid { grid-template-columns: repeat(3, 1fr); }
}

/* — 1441px y más (pantallas grandes) — */
@media (min-width: 1441px) {
  .main { padding: var(--space-10) var(--space-8); }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }
  .stat-value { font-size: 36px; }
}

/* ──────────────────────────────────────────────────────────────────
   25. UTILIDADES — accesibilidad y estados de focus
   ────────────────────────────────────────────────────────────────── */

/* Focus visible para teclado */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Touch — targets mínimos de 44px */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .modal-close { width: 36px; height: 36px; }
  .dash-tab { padding: 12px 16px; }
  input, select { min-height: 44px; }
}