/* =============================================================
   WilCore ERP · Sistema de diseño
   Paleta de marca (coral + índigo) sobre lienzo neutro.
   Modo claro y oscuro con toggle. Logo animado integrado.
   ============================================================= */

:root {
  /* Marca */
  --coral: #e26a5a;
  --coral-strong: #cf5446;
  --coral-soft: rgba(226, 106, 90, 0.10);
  --indigo: #5a5eaa;
  --indigo-strong: #474b94;
  --indigo-soft: rgba(90, 94, 170, 0.10);

  /* Estado */
  --success: #2ea676;
  --success-soft: rgba(46, 166, 118, 0.14);
  --warning: #d99834;
  --warning-soft: rgba(217, 152, 52, 0.16);
  --danger: #e26a5a;
  --danger-soft: rgba(226, 106, 90, 0.14);

  /* Geometría */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Movimiento */
  --t-fast: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-med: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 360ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 220ms ease;

  /* Tipografía */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Sora", "Inter", system-ui, sans-serif;
}

/* ---------- Tema claro (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f7fa;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --panel-soft: #f1f2f6;
  --surface: #ffffff;
  --surface-soft: #f1f2f6;
  --surface-hover: #ecedf2;
  --line: #e6e7ed;
  --line-strong: #d3d5de;
  --text: #1a1c2c;
  --text-soft: #4d5169;
  --muted: #8a8ea3;
  --primary: var(--coral);
  --primary-strong: var(--coral-strong);
  --primary-soft: var(--coral-soft);
  --secondary: var(--indigo);
  --secondary-soft: var(--indigo-soft);
  --shadow-sm: 0 1px 2px rgba(20, 22, 40, 0.04);
  --shadow-md: 0 6px 18px rgba(20, 22, 40, 0.06);
  --shadow-lg: 0 20px 50px rgba(20, 22, 40, 0.10);
  --shadow-primary: 0 8px 22px rgba(226, 106, 90, 0.22);
}

/* ---------- Tema oscuro ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161f;
  --bg-elevated: #1a1d28;
  --panel: #1a1d28;
  --panel-strong: #20232f;
  --panel-soft: #1f222d;
  --surface: #1a1d28;
  --surface-soft: #1f222d;
  --surface-hover: #262934;
  --line: #2a2d3a;
  --line-strong: #3a3d4c;
  --text: #e7e9f2;
  --text-soft: #aab0c2;
  --muted: #71768a;
  --primary: var(--coral);
  --primary-strong: var(--coral-strong);
  --primary-soft: rgba(226, 106, 90, 0.16);
  --secondary: var(--indigo);
  --secondary-soft: rgba(120, 124, 200, 0.16);
  --coral-soft: rgba(226, 106, 90, 0.16);
  --indigo-soft: rgba(120, 124, 200, 0.16);
  --success-soft: rgba(46, 166, 118, 0.18);
  --warning-soft: rgba(217, 152, 52, 0.20);
  --danger-soft: rgba(226, 106, 90, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.45);
  --shadow-primary: 0 8px 22px rgba(226, 106, 90, 0.30);
}

/* =============================================================
   BASE
   ============================================================= */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med), color var(--t-med);
}
body {
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  border: 0;
  background: none;
}
a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* Ambient decorativo desactivado (ahora canvas neutro) */
.ambient {
  display: none;
}

#app, .toast-stack {
  position: relative;
  z-index: 1;
}

/* =============================================================
   AUTH (LOGIN + REGISTRO)
   ============================================================= */
.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  min-height: 100vh;
}

.auth-hero,
.auth-panel {
  padding: 56px;
}

