/* ==========================================================================
   Maker Things · sistema de diseño
   --------------------------------------------------------------------------
   Un único archivo, sin build. Orden: tokens → base → layout → componentes →
   tablas de datos → utilidades → responsive.

   Principios:
   · Densidad alta pero legible: esto es una herramienta de trabajo diaria.
   · El color de marca de cada red es dato, no decoración: se usa siempre para
     identificar la misma red en toda la aplicación.
   · Los números mandan: tabulares, alineados a la derecha, jerarquía clara.
   ========================================================================== */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  /* Marca */
  --brand-50:  #EEF2FF;
  --brand-100: #E0E7FF;
  --brand-200: #C7D2FE;
  --brand-300: #A5B4FC;
  --brand-400: #818CF8;
  --brand-500: #6366F1;
  --brand-600: #4F46E5;
  --brand-700: #4338CA;
  --brand-800: #3730A3;
  --brand-900: #312E81;

  /* Neutros */
  --gray-0:   #FFFFFF;
  --gray-25:  #FCFCFD;
  --gray-50:  #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --gray-950: #0B0F19;

  /* Semánticos */
  --success-50:  #ECFDF5;  --success-500: #10B981;  --success-700: #047857;
  --warning-50:  #FFFBEB;  --warning-500: #F59E0B;  --warning-700: #B45309;
  --danger-50:   #FEF2F2;  --danger-500:  #EF4444;  --danger-700:  #B91C1C;
  --info-50:     #EFF6FF;  --info-500:    #3B82F6;  --info-700:    #1D4ED8;

  /* Superficies (tema claro por defecto) */
  --surface:        var(--gray-0);
  --surface-sunken: var(--gray-50);
  --surface-raised: var(--gray-0);
  --surface-hover:  var(--gray-50);
  --border:         var(--gray-200);
  --border-strong:  var(--gray-300);

  /* Texto */
  --text:        var(--gray-900);
  --text-muted:  var(--gray-500);
  --text-subtle: var(--gray-400);
  --text-invert: var(--gray-0);

  /* Tipografía */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, "Roboto Mono", Menlo, monospace;

  --text-xs:   0.75rem;   /* 12 */
  --text-sm:   0.8125rem; /* 13 */
  --text-base: 0.875rem;  /* 14 — base de la app, no 16: es una herramienta densa */
  --text-md:   1rem;      /* 16 */
  --text-lg:   1.125rem;  /* 18 */
  --text-xl:   1.375rem;  /* 22 */
  --text-2xl:  1.75rem;   /* 28 */
  --text-3xl:  2.25rem;   /* 36 */
  --text-4xl:  3rem;      /* 48 */

  /* Espaciado — escala de 4 */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;  --sp-4: 1rem;
  --sp-5: 1.25rem;  --sp-6: 1.5rem;   --sp-8: 2rem;     --sp-10: 2.5rem;
  --sp-12: 3rem;    --sp-16: 4rem;    --sp-20: 5rem;

  /* Radios y sombras */
  --radius-sm: 6px;  --radius: 10px;  --radius-lg: 14px;  --radius-xl: 20px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12), 0 4px 8px rgba(16, 24, 40, .04);

  /* Layout */
  --sidebar-w: 244px;
  --topbar-h: 60px;
  --content-max: 1600px;

  --transition: 150ms cubic-bezier(.4, 0, .2, 1);
}

