/* ==========================================================================
   ToditoTV — Portal de Distribuidores
   Brand Core Grafito Neutro (#07090e, #141416, #1b1c20, píldoras blancas,
   punto+texto de estado, naranja #ff5722 reservado a marca/promos).
   Sin dependencias externas, sin Google Fonts, compatible con CSP estricta.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Lienzo y superficies — Grafito Neutro */
  --bg-main: #07090e;
  --bg-surface: #0b0e16;
  --surface-1: rgba(30, 31, 35, 0.90);
  --surface-1-solid: #141416;
  --surface-2: #1b1c20;
  --surface-3: #23252b;
  --surface-dialog: rgba(12, 15, 22, 0.96);
  --surface-toast: rgba(30, 31, 35, 0.94);
  --surface-input: rgba(255, 255, 255, 0.05);
  --surface-input-focus: rgba(255, 255, 255, 0.08);
  --surface-raised: rgba(255, 255, 255, 0.045);
  --surface-raised-hover: rgba(255, 255, 255, 0.075);

  /* Cristal (topbar, toasts) */
  --glass-crystal-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.05) 100%), rgba(15, 18, 26, 0.62);
  --glass-crystal-edge: inset 0 1px 0 rgba(255, 255, 255, 0.22);
  --glass-blur: blur(22px) saturate(190%);

  /* Blancos translúcidos */
  --white-a04: rgba(255, 255, 255, 0.04);
  --white-a06: rgba(255, 255, 255, 0.06);
  --white-a08: rgba(255, 255, 255, 0.08);
  --white-a10: rgba(255, 255, 255, 0.10);
  --white-a12: rgba(255, 255, 255, 0.12);
  --white-a16: rgba(255, 255, 255, 0.16);
  --white-a24: rgba(255, 255, 255, 0.24);

  /* Bordes */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-glass: rgba(255, 255, 255, 0.16);
  --border-control: rgba(255, 255, 255, 0.36);
  --border-control-hover: rgba(255, 255, 255, 0.48);
  --border-control-focus: rgba(255, 255, 255, 0.72);
  --border-focus: #ffffff;

  /* Texto */
  --text-primary: #f8fafc;
  --text-emphasis: #cbd5e1;
  --text-secondary: #94a3b8;
  --text-muted: #8e95a2;
  --text-disabled: #64748b;
  --text-on-white: #07090e;

  /* Estados (punto + texto) y acento reservado */
  --status-ok: #34d399;
  --status-ok-bg: rgba(52, 211, 153, 0.14);
  --status-ok-border: rgba(52, 211, 153, 0.40);
  --status-warn: #fbbf24;
  --status-warn-bg: rgba(251, 191, 36, 0.12);
  --status-warn-border: rgba(251, 191, 36, 0.42);
  --status-live: #ef4444;
  --status-live-glow: 0 0 6px #ef4444;
  --status-danger-fg: #fca5a5;
  --status-danger-bg: rgba(239, 68, 68, 0.16);
  --status-danger-border: rgba(252, 165, 165, 0.45);
  --brand-orange: #ff5722;
  --brand-orange-bg: rgba(255, 87, 34, 0.18);
  --brand-orange-border: rgba(255, 87, 34, 0.55);

  /* Tipografía */
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-xl: 1.25rem;
  --fs-2xl: 1.5rem;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --tracking-tight: -0.02em;

  /* Radios */
  --radius-pill: 9999px;
  --radius-circle: 50%;
  --radius-dialog: 24px;
  --radius-panel: 20px;
  --radius-card: 14px;
  --radius-row: 12px;
  --radius-badge: 6px;

  /* Espaciado */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  /* Sombras */
  --shadow-dialog: 0 28px 68px rgba(0, 0, 0, 0.72);
  --shadow-active-pill: 0 2px 10px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 20px 50px rgba(0, 0, 0, 0.78), 0 6px 18px rgba(0, 0, 0, 0.45);

  /* Foco y controles */
  --focus-width: 2px;
  --focus-offset: 2px;
  --control-h-sm: 36px;
  --control-h-md: 40px;
  --control-h-lg: 44px;
  --header-h: 68px;
  --sidebar-w: 248px;

  /* Transiciones */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 160ms;
  --duration-med: 240ms;
}