.auth-hero {
  display: grid;
  align-content: space-between;
  gap: 32px;
  background: #1f2240;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-hero::before {
  content: "";
  position: absolute;
  width: 46rem;
  height: 46rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 124, 200, 0.35) 0%, transparent 60%);
  bottom: -22rem;
  left: -14rem;
  pointer-events: none;
}
.auth-hero::after {
  content: "";
  position: absolute;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(226, 106, 90, 0.28) 0%, transparent 60%);
  top: -10rem;
  right: -10rem;
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-badge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: var(--coral);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: var(--shadow-primary);
}
/* Cuando el brand-badge contiene el logo animado, vuelve a wrapper transparente */
.brand-badge:has(.wc-logo),
.brand-badge:has(> svg) {
  background: transparent;
  box-shadow: none;
  width: 44px;
  height: 44px;
  padding: 0;
}
.auth-hero .brand-copy strong { color: #fff; }
.auth-hero .brand-copy span,
.auth-hero .brand-copy small { color: rgba(255,255,255,0.65); }

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-copy strong {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-hero .eyebrow { color: rgba(255,255,255,0.6); }

.auth-copy { max-width: 640px; }
.hero-title {
  margin: 14px 0 18px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #fff;
}
.hero-subtitle,
.auth-hero p {
  color: rgba(255,255,255,0.78);
  font-size: 1rem;
  max-width: 480px;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.hero-grid .stat-card {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  color: #fff;
  min-height: 0;
  padding: 16px;
  border-radius: 14px;
}
.hero-grid .stat-card::before { display: none; }
.hero-grid .stat-card .eyebrow { color: rgba(255,255,255,0.6); }
.hero-grid .stat-card .stat-value {
  color: #fff;
  font-size: 1.5rem;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}
.hero-grid .stat-card .stat-trend {
  background: transparent;
  color: rgba(255,255,255,0.7);
  padding: 0;
}

.auth-panel {
  display: grid;
  place-items: center;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}
.auth-card h2,
.auth-card .card-title {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 6px;
}
.panel-copy,
.panel-subtitle {
  color: var(--text-soft);
}
.panel-subtitle { margin: 0 0 18px; font-size: 0.92rem; }

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.toggle-btn {
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--t-fast);
}
.toggle-btn.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.toggle-btn:hover:not(.active) {
  color: var(--text);
}

.auth-footer,
.helper-text,
.muted {
  color: var(--muted);
  font-size: 0.85rem;
}
.auth-footer {
  margin-top: 14px;
  text-align: center;
}

/* =============================================================
   APP SHELL (sidebar lateral + drawer móvil + colapso)
   ============================================================= */
.erp-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns var(--t-med);
}
.erp-shell.collapsed {
  grid-template-columns: 68px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100vh;
  padding: 20px 12px 14px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--line);
  overflow: hidden;
  transition: background var(--t-med), border-color var(--t-med), padding var(--t-med);
}
.sidebar.collapsed {
  /* mantiene position: sticky de la regla base — el sidebar SIGUE en su
     columna del grid (68px). Sin position:fixed para que main-shell
     no caiga en la columna del sidebar. */
  padding: 20px 8px 14px;
  align-items: center;
  transition: width var(--t-med), padding var(--t-med), box-shadow var(--t-med),
              background var(--t-med), border-color var(--t-med);
}
/* Hover-to-expand: la sidebar visual crece a 240px y se sale por encima de
   la columna de 68px del grid, montándose sobre el contenido (sin moverlo). */
.sidebar.collapsed:hover {
  width: 240px;
  padding: 20px 12px 14px;
  align-items: stretch;
  box-shadow: var(--shadow-lg);
  z-index: 52;
}

.sidebar > .brand-row {
  padding: 0 6px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  transition: padding var(--t-med);
}
.sidebar.collapsed > .brand-row {
  padding: 0 0 14px;
  justify-content: center;
}
.sidebar.collapsed:hover > .brand-row {
  padding: 0 6px 14px;
  justify-content: flex-start;
}
.sidebar.collapsed .brand-copy {
  display: none;
}
.sidebar.collapsed:hover .brand-copy {
  display: flex;
}

/* Buscador del menú */
.nav-search-shell {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 4px;
  margin: 0 0 4px;
  flex-shrink: 0;
}
.nav-search-icon {
  position: absolute;
  left: 14px;
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.nav-search-input {
  width: 100%;
  padding: 8px 56px 8px 34px;
  background: var(--surface-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: 0;
  font-size: 0.86rem;
  transition: all var(--t-fast);
}
.nav-search-input::placeholder {
  color: var(--muted);
}
.nav-search-input:focus {
  background: var(--bg-elevated);
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.nav-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}
.nav-search-kbd {
  position: absolute;
  right: 12px;
  padding: 2px 6px;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 5px;
  pointer-events: none;
  letter-spacing: 0.01em;
}
.nav-search-input:focus + .nav-search-kbd {
  opacity: 0.4;
}

/* Oculto en modo colapsado */
.sidebar.collapsed .nav-search-shell {
  display: none;
}

.nav-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Navegación vertical */
.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.nav-section::-webkit-scrollbar { width: 4px; }
.nav-section::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  border: 0;
  text-align: left;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  transition: all var(--t-fast);
}
.nav-item:hover {
  color: var(--text);
  background: var(--surface-hover);
  transform: translateX(2px);
}
.nav-item.active {
  background: var(--coral-soft);
  color: var(--coral);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  background: var(--coral);
  border-radius: 0 3px 3px 0;
  animation: slideInLeft 240ms cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity var(--t-fast), transform var(--t-fast);
}
.nav-item .nav-icon svg {
  width: 100%;
  height: 100%;
}
.nav-item.active .nav-icon {
  opacity: 1;
}
.nav-item:hover .nav-icon {
  transform: scale(1.08);
}

/* Modo colapsado: solo iconos centrados */
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 11px 0;
  width: 44px;
  margin: 0 auto;
}
.sidebar.collapsed .nav-item:hover {
  transform: translateX(0) scale(1.06);
}
.sidebar.collapsed .nav-label {
  display: none;
}
.sidebar.collapsed .nav-item.active::before {
  display: none;
}
.sidebar.collapsed .nav-item.active {
  background: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-primary);
}