/* Tema oscuro: se aplica por preferencia del sistema o por atributo. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface:        #151A24;
    --surface-sunken: var(--gray-950);
    --surface-raised: #1B2130;
    --surface-hover:  #212938;
    --border:         #283044;
    --border-strong:  #384156;
    --text:           #E8EBF2;
    --text-muted:     #9BA5B8;
    --text-subtle:    #6E7891;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --surface:        #151A24;
  --surface-sunken: var(--gray-950);
  --surface-raised: #1B2130;
  --surface-hover:  #212938;
  --border:         #283044;
  --border-strong:  #384156;
  --text:           #E8EBF2;
  --text-muted:     #9BA5B8;
  --text-subtle:    #6E7891;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-sunken);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--sp-3); line-height: 1.25; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }
p  { margin: 0 0 var(--sp-4); }

a { color: var(--brand-600); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-700); text-decoration: underline; }
:root[data-theme="dark"] a { color: var(--brand-300); }
:root[data-theme="dark"] a:hover { color: var(--brand-200); }

img, svg, video { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: var(--sp-2); z-index: 999;
  background: var(--brand-600); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
}
.skip-link:focus { left: var(--sp-2); }

/* ── Layout de aplicación ───────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}

.sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.sidebar__logo {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: var(--text-sm); letter-spacing: -.03em;
}
.sidebar__name { font-weight: 680; font-size: var(--text-md); letter-spacing: -.02em; }

.sidebar__workspace { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }

.sidebar__nav { flex: 1; padding: var(--sp-4) var(--sp-3); }
.nav__group + .nav__group { margin-top: var(--sp-5); }
.nav__label {
  font-size: var(--text-xs); font-weight: 650; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-subtle);
  padding: 0 var(--sp-3) var(--sp-2);
}
.nav__link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 520;
  transition: background var(--transition), color var(--transition);
}
.nav__link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav__link.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
:root[data-theme="dark"] .nav__link.is-active { background: rgba(99, 102, 241, .16); color: var(--brand-300); }
.nav__link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.nav__count {
  margin-left: auto; font-size: var(--text-xs); font-variant-numeric: tabular-nums;
  background: var(--surface-hover); color: var(--text-muted);
  padding: 1px var(--sp-2); border-radius: var(--radius-full);
}

.sidebar__footer { padding: var(--sp-3); border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-4);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { font-size: var(--text-md); font-weight: 650; margin: 0; }
.topbar__subtitle { font-size: var(--text-sm); color: var(--text-muted); margin: 0; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }

.content {
  padding: var(--sp-6);
  max-width: var(--content-max);
  width: 100%;
  flex: 1;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.page-header__text h1 { margin-bottom: var(--sp-1); }
.page-header__text p { margin: 0; color: var(--text-muted); }
.page-header__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ── Botones ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font: inherit; font-weight: 570; font-size: var(--text-base);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn--primary { background: var(--brand-600); color: #fff; box-shadow: var(--shadow-xs); }
.btn--primary:hover { background: var(--brand-700); color: #fff; }

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

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn--danger { background: var(--danger-500); color: #fff; }
.btn--danger:hover { background: var(--danger-700); color: #fff; }

.btn--sm { padding: var(--sp-1) var(--sp-3); font-size: var(--text-sm); }
.btn--lg { padding: var(--sp-3) var(--sp-6); font-size: var(--text-md); }
.btn--block { width: 100%; }
.btn--icon { padding: var(--sp-2); }

/* ── Tarjetas ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card__title { margin: 0; font-size: var(--text-md); font-weight: 640; }
.card__subtitle { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }
.card__footer {
  padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border);
  background: var(--surface-sunken); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-size: var(--text-sm); color: var(--text-muted);
}

/* ── KPIs ───────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: var(--sp-5);
}
.kpi {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-4) var(--sp-5);
  display: flex; flex-direction: column; gap: var(--sp-2);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--kpi-color, var(--brand-500));
}
.kpi__label {
  font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
}
.kpi__value {
  font-size: var(--text-2xl); font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.kpi__meta { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); color: var(--text-muted); }

.delta { font-size: var(--text-xs); font-weight: 640; padding: 1px var(--sp-2); border-radius: var(--radius-full); font-variant-numeric: tabular-nums; }
.delta--up   { color: var(--success-700); background: var(--success-50); }
.delta--down { color: var(--danger-700);  background: var(--danger-50); }
.delta--flat { color: var(--text-muted);  background: var(--surface-hover); }
.delta--none { color: var(--text-subtle); background: transparent; font-weight: 500; }
:root[data-theme="dark"] .delta--up   { background: rgba(16, 185, 129, .16); color: #6EE7B7; }
:root[data-theme="dark"] .delta--down { background: rgba(239, 68, 68, .16);  color: #FCA5A5; }

/* ── Insignias ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  font-size: var(--text-xs); font-weight: 600; line-height: 1.6;
  padding: 1px var(--sp-2); border-radius: var(--radius-full);
  white-space: nowrap;
}
.badge--success  { background: var(--success-50); color: var(--success-700); }
.badge--warning  { background: var(--warning-50); color: var(--warning-700); }
.badge--danger   { background: var(--danger-50);  color: var(--danger-700); }
.badge--info     { background: var(--info-50);    color: var(--info-700); }
.badge--progress { background: var(--brand-50);   color: var(--brand-700); }
.badge--neutral  { background: var(--surface-hover); color: var(--text-muted); }

:root[data-theme="dark"] .badge--success  { background: rgba(16, 185, 129, .16); color: #6EE7B7; }
:root[data-theme="dark"] .badge--warning  { background: rgba(245, 158, 11, .16); color: #FCD34D; }
:root[data-theme="dark"] .badge--danger   { background: rgba(239, 68, 68, .16);  color: #FCA5A5; }
:root[data-theme="dark"] .badge--info     { background: rgba(59, 130, 246, .16); color: #93C5FD; }
:root[data-theme="dark"] .badge--progress { background: rgba(99, 102, 241, .18); color: #A5B4FC; }

.badge--platform {
  background: color-mix(in srgb, var(--badge-color) 12%, transparent);
  color: var(--badge-color);
  border: 1px solid color-mix(in srgb, var(--badge-color) 22%, transparent);
}
.badge--platform .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--badge-color); flex-shrink: 0;
}
:root[data-theme="dark"] .badge--platform {
  background: color-mix(in srgb, var(--badge-color) 22%, transparent);
  color: color-mix(in srgb, var(--badge-color) 70%, white);
}

/* ── Avatares ───────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; background: var(--surface-hover);
  display: grid; place-items: center;
  font-size: var(--text-xs); font-weight: 650; color: var(--text-muted);
  border: 1px solid var(--border);
}
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 48px; height: 48px; font-size: var(--text-base); }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

.account-chip { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.account-chip__meta { min-width: 0; }
.account-chip__name {
  font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.account-chip__handle { font-size: var(--text-xs); color: var(--text-muted); }
.account-chip__platform {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0;
  background: var(--platform-color, var(--gray-400));
}

/* ── Formularios ────────────────────────────────────────────────────────── */
.field { margin-bottom: var(--sp-4); }
.field__label { display: block; font-weight: 580; font-size: var(--text-sm); margin-bottom: var(--sp-2); }
.field__label .req { color: var(--danger-500); }
.field__help { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--sp-1); }
.field__error { font-size: var(--text-xs); color: var(--danger-700); margin-top: var(--sp-1); font-weight: 560; }