@property --drawer-backdrop {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

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

html {
  background-color: var(--bg-main);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body.portal-body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--fs-md);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] {
  display: none !important;
}

:focus {
  outline: none;
}

:focus-visible {
  outline: var(--focus-width) solid var(--border-focus);
  outline-offset: var(--focus-offset);
}

main:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 1000;
  background: #ffffff;
  color: var(--text-on-white);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  text-decoration: none;
  box-shadow: var(--shadow-active-pill);
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 12px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.ui-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.ui-icon-lg {
  width: 20px;
  height: 20px;
}

/* Puntos de estado */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-circle);
  display: inline-block;
  flex-shrink: 0;
  background: var(--text-disabled);
}

.status-dot.dot-green {
  background: var(--status-ok);
}

.status-dot.dot-amber {
  background: var(--status-warn);
}

.status-dot.dot-red {
  background: var(--status-live);
  box-shadow: var(--status-live-glow);
}

.status-dot.dot-muted {
  background: rgba(255, 255, 255, 0.30);
}

/* ==========================================================================
   Botones y controles base
   ========================================================================== */

.btn {
  position: relative;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h-lg);
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-family);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  min-height: var(--control-h-sm);
  padding: 0 14px;
  font-size: var(--fs-sm);
}

.btn-xs {
  min-height: 30px;
  padding: 0 11px;
  font-size: var(--fs-xs);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: #ffffff;
  border-color: #ffffff;
  color: var(--text-on-white);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-active-pill);
}

.btn-primary:hover:not(:disabled) {
  background-color: #e2e8f0;
  border-color: #e2e8f0;
}

.btn-secondary {
  background-color: var(--white-a12);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--white-a16);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-emphasis);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--white-a08);
  color: var(--text-primary);
}

.btn-danger {
  background-color: var(--status-danger-bg);
  border-color: var(--status-danger-border);
  color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background-color: rgba(239, 68, 68, 0.26);
}

.btn-icon {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-circle);
  border: 1px solid var(--border-subtle);
  background: var(--white-a06);
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease;
}

.btn-icon:hover {
  background: var(--white-a12);
  border-color: var(--border-medium);
}

.btn.is-busy {
  color: transparent;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid var(--text-on-white);
  border-right-color: transparent;
  animation: portal-spin 0.7s linear infinite;
}

.btn-secondary.is-busy::after,
.btn-danger.is-busy::after {
  border-color: var(--text-primary);
  border-right-color: transparent;
}

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

/* ==========================================================================
   Formularios y validación tras interacción (:user-invalid + fallback)
   ========================================================================== */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.form-group > label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-emphasis);
}

.field-hint {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  line-height: 1.4;
}

.field-hint.is-warn {
  color: var(--status-warn);
}

.field-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.field-row > input {
  flex: 1 1 auto;
  min-width: 0;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="search"],
input[type="date"],
input[type="number"],
select,
textarea {
  appearance: none;
  width: 100%;
  min-height: var(--control-h-md);
  padding: 8px 12px;
  border-radius: var(--radius-row);
  border: 1px solid var(--border-control);
  background-color: var(--surface-input);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9375rem;
  line-height: 1.4;
  transition: border-color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

select {
  appearance: auto;
}

textarea {
  resize: vertical;
  min-height: 84px;
}

select option {
  background-color: var(--surface-1-solid);
  color: var(--text-primary);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--border-control-hover);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-control-focus);
  background-color: var(--surface-input-focus);
}

:is(input, select, textarea):is(:user-invalid, .user-invalid-fallback, [aria-invalid="true"]) {
  border-color: var(--status-danger-fg);
  background-color: rgba(239, 68, 68, 0.08);
}