/* Hover-to-expand: restaurar look de "expandido" sin cambiar estado */
.sidebar.collapsed:hover .nav-item {
  justify-content: flex-start;
  padding: 10px 12px;
  width: 100%;
  margin: 0;
}
.sidebar.collapsed:hover .nav-item:hover {
  transform: translateX(2px);
}
.sidebar.collapsed:hover .nav-label {
  display: inline;
}
.sidebar.collapsed:hover .nav-item.active {
  background: var(--coral-soft);
  color: var(--coral);
  box-shadow: none;
}
.sidebar.collapsed:hover .nav-item.active::before {
  display: block;
}
.sidebar.collapsed:hover .nav-search-shell {
  display: flex;
}
.sidebar.collapsed:hover .sidebar-collapse-btn {
  align-self: flex-end;
}

/* Botón de colapsar */
.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  align-self: flex-end;
  flex-shrink: 0;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all var(--t-fast);
}
.sidebar-collapse-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--line-strong);
}
.sidebar-collapse-btn svg {
  transition: transform var(--t-med);
}
.sidebar.collapsed .sidebar-collapse-btn {
  align-self: center;
}
.sidebar.collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-footer {
  display: none;
}

/* Backdrop del drawer móvil */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 40, 0.45);
  backdrop-filter: blur(4px);
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  border: 0;
  transition: opacity var(--t-med);
}
.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.main-shell {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 26px 28px 60px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar > div:first-child {
  flex: 1 1 320px;
  min-width: 0;
}
.topbar h1 {
  margin: 4px 0 4px;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  line-height: 1.15;
  font-weight: 700;
}
.topbar .section-subtitle,
.topbar p {
  color: var(--text-soft);
  margin: 0;
  font-size: 0.9rem;
}
.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
/* Compatibilidad con código viejo si vuelve a aparecer .topbar-user */
.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  font-size: 0.82rem;
}

/* Avatar + nombre compactos */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  cursor: default;
  transition: all var(--t-fast);
}
.user-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}
.user-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coral), var(--indigo));
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(226, 106, 90, 0.25);
}
.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.company-meta {
  color: var(--muted);
}

/* Selector de empresa compacto */
.topbar-actions .select-company {
  min-height: 40px;
  padding: 0 28px 0 12px;
  font-size: 0.85rem;
  max-width: 190px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8ea3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
[data-theme="dark"] .topbar-actions .select-company {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371768a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* Theme toggle (knob) */
.theme-toggle {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: all var(--t-med);
  flex-shrink: 0;
}
.theme-toggle::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med);
}
[data-theme="dark"] .theme-toggle::before {
  transform: translateX(22px);
}
.theme-toggle::after {
  content: "☀";
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
}
[data-theme="dark"] .theme-toggle::after {
  content: "☾";
  left: auto;
  right: 8px;
}

/* =============================================================
   BUTTONS (primario, secundario, ghost, icon)
   ============================================================= */
.primary-btn,
.secondary-btn,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--t-fast);
}

.primary-btn {
  background: var(--coral);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.primary-btn:hover {
  background: var(--coral-strong);
  transform: translateY(-1px);
}

.secondary-btn {
  background: var(--indigo);
  color: #fff;
}
.secondary-btn:hover {
  background: var(--indigo-strong);
}

.ghost-btn {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--line);
}
.ghost-btn:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.button-row,
.toolbar-actions,
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topbar-actions {
  align-items: center;
  justify-content: flex-end;
}

/* Tamaño de SVG dentro de botones — evita íconos gigantes */
.primary-btn svg,
.secondary-btn svg,
.ghost-btn svg,
.toggle-btn svg,
.table-action svg,
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.stat-icon svg,
.feed-dot svg {
  width: 18px;
  height: 18px;
}
.icon-btn svg,
.mobile-nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Icon buttons */
.icon-btn,
.mobile-nav-btn,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  color: var(--text-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.icon-btn:hover,
.mobile-nav-btn:hover,
.table-action:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.mobile-nav-btn {
  display: none;
}

/* =============================================================
   INPUTS
   ============================================================= */
.field-grid { display: grid; gap: 14px; }
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: grid;
  gap: 5px;
}
.field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  outline: 0;
  font-size: 0.92rem;
  transition: all var(--t-fast);
}
.textarea {
  min-height: 96px;
  resize: vertical;
  font-family: inherit;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}
.input::placeholder { color: var(--muted); }

.input-readonly {
  display: flex;
  align-items: center;
  min-height: 44px;
}

/* =============================================================
   CARDS
   ============================================================= */
.stat-card,
.section-card,
.table-card,
.chart-card,
.insight-card,
.alert-card,
.quick-card,
.empty-card,
.form-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: all var(--t-med);
}

.section-card,
.table-card,
.chart-card,
.form-card,
.quick-card,
.empty-card {
  padding: 18px;
}