.field__control {
  width: 100%; padding: var(--sp-2) var(--sp-3);
  font: inherit; font-size: var(--text-base); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field__control:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 18%, transparent);
}
.field__control::placeholder { color: var(--text-subtle); }
textarea.field__control { resize: vertical; min-height: 100px; line-height: 1.6; }
select.field__control { cursor: pointer; }
.field--error .field__control { border-color: var(--danger-500); }

.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.check-list { display: grid; gap: var(--sp-2); }
.check-list label {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.check-list label:hover { background: var(--surface-hover); }
.check-list input:checked + span { font-weight: 600; }
.check-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }

/* ── Barra de filtros ───────────────────────────────────────────────────── */
.filters {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
}
.filters__group { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.filters__label {
  font-size: var(--text-xs); font-weight: 640; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-subtle);
}
.filters__divider { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--sp-1); }
.filters__spacer { margin-left: auto; }

.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-3); font-size: var(--text-sm); font-weight: 540;
  color: var(--text-muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-full);
  cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.is-active {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 600;
}
.chip.is-active:hover { color: #fff; background: var(--brand-700); }
.chip--platform.is-active {
  background: var(--chip-color, var(--brand-600));
  border-color: var(--chip-color, var(--brand-600));
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip-color, currentColor); }

.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: var(--sp-3); width: 15px; height: 15px; color: var(--text-subtle); }
.search-box input { padding-left: calc(var(--sp-3) * 2 + 15px); min-width: 220px; }

/* ── Tablas de datos ────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  -webkit-overflow-scrolling: touch;
}
.table-wrap--bordered {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-sunken);
  padding: var(--sp-3) var(--sp-4);
  text-align: left; font-weight: 620; font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table thead th a { color: inherit; display: inline-flex; align-items: center; gap: var(--sp-1); }
.table thead th a:hover { color: var(--text); text-decoration: none; }
.table thead th.is-sorted { color: var(--brand-600); }
.table thead th .sort-arrow { font-size: 9px; opacity: .8; }

.table tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }

/* Numérico: siempre a la derecha, siempre tabular. Así las columnas se leen
   en vertical de un vistazo. */
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .num--strong { font-weight: 650; color: var(--text); }
.table th.num { text-align: right; }

.table .cell--primary { font-weight: 580; color: var(--text); }
.table .cell--muted { color: var(--text-muted); }
.cell--empty { color: var(--text-subtle); cursor: help; border-bottom: 1px dotted var(--border-strong); }

