/* ============================================================
   Panel de Suscripciones — dos identidades de marca
   El tema se controla con <html data-biz="studio-ivr|takeward">
   ============================================================ */

/* ---------- Base tokens (shared skeleton) ---------- */
:root {
  --radius: 16px;
  --radius-sm: 10px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --pos: #34d399;
  --neg: #fb7185;
}

/* ---------- STUDIO IVR theme ---------- */
[data-biz="studio-ivr"] {
  --bg: #0c0a14;
  --surface: rgba(26, 20, 44, 0.55);
  --surface-solid: #17122a;
  --surface-2: rgba(40, 30, 66, 0.6);
  --border: rgba(139, 108, 225, 0.16);
  --border-soft: rgba(139, 108, 225, 0.10);
  --text: #f2effb;
  --text-dim: #a99fc4;
  --text-faint: #6f6690;
  --accent: #a855f7;
  --accent-2: #ec4899;
  --accent-grad: linear-gradient(120deg, #a855f7, #ec4899);
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --display: "Plus Jakarta Sans", system-ui, sans-serif;
  --display-weight: 800;
  --display-spacing: -1.2px;
  --title-transform: none;
  --pill-radius: 999px;
  --panel-blur: 16px;
}

/* ---------- TAKEWARD theme ---------- */
[data-biz="takeward"] {
  --bg: #050505;
  --surface: rgba(20, 18, 16, 0.7);
  --surface-solid: #141210;
  --surface-2: rgba(32, 28, 24, 0.7);
  --border: rgba(214, 137, 87, 0.18);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f5f2ee;
  --text-dim: #a39b90;
  --text-faint: #6e675d;
  --accent: #d68957;
  --accent-2: #c9743f;
  --accent-grad: linear-gradient(120deg, #e09a63, #c9743f);
  --sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --display: "Archivo", system-ui, sans-serif;
  --display-weight: 900;
  --display-spacing: -1.8px;
  --title-transform: none;
  --pill-radius: 999px;
  --panel-blur: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
img { max-width: 100%; height: auto; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .6s ease;
}

/* ---------- Ambient backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.backdrop-ivr, .backdrop-tw {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .7s ease;
}
[data-biz="studio-ivr"] .backdrop-ivr { opacity: 1; }
[data-biz="takeward"] .backdrop-tw { opacity: 1; }

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .5;
}
.nebula-1 { width: 620px; height: 620px; top: -180px; left: 8%;
  background: radial-gradient(circle, #a855f7, transparent 70%); }
.nebula-2 { width: 560px; height: 560px; top: 4%; right: -120px;
  background: radial-gradient(circle, #ec4899, transparent 70%); opacity: .38; }
.nebula-3 { width: 480px; height: 480px; bottom: -160px; left: 30%;
  background: radial-gradient(circle, #6d28d9, transparent 70%); opacity: .32; }

.grid-lines {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(214,137,87,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214,137,87,.05) 1px, transparent 1px);
  background-size: 62px 62px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 100%);
}
.tw-glow {
  position: absolute; top: -240px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 520px;
  background: radial-gradient(ellipse, rgba(214,137,87,.22), transparent 70%);
  filter: blur(40px);
}

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 28px; }
.brand-logo {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-name {
  font-family: var(--display);
  font-weight: var(--display-weight);
  font-size: 17px;
  letter-spacing: -.3px;
}
[data-biz="takeward"] .brand-name { letter-spacing: -.5px; }

.biz-switch { display: flex; flex-direction: column; gap: 5px; }
.biz-btn {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-align: left;
  transition: background .2s, color .2s, border-color .2s;
}
.biz-btn:hover { background: var(--surface-2); color: var(--text); }
.biz-btn.is-active { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.biz-logo {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.biz-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.biz-btn:first-child .biz-dot { background: #a855f7; box-shadow: 0 0 0 3px rgba(168,85,247,.22); }
.biz-btn:last-child .biz-dot { background: #d68957; box-shadow: 0 0 0 3px rgba(214,137,87,.22); }

.sidebar-foot { margin-top: auto; padding: 8px; }
.sync-state { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.sync-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 30px 34px 70px; max-width: 1280px; }

.topbar { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 30px; }
.menu-toggle {
  display: none;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 18px;
  width: 42px; height: 42px; border-radius: var(--radius-sm); cursor: pointer;
}
.topbar-head { flex: 1; min-width: 0; }
.eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.page-title {
  font-family: var(--display);
  font-weight: var(--display-weight);
  font-size: 34px;
  letter-spacing: var(--display-spacing);
  line-height: 1.02;
  text-transform: var(--title-transform);
}
.range-select select {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 13px; cursor: pointer;
  backdrop-filter: blur(var(--panel-blur));
}

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 13px; margin-bottom: 13px; }
.kpi {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  overflow: hidden;
}
.kpi--hero { border-color: var(--border); }
.kpi--hero::before {
  content: ""; position: absolute; inset: 0;
  background: var(--accent-grad); opacity: .10;
  pointer-events: none;
}
.kpi-label { font-size: 12px; color: var(--text-dim); font-weight: 500; position: relative; }
.kpi-value {
  font-family: var(--display);
  font-size: clamp(22px, 2.2vw, 28px); font-weight: var(--display-weight);
  letter-spacing: -.8px; font-variant-numeric: tabular-nums; line-height: 1.05;
  position: relative;
}
.kpi--hero .kpi-value {
  font-size: clamp(28px, 3vw, 36px);
  padding-bottom: 4px;
}
.kpi--hero .kpi-value {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-delta { font-family: var(--mono); font-size: 12px; color: var(--text-faint); position: relative; }
.kpi-delta.pos { color: var(--pos); }
.kpi-delta.neg { color: var(--neg); }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px; margin-top: 13px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panel-head h2 { font-family: var(--display); font-size: 16px; font-weight: 700; letter-spacing: -.3px; }
.panel-note { font-family: var(--mono); font-size: 12px; color: var(--text-faint); }

/* ---------- Chart ---------- */
.chart-wrap { position: relative; }
.chart { width: 100%; height: 230px; display: block; overflow: visible; }
.chart-x { display: flex; justify-content: space-between; margin-top: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); }
.chart-x span { flex: 1; text-align: center; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 336px;            /* ~5 filas + encabezado; el resto hace scroll */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-solid);
}
.data-table th {
  text-align: left; font-weight: 500; font-size: 11.5px;
  color: var(--text-faint); padding: 10px 14px 12px 0;
  border-bottom: 1px solid var(--border-soft); white-space: nowrap;
}
.data-table td { padding: 13px 14px 13px 0; border-bottom: 1px solid var(--border-soft); color: var(--text-dim); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .ta-right { text-align: right; }
.cust { color: var(--text); font-weight: 600; }
.cust small { display: block; color: var(--text-faint); font-weight: 400; font-size: 11.5px; }
.amt { font-family: var(--mono); color: var(--text); text-align: right; }
.plan-tag {
  display: inline-block; font-size: 11.5px; padding: 3px 10px;
  border-radius: var(--pill-radius);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
}
.date-cell { font-family: var(--mono); font-size: 12.5px; }
.empty { padding: 32px 10px; text-align: center; color: var(--text-faint); font-size: 13px; }

/* ---------- Mobile ---------- */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; }
.scrim.show { display: block; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi--hero { grid-column: 1 / -1; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .28s;
    width: 82vw; max-width: 300px;
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex-shrink: 0;
  }
  .main { padding: 16px 14px 48px; }

  /* Topbar compacto con logo de marca visible */
  .topbar { align-items: center; gap: 12px; margin-bottom: 18px; }
  .topbar-head { display: flex; flex-direction: column; }
  .eyebrow {
    order: 2; margin-bottom: 0; margin-top: 3px;
    font-size: 9.5px; letter-spacing: 1px;
    padding: 0; border: none; color: var(--text-faint);
  }
  .page-title { order: 1; font-size: 22px; letter-spacing: -.6px; }

  /* KPIs como scoreboard 2x2 + hero full-width */
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 9px; }
  .kpi { padding: 14px; border-radius: 13px; gap: 6px; }
  .kpi-label { font-size: 10.5px; }
  .kpi-value { font-size: 20px; letter-spacing: -.5px; }
  .kpi--hero { grid-column: 1 / -1; padding: 18px; }
  .kpi--hero .kpi-value { font-size: 30px; }
  .kpi-delta { font-size: 11px; }

  /* Paneles y gráfica más ajustados */
  .panel { padding: 16px 14px; margin-top: 9px; border-radius: 13px; }
  .panel-head { margin-bottom: 12px; }
  .panel-head h2 { font-size: 14px; }
  .panel-note { font-size: 10.5px; }
  .chart { height: 170px; }
  .chart-x { font-size: 9px; margin-top: 8px; }

  .split { gap: 9px; }

  /* En móvil las filas-tarjeta son más altas: ~5 caben en esta altura */
  .table-wrap { max-height: 400px; }

  /* Tablas → filas tipo tarjeta (sin scroll horizontal) */
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table thead { display: none; }
  .data-table tr {
    position: relative;
    padding: 13px 0; border-bottom: 1px solid var(--border-soft);
  }
  .data-table tr:last-child { border-bottom: none; }
  .data-table td { padding: 0; border: none; white-space: normal; }
  /* plan y fecha comparten línea meta */
  .data-table td:nth-child(2), .data-table td:nth-child(3) { display: inline-block; }
  /* nombre + email */
  .data-table td.cust, .data-table td:first-child { margin-bottom: 8px; padding-right: 70px; }
  /* importe fijo arriba a la derecha */
  .data-table .amt {
    position: absolute; top: 13px; right: 0;
    font-size: 13px; text-align: right;
  }
  /* plan y fecha en una línea meta */
  .data-table .plan-tag { font-size: 10.5px; padding: 2px 9px; }
  .data-table .date-cell {
    font-size: 11.5px; color: var(--text-faint);
    display: inline-block; margin-left: 10px;
  }
  .range-select { display: none; }
}

@media (max-width: 380px) {
  .kpi-value { font-size: 18px; }
  .kpi--hero .kpi-value { font-size: 27px; }
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}