.stat-card {
  min-height: 104px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.stat-card:hover,
.table-card:hover,
.chart-card:hover,
.quick-card:hover,
.alert-card:hover,
.insight-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.stat-icon,
.nav-icon,
.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--indigo-soft);
  color: var(--indigo);
  flex-shrink: 0;
}
.stat-icon.coral,
.stat-icon.is-danger {
  background: var(--coral-soft);
  color: var(--coral);
}
.stat-icon.is-success {
  background: var(--success-soft);
  color: var(--success);
}
.stat-icon.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 1.6vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 4px;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 500;
  align-self: flex-start;
}
.stat-trend.up,
.stat-trend.success {
  color: var(--success);
  background: var(--success-soft);
}
.stat-trend.down,
.stat-trend.danger,
.stat-trend.is-danger {
  color: var(--coral);
  background: var(--coral-soft);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.card-copy,
.section-subtitle,
.table-subtitle,
.placeholder-line,
.chart-note,
.table-empty,
.empty-card p {
  color: var(--text-soft);
  font-size: 0.9rem;
  margin: 2px 0 0;
}

.empty-card {
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
}

/* =============================================================
   CHIPS
   ============================================================= */
.chip,
.status-chip,
.role-chip,
.severity-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.status-chip.online {
  color: var(--success);
  background: var(--success-soft);
  border-color: transparent;
}

.role-chip {
  color: var(--indigo);
  background: var(--indigo-soft);
  border-color: transparent;
}

.severity-high,
.chip-error,
.severity-pill.is-error {
  color: var(--coral);
  background: var(--coral-soft);
  border-color: transparent;
}
.severity-medium,
.chip-warning {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: transparent;
}
.severity-low,
.chip-success {
  color: var(--success);
  background: var(--success-soft);
  border-color: transparent;
}
.chip-muted {
  color: var(--muted);
  background: var(--surface-soft);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.mini-stat {
  min-width: 130px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.mini-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* =============================================================
   GRIDS (dashboard / contenido)
   ============================================================= */
.hero-grid,
.stats-grid,
.content-grid,
.stack-grid,
.table-grid,
.dashboard-grid {
  display: grid;
  gap: 16px;
}
.hero-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.content-grid { grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.95fr); }
.table-grid { grid-template-columns: minmax(340px, 0.88fr) minmax(0, 1.12fr); }

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: stretch;
  grid-auto-rows: minmax(240px, auto);
}
.dashboard-content-grid { grid-auto-rows: minmax(240px, auto); }
.dashboard-span-3 { grid-column: span 3; }
.dashboard-span-4 { grid-column: span 4; }
.dashboard-span-6 { grid-column: span 6; }
.dashboard-span-8 { grid-column: span 8; }
.dashboard-span-12 { grid-column: span 12; }

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.dashboard-kpi-grid-manager {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  height: 100%;
  min-height: 180px;
}
.dashboard-card.stat-card { min-height: 104px; }
.dashboard-card.dashboard-kpi-card {
  min-height: 96px;
  padding: 12px 14px;
  gap: 4px;
}
.dashboard-kpi-card .stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.dashboard-kpi-card .stat-icon svg {
  width: 15px;
  height: 15px;
}
.dashboard-kpi-card .stat-value {
  font-size: clamp(1.1rem, 1.4vw, 1.3rem);
  margin-top: 0;
}
.dashboard-card-body { flex: 1; min-height: 0; }

.dashboard-focus-card { min-height: 360px; }
.dashboard-primary-card { min-height: 280px; }
.dashboard-alerts-card { min-height: 240px; }

.dashboard-scroll {
  overflow-y: auto;
  max-height: 300px;
  padding-right: 6px;
}
.dashboard-scroll-primary { max-height: 420px; }

.dashboard-chart-wrap { display: flex; align-items: stretch; min-height: 0; }
.dashboard-chart-wrap canvas { flex: 1; min-height: 220px; }
.dashboard-chart-wrap-compact canvas { min-height: 200px; }
.chart-card canvas { width: 100%; height: 220px; display: block; }

.dashboard-filter-panel { gap: 14px; }
.dashboard-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.dashboard-filter-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.dashboard-table-shell { overflow: auto; }

.dashboard-dual-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
}
.dashboard-sublist { display: grid; gap: 10px; min-height: 0; }
.dashboard-sublist-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.dashboard-mini-list { display: grid; gap: 10px; min-height: 0; }
.dashboard-mini-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.dashboard-mini-meta { display: grid; gap: 2px; text-align: right; }
.dashboard-note-grid { display: grid; gap: 10px; }
.dashboard-note-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.compact-empty-card {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.insight-card,
.alert-card { padding: 16px; }
.alert-card { display: grid; gap: 10px; }

.insight-grid,
.alert-grid,
.quick-card-grid {
  display: grid;
  gap: 12px;
}
.quick-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.management-panel { display: grid; gap: 16px; }

/* =============================================================
   COMPANIES / ADMIN
   ============================================================= */
.company-admin-grid { align-items: start; }
.company-admin-summary { display: grid; gap: 14px; }
.company-admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.company-admin-summary-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.company-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.company-module-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--t-fast);
}
.company-module-option:hover,
.company-module-option.is-enabled {
  border-color: var(--indigo);
  background: var(--indigo-soft);
}
.company-module-option input { margin-top: 3px; }
.company-module-copy { display: grid; gap: 4px; }

