/* ==========================================================================
   NexoPublisher · Sistema de diseño
   CSS propio, sin frameworks. Temas claro y oscuro diseñados por separado.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F4F9;
  --surface-hover: #F3F6FA;
  --surface-active: #EAF0F8;
  --border: #E4E8EF;
  --border-strong: #D3DAE5;
  --text: #0F172A;
  --text-2: #475569;
  --text-3: #64748B;
  --text-inverse: #FFFFFF;

  --primary: #1D4ED8;
  --primary-hover: #1E40AF;
  --primary-2: #3B82F6;
  --primary-soft: #EFF4FF;
  --primary-soft-2: #DBE6FE;
  --primary-text: #1D4ED8;
  --ring: rgba(59, 130, 246, 0.28);
  --navy: #0D1424;

  --success: #067647;
  --success-soft: #ECFDF3;
  --success-text: #067647;
  --success-border: #ABEFC6;
  --danger: #B42318;
  --danger-hover: #912018;
  --danger-soft: #FEF3F2;
  --danger-text: #B42318;
  --danger-border: #FECDCA;
  --warning: #B45309;
  --warning-soft: #FFFAEB;
  --warning-text: #B45309;
  --warning-border: #FEDF89;
  --gray-soft: #F1F5F9;
  --gray-text: #475569;
  --gray-border: #E2E8F0;
  --violet-soft: #F4F3FF;
  --violet-text: #5B21B6;
  --violet-border: #DDD6FE;
  --teal-soft: #F0FDFA;
  --teal-text: #0F766E;
  --teal-border: #99F6E4;
  --slate-soft: #EEF2F6;
  --slate-text: #334155;
  --slate-border: #CBD5E1;

  --chart-published: #1D4ED8;
  --chart-failed: #D03B3B;
  --chart-grid: #EEF1F5;
  --meter-track: #DBE6FE;

  --sidebar-bg: #0D1424;
  --sidebar-border: #182238;
  --sidebar-text: #AEB9CC;
  --sidebar-text-strong: #F4F7FC;
  --sidebar-muted: #6D7B94;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(59, 130, 246, 0.16);
  --sidebar-accent: #60A5FA;

  --skeleton-a: #EEF2F7;
  --skeleton-b: #F8FAFD;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 6px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px -12px rgba(15, 23, 42, 0.18), 0 4px 10px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 32px 64px -16px rgba(15, 23, 42, 0.28), 0 8px 16px rgba(15, 23, 42, 0.06);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --sidebar-w: 260px;
  --sidebar-collapsed-w: 72px;
  --topbar-h: 60px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0A0F1C;
  --surface: #0F1629;
  --surface-2: #121A2F;
  --surface-3: #151E35;
  --surface-hover: #162039;
  --surface-active: #1B2644;
  --border: #1E2942;
  --border-strong: #2A3654;
  --text: #E6EBF5;
  --text-2: #A7B3C9;
  --text-3: #8490A8;
  --text-inverse: #FFFFFF;

  --primary: #3B82F6;
  --primary-hover: #5B95F8;
  --primary-2: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-soft-2: rgba(59, 130, 246, 0.22);
  --primary-text: #8DB6FB;
  --ring: rgba(59, 130, 246, 0.38);

  --success: #3FB97A;
  --success-soft: rgba(6, 118, 71, 0.2);
  --success-text: #6CD9A0;
  --success-border: rgba(63, 185, 122, 0.32);
  --danger: #E5544A;
  --danger-hover: #F06C62;
  --danger-soft: rgba(180, 35, 24, 0.2);
  --danger-text: #FF8F86;
  --danger-border: rgba(240, 100, 90, 0.34);
  --warning: #E8A23B;
  --warning-soft: rgba(180, 83, 9, 0.2);
  --warning-text: #F5BE6A;
  --warning-border: rgba(232, 162, 59, 0.34);
  --gray-soft: rgba(148, 163, 184, 0.12);
  --gray-text: #A7B3C9;
  --gray-border: rgba(148, 163, 184, 0.22);
  --violet-soft: rgba(139, 92, 246, 0.16);
  --violet-text: #C4B5FD;
  --violet-border: rgba(139, 92, 246, 0.32);
  --teal-soft: rgba(20, 184, 166, 0.14);
  --teal-text: #5EEAD4;
  --teal-border: rgba(20, 184, 166, 0.3);
  --slate-soft: rgba(148, 163, 184, 0.16);
  --slate-text: #CBD5E1;
  --slate-border: rgba(148, 163, 184, 0.3);

  --chart-published: #3987E5;
  --chart-failed: #E66767;
  --chart-grid: #1A2440;
  --meter-track: rgba(59, 130, 246, 0.18);

  --sidebar-bg: #070B16;
  --sidebar-border: #141C31;
  --sidebar-text: #A3AFC4;
  --sidebar-text-strong: #F4F7FC;
  --sidebar-muted: #647189;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(59, 130, 246, 0.16);

  --skeleton-a: #131B30;
  --skeleton-b: #1A2440;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 44px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-xl: 0 32px 72px -16px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* --------------------------------------------------------------------------
   Base
   ----------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, pre { font-family: var(--mono); }
::selection { background: rgba(59, 130, 246, 0.24); }

:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; border-radius: 4px; }

.icon { flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.sr-only { 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: 12px; top: -48px; z-index: 300; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600; transition: top 0.15s; }
.skip-link:focus { top: 12px; text-decoration: none; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Estructura principal
   ----------------------------------------------------------------------- */

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: width 0.22s var(--ease), transform 0.22s var(--ease);
}

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--sidebar-text-strong); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; display: block; }
.brand-mark svg { width: 32px; height: 32px; display: block; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-name span { color: var(--sidebar-accent); }

.sidebar-toggle {
  width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--sidebar-muted);
  display: grid; place-items: center; transition: background 0.15s, color 0.15s, transform 0.22s var(--ease);
}
.sidebar-toggle:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 16px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #243049; }

.nav-section {
  margin: 18px 10px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.nav-item .icon { color: var(--sidebar-muted); transition: color 0.15s; }
.nav-item:hover .icon { color: var(--sidebar-text-strong); }
.nav-item.is-active { background: var(--sidebar-active); color: var(--sidebar-text-strong); }
.nav-item.is-active .icon { color: var(--sidebar-accent); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sidebar-accent);
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 650;
  display: inline-grid; place-items: center; background: rgba(255, 255, 255, 0.08); color: var(--sidebar-text-strong);
}
.nav-count.is-warning { background: rgba(232, 162, 59, 0.2); color: #F5BE6A; }
.nav-count.is-danger { background: rgba(229, 84, 74, 0.22); color: #FF9A92; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.user-card:hover { background: var(--sidebar-hover); }
.user-meta { flex: 1; min-width: 0; line-height: 1.3; }
.user-name { color: var(--sidebar-text-strong); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.user-name:hover { text-decoration: none; color: #fff; }
.user-role { color: var(--sidebar-muted); font-size: 12px; }
.logout-form { margin: 0; }
.logout-btn { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--sidebar-muted); display: grid; place-items: center; }
.logout-btn:hover { background: rgba(229, 84, 74, 0.16); color: #FF9A92; }

.main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 0.22s var(--ease); }

.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-w); }
.sidebar-collapsed .main { margin-left: var(--sidebar-collapsed-w); }
.sidebar-collapsed .brand-name,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-count,
.sidebar-collapsed .user-meta,
.sidebar-collapsed .logout-form { display: none; }
.sidebar-collapsed .sidebar-header { padding: 0; justify-content: center; flex-direction: column; gap: 0; }
.sidebar-collapsed .sidebar-header .brand { display: none; }
.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); width: 40px; height: 40px; }
.sidebar-collapsed .nav-section { height: 1px; margin: 14px 12px; background: var(--sidebar-border); font-size: 0; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 0; height: 40px; }
.sidebar-collapsed .nav-item.is-active::before { left: -10px; }
.sidebar-collapsed .user-card { justify-content: center; padding: 6px 0; }
.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 550;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 80;
}