:is(input, select, textarea):is(:user-valid, .user-valid-fallback):not([aria-invalid="true"]) {
  border-color: rgba(52, 211, 153, 0.52);
}

.field-error {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--status-danger-fg);
  margin-top: 2px;
}

.err-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: var(--radius-circle);
  background: var(--status-danger-bg);
  border: 1px solid var(--status-danger-border);
  font-size: 0.6875rem;
  font-weight: var(--fw-bold);
}

.form-group:has(:is(:user-invalid, .user-invalid-fallback, [aria-invalid="true"])) .field-error {
  display: flex;
}

.availability-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.availability-status.is-available {
  color: var(--status-ok);
}

.availability-status.is-checking {
  color: var(--text-secondary);
}

.alert-banner {
  border: 1px solid var(--status-danger-border);
  background: var(--status-danger-bg);
  color: #fecaca;
  border-radius: var(--radius-row);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.dialog-status-banner {
  border: 1px solid var(--status-ok-border);
  background: var(--status-ok-bg);
  color: #a7f3d0;
  border-radius: var(--radius-row);
  padding: 8px 12px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

/* ==========================================================================
   1. Pantalla de Login
   ========================================================================== */

.login-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 68%);
  background-repeat: no-repeat;
}

.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--surface-dialog);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-dialog);
  box-shadow: var(--shadow-dialog);
  padding: 32px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.brand-icon-box {
  width: 44px;
  height: 44px;
}

.brand-icon-box > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-card h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.2;
  margin-top: var(--space-1);
}

.page-desc {
  color: var(--text-secondary);
  margin-top: -6px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.login-foot {
  margin-top: var(--space-2);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* ==========================================================================
   2. Topbar fija de cristal + Layout Sidebar/Drawer
   ========================================================================== */

.portal-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: var(--header-h);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  background: var(--glass-crystal-bg);
  box-shadow: var(--glass-crystal-edge);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

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

.topbar-logo {
  display: block;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.topbar-brand-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.topbar-brand-sub {
  background: var(--white-a10);
  color: var(--text-emphasis);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  letter-spacing: 0;
}

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

.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border-glass);
  font-size: var(--fs-sm);
  color: var(--text-emphasis);
}

.credits-pill-value {
  color: #ffffff;
  font-size: 1rem;
  font-weight: var(--fw-bold);
}

.credits-pill.is-low-credits {
  border-color: var(--status-warn-border);
  background: var(--status-warn-bg);
  color: #fde68a;
}

.credits-pill.is-low-credits .credits-pill-value {
  color: var(--status-warn);
}

.credits-warn-tag {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--status-warn);
}

.reseller-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--white-a06);
  border: 1px solid var(--border-subtle);
  color: var(--text-emphasis);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-layout {
  flex: 1 1 auto;
  display: block;
}

/* ==========================================================================
   Navegación Sidebar (>= 960px) y Drawer (< 960px)
   ========================================================================== */

.drawer-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--surface-1-solid);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-4) var(--space-3);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 4px var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--fw-bold);
  color: #ffffff;
}

.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-emphasis);
  font-family: var(--font-family);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.nav-item:hover:not(.is-active) {
  background: var(--white-a08);
  color: #ffffff;
}

.nav-item.is-active {
  background: #ffffff;
  color: var(--text-on-white);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-active-pill);
}

.drawer-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.drawer-account-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--surface-raised);
}

.drawer-account-label {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-account-name {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 960px) {
  .drawer-toggle,
  .drawer-head {
    display: none;
  }

  .portal-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    align-items: start;
  }

  .portal-drawer {
    display: block;
    position: sticky;
    top: var(--header-h);
    inset-inline: auto;
    width: var(--sidebar-w);
    height: calc(100dvh - var(--header-h));
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    overflow: visible;
  }

  .drawer-scroller {
    display: block;
    height: 100%;
    overflow: visible;
    scroll-snap-type: none;
  }

  .drawer-scroller::after {
    display: none;
  }

  .drawer-sheet {
    height: 100%;
    overflow-y: auto;
  }
}