/* =============================================================
   INBOX / ALERTAS / MESSAGING
   ============================================================= */
.inbox-list { display: grid; gap: 12px; }
.inbox-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}
.inbox-item-read { opacity: 0.82; }
.inbox-main {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 8px;
}
.inbox-header {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}
.inbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.inbox-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--coral);
  box-shadow: 0 0 0 3px var(--coral-soft);
  flex: 0 0 auto;
}
.inbox-meta { display: flex; gap: 12px; flex-wrap: wrap; }
.inbox-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.messaging-layout {
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}
.messaging-pane { min-height: 0; }
.messaging-pane-sidebar,
.messaging-pane-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.messaging-conversation-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
}
.messaging-conversation-item {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast);
}
.messaging-conversation-item:hover,
.messaging-conversation-item.active {
  transform: translateY(-1px);
  border-color: var(--indigo);
  background: var(--indigo-soft);
}
.messaging-conversation-head,
.messaging-conversation-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.messaging-conversation-preview {
  color: var(--text-soft);
  line-height: 1.45;
}
.messaging-thread-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  flex: 1;
}
.messaging-thread-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
}
.chat-message {
  display: grid;
  gap: 6px;
  max-width: min(78%, 620px);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
}
.chat-message p { margin: 0; line-height: 1.55; }
.chat-message-client {
  justify-self: flex-start;
  background: var(--surface-soft);
}
.chat-message-agent {
  justify-self: flex-end;
  background: var(--indigo-soft);
  border-color: transparent;
}
.chat-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-soft);
  font-size: 0.78rem;
}
.chat-message-meta strong { color: var(--text); }
.messaging-composer { margin-top: auto; }

.support-contact-list,
.support-message-thread {
  display: grid;
  gap: 10px;
}
.support-contact-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.support-message-thread {
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.support-message-bubble {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--indigo-soft);
  border: 1px solid transparent;
}
.support-message-bubble.is-admin {
  background: var(--coral-soft);
}
.support-message-bubble small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}
.support-message-bubble p {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}

/* =============================================================
   TABLES
   ============================================================= */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.filter-bar .input,
.filter-bar .select { flex: 1 1 180px; }

.table-shell {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.table th,
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}
.table th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  background: var(--surface-soft);
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover {
  background: var(--surface-soft);
}
.table-strong { font-weight: 700; }
.table-stack { display: grid; gap: 2px; }

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.table-action {
  width: auto;
  min-width: 36px;
  height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.table-action.danger {
  color: var(--coral);
  background: var(--coral-soft);
  border-color: transparent;
}
.table-action.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: transparent;
}

.compact-table th,
.compact-table td {
  padding-top: 9px;
  padding-bottom: 9px;
}

/* =============================================================
   MODALS
   ============================================================= */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(20, 22, 40, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 95;
  animation: fadeIn 180ms ease;
}
.modal-panel {
  width: min(100%, 560px);
  max-height: min(88vh, 820px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  animation: fadeUp 240ms ease;
}
.modal-panel-wide { width: min(100%, 960px); }
.modal-shell-copy {
  margin: -4px 0 0;
  color: var(--text-soft);
  font-size: 0.92rem;
}
.modal-panel h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
}

/* =============================================================
   LOADERS (con WCLogo)
   ============================================================= */
.loader-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 40, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 30;
}
.loader-card {
  min-width: 260px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  text-align: center;
  display: grid;
  place-items: center;
  gap: 14px;
}

/* Spinner viejo: oculto, reemplazado por WCLogo */
.spinner {
  display: none;
}
.loader-card::before {
  content: "";
  display: block;
  width: 64px;
  height: 64px;
  background-image: var(--wc-logo-static, none);
}

/* =============================================================
   TOASTS
   ============================================================= */
.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  z-index: 40;
}
.toast {
  min-width: 280px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  animation: toastIn 220ms ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--coral); }
.toast-title { font-weight: 700; margin-bottom: 4px; }
.toast-copy { color: var(--text-soft); font-size: 0.88rem; }

/* =============================================================
   ANIMATIONS
   ============================================================= */
.fade-in { animation: fadeIn 280ms ease; }
.view-section {
  display: grid;
  gap: 18px;
  animation: fadeIn 280ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =============================================================
   SUBSCRIPTIONS / SUSPENSION
   ============================================================= */
.subscription-warning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
}
.subscription-warning-banner h3 {
  margin: 6px 0 6px;
  font-size: 1.05rem;
}
.subscription-warning-banner p {
  margin: 0;
  color: var(--text-soft);
}