.sidebar-backdrop { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar .mobile-menu { display: none; }

.breadcrumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--text-3); }
.breadcrumbs a { color: var(--text-3); white-space: nowrap; }
.breadcrumbs a:hover { color: var(--text); text-decoration: none; }
.breadcrumbs .current { color: var(--text); font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumbs .sep { color: var(--border-strong); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.limit-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.limit-chip:hover { text-decoration: none; border-color: var(--border-strong); }
.limit-chip strong { color: var(--text); font-weight: 650; }
.limit-chip-meter { width: 34px; height: 6px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.limit-chip-meter span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.limit-chip.is-warning .limit-chip-meter span { background: var(--warning); }
.limit-chip.is-full .limit-chip-meter span { background: var(--danger); }

.page { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px 32px 56px; flex: 1; }
.page-wide { max-width: none; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-heading { min-width: 0; }
.page-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--primary-text); margin-bottom: 6px; }
.page-title { font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -0.02em; }
.page-subtitle { margin-top: 4px; color: var(--text-2); font-size: 14px; max-width: 760px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }

/* --------------------------------------------------------------------------
   Utilidades
   ----------------------------------------------------------------------- */

.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pre-line { white-space: pre-line; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 24px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.color-success { color: var(--success-text); }
.color-danger { color: var(--danger-text); }
.color-warning { color: var(--warning-text); }
.color-primary { color: var(--primary-text); }

/* --------------------------------------------------------------------------
   Botones
   ----------------------------------------------------------------------- */

.btn {
  --spinner: currentColor;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s, transform 0.08s;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn .icon { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(29, 78, 216, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.12); --spinner: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover { background: var(--primary-soft-2); color: var(--primary-text); }
.btn-danger { background: var(--danger); color: #fff; --spinner: #fff; }
.btn-danger:hover { background: var(--danger-hover); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; --spinner: #fff; }
.btn-success:hover { filter: brightness(1.08); color: #fff; }
.btn-warning-soft { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.btn-warning-soft:hover { border-color: var(--warning); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; gap: 6px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-xs .icon { width: 13px; height: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn-xl { height: 54px; padding: 0 28px; font-size: 16px; border-radius: 12px; font-weight: 600; letter-spacing: 0.01em; }
.btn-xl .icon { width: 20px; height: 20px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-icon.btn-xs { width: 26px; }

.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .icon { opacity: 0; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2px solid var(--spinner);
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--text-2); border-right-color: transparent; }
.btn-soft.is-loading::after { border-color: var(--primary); border-right-color: transparent; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn + .btn { margin-left: -1px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-2);
  display: inline-grid; place-items: center; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.is-bordered { border-color: var(--border); background: var(--surface); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-right-color: var(--primary); animation: spin 0.7s linear infinite; display: inline-block; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* --------------------------------------------------------------------------
   Tarjetas
   ----------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header.no-border { border-bottom: 0; padding-bottom: 4px; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.card-title .icon { color: var(--text-3); }
.card-subtitle { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.compact { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-link { font-size: 13px; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }
.card.is-interactive { transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.card.is-interactive:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

/* --------------------------------------------------------------------------
   Estadísticas y medidores
   ----------------------------------------------------------------------- */

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.stats-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.page { container-type: inline-size; container-name: page; }
@container page (max-width: 1060px) {
  .stats-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .stats-grid > * { grid-column: span 2; }
  .stats-grid > :nth-child(4):nth-last-child(2), .stats-grid > :nth-child(5):last-child { grid-column: span 3; }
  .stats-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid.cols-4 > *, .stats-grid.cols-3 > * { grid-column: auto; }
}
@container page (max-width: 700px) {
  .stats-grid, .stats-grid.cols-3, .stats-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stats-grid > *, .stats-grid.cols-3 > *, .stats-grid.cols-4 > *,
  .stats-grid > :nth-child(4):nth-last-child(2), .stats-grid > :nth-child(5):last-child { grid-column: auto; }
  .stats-grid > :last-child:nth-child(odd) { grid-column: span 2; }
}
.stat-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; }
.stat-card:hover { text-decoration: none; }
a.stat-card { color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
a.stat-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 550; }
.stat-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.stat-icon .icon { width: 17px; height: 17px; }
.stat-icon.tone-green { background: var(--success-soft); color: var(--success-text); }
.stat-icon.tone-yellow { background: var(--warning-soft); color: var(--warning-text); }
.stat-icon.tone-red { background: var(--danger-soft); color: var(--danger-text); }
.stat-icon.tone-gray { background: var(--gray-soft); color: var(--gray-text); }
.stat-icon.tone-violet { background: var(--violet-soft); color: var(--violet-text); }
.stat-value { font-size: 30px; line-height: 1; font-weight: 650; letter-spacing: -0.03em; }
.stat-value small { font-size: 17px; font-weight: 550; color: var(--text-3); letter-spacing: -0.01em; margin-left: 2px; }
.stat-meta { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }

.meter { height: 8px; border-radius: 999px; background: var(--meter-track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.5s var(--ease); }
.meter.is-warning .meter-fill { background: var(--warning); }
.meter.is-full .meter-fill { background: var(--danger); }
.meter-lg { height: 10px; }

.limit-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 16px 20px; margin-top: 16px; }
.limit-card-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.limit-card-title { font-weight: 600; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.limit-card-title span { font-weight: 500; color: var(--text-2); font-size: 13px; }
.limit-slots { display: flex; gap: 6px; }
.limit-slot { width: 26px; height: 8px; border-radius: 999px; background: var(--meter-track); }
.limit-slot.is-used { background: var(--primary); }
.limit-card.is-full .limit-slot.is-used { background: var(--danger); }
.limit-card.is-warning .limit-slot.is-used { background: var(--warning); }

/* --------------------------------------------------------------------------
   Insignias
   ----------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  background: var(--gray-soft);
  color: var(--gray-text);
  border: 1px solid var(--gray-border);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge .icon { width: 12px; height: 12px; }
.badge-blue { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-soft-2); }
.badge-green { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.badge-yellow { background: var(--warning-soft); color: var(--warning-text); border-color: var(--warning-border); }
.badge-red { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.badge-gray { background: var(--gray-soft); color: var(--gray-text); border-color: var(--gray-border); }
.badge-violet { background: var(--violet-soft); color: var(--violet-text); border-color: var(--violet-border); }
.badge-teal { background: var(--teal-soft); color: var(--teal-text); border-color: var(--teal-border); }
.badge-slate { background: var(--slate-soft); color: var(--slate-text); border-color: var(--slate-border); }
.badge-outline { background: transparent; }
.badge-square { border-radius: 6px; }
.badge-lg { height: 26px; padding: 0 10px; font-size: 12.5px; }

.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag .icon { width: 13px; height: 13px; color: var(--text-3); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--text-3); flex-shrink: 0; }
.status-dot.is-green { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.is-yellow { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.status-dot.is-red { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.is-gray { background: var(--text-3); box-shadow: 0 0 0 3px var(--gray-soft); }
.status-dot.is-blue { background: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-soft); }

/* --------------------------------------------------------------------------
   Formularios
   ----------------------------------------------------------------------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2, .span-full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 550; color: var(--text); display: flex; align-items: center; gap: 6px; }
.label .optional { font-weight: 400; color: var(--text-3); font-size: 12px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.field-error { font-size: 12.5px; color: var(--danger-text); display: none; }
.field.has-error .field-error { display: block; }

.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  min-width: 0;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 0.8; }
.input:hover, .select:hover, .textarea:hover { border-color: #C2CBD8; }
[data-theme="dark"] .input:hover, [data-theme="dark"] .select:hover, [data-theme="dark"] .textarea:hover { border-color: #37456A; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--ring); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-2); color: var(--text-2); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea, .input.is-invalid { border-color: var(--danger); }
.input-sm, .select.input-sm { height: 32px; font-size: 13px; padding: 0 10px; }
.select.input-sm { padding-right: 28px; background-position: right 8px center; }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.textarea.is-tall { min-height: 180px; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.input[type="date"], .input[type="time"], .input[type="datetime-local"] { font-variant-numeric: tabular-nums; }
.input-mono { font-family: var(--mono); font-size: 13px; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 36px; }
.input-group > .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; width: 16px; height: 16px; }
.input-group.has-action .input { padding-right: 42px; }
.input-action { position: absolute; right: 4px; width: 32px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.input-action:hover { background: var(--surface-hover); color: var(--text); }
.input-addon { display: flex; }
.input-addon .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-addon .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; height: 38px; }

.char-count { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.char-count.is-over { color: var(--danger-text); }

.checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.checkbox::before {
  content: "";
  width: 10px;
  height: 10px;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0);
  transition: transform 0.12s var(--ease);
}
.checkbox:checked { background: var(--primary); border-color: var(--primary); }
.checkbox:checked::before { transform: scale(1); }
.checkbox:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; user-select: none; }
.check-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.check-row:hover { border-color: var(--border-strong); }
.check-row.is-checked { border-color: var(--primary-2); background: var(--primary-soft); }
.check-row .checkbox { margin-top: 2px; }

.radio { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0; border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; }
.radio::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform 0.12s; }
.radio:checked { background: var(--primary); border-color: var(--primary); }
.radio:checked::before { transform: scale(1); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); transition: background 0.18s; flex-shrink: 0; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25); transition: transform 0.18s var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--ring); }
.switch input:disabled + .switch-track { opacity: 0.5; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border); }
.segmented button, .segmented a {
  height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 550; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.segmented button:hover, .segmented a:hover { color: var(--text); text-decoration: none; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .segmented .is-active { background: var(--surface-active); }

.fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.fieldset legend { padding: 0; font-weight: 600; margin-bottom: 10px; }

.form-section { padding: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.form-section-desc { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }

/* --------------------------------------------------------------------------
   Tarjetas seleccionables (wizard)
   ----------------------------------------------------------------------- */

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.choice-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.15s;
}
.choice-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.choice-card.is-selected { border-color: var(--primary-2); background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%); box-shadow: 0 0 0 3px var(--ring); }
.choice-card.is-compact { min-height: 0; flex-direction: row; align-items: center; padding: 12px 14px; }
.choice-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.choice-card.is-selected .choice-icon { background: var(--primary); color: #fff; }
.choice-title { font-weight: 600; font-size: 14px; }
.choice-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.choice-check { position: absolute; top: 12px; right: 12px; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; color: #fff; transition: all 0.15s; }
.choice-check .icon { width: 12px; height: 12px; stroke-width: 3; opacity: 0; }
.choice-card.is-selected .choice-check { background: var(--primary); border-color: var(--primary); }
.choice-card.is-selected .choice-check .icon { opacity: 1; }

/* --------------------------------------------------------------------------
   Tablas
   ----------------------------------------------------------------------- */

.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tr.is-clickable { cursor: pointer; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-actions { text-align: right; white-space: nowrap; width: 1%; }
.table-compact td { padding: 9px 14px; }
.table-compact th { padding: 8px 14px; }
.card .table th:first-child { border-top-left-radius: 0; }
.cell-title { font-weight: 550; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.cell-media { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--surface-3); border: 1px solid var(--border); }
.cell-media-empty { width: 44px; height: 44px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); }

.inline-bar { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.inline-bar-track { flex: 1; height: 8px; border-radius: 0 4px 4px 0; background: transparent; position: relative; }
.inline-bar-fill { height: 8px; border-radius: 0 4px 4px 0; background: var(--chart-published); min-width: 2px; }
.inline-bar-value { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--text-2); min-width: 28px; text-align: right; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.pagination-controls { display: flex; gap: 6px; }

/* --------------------------------------------------------------------------
   Pestañas y filtros
   ----------------------------------------------------------------------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 12px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-2); font-weight: 550; font-size: 13.5px; white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--text); border-bottom-color: var(--primary); }
.tab .icon { width: 16px; height: 16px; color: var(--text-3); }
.tab.is-active .icon { color: var(--primary-text); }
.tab-count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; background: var(--surface-3); color: var(--text-3); border: 1px solid var(--border); }
.tab.is-active .tab-count { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-soft-2); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 550; transition: all 0.15s; white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.pill.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .pill.is-active { background: var(--primary); border-color: var(--primary); }
.pill .tab-count { background: rgba(148, 163, 184, 0.14); border: 0; color: inherit; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-input { width: 260px; }

.filter-bar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filter-bar .field { gap: 4px; }
.filter-bar .label { font-size: 12px; color: var(--text-3); font-weight: 550; }

/* --------------------------------------------------------------------------
   Alertas
   ----------------------------------------------------------------------- */

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 13.5px; color: var(--text-2); }
.alert > .icon { margin-top: 1px; width: 18px; height: 18px; }
.alert-title { font-weight: 600; color: var(--text); margin-bottom: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.alert-info { background: var(--primary-soft); border-color: var(--primary-soft-2); }
.alert-info > .icon { color: var(--primary-text); }
.alert-success { background: var(--success-soft); border-color: var(--success-border); }
.alert-success > .icon { color: var(--success-text); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); }
.alert-warning > .icon { color: var(--warning-text); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); }
.alert-error > .icon { color: var(--danger-text); }

/* --------------------------------------------------------------------------
   Estados vacíos, esqueletos y carga
   ----------------------------------------------------------------------- */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 44px 24px; }
.empty-icon { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-3); margin-bottom: 8px; }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-title { font-weight: 600; font-size: 15px; }
.empty-text { color: var(--text-2); max-width: 420px; font-size: 13.5px; }
.empty .btn { margin-top: 12px; }
.empty-sm { padding: 24px 16px; }
.empty-sm .empty-icon { width: 40px; height: 40px; }

.skeleton { background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 37%, var(--skeleton-a) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 6px; }
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-block { height: 120px; border-radius: 12px; }
.skeleton-card { padding: 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }

.loading-overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 70%, transparent); display: grid; place-items: center; z-index: 5; border-radius: inherit; }
.is-refreshing { opacity: 0.55; pointer-events: none; transition: opacity 0.2s; }

/* --------------------------------------------------------------------------
   Modales y paneles laterales
   ----------------------------------------------------------------------- */

.modal-root { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(8, 13, 25, 0.5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fadeIn 0.16s ease; }
.modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s var(--ease);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1040px; }
.modal-header { display: flex; align-items: flex-start; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.modal-header.no-border { border-bottom: 0; padding-bottom: 4px; }
.modal-heading { flex: 1; min-width: 0; }
.modal-title { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-desc { font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.modal-close { margin: -4px -6px 0 0; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); flex-wrap: wrap; }
.modal-footer .spacer { margin-right: auto; }
.modal-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-soft); color: var(--primary-text); }
.modal-icon.tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.modal-icon.tone-warning { background: var(--warning-soft); color: var(--warning-text); }
.modal-icon.tone-success { background: var(--success-soft); color: var(--success-text); }
body.has-modal { overflow: hidden; }

.drawer-root { position: fixed; inset: 0; z-index: 110; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; animation: drawerIn 0.24s var(--ease);
}
.drawer-header { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Notificaciones (toasts)
   ----------------------------------------------------------------------- */

.toast-region { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(390px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  overflow: hidden;
  animation: toastIn 0.26s var(--ease);
}
.toast.is-leaving { animation: toastOut 0.2s ease forwards; }
.toast-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toast-icon .icon { width: 16px; height: 16px; }
.toast-success .toast-icon { background: var(--success-soft); color: var(--success-text); }
.toast-error .toast-icon { background: var(--danger-soft); color: var(--danger-text); }
.toast-warning .toast-icon { background: var(--warning-soft); color: var(--warning-text); }
.toast-info .toast-icon { background: var(--primary-soft); color: var(--primary-text); }
.toast-content { flex: 1; min-width: 0; padding-top: 3px; }
.toast-title { font-weight: 600; font-size: 13.5px; }
.toast-message { font-size: 13px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.toast-action { margin-top: 8px; }
.toast-close { width: 26px; height: 26px; border: 0; background: transparent; color: var(--text-3); border-radius: 6px; display: grid; place-items: center; margin: -2px -4px 0 0; }
.toast-close:hover { background: var(--surface-hover); color: var(--text); }
.toast-progress { position: absolute; left: 0; bottom: 0; height: 2px; background: currentColor; opacity: 0.35; animation-name: toastProgress; animation-timing-function: linear; animation-fill-mode: forwards; }
.toast-success .toast-progress { color: var(--success); }
.toast-error .toast-progress { color: var(--danger); }
.toast-warning .toast-progress { color: var(--warning); }
.toast-info .toast-progress { color: var(--primary); }
.toast:hover .toast-progress { animation-play-state: paused; }

/* --------------------------------------------------------------------------
   Menús desplegables
   ----------------------------------------------------------------------- */

.dropdown { position: relative; display: inline-flex; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
  z-index: 70; display: none; animation: menuIn 0.14s var(--ease);
}
.menu.align-left { left: 0; right: auto; }
.menu.drop-up { top: auto; bottom: calc(100% + 6px); }
.dropdown.is-open > .menu { display: block; }
.menu-label { padding: 6px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); font-size: 13.5px; text-align: left; white-space: nowrap; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); text-decoration: none; outline: none; }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-3); }
.menu-item.is-danger { color: var(--danger-text); }
.menu-item.is-danger .icon { color: var(--danger-text); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.menu-item.is-active { font-weight: 600; }
.menu-item.is-active::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

/* --------------------------------------------------------------------------
   Componentes varios
   ----------------------------------------------------------------------- */

.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: linear-gradient(135deg, #1D4ED8, #3B82F6); color: #fff; font-weight: 650; font-size: 12px; letter-spacing: 0.02em; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }

.code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; color: var(--text); overflow-wrap: anywhere; }
.code-block { position: relative; display: block; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px; padding: 12px 48px 12px 14px; overflow-x: auto; white-space: pre; color: var(--text); }
.code-block .copy-btn { position: absolute; top: 6px; right: 6px; }
.copy-field { display: flex; align-items: stretch; gap: 0; }
.copy-field .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); font-family: var(--mono); font-size: 12.5px; }
.copy-field .btn { height: 38px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 10px 20px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
a.list-item { color: inherit; }
a.list-item:hover { background: var(--surface-hover); text-decoration: none; }
.list-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex-shrink: 0; }
.list-icon.tone-blue { background: var(--primary-soft); color: var(--primary-text); }
.list-icon.tone-red { background: var(--danger-soft); color: var(--danger-text); }
.list-icon.tone-yellow { background: var(--warning-soft); color: var(--warning-text); }
.list-icon.tone-green { background: var(--success-soft); color: var(--success-text); }
.list-icon.tone-violet { background: var(--violet-soft); color: var(--violet-text); }
.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 550; font-size: 13.5px; }
.list-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.list-meta { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline-item { position: relative; padding: 0 0 18px 26px; }
.timeline-item::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: -2px; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 0; top: 4px; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--surface); background: var(--text-3); box-shadow: 0 0 0 1px var(--border-strong); }
.timeline-dot.is-success { background: var(--success); box-shadow: 0 0 0 1px var(--success-border); }
.timeline-dot.is-error { background: var(--danger); box-shadow: 0 0 0 1px var(--danger-border); }
.timeline-dot.is-warning { background: var(--warning); box-shadow: 0 0 0 1px var(--warning-border); }
.timeline-dot.is-info { background: var(--primary-2); box-shadow: 0 0 0 1px var(--primary-soft-2); }
.timeline-title { font-size: 13.5px; font-weight: 550; }
.timeline-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.timeline-text { font-size: 13px; color: var(--text-2); margin-top: 4px; overflow-wrap: anywhere; }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 28px 20px; border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2); color: var(--text-2); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--primary-2); background: var(--primary-soft); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary-text); box-shadow: var(--shadow-xs); }
.dropzone-title { font-weight: 600; color: var(--text); }
.dropzone-hint { font-size: 12.5px; color: var(--text-3); }

.image-frame { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background-color: var(--surface-3); }
.image-frame img { width: 100%; height: 100%; object-fit: contain; }
.checker {
  background-color: var(--surface-3);
  background-image: linear-gradient(45deg, var(--surface-2) 25%, transparent 25%), linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--surface-2) 75%), linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.info-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.info-row .icon { width: 15px; height: 15px; color: var(--text-3); }

.secret-display { display: flex; align-items: center; gap: 10px; padding: 0 12px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-family: var(--mono); font-size: 13px; color: var(--text-2); min-width: 0; }
.secret-display .icon { color: var(--text-3); }
.secret-display span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.result-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.result-box.is-success { border-color: var(--success-border); background: var(--success-soft); }
.result-box.is-error { border-color: var(--danger-border); background: var(--danger-soft); }

.progress-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.progress-step { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-3); }
.progress-step .step-state { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; }
.progress-step.is-active { color: var(--text); }
.progress-step.is-active .step-state { border-color: var(--primary); border-right-color: transparent; animation: spin 0.8s linear infinite; }
.progress-step.is-done { color: var(--text); }
.progress-step.is-done .step-state { background: var(--success); border-color: var(--success); color: #fff; }
.progress-step.is-error .step-state { background: var(--danger); border-color: var(--danger); color: #fff; }
.progress-step .step-state .icon { width: 13px; height: 13px; stroke-width: 3; }

/* --------------------------------------------------------------------------
   Dashboard
   ----------------------------------------------------------------------- */

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.hero-date { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.hero-title { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; }
.hero-subtitle { color: var(--text-2); margin-top: 6px; font-size: 15px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
.dashboard-col { display: grid; gap: 20px; min-width: 0; }

.manual-banner { border-color: var(--warning-border); background: linear-gradient(180deg, var(--warning-soft), var(--surface) 90px); margin-top: 20px; }
.manual-banner .card-header { border-bottom-color: var(--warning-border); }
.manual-banner .card-title .icon { color: var(--warning-text); }
.manual-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.manual-item:last-child { border-bottom: 0; }
.manual-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-3); }
.manual-thumb-empty { width: 56px; height: 56px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.manual-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.queue-item { grid-template-columns: 64px minmax(0, 1fr) auto; }
.queue-detail-label { display: none; }

.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-item { display: grid; grid-template-columns: 58px 14px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 20px; position: relative; cursor: pointer; transition: background 0.12s; }
.agenda-item:hover { background: var(--surface-hover); }
.agenda-item + .agenda-item { border-top: 1px solid var(--border); }
.agenda-time { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.agenda-time small { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.agenda-rail { width: 10px; height: 10px; border-radius: 50%; background: var(--primary-2); box-shadow: 0 0 0 4px var(--primary-soft); }
.agenda-rail.tone-green { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.agenda-rail.tone-yellow { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-soft); }
.agenda-rail.tone-red { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.agenda-rail.tone-gray { background: var(--text-3); box-shadow: 0 0 0 4px var(--gray-soft); }
.agenda-dest { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.agenda-dest .icon { width: 15px; height: 15px; color: var(--text-3); }
.agenda-topic { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.agenda-item.is-past .agenda-time { color: var(--text-3); }

.campaign-mini { padding: 14px 20px; border-bottom: 1px solid var(--border); display: block; color: inherit; }
.campaign-mini:last-child { border-bottom: 0; }
.campaign-mini:hover { background: var(--surface-hover); text-decoration: none; }
.campaign-mini-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.campaign-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.campaign-mini-name { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.campaign-mini-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 8px; }

/* --------------------------------------------------------------------------
   Campañas
   ----------------------------------------------------------------------- */

.campaign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.campaign-card { display: flex; flex-direction: column; overflow: hidden; }
.campaign-card-cover { height: 6px; }
.campaign-card-body { padding: 18px 20px 16px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.campaign-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.campaign-name { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); display: block; }
.campaign-name:hover { color: var(--primary-text); text-decoration: none; }
.campaign-desc { font-size: 13px; color: var(--text-2); }
.campaign-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.campaign-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.campaign-metric { padding: 8px 10px; text-align: left; }
.campaign-metric + .campaign-metric { border-left: 1px solid var(--border); }
.campaign-metric-value { font-weight: 650; font-size: 16px; }
.campaign-metric-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.campaign-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.campaign-dates { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.campaign-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

/* --------------------------------------------------------------------------
   Calendario
   ----------------------------------------------------------------------- */

.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.calendar-title { font-size: 18px; font-weight: 650; letter-spacing: -0.015em; text-transform: capitalize; min-width: 180px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-weekday { padding: 10px 10px 8px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-cell { min-height: 128px; padding: 6px 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); min-width: 0; transition: background 0.12s; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.is-outside { background: var(--surface-2); }
.cal-cell.is-outside .cal-date { color: var(--text-3); }
.cal-cell.is-dragover { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary-2); }
.cal-cell.is-full.is-dragover { background: var(--danger-soft); box-shadow: inset 0 0 0 2px var(--danger); }
.cal-cell-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 4px; }
.cal-date { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; border: 0; background: transparent; color: var(--text); }
.cal-date:hover { background: var(--surface-hover); }
.cal-cell.is-today .cal-date { background: var(--primary); color: #fff; }
.cal-usage { font-size: 11px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 999px; }
.cal-usage.is-full { color: var(--danger-text); background: var(--danger-soft); }
.cal-more { font-size: 11.5px; font-weight: 600; color: var(--text-2); border: 0; background: transparent; padding: 2px 6px; margin-top: 2px; border-radius: 6px; }
.cal-more:hover { background: var(--surface-hover); color: var(--text); }

.cal-event {
  --ev-bg: var(--primary-soft); --ev-fg: var(--primary-text); --ev-accent: var(--primary-2);
  display: flex; align-items: center; gap: 6px; width: 100%; margin-top: 3px; padding: 3px 6px 3px 7px;
  border: 0; border-left: 3px solid var(--ev-accent); border-radius: 6px; background: var(--ev-bg); color: var(--text);
  font-size: 12px; line-height: 1.35; text-align: left; cursor: pointer; min-width: 0; transition: filter 0.12s, box-shadow 0.12s;
}
.cal-event:hover { box-shadow: var(--shadow-sm); filter: saturate(1.15); }
.cal-event[draggable="true"] { cursor: grab; }
.cal-event.is-dragging { opacity: 0.45; }
.cal-event-time { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--ev-fg); flex-shrink: 0; }
.cal-event-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--text); }
.ev-blue { --ev-bg: var(--primary-soft); --ev-fg: var(--primary-text); --ev-accent: #3B82F6; }
.ev-green { --ev-bg: var(--success-soft); --ev-fg: var(--success-text); --ev-accent: var(--success); }
.ev-yellow { --ev-bg: var(--warning-soft); --ev-fg: var(--warning-text); --ev-accent: var(--warning); }
.ev-red { --ev-bg: var(--danger-soft); --ev-fg: var(--danger-text); --ev-accent: var(--danger); }
.ev-gray { --ev-bg: var(--gray-soft); --ev-fg: var(--gray-text); --ev-accent: #94A3B8; }

.cal-week { display: grid; grid-template-columns: 60px repeat(7, minmax(0, 1fr)); position: relative; }
.cal-week-head { position: sticky; top: var(--topbar-h); z-index: 3; display: contents; }
.cal-week-dayhead { padding: 10px 8px; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface-2); text-align: center; }
.cal-week-dayhead.is-today .cal-week-daynum { background: var(--primary); color: #fff; }
.cal-week-dayname { font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.cal-week-daynum { width: 30px; height: 30px; margin: 4px auto 0; border-radius: 999px; display: grid; place-items: center; font-size: 15px; font-weight: 650; }
.cal-week-corner { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cal-scroll { max-height: calc(100vh - 290px); min-height: 480px; overflow-y: auto; }
.cal-hours { display: grid; grid-template-columns: 60px repeat(7, minmax(0, 1fr)); }
.cal-hour-label { height: 56px; padding: 0 8px; font-size: 11px; color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; transform: translateY(-7px); }
.cal-day-col { position: relative; border-left: 1px solid var(--border); }
.cal-slot { height: 56px; border-bottom: 1px solid var(--chart-grid); }
.cal-slot.is-dragover { background: var(--primary-soft); }
.cal-day-col.is-today { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.cal-block { position: absolute; left: 3px; right: 3px; min-height: 46px; padding: 5px 7px; border-radius: 8px; flex-direction: column; align-items: flex-start; gap: 1px; margin: 0; overflow: hidden; z-index: 1; }
.cal-block .cal-event-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 2; pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

.cal-day { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.cal-day-list .cal-hours { grid-template-columns: 60px minmax(0, 1fr); }
.cal-day-side { border-left: 1px solid var(--border); padding: 18px; background: var(--surface-2); }

.post-panel-media { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); max-height: 360px; display: grid; place-items: center; }
.post-panel-media img { max-height: 360px; width: auto; object-fit: contain; }
.post-text { white-space: pre-line; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.panel-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.panel-section:first-child { padding-top: 0; }
.panel-section:last-child { border-bottom: 0; }
.panel-label { font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }

/* --------------------------------------------------------------------------
   Asistente de publicación
   ----------------------------------------------------------------------- */

.stepper { display: flex; align-items: center; gap: 0; padding: 16px 20px; overflow-x: auto; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.step { display: flex; align-items: center; gap: 10px; flex: 1; min-width: max-content; border: 0; background: transparent; padding: 0; color: var(--text-3); }
.step:disabled { cursor: default; }
.step-index { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--text-3); background: var(--surface); flex-shrink: 0; transition: all 0.2s; }
.step-index .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.step-label { font-size: 13px; font-weight: 550; white-space: nowrap; }
.step-line { flex: 1; height: 1.5px; min-width: 24px; background: var(--border); margin: 0 12px; border-radius: 2px; }
.step.is-active { color: var(--text); }
.step.is-active .step-index { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--ring); }
.step.is-done { color: var(--text-2); }
.step.is-done .step-index { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.step.is-done + .step-line, .step-line.is-done { background: var(--primary-2); }

.wizard-panel { padding: 24px; min-height: 360px; }
.wizard-layout > .card { container-type: inline-size; container-name: wizard; }
@container wizard (max-width: 860px) {
  .step { min-width: 0; flex: 0 0 auto; }
  .step-label { display: none; }
  .step.is-active .step-label { display: inline; }
  .step-line { min-width: 16px; margin: 0 8px; }
  .choice-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container wizard (max-width: 520px) {
  .choice-grid.cols-5, .choice-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}
.wizard-heading { margin-bottom: 18px; }
.wizard-step-title { font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.wizard-step-desc { color: var(--text-2); margin-top: 4px; }
.wizard-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.wizard-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.wizard-aside { position: sticky; top: calc(var(--topbar-h) + 20px); }
.source-panel { margin-top: 18px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }

.generate-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 36px 20px; border: 1px solid var(--border); border-radius: 16px; background: radial-gradient(120% 90% at 50% 0%, var(--primary-soft), transparent 70%), var(--surface); }
.generate-orb { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #1D4ED8, #3B82F6); box-shadow: 0 12px 30px -8px rgba(29, 78, 216, 0.55); }
.generate-orb .icon { width: 30px; height: 30px; }
.generate-orb.is-working { animation: pulse 1.6s ease-in-out infinite; }
.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.fb-preview { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.fb-preview-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.fb-preview-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #1D4ED8, #3B82F6); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.fb-preview-name { font-weight: 600; font-size: 14px; }
.fb-preview-meta { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.fb-preview-text { padding: 4px 14px 12px; font-size: 14px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }
.fb-preview-text .headline { font-weight: 650; }
.fb-preview-image { background: var(--surface-3); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.fb-preview-image img { width: 100%; max-height: 420px; object-fit: cover; }
.fb-preview-actions { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px 8px; }
.fb-preview-action { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.fb-preview-action .icon { width: 16px; height: 16px; }

.editor-field { position: relative; }
.editor-field .label-row { margin-bottom: 6px; }
.hashtag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 38px; padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.hashtag-input:focus-within { border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--ring); }
.hashtag-input input { flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent; height: 26px; font-size: 13.5px; }
.hashtag-chip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 9px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-text); font-size: 12.5px; font-weight: 550; }
.hashtag-chip button { width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: grid; place-items: center; }
.hashtag-chip button:hover { background: var(--primary-soft-2); }

.destination-option { display: grid; grid-template-columns: auto 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.destination-option:hover { border-color: var(--border-strong); }
.destination-option.is-checked { border-color: var(--primary-2); background: var(--primary-soft); }
.destination-option.is-disabled { opacity: 0.55; cursor: not-allowed; }
.destination-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.destination-icon.is-page { background: var(--primary-soft); color: var(--primary-text); }
.destination-icon.is-group { background: var(--violet-soft); color: var(--violet-text); }
.destination-list { display: grid; gap: 8px; }

.availability { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.availability.is-full { border-color: var(--danger-border); background: var(--danger-soft); }
.availability.is-warning { border-color: var(--warning-border); background: var(--warning-soft); }
.availability-text { flex: 1; font-size: 13px; }

/* --------------------------------------------------------------------------
   Biblioteca de medios
   ----------------------------------------------------------------------- */

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.media-grid.is-compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.media-item { position: relative; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: pointer; text-align: left; padding: 0; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.media-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.media-item.is-selected { border-color: var(--primary-2); box-shadow: 0 0 0 3px var(--ring); }
.media-thumb-wrap { position: relative; aspect-ratio: 1 / 1; overflow: hidden; }
.media-thumb { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s var(--ease); }
.media-item:hover .media-thumb { transform: scale(1.03); }
.media-flags { position: absolute; top: 8px; left: 8px; display: flex; gap: 4px; }
.media-flag { height: 22px; padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 650; display: inline-flex; align-items: center; gap: 4px; background: rgba(13, 20, 36, 0.72); color: #fff; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.media-flag .icon { width: 12px; height: 12px; }
.media-info { padding: 9px 11px 10px; min-width: 0; }
.media-name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.media-select-check { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; display: none; place-items: center; box-shadow: 0 0 0 2px #fff; }
.media-item.is-selected .media-select-check { display: grid; }
.media-select-check .icon { width: 13px; height: 13px; stroke-width: 3; }

.media-viewer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 480px; }
.media-viewer-stage { display: grid; place-items: center; padding: 20px; border-right: 1px solid var(--border); min-height: 420px; }
.media-viewer-stage img { max-height: 68vh; width: auto; max-width: 100%; border-radius: 8px; box-shadow: var(--shadow-md); }
.media-viewer-side { padding: 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; max-height: 76vh; }

.load-more { display: flex; justify-content: center; padding: 20px 0 4px; }

/* --------------------------------------------------------------------------
   Planificador semanal
   ----------------------------------------------------------------------- */

.planner-config { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 0; }
.planner-config-main { padding: 20px; border-right: 1px solid var(--border); }
.planner-config-side { padding: 20px; }
.week-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.week-range .input { width: 170px; }
.planner-dest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; margin-top: 20px; }
.day-card { display: flex; flex-direction: column; transition: opacity 0.2s, border-color 0.2s; }
.day-card.is-disabled { opacity: 0.58; }
.day-card.is-disabled .day-items { filter: grayscale(0.6); }
.day-card.is-over { border-color: var(--danger-border); }
.day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--border); }
.day-name { font-size: 14px; font-weight: 650; text-transform: capitalize; }
.day-date { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.day-usage { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.day-topic { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.35; }
.day-angle { font-size: 13px; color: var(--text-2); }
.day-evidence { font-size: 12px; color: var(--text-3); border-left: 2px solid var(--border-strong); padding: 2px 0 2px 10px; font-style: italic; }
.day-items { display: grid; gap: 8px; }
.plan-item { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); transition: border-color 0.15s, opacity 0.2s; }
.plan-item:hover { border-color: var(--border-strong); }
.plan-item.is-off { opacity: 0.5; }
.plan-item.is-loading { opacity: 0.6; pointer-events: none; }
.plan-thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); background: var(--surface-3); cursor: pointer; }
.plan-thumb-empty { width: 52px; height: 52px; border-radius: 9px; border: 1px dashed var(--border-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); cursor: pointer; }
.plan-thumb-empty:hover { border-color: var(--primary-2); color: var(--primary-text); }
.plan-item-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.plan-dest { font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px; min-width: 0; }
.plan-dest .icon { width: 13px; height: 13px; color: var(--text-3); }
.plan-headline { font-size: 13px; color: var(--text); margin-top: 3px; line-height: 1.4; }
.plan-controls { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.plan-controls .input { width: 92px; height: 28px; font-size: 12.5px; padding: 0 6px; }
.plan-controls .select { height: 28px; font-size: 12px; padding: 0 24px 0 8px; background-position: right 6px center; max-width: 150px; }
.day-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.planner-bar { position: sticky; bottom: 16px; z-index: 20; margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px 14px 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); flex-wrap: wrap; }
.planner-bar-stats { display: flex; gap: 22px; flex-wrap: wrap; }
.planner-bar-stat strong { display: block; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.planner-bar-stat span { font-size: 12px; color: var(--text-3); }

/* --------------------------------------------------------------------------
   Fuentes, destinos y grupos
   ----------------------------------------------------------------------- */

.source-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: flex-start; padding: 20px; }
.source-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.source-icon.is-manual { background: var(--violet-soft); color: var(--violet-text); }
.source-name { font-size: 16px; font-weight: 650; }
.source-url { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.source-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.source-stats .info-row { font-size: 13px; }
.structured-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.structured-block { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.structured-block h4 { font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.structured-block ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.structured-block li::marker { color: var(--primary-2); }
.clean-content { max-height: 520px; overflow: auto; white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; padding: 16px; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); overflow-wrap: anywhere; }

.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.group-card { display: flex; flex-direction: column; }
.group-card-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.group-head { display: flex; align-items: flex-start; gap: 12px; }
.group-avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--violet-soft); color: var(--violet-text); flex-shrink: 0; font-weight: 700; }
.group-name { font-size: 15px; font-weight: 650; letter-spacing: 0.01em; }
.group-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; font-size: 13px; }
.group-fact-label { font-size: 11.5px; color: var(--text-3); font-weight: 550; }
.group-fact-value { font-weight: 550; margin-top: 1px; }
.group-rules { font-size: 13px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; white-space: pre-line; max-height: 110px; overflow: auto; }
.group-card-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }

.fb-connection { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 22px; }
.fb-logo { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: #1877F2; color: #fff; }
.fb-logo .icon { width: 26px; height: 26px; stroke-width: 2; }

/* --------------------------------------------------------------------------
   Ajustes
   ----------------------------------------------------------------------- */

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: grid; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; border-radius: 9px; color: var(--text-2); font-weight: 550; font-size: 13.5px; }
.settings-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.settings-nav a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.settings-nav a .icon { width: 16px; height: 16px; color: var(--text-3); }
.settings-nav a.is-active .icon { color: var(--primary-text); }
.setting-row { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 24px; padding: 20px; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-title { font-weight: 600; font-size: 14px; }
.setting-desc { font-size: 13px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.setting-control { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.time-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.time-chip { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 4px 0 10px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 550; }
.time-chip button { width: 22px; height: 22px; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.time-chip button:hover { background: var(--danger-soft); color: var(--danger-text); }
.system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.system-item { padding: 14px 20px; border-bottom: 1px solid var(--border); }
.system-item:nth-child(odd) { border-right: 1px solid var(--border); }
.system-item dt { font-size: 12px; color: var(--text-3); font-weight: 550; }
.system-item dd { margin: 3px 0 0; font-weight: 550; overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   Estadísticas (gráficos)
   ----------------------------------------------------------------------- */

.chart-card-body { padding: 16px 20px 20px; position: relative; }
.stats-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@container page (min-width: 1180px) { .stats-split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; }
.chart-legend-swatch.is-published { background: var(--chart-published); }
.chart-legend-swatch.is-failed { background: var(--chart-failed); }
.bar-chart { position: relative; }
.bar-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.bar-chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.bar-chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.bar-chart .axis-text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar-chart .bar-published { fill: var(--chart-published); }
.bar-chart .bar-failed { fill: var(--chart-failed); }
.bar-chart .bar-hit { fill: transparent; cursor: pointer; }
.bar-chart .bar-hit:hover + g .bar-group-mark, .bar-chart g.is-hover .bar-published, .bar-chart g.is-hover .bar-failed { filter: brightness(1.12); }
.bar-chart .hover-band { fill: var(--surface-hover); }
.chart-tooltip { position: absolute; pointer-events: none; z-index: 10; min-width: 150px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: 12.5px; transform: translate(-50%, calc(-100% - 12px)); }
.chart-tooltip-title { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.chart-tooltip-row { display: flex; align-items: center; gap: 8px; color: var(--text-2); margin-top: 3px; }
.chart-tooltip-row strong { color: var(--text); font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }
.chart-tooltip-key { width: 12px; height: 2px; border-radius: 2px; }
.chart-empty { height: 220px; display: grid; place-items: center; color: var(--text-3); font-size: 13px; }

/* --------------------------------------------------------------------------
   Logs
   ----------------------------------------------------------------------- */

.log-level { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; font-family: var(--mono); }
.log-level.is-info { background: var(--primary-soft); color: var(--primary-text); }
.log-level.is-warning { background: var(--warning-soft); color: var(--warning-text); }
.log-level.is-error { background: var(--danger-soft); color: var(--danger-text); }
.log-message { font-size: 13px; overflow-wrap: anywhere; }
.log-context { margin-top: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 200px; overflow: auto; }
.log-time { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; }
.log-channel { font-family: var(--mono); font-size: 12px; }

/* --------------------------------------------------------------------------
   Páginas de error
   ----------------------------------------------------------------------- */

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.error-card { width: 100%; max-width: 480px; text-align: center; padding: 40px 36px; }
.error-code { font-size: 64px; font-weight: 700; letter-spacing: -0.04em; line-height: 1; background: linear-gradient(135deg, #1D4ED8, #60A5FA); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-title { font-size: 20px; font-weight: 650; margin-top: 14px; }
.error-text { color: var(--text-2); margin-top: 8px; }

/* --------------------------------------------------------------------------
   Animaciones
   ----------------------------------------------------------------------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0; } }
@keyframes pulse { 0%, 100% { transform: scale(1); box-shadow: 0 12px 30px -8px rgba(29, 78, 216, 0.55); } 50% { transform: scale(1.06); box-shadow: 0 16px 40px -6px rgba(29, 78, 216, 0.7); } }

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

/* --------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------- */

@media (max-width: 1360px) {
  .page { padding: 24px 24px 48px; }
  .wizard-layout { grid-template-columns: minmax(0, 1fr) 340px; }
  .filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .wizard-layout { grid-template-columns: minmax(0, 1fr); }
  .wizard-aside { position: static; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .planner-config { grid-template-columns: minmax(0, 1fr); }
  .planner-config-main { border-right: 0; border-bottom: 1px solid var(--border); }
  .media-viewer { grid-template-columns: minmax(0, 1fr); }
  .media-viewer-stage { border-right: 0; border-bottom: 1px solid var(--border); }
  .cal-day { grid-template-columns: minmax(0, 1fr); }
  .cal-day-side { border-left: 0; border-top: 1px solid var(--border); }
  .choice-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-xl); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 13, 25, 0.5); z-index: 55; animation: fadeIn 0.2s; }
  .main, .sidebar-collapsed .main { margin-left: 0; }
  .sidebar-collapsed .brand-name, .sidebar-collapsed .nav-label, .sidebar-collapsed .nav-count, .sidebar-collapsed .user-meta, .sidebar-collapsed .logout-form { display: initial; }
  .sidebar-collapsed .sidebar-header { padding: 0 14px 0 18px; flex-direction: row; justify-content: space-between; }
  .sidebar-collapsed .sidebar-header .brand { display: flex; }
  .sidebar-collapsed .nav-section { height: auto; margin: 18px 10px 6px; background: none; font-size: 11px; }
  .sidebar-collapsed .nav-item { justify-content: flex-start; padding: 0 10px; height: 36px; }
  .sidebar-collapsed .user-card { justify-content: flex-start; padding: 8px; }
  .sidebar-toggle { display: none; }
  .topbar .mobile-menu { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; padding-bottom: 4px; }
  .settings-nav a { flex-shrink: 0; }
  .setting-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .source-card { grid-template-columns: auto minmax(0, 1fr); }
  .source-card > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .grid-2, .grid-3, .structured-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .campaign-grid, .group-grid, .week-grid { grid-template-columns: minmax(0, 1fr); }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .planner-dest-grid { grid-template-columns: minmax(0, 1fr); }
  .limit-card { grid-template-columns: auto minmax(0, 1fr); }
  .limit-card > :last-child { grid-column: 1 / -1; }
  .limit-chip-label { display: none; }
  .cal-cell { min-height: 92px; padding: 4px; }
  .cal-event-time { display: none; }
  .cal-event { padding: 2px 4px; font-size: 11px; }
  .system-grid { grid-template-columns: minmax(0, 1fr); }
  .system-item:nth-child(odd) { border-right: 0; }
  .fb-connection { grid-template-columns: auto minmax(0, 1fr); }
  .fb-connection > :last-child { grid-column: 1 / -1; }
  .choice-grid.cols-5, .choice-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-input { width: 100%; }
  .toolbar-group { width: 100%; }
}

@media (max-width: 640px) {
  .page { padding: 18px 16px 40px; }
  .page-title { font-size: 21px; }
  .hero-title { font-size: 23px; }
  .page-header { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .topbar-new-label { display: none; }
  .breadcrumbs { display: none; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 28px; height: 28px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .agenda-item { grid-template-columns: 50px 10px minmax(0, 1fr); padding: 12px 16px; }
  .agenda-item > :last-child { grid-column: 3; justify-self: start; }
  .manual-item { grid-template-columns: 48px minmax(0, 1fr); padding: 12px 16px; }
  .queue-item { grid-template-columns: 56px minmax(0, 1fr); }
  .manual-item .manual-actions { grid-column: 1 / -1; justify-content: flex-start; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-item .manual-actions .btn { justify-content: center; min-width: 0; }
  .manual-item .manual-actions .btn-success { grid-column: 1 / -1; order: 10; }
  .queue-item .manual-actions .queue-detail { width: auto; padding: 0 8px; background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
  .queue-item .queue-detail-label { display: inline; }
  .manual-item:not(.queue-item) .agenda-dest { flex-wrap: wrap; row-gap: 4px; }
  .manual-thumb, .manual-thumb-empty { width: 48px; height: 48px; }
  .modal-root { padding: 0; align-items: flex-end; }
  .modal, .modal-lg, .modal-xl, .modal-sm { max-width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-footer { border-radius: 0; }
  .modal-footer .btn { flex: 1; }
  .wizard-panel { padding: 18px 16px; }
  .wizard-footer { padding: 12px 16px; }
  .step-label { display: none; }
  .step.is-active .step-label { display: inline; }
  .choice-grid, .choice-grid.cols-5, .choice-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .choice-card { min-height: 0; flex-direction: row; align-items: center; }
  .choice-card .choice-desc { display: none; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .campaign-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .campaign-metric:nth-child(3) { border-left: 0; }
  .campaign-metric:nth-child(n+3) { border-top: 1px solid var(--border); }
  .filter-bar { grid-template-columns: minmax(0, 1fr); }
  .cal-weekday { font-size: 10px; padding: 8px 4px; text-align: center; }
  .cal-cell { min-height: 70px; }
  .cal-event-title { display: none; }
  .cal-event { height: 6px; padding: 0; margin-top: 2px; border-left-width: 0; background: var(--ev-accent); }
  .cal-usage { display: none; }
  .planner-bar { bottom: 8px; padding: 12px; }
  .planner-bar .btn-xl { width: 100%; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .group-facts { grid-template-columns: minmax(0, 1fr); }
  .toast-region { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
  .source-card { grid-template-columns: minmax(0, 1fr); }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
}

@media print {
  .sidebar, .topbar, .toast-region, .page-actions { display: none !important; }
  .main { margin: 0 !important; }
  .card { box-shadow: none; }
}

@media (forced-colors: active) {
  .badge, .btn, .card, .input, .select, .textarea { border: 1px solid CanvasText; }
  .meter-fill, .limit-slot.is-used, .bar-published, .bar-failed { forced-color-adjust: none; }
}