/* Fila de totales: cierra la tabla y confirma que los números cuadran. */
.table tfoot td {
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-sunken);
  font-weight: 680; border-top: 2px solid var(--border-strong);
}

/* Barra proporcional dentro de la celda: relaciona cada fila con el máximo
   de su columna sin necesidad de un gráfico aparte. */
.bar-cell { display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }
.bar-cell__value { min-width: 52px; text-align: right; font-weight: 600; }
.bar-cell__track {
  width: 68px; height: 5px; border-radius: var(--radius-full);
  background: var(--surface-hover); overflow: hidden; flex-shrink: 0;
}
.bar-cell__fill {
  height: 100%; border-radius: var(--radius-full);
  background: var(--bar-color, var(--brand-500));
}

.table--compact tbody td, .table--compact thead th { padding: var(--sp-2) var(--sp-3); }
.table--linked tbody tr { cursor: pointer; }

.table__row-actions { display: flex; gap: var(--sp-1); justify-content: flex-end; opacity: 0; transition: opacity var(--transition); }
.table tbody tr:hover .table__row-actions { opacity: 1; }
@media (hover: none) { .table__row-actions { opacity: 1; } }

/* ── Estado vacío ───────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: var(--sp-12) var(--sp-6); color: var(--text-muted);
}
.empty__icon {
  width: 44px; height: 44px; margin: 0 auto var(--sp-4);
  display: grid; place-items: center; border-radius: var(--radius-lg);
  background: var(--surface-hover); color: var(--text-subtle);
}
.empty__title { font-size: var(--text-md); font-weight: 620; color: var(--text); margin-bottom: var(--sp-2); }
.empty p { max-width: 42ch; margin: 0 auto var(--sp-4); }

/* ── Mensajes ───────────────────────────────────────────────────────────── */
.messages { position: fixed; top: var(--sp-4); right: var(--sp-4); z-index: 100; display: grid; gap: var(--sp-2); max-width: 420px; }
.message {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-raised); border: 1px solid var(--border);
  border-left: 3px solid var(--info-500);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  animation: slide-in 220ms cubic-bezier(.2, .9, .3, 1);
}
.message--success { border-left-color: var(--success-500); }
.message--warning { border-left-color: var(--warning-500); }
.message--error   { border-left-color: var(--danger-500); }
.message__close { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--text-subtle); font-size: var(--text-md); padding: 0; }

@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
  font-size: var(--text-sm); margin-bottom: var(--sp-4);
  border: 1px solid var(--border);
}
.alert--info    { background: var(--info-50);    border-color: color-mix(in srgb, var(--info-500) 25%, transparent); }
.alert--warning { background: var(--warning-50); border-color: color-mix(in srgb, var(--warning-500) 30%, transparent); }
.alert--danger  { background: var(--danger-50);  border-color: color-mix(in srgb, var(--danger-500) 25%, transparent); }
:root[data-theme="dark"] .alert--info    { background: rgba(59, 130, 246, .12); }
:root[data-theme="dark"] .alert--warning { background: rgba(245, 158, 11, .12); }
:root[data-theme="dark"] .alert--danger  { background: rgba(239, 68, 68, .12); }
.alert__title { font-weight: 640; margin-bottom: var(--sp-1); }

/* ── Gráficos ───────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; height: 280px; }
.chart--tall { height: 340px; }
.chart--short { height: 180px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-3); font-size: var(--text-sm); }
.chart-legend__item { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); }
.chart-legend__swatch { width: 10px; height: 10px; border-radius: 3px; }

/* ── Pestañas ───────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); overflow-x: auto; }
.tab {
  padding: var(--sp-3) var(--sp-4); font-weight: 570; color: var(--text-muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand-600); border-bottom-color: var(--brand-600); font-weight: 640; }

/* ── Rejillas ───────────────────────────────────────────────────────────── */
.grid { display: grid; gap: var(--sp-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid--composer { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); }

/* ── Comparativa multi-red de una publicación ───────────────────────────── */
.network-compare { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.network-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-raised); overflow: hidden;
  border-top: 3px solid var(--net-color, var(--gray-400));
}
.network-card__head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.network-card__name { font-weight: 620; }
.network-card__metrics { padding: var(--sp-2) 0; }
.metric-row {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: var(--sp-2) var(--sp-4); gap: var(--sp-3);
}
.metric-row + .metric-row { border-top: 1px solid var(--border); }
.metric-row__label { font-size: var(--text-sm); color: var(--text-muted); }
.metric-row__value { font-weight: 660; font-variant-numeric: tabular-nums; }