.suspension-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.suspension-card {
  width: min(1180px, 100%);
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--coral);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}
.suspension-copy h1 {
  margin: 10px 0 12px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.1;
}
.suspension-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.suspension-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.suspension-panel { min-height: 100%; }
.suspension-summary-grid { margin-bottom: 16px; }

/* =============================================================
   ACCOUNTING
   ============================================================= */
.accounting-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.accounting-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.accounting-main-grid {
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
}
.accounting-card { display: grid; gap: 16px; }
.accounting-export-actions { justify-content: flex-end; }
.accounting-report-grid,
.accounting-ledger-list,
.accounting-form-lines {
  display: grid;
  gap: 14px;
}
.accounting-report-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.accounting-report-columns-dual {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.accounting-report-columns h5 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--text-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.accounting-report-list { min-height: 0; }
.accounting-ledger-card { gap: 12px; }
.accounting-ledger-summary .mini-stat { min-width: 124px; }
.accounting-line-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.2fr) minmax(120px, 0.6fr) minmax(120px, 0.6fr) 60px;
  gap: 10px;
  align-items: end;
}
.accounting-line-action { display: grid; }
.accounting-account-name { display: inline-block; }
.accounting-balance-positive { color: var(--success); font-weight: 700; }
.accounting-balance-negative { color: var(--coral); font-weight: 700; }
.accounting-balance-neutral { color: var(--text-soft); font-weight: 700; }

/* =============================================================
   INVOICES
   ============================================================= */
.invoice-lines { display: grid; gap: 10px; }
.invoice-line {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 110px 140px 48px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}
.invoice-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--coral-soft);
  border: 1px solid transparent;
}
.invoice-summary strong { display: block; }

/* =============================================================
   POS
   ============================================================= */
.pos-summary-grid,
.pos-last-sale-grid,
.pos-config-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}
.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.pos-product-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  min-height: 168px;
  cursor: pointer;
  transition: all var(--t-fast);
}
.pos-product-card:hover {
  border-color: var(--coral);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.pos-product-card.is-disabled {
  opacity: 0.62;
  cursor: not-allowed;
}
.pos-product-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.pos-product-card strong { display: block; margin-bottom: 4px; }
.pos-product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-soft);
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.pos-cart-card,
.pos-catalog-card { gap: 16px; }
.pos-checkout-form { gap: 16px; }
.pos-cart-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}
.pos-cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
}
.pos-cart-row small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}
.pos-cart-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.pos-cart-controls span {
  min-width: 26px;
  text-align: center;
  font-weight: 600;
}
.pos-cart-amounts {
  display: grid;
  justify-items: end;
  gap: 2px;
}
.pos-total-shell {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.pos-cart-sticky {
  position: sticky;
  top: 78px;
}
.pos-cash-shell {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
.pos-cash-quick { gap: 8px; }
.pos-cash-status {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-soft);
  font-weight: 600;
}
.pos-cash-status.is-error {
  color: var(--coral);
  background: var(--coral-soft);
}
.pos-cash-status.is-success {
  color: var(--success);
  background: var(--success-soft);
}
.pos-action-row { justify-content: space-between; }

.pos-search-shell { display: grid; gap: 10px; }
.pos-filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.pos-search-input {
  min-height: 48px;
  font-size: 1rem;
}
.pos-search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* =============================================================
   SECURE / FISCAL SETTINGS
   ============================================================= */
.secure-entry-btn { min-width: 170px; }
.secure-settings-card { gap: 16px; }
.compact-button-row { gap: 8px; flex-wrap: wrap; }
.secure-settings-strip { align-items: stretch; }
.secure-settings-grid { max-width: 860px; }
.fiscal-settings-grid { max-width: 960px; }
.fiscal-settings-card { padding: 18px; }
.secure-settings-note { max-width: 840px; }
.secure-logo-shell {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.secure-logo-preview {
  min-height: 180px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}
.secure-logo-preview.is-empty { color: var(--text-soft); }
.secure-logo-preview img {
  width: 100%;
  height: 100%;
  max-height: 180px;
  object-fit: contain;
}
.secure-logo-meta { display: flex; flex-direction: column; gap: 12px; }

/* =============================================================
   WCLOGO COMPONENT (logo animado)
   ============================================================= */
.wc-logo {
  position: relative;
  display: inline-block;
  line-height: 0;
}
.wc-logo svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.wc-logo[data-size="xs"] { width: 24px; height: 24px; }
.wc-logo[data-size="sm"] { width: 40px; height: 40px; }
.wc-logo[data-size="md"] { width: 88px; height: 88px; }
.wc-logo[data-size="lg"] { width: 160px; height: 160px; }
.wc-logo[data-size="xl"] {
  width: min(78vw, 360px);
  aspect-ratio: 1;
  height: auto;
}
.wc-logo:not([data-size]) { width: 40px; height: 40px; }

.wc-heartbeat {
  transform-origin: center;
  transform-box: fill-box;
  animation: wc-hb 1.5s ease-in-out infinite;
}
@keyframes wc-hb {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.07); }
  28% { transform: scale(1); }
  42% { transform: scale(1.04); }
  70% { transform: scale(1); }
}