@media (max-width: 959px) {
  .portal-drawer {
    --drawer-width: min(20em, 80dvw, 100dvw - 24px);
    --drawer-backdrop: 0;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    overflow: visible;
    color: inherit;
  }

  .portal-drawer::backdrop {
    background: #000000;
    opacity: calc(var(--drawer-backdrop) * 0.68);
  }

  .drawer-scroller {
    position: relative;
    display: grid;
    grid-template-columns: var(--drawer-width) 100%;
    overflow-x: scroll;
    overscroll-behavior: none;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
  }

  @media (prefers-reduced-motion: no-preference) {
    .drawer-scroller {
      scroll-behavior: smooth;
    }
  }

  .drawer-scroller::after {
    content: "";
    scroll-snap-align: end;
    scroll-initial-target: nearest;
  }

  .drawer-sheet {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100svh;
    overflow-y: auto;
    scroll-snap-align: start;
    scrollbar-width: none;
  }
}

@supports (animation-timeline: scroll()) {
  @media (max-width: 959px) {
    .portal-drawer {
      timeline-scope: --drawer-fade;
      animation: fade-drawer-backdrop linear both;
      animation-timeline: --drawer-fade;
    }

    .drawer-scroller {
      scroll-timeline: --drawer-fade x;
    }

    @keyframes fade-drawer-backdrop {
      0% { --drawer-backdrop: 1; }
      100% { --drawer-backdrop: 0; }
    }
  }
}

/* ==========================================================================
   3. Contenido Principal, KPIs y Paneles
   ========================================================================== */

.portal-main {
  min-width: 0;
  padding: var(--space-6) clamp(16px, 3vw, 32px) var(--space-8);
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

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

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.section-title {
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  color: #ffffff;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  margin-top: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
}

.kpi-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, transform 0.12s ease;
}

.kpi-card:hover {
  background: var(--surface-3);
  border-color: var(--border-medium);
}

.kpi-card:active {
  transform: scale(0.99);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
}

.kpi-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.kpi-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--text-emphasis);
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  color: #ffffff;
}

.quick-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.home-panels-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .home-panels-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--surface-1-solid);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-panel);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.panel-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: #ffffff;
}

.panel-desc {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

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

.panel-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.panel-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.panel-item-title {
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-item-meta {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.panel-item-end {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.panel-empty {
  padding: var(--space-4);
  border-radius: var(--radius-row);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  text-align: center;
}

/* ==========================================================================
   4. Sub-pestañas, filtros, buscador y Planes
   ========================================================================== */

.subtabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-1-solid);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
}

.subtab-btn {
  appearance: none;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 0;
  background: transparent;
  color: var(--text-emphasis);
  font-family: var(--font-family);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.subtab-btn:hover:not(.is-active) {
  background: var(--white-a08);
  color: #ffffff;
}

.subtab-btn.is-active {
  background: #ffffff;
  color: var(--text-on-white);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-active-pill);
}

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

.toolbar-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--surface-1-solid);
  border: 1px solid var(--border-subtle);
}

.toolbar-search {
  flex: 1 1 260px;
  min-width: 0;
}

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

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-pill {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-emphasis);
  font-family: var(--font-family);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.filter-pill:hover:not(.is-active) {
  background: var(--surface-3);
  border-color: var(--border-medium);
}

.filter-pill.is-active {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--text-on-white);
  font-weight: var(--fw-bold);
  box-shadow: var(--shadow-active-pill);
}

.pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--white-a12);
  font-size: var(--fs-xs);
}

.filter-pill.is-active .pill-count {
  background: rgba(7, 9, 14, 0.14);
  color: var(--text-on-white);
}

/* Formularios de creación / perfil */
.form-card {
  max-width: 860px;
}

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

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (max-width: 720px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}

