:root {
  --bg: #0a0a0f;
  --bg2: #111118;
  --card: #16161f;
  --card2: #1c1c28;
  --border: #2a2a3a;
  --red: #e50914;
  --red2: #c0030f;
  --text: #f0f0f5;
  --text2: #9090a8;
  --green: #1db954;
  --orange: #f39c12;
  --purple: #7c3aed;
  --blue: #2196f3;
  --sidebar-w: 220px;
  --topbar-h: 60px;
}

* { margin:0; padding:0; box-sizing:border-box; }

html, body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 2px;
}
.logo-flix { color: var(--text); }
.logo-tv { color: var(--red); }
.logo-badge {
  margin-left: 6px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: .5px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: var(--card2); color: var(--text); }
.nav-item.active { background: var(--red); color: white; }
.nav-item.active svg { stroke: white; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.nav-item.active .nav-badge { background: white; color: var(--red); }

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-info { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text2); }
.user-online {
  margin-left: auto;
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
}

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.menu-toggle {
  background: none; border: none;
  cursor: pointer; padding: 4px;
  display: none;
}
.menu-toggle svg { width: 20px; height: 20px; stroke: var(--text); stroke-width: 2; fill: none; }
.topbar-date { font-size: 13px; color: var(--text2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.icon-btn:hover { background: var(--card2); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: var(--text2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notif-dot {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: white;
  font-size: 9px;
  font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.chip-avatar {
  width: 26px; height: 26px;
  background: var(--red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.chip-name { font-size: 12px; font-weight: 600; line-height: 1.2; }
.chip-role { font-size: 10px; color: var(--text2); }

/* ---- PAGES ---- */
.page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.page::-webkit-scrollbar { width: 4px; }
.page::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.page.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-family: 'Rajdhani', sans-serif; font-size: 26px; font-weight: 700; }
.page-header p { font-size: 13px; color: var(--text2); margin-top: 2px; }

.page-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header-row h1 { font-family: 'Rajdhani', sans-serif; font-size: 26px; font-weight: 700; }
.page-header-row p { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-card.purple .stat-icon { background: rgba(124,58,237,.2); color: #a78bfa; }
.stat-card.purple .stat-icon svg { stroke: #a78bfa; }
.stat-card.green .stat-icon { background: rgba(29,185,84,.2); color: var(--green); }
.stat-card.green .stat-icon svg { stroke: var(--green); }
.stat-card.orange .stat-icon { background: rgba(243,156,18,.2); color: var(--orange); }
.stat-card.orange .stat-icon svg { stroke: var(--orange); }
.stat-card.red .stat-icon { background: rgba(229,9,20,.2); color: var(--red); }
.stat-card.red .stat-icon svg { stroke: var(--red); }

.stat-icon svg { width: 22px; height: 22px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.stat-content { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: 11px; color: var(--text2); font-weight: 500; }
.stat-value { font-family: 'Rajdhani', sans-serif; font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-change { font-size: 11px; }
.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--red); }

/* ---- CARD ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  font-size: 13.5px; font-weight: 600;
}

/* ---- CHARTS ROW ---- */
.charts-row {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
}
.chart-card { flex: 2; }
.donut-card { flex: 1; }

.donut-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.donut-total { font-family: 'Rajdhani', sans-serif; font-size: 22px; font-weight: 700; }
.donut-label { font-size: 10px; color: var(--text2); }

.legend { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---- BOTTOM ROW ---- */
.bottom-row { display: flex; gap: 14px; }
.bottom-row .card { flex: 1; }
.summary-card { flex: 0.7 !important; }

/* ---- TABLE ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(42,42,58,.5);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.full-table th, .full-table td { padding: 10px 14px; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge.success { background: rgba(29,185,84,.15); color: var(--green); }
.badge.warning { background: rgba(243,156,18,.15); color: var(--orange); }
.badge.danger { background: rgba(229,9,20,.15); color: var(--red); }
.badge.info { background: rgba(33,150,243,.15); color: var(--blue); }
.badge.muted { background: rgba(144,144,168,.15); color: var(--text2); }

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--red);
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background .2s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--red2); }

.btn-secondary {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background .2s;
}
.btn-secondary:hover { background: var(--border); }

.btn-link { background: none; border: none; color: var(--red); font-size: 12px; cursor: pointer; font-family: 'DM Sans', sans-serif; }
.btn-link:hover { text-decoration: underline; }

.btn-wa {
  background: rgba(37,211,102,.15);
  color: #25d366;
  border: none;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background .2s;
}
.btn-wa:hover { background: rgba(37,211,102,.3); }

.btn-wa-big {
  background: #25d366;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  transition: background .2s;
}
.btn-wa-big:hover { background: #1da851; }

/* ---- TOOLBAR ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  flex: 1;
  min-width: 200px;
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--red); }
.search-input::placeholder { color: var(--text2); }

/* ---- FORMS ---- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text2); }
.form-input {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color .2s;
}
.form-input:focus { border-color: var(--red); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.select-filter {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  outline: none;
}
.select-sm {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  outline: none;
}
.textarea {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  resize: vertical;
  transition: border-color .2s;
  width: 100%;
}
.textarea:focus { border-color: var(--red); }
.date-input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
}
.filter-group { display: flex; gap: 8px; }

/* ---- SUMMARY ITEMS ---- */
.summary-items { display: flex; flex-direction: column; gap: 14px; }
.summary-item { display: flex; align-items: center; gap: 10px; }
.sum-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.green-icon { background: rgba(29,185,84,.15); color: var(--green); }
.orange-icon { background: rgba(243,156,18,.15); color: var(--orange); }
.red-icon { background: rgba(229,9,20,.15); color: var(--red); }
.gray-icon { background: rgba(144,144,168,.15); color: var(--text2); }
.sum-info { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text2); }
.progress-bar { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 1s; }
.green-fill { background: var(--green); }
.orange-fill { background: var(--orange); }
.red-fill { background: var(--red); }
.gray-fill { background: var(--text2); }
.sum-num { font-weight: 700; font-size: 14px; min-width: 36px; text-align: right; }
.sum-pct { font-size: 12px; color: var(--text2); min-width: 32px; text-align: right; }

/* ---- PLANES GRID ---- */
.planes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.plan-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 18px;
  display: flex; flex-direction: column; gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform .2s, border-color .2s;
}
.plan-card:hover { transform: translateY(-4px); border-color: var(--red); }
.plan-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.plan-card.red::before { background: var(--red); }
.plan-card.green::before { background: var(--green); }
.plan-card.orange::before { background: var(--orange); }
.plan-card.purple::before { background: var(--purple); }

.plan-name { font-family: 'Rajdhani', sans-serif; font-size: 18px; font-weight: 700; }
.plan-price { font-family: 'Rajdhani', sans-serif; font-size: 28px; font-weight: 700; }
.plan-price span { font-size: 14px; color: var(--text2); font-family: 'DM Sans', sans-serif; }
.plan-features { display: flex; flex-direction: column; gap: 6px; }
.plan-feature { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.plan-feature::before { content: '✓'; color: var(--green); font-weight: 700; }
.plan-clientes { font-size: 12px; color: var(--text2); padding-top: 8px; border-top: 1px solid var(--border); }
.plan-actions { display: flex; gap: 8px; }

/* ---- PAGINATION ---- */
.pagination {
  display: flex; gap: 6px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}
.page-btn {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.page-btn:hover, .page-btn.active { background: var(--red); border-color: var(--red); color: white; }
.page-info { font-size: 12px; color: var(--text2); }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .3s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity:0; } to { transform: translateY(0); opacity:1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-family: 'Rajdhani', sans-serif; font-size: 20px; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text2); cursor: pointer; font-size: 18px;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background .2s;
}
.modal-close:hover { background: var(--card2); color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 22px 20px;
  border-top: 1px solid var(--border);
}

/* ---- REPORT ---- */
.report-tabs { display: flex; gap: 4px; margin-bottom: 16px; background: var(--card); border-radius: 8px; padding: 4px; width: fit-content; }
.rtab {
  background: none; border: none;
  color: var(--text2);
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: all .2s;
}
.rtab.active { background: var(--red); color: white; }
.export-row { display: flex; gap: 10px; margin-top: 14px; }

/* ---- MENSAJES ---- */
.mensajes-layout { display: flex; gap: 16px; }
.mensajes-form { flex: 1; }
.mensajes-history { flex: 1.2; }
.char-count { font-size: 11px; color: var(--text2); text-align: right; margin-top: 4px; }
.msg-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 13px;
}
.msg-item .msg-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.msg-item .msg-cliente { font-weight: 600; }
.msg-item .msg-time { font-size: 11px; color: var(--text2); }
.msg-item .msg-text { color: var(--text2); font-size: 12px; }
.msg-item .msg-status { font-size: 11px; color: var(--green); margin-top: 6px; }

/* ---- CONFIG ---- */
.config-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.toggle-group { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.toggle-group:last-child { border-bottom: none; }
.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: var(--text2);
  border-radius: 50%;
  transition: all .2s;
}
.toggle.active { background: var(--red); }
.toggle.active::after { left: 21px; background: white; }

/* ---- USER CELL ---- */
.user-cell { display: flex; align-items: center; gap: 8px; }
.mini-avatar {
  width: 28px; height: 28px;
  background: var(--red);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--card);
  border: 1px solid var(--green);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all .3s;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ---- LOGIN ---- */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 400px;
  max-width: 92vw;
}
.login-logo {
  font-family: 'Rajdhani', sans-serif;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}
.login-card h2 {
  font-family: 'Rajdhani', sans-serif;
  text-align: center;
  font-size: 22px;
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-btn { width: 100%; margin-top: 8px; padding: 12px; }
.login-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text2);
  margin-top: 16px;
}

/* ---- RENOVACIONES ---- */
#renovacionesTbody tr td:nth-child(4) { font-weight: 600; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-row { flex-direction: column; }
  .bottom-row { flex-direction: column; }
  .mensajes-layout { flex-direction: column; }
  .config-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 14px; }
  .page-header-row { flex-direction: column; gap: 10px; }
}