/* =============================================================
   WC SPLASH (overlay del login)
   ============================================================= */
.wc-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  background:
    radial-gradient(circle at 18% 22%, rgba(90, 94, 170, 0.42) 0%, transparent 42%),
    radial-gradient(circle at 82% 78%, rgba(227, 107, 88, 0.28) 0%, transparent 45%),
    linear-gradient(135deg, #14162a 0%, #1a1d3a 55%, #1e1827 100%);
  color: #fff;
  text-align: center;
  animation: fadeIn 380ms ease;
}
.wc-splash.open {
  display: grid;
}
.wc-splash-content {
  display: grid;
  place-items: center;
  gap: 30px;
  padding: 24px;
}
.wc-splash-tagline {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}
.wc-splash-tagline.visible {
  opacity: 1;
  transform: translateY(0);
}
.wc-splash-tagline h2 {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  margin: 0;
  line-height: 1.1;
  color: #fff;
}
.wc-splash-tagline h2 .heart {
  color: var(--coral);
  animation: heartGlow 2.4s ease-in-out infinite;
}
@keyframes heartGlow {
  0%, 100% { text-shadow: 0 0 0 transparent; }
  50% { text-shadow: 0 0 20px rgba(227, 107, 88, 0.55); }
}
.wc-splash-tagline p {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.88rem;
}

/* =============================================================
   WC LOADERS (overlay e inline)
   ============================================================= */
.wc-loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 40, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 200ms ease;
}
.wc-loader-overlay.closing,
.wc-loader-inline.closing {
  animation: fadeOut 200ms ease forwards;
}
@keyframes fadeOut {
  to { opacity: 0; }
}
.wc-loader-overlay .wc-loader-body {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 30px 40px;
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  gap: 14px;
}
.wc-loader-inline {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(247, 247, 250, 0.85);
  backdrop-filter: blur(2px);
  z-index: 5;
  border-radius: inherit;
}
[data-theme="dark"] .wc-loader-inline {
  background: rgba(20, 22, 31, 0.78);
}
.wc-loader-inline .wc-loader-body {
  display: grid;
  place-items: center;
  gap: 10px;
}
.wc-loader-label {
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 500;
}

/* =============================================================
   RESPONSIVE
   ============================================================= */