.plan-fieldset {
  border: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.plan-fieldset > legend {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-emphasis);
  margin-bottom: var(--space-1);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: var(--space-3);
}

.plan-option {
  position: relative;
  display: block;
  cursor: pointer;
}

.plan-radio {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.plan-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  transition: border-color var(--duration-fast) ease, background-color var(--duration-fast) ease;
}

.plan-option:hover .plan-card {
  background: var(--surface-3);
  border-color: var(--border-medium);
}

.plan-radio:focus-visible + .plan-card {
  outline: var(--focus-width) solid #ffffff;
  outline-offset: 2px;
}

.plan-radio:checked + .plan-card {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--text-on-white);
  box-shadow: var(--shadow-active-pill);
}

.plan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.plan-name {
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
}

.plan-promo-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-orange);
  color: #ffffff;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.plan-credits {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
}

.plan-duration {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.plan-radio:checked + .plan-card .plan-duration {
  color: rgba(7, 9, 14, 0.78);
}

.balance-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 12px 14px;
  border-radius: var(--radius-row);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.balance-preview.is-insufficient {
  border-color: var(--status-danger-border);
  background: var(--status-danger-bg);
  color: #fecaca;
}

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

/* ==========================================================================
   5. Tablas Responsivas (responsive-table: sticky + @container < 760px)
   ========================================================================== */

.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(640px, 72dvh);
  container-type: inline-size;
  border-radius: var(--radius-card);
  background: var(--surface-1-solid);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: var(--fs-sm);
}

.data-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
}

.data-table thead th {
  background: var(--surface-1-solid);
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-medium);
  white-space: nowrap;
}

.data-table tbody th[scope="row"] {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  background: var(--surface-1-solid);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  text-align: left;
}

.data-table tbody th,
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover th,
.data-table tbody tr:hover td {
  background: var(--surface-2);
}

.user-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 150px;
}

.user-cell-handle {
  color: #ffffff;
  font-weight: var(--fw-bold);
}

.user-cell-name {
  color: var(--text-emphasis);
  font-size: var(--fs-xs);
}