/* ── Calendario ─────────────────────────────────────────────────────────── */
.calendar { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-raised); }
.calendar__head, .calendar__week { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar__head div {
  padding: var(--sp-2); text-align: center; font-size: var(--text-xs);
  font-weight: 640; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}
.calendar__day {
  min-height: 108px; padding: var(--sp-2);
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.calendar__day:nth-child(7n) { border-right: none; }
.calendar__day.is-outside { background: var(--surface-sunken); opacity: .55; }
.calendar__day.is-today .calendar__date {
  background: var(--brand-600); color: #fff; border-radius: var(--radius-full);
  width: 22px; height: 22px; display: grid; place-items: center;
}
.calendar__date { font-size: var(--text-xs); font-weight: 640; color: var(--text-muted); }
.calendar__event {
  font-size: var(--text-xs); padding: 2px var(--sp-2); border-radius: var(--radius-sm);
  background: var(--surface-hover); border-left: 2px solid var(--event-color, var(--brand-500));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); text-decoration: none; display: block;
}
.calendar__event:hover { background: var(--border); text-decoration: none; }

/* ── Editor de publicaciones ────────────────────────────────────────────── */
.composer__preview {
  position: sticky; top: calc(var(--topbar-h) + var(--sp-6));
  max-height: calc(100vh - var(--topbar-h) - var(--sp-12));
  overflow-y: auto;
}
.media-grid { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.media-item {
  position: relative; aspect-ratio: 1; border-radius: var(--radius);
  overflow: hidden; border: 2px solid var(--border); cursor: pointer;
  background: var(--surface-hover);
}
.media-item.is-selected { border-color: var(--brand-600); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-500) 25%, transparent); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item__order {
  position: absolute; top: var(--sp-1); left: var(--sp-1);
  width: 20px; height: 20px; border-radius: 50%; background: var(--brand-600);
  color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
}
.media-item__badge {
  position: absolute; bottom: var(--sp-1); right: var(--sp-1);
  background: rgba(0, 0, 0, .7); color: #fff; font-size: 10px;
  padding: 1px 5px; border-radius: var(--radius-sm);
}

.char-counter { font-size: var(--text-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.char-counter.is-warning { color: var(--warning-700); font-weight: 600; }
.char-counter.is-over { color: var(--danger-700); font-weight: 700; }

/* ── Paginación ─────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4); flex-wrap: wrap; }
.pagination__info { font-size: var(--text-sm); color: var(--text-muted); }
.pagination__links { display: flex; gap: var(--sp-1); }
.pagination__link {
  min-width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-muted); padding: 0 var(--sp-2);
}
.pagination__link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.pagination__link.is-active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 640; }

/* ── Desplegables ───────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + var(--sp-2)); z-index: 40;
  min-width: 220px; padding: var(--sp-1);
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.dropdown__item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--text-sm); width: 100%;
  background: none; border: none; text-align: left; cursor: pointer; font-family: inherit;
}
.dropdown__item:hover { background: var(--surface-hover); text-decoration: none; }
.dropdown__divider { height: 1px; background: var(--border); margin: var(--sp-1) 0; }

/* ── Utilidades ─────────────────────────────────────────────────────────── */
.stack   { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); }
.text-muted  { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }

/* ── Sitio público ──────────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  max-width: 1180px; margin: 0 auto; padding: var(--sp-4) var(--sp-6);
  display: flex; align-items: center; gap: var(--sp-6);
}
.site-nav { display: flex; gap: var(--sp-5); margin-left: auto; align-items: center; }
.site-nav a { color: var(--text-muted); font-weight: 540; }
.site-nav a:hover { color: var(--text); text-decoration: none; }

.section { padding: var(--sp-20) var(--sp-6); }
.section__inner { max-width: 1180px; margin: 0 auto; }
.section--alt { background: var(--surface); border-block: 1px solid var(--border); }
.section__eyebrow {
  font-size: var(--text-xs); font-weight: 680; text-transform: uppercase;
  letter-spacing: .1em; color: var(--brand-600); margin-bottom: var(--sp-3);
}
.section__title { font-size: var(--text-3xl); letter-spacing: -.025em; margin-bottom: var(--sp-4); }
.section__lead { font-size: var(--text-lg); color: var(--text-muted); max-width: 62ch; }

.hero { padding: var(--sp-20) var(--sp-6) var(--sp-16); text-align: center; }
.hero h1 {
  font-size: clamp(2.25rem, 5.5vw, 3.75rem); line-height: 1.06;
  letter-spacing: -.035em; margin-bottom: var(--sp-5); font-weight: 720;
}
.hero__gradient {
  background: linear-gradient(120deg, var(--brand-500), #A855F7 45%, #EC4899);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lead { font-size: var(--text-lg); color: var(--text-muted); max-width: 58ch; margin: 0 auto var(--sp-8); }
.hero__actions { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; }
.hero__networks { display: flex; gap: var(--sp-3); justify-content: center; flex-wrap: wrap; margin-top: var(--sp-10); }

.feature-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: var(--sp-10); }
.feature-card {
  padding: var(--sp-6); border: 1px solid var(--border);
  border-radius: var(--radius-xl); background: var(--surface-raised);
  transition: transform var(--transition), box-shadow var(--transition);
}
.feature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.feature-card__icon {
  width: 40px; height: 40px; border-radius: var(--radius); margin-bottom: var(--sp-4);
  background: var(--brand-50); color: var(--brand-600); display: grid; place-items: center;
}
:root[data-theme="dark"] .feature-card__icon { background: rgba(99, 102, 241, .16); color: var(--brand-300); }
.feature-card h3 { margin-bottom: var(--sp-2); }
.feature-card p { color: var(--text-muted); margin: 0; }

.faq { max-width: 760px; margin: var(--sp-10) auto 0; }
.faq details {
  border-bottom: 1px solid var(--border); padding: var(--sp-4) 0;
}
.faq summary { font-weight: 620; cursor: pointer; font-size: var(--text-md); list-style: none; display: flex; justify-content: space-between; gap: var(--sp-4); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--text-subtle); font-size: var(--text-lg); }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: var(--sp-3) 0 0; color: var(--text-muted); }

.site-footer { padding: var(--sp-12) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface); }
.site-footer__inner { max-width: 1180px; margin: 0 auto; display: flex; gap: var(--sp-8); flex-wrap: wrap; justify-content: space-between; }
.site-footer__links { display: flex; gap: var(--sp-6); flex-wrap: wrap; }
.site-footer a { color: var(--text-muted); font-size: var(--text-sm); }

.auth-shell {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--sp-6); background: var(--surface-sunken);
}
.auth-card {
  width: 100%; max-width: 420px; padding: var(--sp-8);
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-md);
}
.auth-card__brand { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .grid--sidebar, .grid--composer { grid-template-columns: 1fr; }
  .composer__preview { position: static; max-height: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 280px;
    transform: translateX(-100%); transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; }
  .sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 25;
  }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); }
  .messages { left: var(--sp-4); right: var(--sp-4); max-width: none; }
}

@media (max-width: 720px) {
  /* Las tablas anchas pasan a tarjetas: en móvil, el scroll horizontal en una
     tabla de 10 columnas es inservible. */
  .table--responsive thead { display: none; }
  .table--responsive tbody tr {
    display: block; padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
  }
  .table--responsive tbody td {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--sp-4); padding: var(--sp-1) 0; border: none; text-align: right;
  }
  .table--responsive tbody td::before {
    content: attr(data-label);
    font-size: var(--text-xs); font-weight: 620; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-muted); text-align: left;
  }
  .table--responsive tbody td.num { text-align: right; }
  .table--responsive .table__row-actions { opacity: 1; justify-content: flex-end; }

  .calendar__day { min-height: 68px; }
  .kpi__value { font-size: var(--text-xl); }
  .section { padding: var(--sp-12) var(--sp-4); }
  .hero { padding: var(--sp-12) var(--sp-4); }
}

@media print {
  .sidebar, .topbar, .filters, .page-header__actions, .table__row-actions { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { break-inside: avoid; box-shadow: none; }
}

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

/* ── Acceso con redes sociales ──────────────────────────────────────────── */
.social-auth { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.social-auth__btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-3) var(--sp-4);
  font: inherit; font-size: var(--text-base); font-weight: 560;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.social-auth__btn:hover {
  background: var(--surface-hover); border-color: var(--provider-color, var(--border-strong));
  color: var(--text); text-decoration: none;
}
.social-auth__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--provider-color, var(--gray-400)); flex-shrink: 0;
}

/* Separador «o» entre el acceso social y el formulario de correo. */
.divider-or {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-5) 0; color: var(--text-subtle); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .08em;
}
.divider-or::before, .divider-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.linked-account {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0;
}
.linked-account + .linked-account { border-top: 1px solid var(--border); }