@media (max-width: 1220px) {
  .auth-shell,
  .content-grid,
  .table-grid,
  .stack-grid,
  .quick-card-grid {
    grid-template-columns: 1fr;
  }
  /* KPI grids siguen auto-fit, no forzar a 2 columnas */
  .dashboard-kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .dashboard-kpi-grid-manager {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
  .company-admin-summary-grid,
  .company-module-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .suspension-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .suspension-panels { grid-template-columns: 1fr; }
  .accounting-filter-grid,
  .accounting-report-columns,
  .accounting-report-columns-dual,
  .accounting-line-grid {
    grid-template-columns: 1fr 1fr;
  }
  .accounting-main-grid { grid-template-columns: 1fr; }
  .dashboard-span-3,
  .dashboard-span-4,
  .dashboard-span-6,
  .dashboard-span-8,
  .dashboard-span-12 {
    grid-column: span 12;
  }
}

@media (max-width: 1100px) {
  /* Sidebar se vuelve drawer deslizable */
  .erp-shell,
  .erp-shell.collapsed {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    height: 100vh;
    transform: translateX(-104%);
    transition: transform var(--t-slow);
    z-index: 90;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .nav-item.active::before {
    display: none;
  }
  .mobile-nav-btn {
    display: inline-flex;
  }
  .main-shell {
    padding: 22px 18px 60px;
  }

  /* En móvil, .collapsed no actúa como mini-rail: sigue siendo drawer
     completo cuando se abre por hamburguesa. */
  .sidebar.collapsed,
  .sidebar.collapsed:hover {
    width: min(86vw, 300px);
    padding: 20px 14px 18px;
    align-items: stretch;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed:not(.open) {
    transform: translateX(-104%);
  }
  .sidebar.collapsed > .brand-row {
    justify-content: flex-start;
    padding: 0 6px 14px;
  }
  .sidebar.collapsed .brand-copy,
  .sidebar.collapsed .nav-search-shell {
    display: flex;
  }
  .sidebar.collapsed .nav-label {
    display: inline;
  }
  .sidebar.collapsed .nav-item {
    justify-content: flex-start;
    padding: 10px 12px;
    width: 100%;
    margin: 0;
  }
  .sidebar.collapsed .nav-item.active {
    background: var(--coral-soft);
    color: var(--coral);
    box-shadow: none;
  }
  .sidebar.collapsed .sidebar-collapse-btn {
    display: none; /* en móvil no tiene sentido colapsar */
  }
}

@media (max-width: 860px) {
  .auth-hero,
  .auth-panel,
  .main-shell {
    padding: 22px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar-actions,
  .topbar-actions .select {
    width: 100%;
    justify-content: flex-start;
  }
  .hero-grid,
  .field-row {
    grid-template-columns: 1fr;
  }
  .subscription-warning-banner,
  .support-contact-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .dashboard-grid,
  .dashboard-kpi-grid,
  .dashboard-kpi-grid-manager,
  .dashboard-filter-grid,
  .dashboard-dual-list,
  .accounting-filter-grid,
  .accounting-report-columns,
  .accounting-report-columns-dual,
  .accounting-line-grid,
  .suspension-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-filter-actions {
    grid-column: auto;
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-mini-item { flex-direction: column; }
  .dashboard-mini-meta { text-align: left; }
  .dashboard-span-3,
  .dashboard-span-4,
  .dashboard-span-6,
  .dashboard-span-8,
  .dashboard-span-12 {
    grid-column: auto;
  }
  .invoice-line { grid-template-columns: 1fr; }
  .toast-stack {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
  .toast { min-width: 0; max-width: none; }
  .pos-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .auth-card,
  .modal-panel { padding: 20px; }
  .section-card,
  .table-card,
  .chart-card,
  .form-card,
  .quick-card { padding: 16px; }
  .table { min-width: 600px; }
  .inbox-item { flex-direction: column; }
  .inbox-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .topbar-meta { gap: 6px; }
  .pos-summary-grid,
  .pos-last-sale-grid,
  .pos-config-strip,
  .pos-total-shell { grid-template-columns: 1fr; }
  .pos-cart-row {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }
  .pos-cart-controls,
  .pos-cart-amounts { justify-self: start; }
  .pos-filter-bar { grid-template-columns: 1fr; }
  .pos-search-meta,
  .pos-action-row {
    flex-direction: column;
    align-items: stretch;
  }
  .secure-logo-shell { grid-template-columns: 1fr; }
}

@media (max-width: 1080px) {
  .messaging-layout { grid-template-columns: 1fr; }
  .messaging-conversation-list,
  .messaging-thread-messages { max-height: none; }
}

@media (max-width: 1180px) {
  .pos-cart-sticky { position: static; }
}

/* =============================================================
   PREFIERE-REDUCED-MOTION
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================
   WEBHOOK helper — bloque dentro de la tarjeta de credenciales WhatsApp
   ============================================================= */
.webhook-helper {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--indigo-soft);
  border: 1px solid var(--indigo);
  border-radius: var(--radius-md);
}
.webhook-helper-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.webhook-helper-head strong {
  color: var(--indigo);
  font-size: 0.92rem;
}
.webhook-helper-url {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}
.webhook-helper-url code {
  flex: 1;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
.webhook-helper-url .ghost-btn {
  flex-shrink: 0;
}

/* =============================================================
   BOT CONFIG — filas dinámicas del menú
   ============================================================= */
.bot-menu-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}
.bot-menu-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.bot-menu-row:has([data-option-escalation]:checked) {
  border-color: var(--coral);
  background: var(--coral-soft);
}
.bot-menu-row[hidden] {
  display: none !important;
}
.bot-menu-row-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bot-menu-row-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--indigo);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.bot-menu-row:has([data-option-escalation]:checked) .bot-menu-row-num {
  background: var(--coral);
}
.bot-menu-row-label {
  flex: 1;
  font-weight: 600;
}
.bot-menu-row-response {
  width: 100%;
  font-size: 0.88rem;
}
.bot-menu-row-escalation {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.bot-menu-row-escalation input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--coral);
}

/* =============================================================
   COMPANIES MASTER-DETAIL (vista de empresas del super admin)
   ============================================================= */
.companies-master-detail {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.companies-master {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  max-height: calc(100vh - 110px);
  overflow: hidden;
}
.companies-master-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.companies-master-search:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
  background: var(--bg-elevated);
}
.companies-master-search > svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.companies-master-input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: 0;
  padding: 9px 0;
  font-size: 0.86rem;
  color: var(--text);
  min-width: 0;
}
.companies-master-input::placeholder {
  color: var(--muted);
}
.companies-master-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  display: none;
}

.companies-master-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-height: 0;
}
.companies-master-list::-webkit-scrollbar { width: 6px; }
.companies-master-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.companies-master-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
}
.companies-master-item:hover {
  background: var(--surface-hover);
  border-color: var(--line);
}
.companies-master-item.is-active {
  background: var(--coral-soft);
  border-color: var(--coral);
}
.companies-master-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.companies-master-name strong {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.companies-master-name small {
  color: var(--muted);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.companies-master-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.companies-master-meta .chip,
.companies-master-meta .severity-pill {
  padding: 2px 8px;
  font-size: 0.7rem;
}
.companies-master-empty {
  padding: 24px 12px;
  text-align: center;
}

.companies-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

@media (max-width: 1100px) {
  .companies-master-detail {
    grid-template-columns: 1fr;
  }
  .companies-master {
    position: static;
    max-height: 480px;
  }
}