.user-cell-note {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.status-pill-inline.is-valid { color: var(--status-ok); }
.status-pill-inline.is-expiring { color: var(--status-warn); }
.status-pill-inline.is-expired { color: var(--status-danger-fg); }
.status-pill-inline.is-suspended { color: var(--text-secondary); }

.plan-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

.plan-cell-dates {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.dev-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--white-a08);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

.dev-pill.is-full {
  background: var(--status-warn-bg);
  color: var(--status-warn);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 220px;
}

.delta-badge {
  font-weight: var(--fw-bold);
  white-space: nowrap;
}

.delta-badge.is-plus { color: var(--status-ok); }
.delta-badge.is-minus { color: var(--status-danger-fg); }
.delta-badge.is-zero { color: var(--text-secondary); }

.users-table {
  --label-2: "Estado";
  --label-3: "Restante";
  --label-4: "Plan y vigencia";
  --label-5: "Créditos";
  --label-6: "Dispositivos";
  --label-7: "Acciones";
}

.ledger-table {
  --label-2: "Tipo";
  --label-3: "Usuario objetivo";
  --label-4: "Variación";
  --label-5: "Saldo resultante";
  --label-6: "Detalle";
}

@container (width < 760px) {
  .table-wrapper {
    max-block-size: none;
    background: transparent;
    border: 0;
  }

  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td {
    display: block;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    margin-block-end: var(--space-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    background: var(--surface-2);
    overflow: hidden;
  }

  .data-table tbody th[scope="row"] {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border-subtle);
  }

  .data-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }

  .data-table tbody td:last-child {
    border-bottom: 0;
  }

  .data-table tbody td::before {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    flex-shrink: 0;
  }

  .data-table tbody td:nth-child(2)::before { content: var(--label-2) ": "; }
  .data-table tbody td:nth-child(3)::before { content: var(--label-3) ": "; }
  .data-table tbody td:nth-child(4)::before { content: var(--label-4) ": "; }
  .data-table tbody td:nth-child(5)::before { content: var(--label-5) ": "; }
  .data-table tbody td:nth-child(6)::before { content: var(--label-6) ": "; }
  .data-table tbody td:nth-child(7)::before { content: var(--label-7) ": "; }

  .users-table tbody td:nth-child(7),
  .subresellers-table tbody td:nth-child(5) {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-actions {
    width: 100%;
    min-width: 0;
  }
}

.empty-state {
  padding: var(--space-6);
  text-align: center;
  border-radius: var(--radius-card);
  background: var(--surface-1-solid);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Registros y Perfil */
.ledger-toolbar {
  align-items: flex-end;
}

.ledger-filter-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-width: 0;
}

.ledger-filter-fields > .form-group {
  flex: 1 1 150px;
}

.ledger-search-group {
  flex: 2 1 220px !important;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.profile-summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.profile-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.profile-summary-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

@media (max-width: 900px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   6. Modales <dialog> (prevent-page-scroll-under-modal-dialog)
   ========================================================================== */

dialog.portal-dialog {
  margin: auto;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: var(--space-5);
  border-radius: var(--radius-dialog);
  border: 1px solid var(--border-glass);
  background: var(--surface-dialog);
  color: var(--text-primary);
  box-shadow: var(--shadow-dialog);
  overflow: auto;
}

dialog.portal-dialog-sm {
  width: min(440px, calc(100vw - 24px));
}

dialog.portal-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

dialog.portal-dialog:modal {
  overscroll-behavior: contain;
}

dialog.portal-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(3, 5, 10, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.dialog-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: #ffffff;
}

.dialog-summary-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 12px 14px;
  border-radius: var(--radius-row);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.dialog-summary-box > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-kicker {
  font-size: var(--fs-2xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.credentials-card {
  display: grid;
  gap: 10px;
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-medium);
}

.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.cred-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.cred-row dt {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}

.cred-row dd {
  font-weight: var(--fw-bold);
  color: #ffffff;
  text-align: right;
  word-break: break-all;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.dialog-actions-stack {
  justify-content: stretch;
}

.dialog-actions-stack > .btn {
  flex: 1 1 auto;
}

.confirm-message {
  color: var(--text-primary);
  font-size: var(--fs-md);
}

.confirm-warning {
  padding: 10px 12px;
  border-radius: var(--radius-row);
  background: var(--status-warn-bg);
  border: 1px solid var(--status-warn-border);
  color: #fde68a;
  font-size: var(--fs-sm);
}

/* ==========================================================================
   7. Notificaciones Toast (persistent-toast-notifications)
   ========================================================================== */

.toast-region {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.toast-item[popover="manual"] {
  position: fixed;
  inset: auto 16px calc(16px + env(safe-area-inset-bottom) + var(--toast-offset, 0px)) auto;
  margin: 0;
  width: min(360px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: var(--radius-card);
  background: var(--surface-toast);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--duration-med) var(--ease-out), transform var(--duration-med) var(--ease-out), display var(--duration-med), overlay var(--duration-med);
  transition-behavior: allow-discrete;
}

.toast-item[popover="manual"]:is(:popover-open, .\:popover-open, .is-open-fallback) {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  .toast-item[popover="manual"]:is(:popover-open, .\:popover-open) {
    opacity: 0;
    transform: translateY(10px);
  }
}

.toast-item.is-closing {
  opacity: 0;
  transform: translateY(8px);
}

.toast-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}

.toast-body .status-dot {
  margin-top: 6px;
}

.toast-text {
  word-break: break-word;
}

.toast-close {
  appearance: none;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-circle);
  border: 1px solid var(--border-subtle);
  background: var(--white-a08);
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.toast-close:hover {
  background: var(--white-a16);
}

/* ==========================================================================
   8. Fase 2: Analítica SVG, Demos (<progress>), Etiquetas, WhatsApp y Sub-distribuidores
   ========================================================================== */

.status-dot.dot-orange {
  background: var(--brand-orange);
}

.pricing-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 10px 14px;
  border-radius: var(--radius-row);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
  color: var(--text-emphasis);
}

.analytics-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: var(--space-3);
}

.analytics-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-row);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.analytics-metric-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-weight: var(--fw-semibold);
}

.analytics-metric-value {
  font-size: 1.375rem;
  font-weight: var(--fw-bold);
  color: #ffffff;
  letter-spacing: var(--tracking-tight);
}

.analytics-metric-value.is-positive {
  color: var(--status-ok);
}

.analytics-metric-value.is-negative {
  color: var(--status-danger-fg);
}

.analytics-chart-wrap {
  padding: var(--space-3) var(--space-2) var(--space-1);
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.analytics-chart-svg {
  display: block;
  width: 100%;
  min-width: 340px;
  height: auto;
}

.chart-grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.chart-axis-line {
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}

.chart-bar {
  fill: #ffffff;
  transition: fill var(--duration-fast) ease, opacity var(--duration-fast) ease;
}

.chart-bar.is-zero {
  fill: rgba(255, 255, 255, 0.22);
}

.chart-bar:hover {
  fill: var(--brand-orange);
}

.chart-value {
  fill: var(--text-emphasis);
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.chart-day-label {
  fill: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 600;
}

.analytics-table-wrap {
  max-block-size: 320px;
}

.analytics-table {
  --label-2: "Créditos";
  --label-3: "Altas / Renov.";
  --label-4: "Ingresos est.";
}

.subresellers-table {
  --label-2: "Estado";
  --label-3: "Créditos";
  --label-4: "Clientes";
  --label-5: "Acciones";
}

.toolbar-tag-filter {
  flex: 0 1 210px;
  min-width: 165px;
}

.tag-suggestions,
.var-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag-chip-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--white-a06);
  color: var(--text-emphasis);
  font-family: var(--font-family);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color var(--duration-fast) ease, border-color var(--duration-fast) ease, color var(--duration-fast) ease;
}

.tag-chip-btn:hover {
  background: var(--white-a12);
  border-color: var(--border-medium);
}

.tag-chip-btn[aria-pressed="true"] {
  background: #ffffff;
  border-color: #ffffff;
  color: var(--text-on-white);
}

.user-handle-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-orange-bg);
  border: 1px solid var(--brand-orange-border);
  color: #ffd8cc;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tag-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--white-a08);
  border: 1px solid var(--border-subtle);
  color: var(--text-emphasis);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
}

/* Barra de progreso nativa <progress> (Modern Web Guidance `progress`) */
.demo-quota-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.demo-quota-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--fs-sm);
}

.demo-quota-head > label {
  font-weight: var(--fw-semibold);
  color: var(--text-emphasis);
}

.demo-quota-head > [role="status"] {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

progress {
  appearance: none;
  border: 0 solid;
  overflow: clip;
  --progress-bar-radius: 9999px;
  --progress-bar-fill: #ffffff;
  width: 100%;
  height: 10px;
  border-radius: var(--progress-bar-radius);
  background: var(--white-a12);
}

progress.is-quota-warn {
  --progress-bar-fill: var(--status-warn);
}

progress.is-quota-full {
  --progress-bar-fill: var(--status-live);
}

progress::-webkit-progress-bar {
  background: transparent;
}

progress::-webkit-progress-value {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
}

progress::-moz-progress-bar {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  transition: inline-size 0.3s;
}

.wa-preview-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-row);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
}

.wa-preview-text {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 420px) {
  .login-card {
    padding: 24px 18px 20px;
  }

  .portal-topbar {
    padding: 10px 14px;
  }

  .reseller-chip {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .btn,
  .kpi-card,
  .panel-card,
  .plan-card,
  .portal-dialog,
  .toast-item,
  .analytics-metric,
  .demo-quota-card,
  progress,
  input,
  select,
  textarea {
    border: 1px solid CanvasText;
  }
}
