/* =============================================
   VAPEMANAGER — DESIGN SYSTEM
   ============================================= */

:root {
  --sidebar-w: 240px;
  /* Sidebar claro: base con undertone violeta muy tenue, acento en el activo */
  --sidebar-bg: #ffffff;
  --sidebar-border: #e8e4f0;
  --sidebar-accent: #7c2ff2;
  --sidebar-accent-bg: rgba(124,47,242,0.13);
  --sidebar-accent-text: #6812d9;
  --sidebar-text: #6d6b76;
  --sidebar-text-hover: #1a1720;
  --sidebar-text-active: #1a1720;
  --sidebar-hover: rgba(124,47,242,0.05);

  --page-bg: #eae6f2;
  --card-bg: #fcfbfe;
  --topbar-bg: #eae6f2;

  /* Glow ambiente del fondo (esquinas) — parte de la "vida" del canvas */
  --ambient-1: rgba(124,47,242,0.09);
  --ambient-2: rgba(124,47,242,0.06);
  /* Stack completo del fondo (degradé de esquinas + color base). Se usa en body
     Y en el topbar, con background-attachment:fixed, para que el degradé de la
     esquina superior derecha NO se corte donde arranca el topbar. Como referencia
     variables temáticas, se recalcula solo en claro/oscuro. */
  --page-bg-stack:
    radial-gradient(60% 45% at 88% -5%, var(--ambient-1), transparent 60%),
    radial-gradient(55% 40% at 0% 108%, var(--ambient-2), transparent 60%),
    var(--page-bg);

  --primary: #7c2ff2;
  --primary-hover: #6c1ee0;
  --primary-light: #f1e8ff;
  --secondary: #64748b;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  /* Texto sobre fondos *-light — legible en ambos temas */
  --primary-text: #6812d9;
  --success-text: #065f46;
  --warning-text: #92400e;
  --danger-text: #991b1b;
  --info-text: #1e40af;

  --text-primary: #1a1720;
  --text-secondary: #55525f;
  --text-muted: #9e9ba8;
  --border: #e2dcef;
  --border-light: #eee9f6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 20px;

  /* Escala tipográfica */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* Paleta de charts (respetada por Chart.js vía getComputedStyle) */
  --chart-1: #7c2ff2;
  --chart-2: #10b981;
  --chart-3: #3b82f6;
  --chart-4: #f59e0b;
  --chart-5: #ef4444;

  --shadow-xs: 0 1px 3px rgba(56,42,105,0.07);
  --shadow-sm: 0 3px 10px rgba(56,42,105,0.08), 0 0 0 1px rgba(56,42,105,0.03);
  --shadow-md: 0 8px 24px rgba(56,42,105,0.11), 0 0 0 1px rgba(56,42,105,0.03);
  --shadow-lg: 0 12px 40px rgba(56,42,105,0.16);

  /* Glow de acento (estilo "iluminado"): anillo + halo del color primario */
  --glow-ring: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
  --glow-primary: 0 0 14px color-mix(in srgb, var(--primary) 28%, transparent);

  /* Vida de cards: A) filo de luz superior + B) aurora en cards de números */
  --card-sheen-top: #ffffff;
  --card-border-top: #efeaf7;
  --card-inner-light: inset 0 1px 0 rgba(255,255,255,0.9);
  --aurora: radial-gradient(130% 90% at 15% 0%, rgba(124,47,242,0.06), transparent 55%);
  /* Relleno estándar de card (sheen→fondo); global: lo usan dashboard, ER, etc. */
  --card-fill: linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.18s ease;
}

/* =============================================
   DARK THEME OVERRIDES
   ============================================= */
[data-theme="dark"] {
  /* Base grafito con undertone violeta muy tenue (no navy) — el acento resalta */
  --sidebar-bg: #17131f;
  --sidebar-border: #282234;
  --sidebar-accent: #9155ff;
  --sidebar-accent-bg: rgba(145,85,255,0.16);
  --sidebar-accent-text: #c7a9ff;
  --sidebar-text: #948da3;
  --sidebar-text-hover: #f5f3f8;
  --sidebar-text-active: #f5f3f8;
  --sidebar-hover: rgba(145,85,255,0.08);

  --page-bg: #120f1c;
  --card-bg: #1d1929;
  --topbar-bg: #120f1c;

  /* Glow ambiente más marcado en oscuro */
  --ambient-1: rgba(145,85,255,0.14);
  --ambient-2: rgba(145,85,255,0.09);

  --primary: #9155ff;
  --primary-hover: #a06aff;
  --primary-light: rgba(145,85,255,0.16);

  --text-primary: #f5f3f8;
  --text-secondary: #a69eb4;
  --text-muted: #766f86;
  --border: #322b42;
  --border-light: #262030;

  --success-light: rgba(16,185,129,0.15);
  --danger-light: rgba(239,68,68,0.15);
  --warning-light: rgba(245,158,11,0.15);
  --info-light: rgba(59,130,246,0.15);

  --primary-text: #c7a9ff;
  --success-text: #6ee7b7;
  --warning-text: #fcd34d;
  --danger-text: #fca5a5;
  --info-text: #93c5fd;

  --chart-1: #a678ff;
  --chart-2: #34d399;
  --chart-3: #60a5fa;
  --chart-4: #fbbf24;
  --chart-5: #f87171;

  /* En oscuro el glow luce más fuerte */
  --glow-ring: inset 0 0 0 1px color-mix(in srgb, var(--primary) 50%, transparent);
  --glow-primary: 0 0 18px color-mix(in srgb, var(--primary) 42%, transparent);

  /* Filo de luz + aurora, más presentes en oscuro */
  --card-sheen-top: #251e37;
  --card-border-top: #463b60;
  --card-inner-light: inset 0 1px 0 rgba(255,255,255,0.06);
  --aurora: radial-gradient(130% 90% at 15% 0%, rgba(145,85,255,0.14), transparent 55%);

  --shadow-xs: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-sm: 0 1px 6px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
}

/* Dark mode: specific component overrides */
[data-theme="dark"] body {
  color: var(--text-primary);
}
[data-theme="dark"] .card { border-color: var(--border); border-top-color: var(--card-border-top); }
[data-theme="dark"] .topbar { border-color: transparent; }
[data-theme="dark"] .input, [data-theme="dark"] select.input, [data-theme="dark"] textarea.input {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme="dark"] .input:focus { background: rgba(255,255,255,0.08); border-color: var(--primary); }
[data-theme="dark"] .input::placeholder { color: var(--text-muted); }
[data-theme="dark"] .table thead th { background: transparent; border-color: var(--border); }
[data-theme="dark"] .table tbody tr { border-color: var(--border); }
[data-theme="dark"] .table tbody tr:hover { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .totals-row { background: rgba(255,255,255,0.04); }
[data-theme="dark"] .pnl-item:hover { background: rgba(255,255,255,0.02); }
[data-theme="dark"] .negative-item { background: rgba(239,68,68,0.04); }
[data-theme="dark"] .negative-item:hover { background: rgba(239,68,68,0.07); }
[data-theme="dark"] .pnl-detail { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .pnl-subtotal { background: rgba(255,255,255,0.05) !important; }
[data-theme="dark"] .pnl-result-positive { background: rgba(16,185,129,0.1); }
[data-theme="dark"] .pnl-result-negative { background: rgba(239,68,68,0.1); }
[data-theme="dark"] .result-positive { background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.08)); border-color: rgba(16,185,129,0.25); }
[data-theme="dark"] .result-negative { background: linear-gradient(135deg, rgba(239,68,68,0.15), rgba(239,68,68,0.08)); border-color: rgba(239,68,68,0.25); }
[data-theme="dark"] .result-banner-label { color: rgba(255,255,255,0.7); }
[data-theme="dark"] .result-banner-value { color: #e2e8f0; }
[data-theme="dark"] .month-selector { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .month-tab { color: var(--text-muted); }
[data-theme="dark"] a.month-tab:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
[data-theme="dark"] .btn-ghost { color: var(--text-secondary); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
[data-theme="dark"] .input-prefix { background: rgba(255,255,255,0.05); border-color: var(--border); color: var(--text-primary); }
[data-theme="dark"] .input-prefix span { background: transparent; color: var(--text-muted); }
[data-theme="dark"] .input-prefix-sm span { background: transparent; color: var(--text-muted); }
[data-theme="dark"] .status-badge { opacity: 0.9; }
[data-theme="dark"] .cat-summary-row { border-color: var(--border); }
[data-theme="dark"] .cat-summary-total-row { border-color: var(--border); }
[data-theme="dark"] .filters-row { background: transparent; }
[data-theme="dark"] .period-tabs { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .period-tab { color: var(--text-muted); }
[data-theme="dark"] .period-tab:hover { background: rgba(255,255,255,0.07); color: var(--text-primary); }
[data-theme="dark"] .pnl-summary-row { border-color: var(--border); }
[data-theme="dark"] .pnl-summary-box { background: var(--card-bg); }
[data-theme="dark"] .dollar-info-card { background: rgba(145,85,255,0.12); border-color: rgba(145,85,255,0.2); }
[data-theme="dark"] .flash-success { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
[data-theme="dark"] .flash-error   { background: rgba(239,68,68,0.15);  border-color: rgba(239,68,68,0.3);  color: #fca5a5; }
[data-theme="dark"] .flash-info    { background: rgba(59,130,246,0.15); border-color: rgba(59,130,246,0.3); color: #93c5fd; }
[data-theme="dark"] .expense-add-card { background: var(--card-bg); }
[data-theme="dark"] .pnl-total-egresos { background: rgba(245,158,11,0.07) !important; }
[data-theme="dark"] .wa-preview { background: rgba(255,255,255,0.04); border-color: var(--border); color: var(--text-secondary); }
[data-theme="dark"] select option { background: #1d1929; color: #f5f3f8; }

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

/* scrollbar-gutter: reserva el ancho de la barra siempre, así la página no se
   corre cuando el contenido crece (desplegar variantes, cambiar de paso, etc.).
   `overflow-y: scroll` hace lo mismo y lo soportan todos los navegadores
   (scrollbar-gutter recién llega a Safari 18.2); en macOS las barras son overlay,
   así que no ocupa ancho ni se ve de más. */
html { font-size: var(--text-md); scrollbar-gutter: stable; overflow-y: scroll; }

body {
  font-family: var(--font);
  background: var(--page-bg-stack);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* =============================================
   LAYOUT
   ============================================= */
.layout {
  display: flex;
  min-height: 100vh;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

/* RAIL: auto-ocultar. Angosto por defecto, se expande al pasar el mouse. */
/* Sin animación en la primera carga (JS quita .no-anim tras el 1er frame) */
.sidebar.no-anim, .sidebar.no-anim * { transition: none !important; }

.sidebar.rail { width: 64px; }
.sidebar.rail:hover {
  width: var(--sidebar-w);
  box-shadow: var(--shadow-lg);
  z-index: 200;
}
.sidebar.rail:not(:hover) .nav-item span,
.sidebar.rail:not(:hover) .nav-label,
.sidebar.rail:not(:hover) .badge-soon,
.sidebar.rail:not(:hover) .sidebar-pin-label,
.sidebar.rail:not(:hover) .sidebar-identity-info,
.sidebar.rail:not(:hover) .account-chevron { display: none; }
.sidebar.rail:not(:hover) .nav-item { justify-content: center; padding: 10px 0; margin: 0; }
.sidebar.rail:not(:hover) .sidebar-account { justify-content: center; padding: 8px 0; }
.sidebar.rail:not(:hover) .sidebar-top { justify-content: center; }
.sidebar.rail:not(:hover) .sidebar-pin { padding: 8px 0; }
/* Rail: íconos repartidos por todo el alto (sin secciones ni huecos) */
.sidebar.rail:not(:hover) .sidebar-nav {
  display: flex; flex-direction: column; justify-content: space-evenly;
}
.sidebar.rail:not(:hover) .nav-section { display: contents; }

/* Logo (usado en el login) */
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), #a678ff);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-lg); font-weight: 700; color: white;
  flex-shrink: 0;
}

/* NAV */
.sidebar-nav {
  flex: 1;
  min-height: 0;          /* permite que scrollee en vez de empujar la cuenta fuera */
  padding: 6px 8px 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;  /* sin barra visible (scrollea igual si la pantalla es baja) */
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section { margin-bottom: 2px; }

/* Separador fino entre grupos */
.nav-section + .nav-section {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--sidebar-border);
}

.nav-label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 1.1px;
  padding: 12px 12px 4px;
  opacity: 0.55;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 14.5px; font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-hover);
}

.nav-item.active {
  background: var(--sidebar-accent-bg);
  color: var(--sidebar-accent-text);
  font-weight: 600;
  box-shadow: var(--glow-ring), var(--glow-primary);
}

.nav-item.active svg { color: var(--sidebar-accent-text); }

.nav-item.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.badge-soon {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--sidebar-text);
  background: var(--sidebar-hover);
  border: 1px solid var(--sidebar-border, transparent);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── FIJAR / AUTO-OCULTAR (top del sidebar) ── */
.sidebar-top { padding: 10px 12px 2px; display: flex; align-items: center; flex-shrink: 0; }
.sidebar-pin {
  display: inline-flex; align-items: center; gap: 11px;
  border: none; background: none; cursor: pointer;
  padding: 8px 11px; border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.sidebar-pin:hover { background: var(--sidebar-hover); color: var(--sidebar-text-hover); }
.sidebar-pin svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ── CUENTA (bottom del sidebar) + menú ── */
.sidebar-account-wrap { position: relative; padding: 8px 10px; flex-shrink: 0; }
.sidebar-identity-info { overflow: hidden; min-width: 0; text-align: left; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sidebar-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 700; flex-shrink: 0;
}
.user-name  { font-size: 0.86rem; font-weight: 600; color: var(--sidebar-text-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.74rem; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-account {
  width: 100%; border: 1px solid var(--sidebar-border); cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-md);
  background: transparent;
  transition: background var(--transition);
}
.sidebar-account:hover, .sidebar-account.menu-open { background: var(--sidebar-hover); }
.account-chevron { width: 16px; height: 16px; color: var(--sidebar-text); flex-shrink: 0; transition: transform var(--transition); }
.sidebar-account.menu-open .account-chevron { transform: rotate(180deg); }

.account-menu {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% - 4px);
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px; margin-bottom: 6px;
  display: none;
}
.account-menu.open { display: block; }
.account-menu-item {
  width: 100%; border: none; background: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 500;
  color: var(--sidebar-text-active); text-align: left;
  transition: background var(--transition);
}
.account-menu-item:hover { background: var(--sidebar-hover); }
.account-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.account-menu-item.danger { color: var(--danger-text); }
.account-menu-item.danger:hover { background: rgba(239,68,68,0.12); }
.account-menu-item + .account-menu-item.danger { border-top: 1px solid var(--sidebar-border); margin-top: 4px; padding-top: 11px; }


/* =============================================
   MAIN AREA
   ============================================= */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* flex item: sin esto no encoge bajo el contenido y una tabla
                   ancha (table-scroll) estira la página en vez de scrollear */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.22s ease;
}

/* Rail: el contenido usa el ancho angosto; el hover expande por encima */
.layout.sidebar-collapsed .main { margin-left: 64px; }

/* TOPBAR — en desktop no existe (la acción vive en el encabezado de cada
   pantalla). Solo aparece en mobile para el hamburguesa (ver media query). */
.topbar {
  display: none;
  align-items: center;
  background: transparent;
  border: none;
  padding: 12px 16px 0;
}
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Atajo global "Nueva venta": pill contorneado (no relleno), deliberadamente
   distinto del btn-primary de cada página para no competir con su acción. */
.btn-newsale {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--primary);
  background: transparent; color: var(--primary);
  font-size: var(--text-base); font-weight: 600;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: all var(--transition);
}
.btn-newsale svg { width: 15px; height: 15px; }
.btn-newsale:hover { background: var(--primary); color: #fff; }


.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: none;               /* desktop: el sidebar se controla con el botón de fijar */
  align-items: center;
  transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--border-light); color: var(--text-primary); }
.sidebar-toggle svg { width: 18px; height: 18px; }

/* BREADCRUMB */
.breadcrumb { display: flex; align-items: center; gap: 6px; }
.bc-item {
  font-size: var(--text-base); color: var(--text-muted);
  transition: color var(--transition);
}
.bc-item:hover { color: var(--primary); }
.bc-item.active { color: var(--text-primary); font-weight: 500; }
.bc-sep { color: var(--text-muted); font-size: var(--text-sm); }

/* CONTENT */
.content {
  flex: 1;
  /* Sin barra en desktop: el aire de arriba lo pone el propio contenido. */
  padding: 36px 32px 32px;
  max-width: 1400px;
  width: 100%;
}

/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: var(--text-2xl); font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.5px;
}

.page-sub {
  font-size: var(--text-base); color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  background: linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-inner-light), var(--shadow-sm);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: var(--text-base); font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 7px;
}

.card-title svg { width: 15px; height: 15px; color: var(--text-muted); }

.card-link {
  font-size: var(--text-sm); color: var(--primary);
  font-weight: 500;
  transition: opacity var(--transition);
}
.card-link:hover { opacity: 0.7; }

.card-body { padding: 16px 18px; }
.card-body.p-0 { padding: 0; }

.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-light);
  background: var(--border-light);
}

.card-success {
  border-color: var(--success);
  background: var(--success-light);
}

.card-warning {
  border-color: var(--warning);
  background: var(--warning-light);
}

.card-danger {
  border-color: var(--danger);
}
.card-danger .card-header {
  border-bottom-color: var(--danger);
  background: var(--danger-light);
}

.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

/* =============================================
   STATS GRID
   ============================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  --sc: var(--border);
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), border-color var(--transition);
}

/* Cada card toma el color de su ícono para el delineado + un aura suave */
.stat-card:has(.stat-icon-green)  { --sc: var(--success); }
.stat-card:has(.stat-icon-blue)   { --sc: var(--info); }
.stat-card:has(.stat-icon-purple) { --sc: var(--primary); }
.stat-card:has(.stat-icon-yellow) { --sc: var(--warning); }
.stat-card:has(.stat-icon-red)    { --sc: var(--danger); }
.stat-card:has(.stat-icon) {
  border-color: color-mix(in srgb, var(--sc) 42%, var(--border));
  background:
    radial-gradient(120% 100% at 10% 0%, color-mix(in srgb, var(--sc) 10%, transparent), transparent 60%),
    linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  box-shadow: var(--card-inner-light), var(--shadow-sm);
}
.stat-card:has(.stat-icon):hover {
  border-color: color-mix(in srgb, var(--sc) 62%, var(--border));
  box-shadow: var(--card-inner-light), 0 0 18px color-mix(in srgb, var(--sc) 16%, transparent), var(--shadow-md);
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }

.stat-icon-purple { background: var(--primary-light); color: var(--primary); }
.stat-icon-blue   { background: var(--info-light);    color: var(--info); }
.stat-icon-green  { background: var(--success-light); color: var(--success); }
.stat-icon-yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon-red    { background: var(--danger-light);  color: var(--danger); }

.stat-body { flex: 1; min-width: 0; }

.stat-value {
  font-size: var(--text-xl); font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.stat-label {
  font-size: var(--text-sm); color: var(--text-muted);
  font-weight: 500; margin-top: 1px;
}

.stat-sub {
  font-size: var(--text-xs); color: var(--text-muted);
  margin-top: 2px;
}

/* =============================================
   METRIC STRIP — métricas de resumen (sobrias)
   Un solo panel dividido por hairlines, no N cajas de colores.
   El color es contenido y con motivo: ícono violeta de marca en las
   métricas informativas; ámbar/rojo (ícono + punto de estado) solo en
   las que marcan una alerta. Reemplaza a .stats-grid/.stat-card en las
   pantallas de resumen (cotización, stock, cuenta del revendedor).
   ============================================= */
.metric-strip {
  background: var(--aurora), var(--card-fill);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-inner-light), var(--shadow-sm);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  overflow: hidden;
  margin-bottom: 20px;
}
.mstat {
  padding: 18px 22px;
  border-left: 1px solid var(--border-light);
  min-width: 0;
}
.mstat:first-child { border-left: none; }

.mstat-ico {
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.mstat-ico svg { width: 15px; height: 15px; }
.ico-violet { background: var(--primary-light); color: var(--primary); }
.ico-green  { background: var(--success-light); color: var(--success-text); }
.ico-amber  { background: var(--warning-light); color: var(--warning-text); }
.ico-red    { background: var(--danger-light);  color: var(--danger-text); }
.ico-blue   { background: var(--info-light);    color: var(--info-text); }

.mstat-label {
  font-size: var(--text-sm); color: var(--text-muted); font-weight: 500;
  margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mstat-value {
  font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.4px;
  color: var(--text-primary); line-height: 1.05;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mstat-value .cur { margin-right: 4px; }
.mstat-value .muted { color: var(--text-muted); font-weight: 500; }
.mstat-value.with-dot { display: inline-flex; align-items: center; gap: 9px; }
.sdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sdot.warn { background: var(--warning); }
.sdot.dang { background: var(--danger); }
.sdot.ok   { background: var(--success); }

.mdelta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-sm); font-weight: 600; margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* slim: banda más fina (solo baja el alto, mantiene el ancho completo).
   Para franjas que resumen poco y no deben pesar (ej. cotización). */
.metric-strip.slim .mstat { padding: 11px 22px; }
.metric-strip.slim .mstat-label { margin-bottom: 4px; }
.metric-strip.slim .mdelta { margin-top: 4px; }
.mdelta svg { width: 14px; height: 14px; }
.mdelta.up   { color: var(--danger-text); }   /* el dólar sube = más caro */
.mdelta.down { color: var(--success-text); }
.mdelta.flat { color: var(--text-muted); }

@media (max-width: 720px) {
  .metric-strip { grid-auto-flow: row; grid-auto-columns: auto; }
  .mstat { border-left: none; border-top: 1px solid var(--border-light); }
  .mstat:first-child { border-top: none; }
}

/* =============================================
   TWO COLUMN LAYOUT
   ============================================= */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* =============================================
   FORM LAYOUTS
   ============================================= */
.form-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

.form-single { max-width: 640px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

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

.form-label {
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-secondary); letter-spacing: 0.2px;
}

.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

.form-actions-sticky {
  position: sticky;
  bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* =============================================
   INPUTS
   ============================================= */
.input {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

.input-sm { padding: 6px 9px; font-size: var(--text-sm); }
.input-lg { padding: 10px 13px; font-size: 15px; font-weight: 600; }

textarea.input { resize: vertical; min-height: 80px; }

.input-icon { position: relative; }
.input-icon > i {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
  width: 15px; height: 15px;
}
.input-icon .input { padding-left: 32px; }

.input-prefix {
  display: flex; align-items: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-prefix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}
.input-prefix > span {
  padding: 0 2px 0 10px;
  font-size: var(--text-base); font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  white-space: nowrap;
  height: 100%;
  display: flex; align-items: center;
  flex-shrink: 0;
}
.input-prefix .input {
  border: none; box-shadow: none; border-radius: 0;
  padding: 7px 10px 7px 4px;
  background: transparent !important;
}
.input-prefix .input:focus { box-shadow: none; border-color: transparent; background: transparent !important; }
.input-prefix-lg .input { padding: 9px 12px; font-size: 15px; font-weight: 600; }

.input-with-action { display: flex; gap: 6px; align-items: center; }
.input-with-action .input { flex: 1; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base); font-weight: 600; line-height: 1.5;
  cursor: pointer; border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary); color: white;
  box-shadow: 0 0 16px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 0 22px color-mix(in srgb, var(--primary) 50%, transparent); }

.btn-secondary {
  background: var(--border-light); color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--border-light); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 7px 13px; font-size: var(--text-base); }
.btn-full { width: 100%; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  cursor: pointer; border: none;
  background: transparent; color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--border-light); color: var(--text-primary); }
.btn-icon.text-danger:hover { background: var(--danger-light); color: var(--danger); }
.btn-icon svg { width: 15px; height: 15px; }

/* =============================================
   BADGES
   ============================================= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600;
  white-space: nowrap;
}

.badge-success  { background: var(--success-light); color: var(--success-text); }
.badge-neutral  { background: var(--border-light); color: var(--text-secondary); }
.badge-warning  { background: var(--warning-light); color: var(--warning-text); }
.badge-danger   { background: var(--danger-light);  color: var(--danger-text); }
.badge-info     { background: var(--info-light);    color: var(--info-text); }
.badge-primary  { background: var(--primary-light); color: var(--primary-text); }
.badge-cash     { background: var(--success-light); color: var(--success-text); }
.badge-transfer { background: var(--info-light);    color: var(--info-text); }
.badge-mp       { background: var(--primary-light); color: var(--primary-text); }
.badge-muted    { background: var(--border-light);  color: var(--text-secondary); }
.badge-purple   { background: var(--primary-light); color: var(--primary-text); }
.badge-blue     { background: var(--info-light);    color: var(--info-text); }
.badge-orange   { background: var(--warning-light); color: var(--warning-text); }

/* STOCK BADGES */
.stock-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 22px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 700;
}
.stock-ok   { background: var(--success-light); color: var(--success-text); }
.stock-low  { background: var(--warning-light); color: var(--warning-text); }
.stock-zero { background: var(--danger-light);  color: var(--danger-text); }

/* BRAND BADGE */
.brand-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600;
}

/* COLLECTION BADGE */
.coll-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--info-light);
  color: var(--info);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600;
}

/* Colecciones: título de sección + divisor + builder de características/variantes */
.section-label { display: block; font-size: 13.5px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.section-label-divider { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border-light); }
.attr-builder { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.attr-row { display: grid; grid-template-columns: 1fr 96px 30px; gap: 6px; align-items: center; }
.attr-row .input { padding: 7px 9px; font-size: 12.5px; }
.attr-row select.input { padding: 7px 6px; }
.attr-add { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--primary); background: none; border: none; cursor: pointer; font-family: inherit; padding: 4px 0; }
.attr-add svg { width: 14px; height: 14px; }
.attr-row-del { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; color: var(--text-muted); cursor: pointer; background: none; border: none; }
.attr-row-del svg { width: 14px; height: 14px; }

/* Alta de Producto: pasos numerados */
.step { border: 1px solid var(--border); border-radius: 14px; margin-bottom: 14px; overflow: hidden; background: var(--card-bg); }
.step-head { display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid var(--border-light); }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.step-title { font-size: 14.5px; font-weight: 700; }
.step-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.step-body { padding: 16px 18px; }
.model-summary { display: flex; align-items: center; gap: 12px; background: var(--success-light); border: 1px solid color-mix(in srgb, var(--success) 30%, var(--border)); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.model-summary svg { width: 18px; height: 18px; color: var(--success); flex: none; }
.model-summary-name { font-weight: 700; font-size: 13.5px; }

/* Alta de Producto: lista de variantes que se van agregando */
.variant-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.variant-row { display: flex; align-items: center; justify-content: space-between; background: var(--border-light); border-radius: 8px; padding: 9px 13px; font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.variant-row button { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: none; border: none; color: var(--text-muted); cursor: pointer; }
.variant-row button:hover { color: var(--danger); background: var(--danger-light); }
.variant-row button svg { width: 14px; height: 14px; }

/* Alta de Producto: vista previa, cada producto en su propio bloque */
.pname-main { font-weight: 600; font-size: 13.5px; color: var(--text-primary); }
.preview-item { background: var(--border-light); border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; }
.preview-item:last-child { margin-bottom: 0; }

/* CODE TAG */
.code-tag {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: var(--text-xs); font-weight: 600;
  background: var(--border-light);
  color: var(--text-secondary);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* =============================================
   CATÁLOGO DE PRODUCTOS (vista por modelo → variantes)
   Ver skill design-system.
   ============================================= */
/* Código de producto: texto monoespaciado como el de Ventas, SIN el chip
   (borde + fondo) — el chip pesaba de más en cada fila. No va en púrpura como
   `.sale-code` porque no es link: no hay pantalla de detalle de producto.
   El código de la variante (`pcode-sub`) va más tenue, subordinado al modelo. */
.pcode {
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: var(--text-base); font-weight: 500;
  color: var(--text-secondary); letter-spacing: -0.2px; white-space: nowrap;
}
.pcode-sub { font-weight: 400; color: var(--text-muted); }

/* Chip de marca: rectangular, color sobrio y distinto por marca */
.brand-chip { display: inline-block; padding: 3px 9px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.brand-chip.bc-purple { background: var(--primary-light); color: var(--primary-text); }
.brand-chip.bc-orange { background: var(--warning-light); color: var(--warning-text); }
.brand-chip.bc-red    { background: var(--danger-light);  color: var(--danger-text); }
.brand-chip.bc-blue   { background: var(--info-light);    color: var(--info-text); }
.brand-chip.bc-green  { background: var(--success-light); color: var(--success-text); }

/* Indicador de estado: punto + texto (verde activo / rojo inactivo) */
.estado { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 500; }
.estado .estado-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.estado.is-activo   { color: var(--success-text); }
.estado.is-activo .estado-dot   { background: var(--success); }
.estado.is-inactivo { color: var(--danger-text); }
.estado.is-inactivo .estado-dot { background: var(--danger); }

/* Filas de variante: NO son un panel aparte, son la misma tabla continuando.
   La jerarquía se comunica con sangría + riel a la izquierda, nunca con un fondo
   de color: cualquier caja o tinte propio hace que el desplegado se lea como
   otra pantalla. Por eso comparten grilla, columnas y fondo con la fila padre. */
/* `table-layout: fixed` es obligatorio acá: con el layout automático, al desplegar
   un modelo entran códigos de variante más largos que el del modelo y el navegador
   recalcula el ancho de TODAS las columnas — la tabla entera saltaba hasta 16px al
   abrir. Con anchos fijos el desplegado no puede mover nada.
   El min-width manda a `.table-scroll` en pantallas angostas en vez de aplastar
   la columna Modelo, que es la única elástica. Se califica con `.table-scroll
   .table` porque esa regla (más abajo) fija min-width:760px y le ganaba por
   especificidad, comprimiendo las columnas. */
.table-scroll .table.catalogo { table-layout: fixed; min-width: 980px; }

.varrow[hidden] { display: none; }
.model-row .model-chev { transition: transform 0.15s ease; }
.model-row.open .model-chev { transform: rotate(90deg); }
/* Nota: `.table td` se define más abajo con la misma especificidad, así que estas
   reglas la califican con `.table` para no perder por orden de cascada. */

/* La fila padre no se separa de sus hijas: el grupo se lee como un bloque */
.table .model-row.open > td { border-bottom: none; }

/* Las hijas son filas normales de la tabla; solo cambia la sangría y el riel.
   El cuerpo NO se achica: el nombre de la variante se tiene que leer igual de
   bien que el del modelo. La jerarquía la marcan la sangría y el riel. */
.table .varrow > td {
  padding-top: 8px; padding-bottom: 8px;
  border-bottom-color: transparent;
}
.table .varrow-name {
  padding-left: 34px;
  border-left: 2px solid var(--primary);
  color: var(--text-secondary);
}

/* Estado de la variante: el punto sigue dando el color, pero la etiqueta va en
   gris. Así el estado del modelo (etiqueta coloreada) manda visualmente y no
   compiten dos indicadores idénticos a dos alturas distintas. */
.table .varrow .estado { color: var(--text-muted); font-weight: 400; }

/* La última fila del grupo sí cierra con la línea de la tabla */
.table .varrow-add > td { padding-bottom: 12px; border-bottom-color: var(--border-light); }

/* Alta inline de variante: última fila del grupo, sin salir de la pantalla */
.varadd-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--text-sm); color: var(--primary); font-weight: 500; cursor: pointer;
}
.varadd-link[hidden] { display: none; }
.varadd-form { display: flex; align-items: center; gap: 8px; }
.varadd-form[hidden] { display: none; }
.varadd-input {
  width: 220px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-primary); font-size: var(--text-sm);
}
.varadd-input:focus { outline: none; border-color: var(--primary); }

/* =============================================
   AJUSTE DE STOCK (planilla de conteo)
   Ver stock/ajuste.html. Input de conteo por fila, celda de diferencia
   coloreada y barra de acción fija con el resumen del ajuste.
   ============================================= */
/* Ajuste rápido de un producto (pantalla de movimientos): form en una línea,
   el motivo se estira y el botón queda al final. */
.quick-adjust { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

.count-input {
  width: 90px; padding: 6px 10px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-primary);
  font-size: var(--text-base); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.count-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow-primary); }
/* El input tiñe su borde según el signo de la diferencia, para ubicar de un
   vistazo qué contaste de más y qué de menos sin leer la columna Diferencia. */
.count-input.is-up   { border-color: var(--success); }
.count-input.is-down { border-color: var(--danger); }

.count-diff { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.count-diff.is-up   { color: var(--success-text); }
.count-diff.is-down { color: var(--danger-text); }
.count-diff.is-zero { color: var(--text-muted); }

/* Barra fija al pie: el resumen y el botón de aplicar quedan siempre a la vista
   aunque la planilla sea larga, sin volver arriba a confirmar. */
.count-actionbar {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 16px; padding: 12px 16px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
}
.count-summary { display: flex; align-items: center; gap: 12px; font-size: var(--text-base); color: var(--text-secondary); }
.count-summary b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.count-sep { width: 1px; height: 18px; background: var(--border); }
.count-net-up   { color: var(--success-text) !important; }
.count-net-down { color: var(--danger-text) !important; }
.count-net-zero { color: var(--text-muted) !important; }
.count-actionbar-right { display: flex; align-items: center; gap: 10px; }
.count-notes {
  width: 280px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-bg); color: var(--text-primary); font-size: var(--text-sm);
}
.count-notes:focus { outline: none; border-color: var(--primary); }
@media (max-width: 640px) {
  .count-actionbar { flex-direction: column; align-items: stretch; }
  .count-notes { width: 100%; }
}

/* =============================================
   ROW MENU (⋮ de acciones al final de una fila)
   Ver macro ui.row_menu() en components.html.
   ============================================= */
.rowmenu { position: relative; display: inline-block; }
.rowmenu-pop {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 60; min-width: 190px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 5px; text-align: left;
}
.rowmenu-pop[hidden] { display: none; }
.rowmenu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: var(--text-base); color: var(--text-primary);
  border-radius: var(--radius-sm); text-align: left; white-space: nowrap;
}
.rowmenu-item:hover { background: var(--border-light); }
.rowmenu-item i { width: 15px; height: 15px; flex: none; color: var(--text-muted); }
.rowmenu-item.danger, .rowmenu-item.danger i { color: var(--danger); }
.rowmenu-item[disabled] { color: var(--text-muted); cursor: not-allowed; }
.rowmenu-sep { height: 1px; margin: 4px 6px; background: var(--border-light); }

/* =============================================
   MODAL (unificado — reemplaza overlays inline)
   ============================================= */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center; justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 440px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-box-lg { width: 560px; }
.modal-title { margin: 0 0 6px; font-size: var(--text-lg); font-weight: 700; }
.modal-sub   { font-size: var(--text-base); color: var(--text-muted); margin: 0 0 16px; }

/* Utilidades de color de texto (para JS: classList en vez de style.color) */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-info    { color: var(--info) !important; }

/* =============================================
   TABLES
   ============================================= */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 10.5px; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-md); color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table-hover tbody tr { transition: background var(--transition); }
.table-hover tbody tr:hover { background: var(--border-light); }

/* Contenedor con scroll horizontal: en angosto la tabla scrollea, no colisiona */
.table-scroll { overflow-x: auto; }
.table-scroll .table { min-width: 760px; }

/* Columnas numéricas: aire extra a la derecha para que el número no se pegue
   a la columna de texto que le sigue. Se aplica a toda tabla del sistema. */
.table .text-right { text-align: right; padding-right: 30px; }
.table .text-center { text-align: center; }

.row-highlight { background: var(--primary-light) !important; }
[data-theme="dark"] .row-highlight { background: rgba(145,85,255,0.14) !important; }

/* Items table inside form */
.items-table-wrap { overflow-x: auto; }
.items-table th, .items-table td { padding: 8px 12px; }

/* =============================================
   FILTERS
   ============================================= */
.filters-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.filter-group .input { min-width: 160px; }

.filter-actions { display: flex; gap: 6px; align-items: center; padding-bottom: 1px; }

/* =============================================
   SUMMARY CHIPS
   ============================================= */
.summary-chips {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: 600;
}
.chip svg { width: 13px; height: 13px; }
.chip-purple { background: var(--primary-light); color: var(--primary); }
.chip-blue   { background: var(--info-light);    color: var(--info); }
.chip-gray   { background: var(--border-light);  color: var(--text-secondary); }
.chip-green  { background: var(--success-light); color: var(--success-text); }
.chip-red    { background: var(--danger-light);  color: var(--danger-text); }
.chip-orange { background: var(--warning-light); color: var(--warning-text); }

/* ── Searchable product dropdown (global, fixed to body via JS) ── */
.product-dd {
  display: none;
  position: fixed;
  z-index: 9999;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  max-height: 260px;
  overflow-y: auto;
  min-width: 240px;
}
.product-dd-item {
  padding: 7px 12px;
  font-size: 0.83rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  line-height: 1.3;
  color: var(--text);
}
.product-dd-item:last-child { border-bottom: none; }
.product-dd-item:hover,
.product-dd-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.product-dd-empty {
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Price margin badges (used in prices module) ── */
.price-margin-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.margin-good { background: var(--success-light); color: var(--success-text); }
.margin-ok   { background: var(--warning-light); color: var(--warning-text); }
.margin-low  { background: var(--danger-light); color: var(--danger-text); }

/* =============================================
   TOTALS CARD
   ============================================= */
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border-light);
}
.total-row:last-child { border-bottom: none; }
.total-row-final {
  padding-top: 12px;
  font-weight: 700;
  font-size: var(--text-md);
}
.total-amount {
  font-size: 18px; font-weight: 800;
  color: var(--primary); letter-spacing: -0.5px;
}

/* =============================================
   ESTADO DE RESULTADOS — hoja contable
   ============================================= */
.stmt-draft-banner {
  display: flex; align-items: center; gap: 12px;
  max-width: 760px; margin: 0 auto 18px;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 10%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
  color: var(--text-secondary); font-size: var(--text-sm);
}
.stmt-draft-banner b { color: var(--warning-text); }
.stmt-draft-banner svg { width: 18px; height: 18px; color: var(--warning-text); flex: none; }
.stmt-draft .stmt-sheet { opacity: 0.85; }
.stmt-pager { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 22px; }
.stmt-pager-btn {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.stmt-pager-btn:hover { background: var(--border-light); color: var(--text-primary); }
.stmt-pager-btn.disabled { opacity: 0.3; pointer-events: none; }
.stmt-pager-btn svg { width: 18px; height: 18px; }
.stmt-pager-center { text-align: center; min-width: 150px; }
.stmt-pager-month { font-size: var(--text-lg); font-weight: 600; }
.stmt-pager-range { font-size: var(--text-sm); color: var(--text-muted); margin-top: 1px; }

.stmt-wrap { position: relative; max-width: 840px; margin: 0 auto; }
.stmt-stack {
  position: absolute; inset: 0; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.stmt-stack-1 { transform: translate(3px, 3px); }
.stmt-stack-2 { transform: translate(6px, 6px); }
.stmt-sheet {
  position: relative; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 40px 52px; box-shadow: var(--shadow-xs);
}

.stmt-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.stmt-title { font-size: 22px; font-weight: 600; }
.stmt-period { font-size: var(--text-md); color: var(--text-muted); margin-top: 2px; }
.stmt-tc { text-align: right; font-size: var(--text-sm); color: var(--text-muted); }
.stmt-tc b { display: block; font-size: var(--text-lg); color: var(--text-primary); font-weight: 600; margin-top: 1px; }

/* columnas: etiqueta flexible + USD + ARS alineadas a la derecha */
.stmt-c1   { flex: 1; min-width: 0; padding-right: 12px; }
.stmt-c-usd { width: 155px; text-align: right; flex-shrink: 0; white-space: nowrap; }
.stmt-c-ars { width: 205px; text-align: right; flex-shrink: 0; white-space: nowrap; }
.stmt-colhead { display: flex; padding: 8px 0; border-bottom: 2px solid var(--text-primary); margin-bottom: 4px; }
.stmt-colhead .h { font-size: var(--text-xs); letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); }

.stmt-section {
  font-size: var(--text-sm); letter-spacing: 1px; color: var(--text-muted);
  text-transform: uppercase; margin: 24px 0 8px;
}
.stmt-section.first { margin-top: 16px; }
.stmt-row { display: flex; align-items: baseline; padding: 6px 0; font-size: var(--text-lg); }
.stmt-note { font-size: var(--text-base); color: var(--text-muted); padding: 0 0 6px; }
.stmt-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-amt.neg { color: var(--danger); }
.stmt-amt.pos { color: var(--success); }
.stmt-subtotal { border-top: 0.5px solid var(--border); margin-top: 6px; padding: 12px 0 4px; font-weight: 600; }
.stmt-group { padding: 5px 0; font-size: var(--text-lg); font-weight: 600; }
.stmt-group.mt { margin-top: 12px; }
.stmt-item { padding: 4px 0 4px 20px; font-size: 15px; color: var(--text-secondary); }
.stmt-pct { color: var(--text-muted); font-weight: 400; font-size: var(--text-sm); margin-left: 6px; }
.stmt-result {
  display: flex; align-items: baseline;
  border-top: 2px solid var(--text-primary); margin-top: 24px; padding-top: 18px;
}
.stmt-result-label { font-size: var(--text-xl); font-weight: 600; }
.stmt-result-sub { font-size: var(--text-base); color: var(--text-muted); margin-top: 2px; }
.stmt-result-amt { font-variant-numeric: tabular-nums; font-size: 23px; font-weight: 600; white-space: nowrap; }
.stmt-foot { font-size: var(--text-base); color: var(--text-muted); margin-top: 24px; }

@media print {
  .sidebar, .topbar, .sidebar-backdrop, .no-print, .breadcrumb { display: none !important; }
  .layout, .main { display: block !important; margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff; }
  .stmt-stack { display: none; }
  .stmt-sheet { border: none; box-shadow: none; padding: 0; }
  .stmt-wrap { max-width: 100%; }
  .page-header { margin-bottom: 12px; }
}

/* =============================================
   DASHBOARD — centro de mando
   ============================================= */
/* Selector de fechas unificado (dashboard + reportes) */
.datefilter { position: relative; display: inline-flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.datefilter-pills {
  display: inline-flex; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 3px; gap: 2px; box-shadow: var(--shadow-xs);
}
.datefilter-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 600; color: var(--text-muted);
  text-decoration: none; border: none; background: transparent; cursor: pointer;
  white-space: nowrap; transition: all var(--transition);
}
.datefilter-pill:hover { color: var(--text-primary); background: var(--border-light); }
.datefilter-pill.active { background: var(--primary); color: #fff; box-shadow: var(--glow-primary); }

/* botón "Personalizado" standalone, separado de los presets */
.datefilter-custom {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--card-bg); box-shadow: var(--shadow-xs);
  font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary);
  cursor: pointer; white-space: nowrap; transition: all var(--transition);
}
.datefilter-custom:hover { background: var(--border-light); color: var(--text-primary); }
.datefilter-custom.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--glow-primary); }
.datefilter-custom svg { width: 15px; height: 15px; }

.datefilter-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 16px; width: 260px; max-width: calc(100vw - 32px);
  z-index: 50; display: none;
}
.datefilter-pop.open { display: block; }
.datefilter-pop-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 12px; }
.datefilter-field { font-size: var(--text-sm); color: var(--text-secondary); display: flex; flex-direction: column; gap: 5px; }
.datefilter-field input { width: 100%; }
@media (max-width: 560px) {
  .datefilter, .datefilter-pills { width: 100%; }
  .datefilter-pop { width: 100%; }
}

.dash-alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 24px; }
.dash-alert {
  display: block; text-decoration: none;
  background: var(--card-bg); border: 1px solid var(--border);
  border-left: 3px solid var(--border); border-radius: var(--radius-lg);
  padding: 14px 16px; transition: box-shadow var(--transition), transform var(--transition);
}
.dash-alert:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.dash-alert-top { display: flex; justify-content: space-between; align-items: center; }
.dash-alert-top .ic {
  width: 30px; height: 30px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--border-light); color: var(--text-muted);
}
.dash-alert-top .ic svg { width: 16px; height: 16px; }
.dash-alert-top svg { width: 16px; height: 16px; }
.dash-alert-num { font-size: var(--text-2xl); font-weight: 700; margin-top: 10px; color: var(--text-primary); letter-spacing: -0.5px; }
.dash-alert-num.sm { font-size: var(--text-xl); }
.dash-alert-label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.dash-alert.warn   { border-color: color-mix(in srgb, var(--warning) 40%, var(--border)); border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, var(--card-bg)); }
.dash-alert.warn   .ic { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning-text); }
.dash-alert.warn   .dash-alert-num { color: var(--warning-text); }
.dash-alert.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--card-bg)); }
.dash-alert.danger .ic { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger-text); }
.dash-alert.danger .dash-alert-num { color: var(--danger-text); }
.dash-alert.info   { border-color: color-mix(in srgb, var(--info) 40%, var(--border)); border-left-color: var(--info); background: color-mix(in srgb, var(--info) 9%, var(--card-bg)); }
.dash-alert.info   .ic { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info-text); }
.dash-alert.info   .dash-alert-num { color: var(--info-text); }
.dash-alert.success { border-color: color-mix(in srgb, var(--success) 40%, var(--border)); border-left-color: var(--success); background: color-mix(in srgb, var(--success) 9%, var(--card-bg)); }
.dash-alert.success .ic { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success-text); }
.dash-alert.success .dash-alert-num { color: var(--success-text); }
.dash-alert.muted  { border-left-color: var(--border); }
.dash-alert.muted  .dash-alert-num { color: var(--text-muted); font-weight: 600; }
.dash-section-label { font-size: var(--text-xs); letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.dash-sep { border: none; border-top: 1px solid var(--border); margin: 2px 0 26px; }

/* Panel de métricas con comparación de período (estilo analítico) */
.metricpanel {
  background: linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-inner-light), var(--shadow-xs);
  padding: 6px 26px 22px; margin-bottom: 24px;
}
.cval[hidden] { display: none !important; }
.metric-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 18px 4px 16px; flex-wrap: wrap;
}
.metric-head .datefilter { margin-bottom: 0; }
.metric-cur { display: inline-flex; background: var(--border-light); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.cur-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 4px 14px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.3px;
  color: var(--text-muted); transition: all var(--transition);
}
.cur-btn:hover { color: var(--text-primary); }
.cur-btn.active { background: var(--card-bg); color: var(--primary-text); box-shadow: var(--glow-ring), var(--glow-primary); }
.metric-tabs {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.metric-tab {
  text-align: left; background: none; border: none; cursor: pointer;
  padding: 16px 18px 14px; border-bottom: 2px solid transparent;
  transition: background var(--transition); border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.metric-tab + .metric-tab { border-left: 1px solid var(--border); }
.metric-tab:hover { background: var(--border-light); }
.metric-tab.active { border-bottom-color: var(--primary); }
.metric-label { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin-bottom: 7px; }
.metric-tab.active .metric-label { color: var(--primary-text); }
.metric-val { display: block; font-size: var(--text-2xl); font-weight: 700; color: var(--text-primary); line-height: 1; }
.metric-tab:not(.active) .metric-val { color: var(--text-secondary); font-weight: 600; }
.metric-delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--text-xs); font-weight: 600; margin-top: 8px; }
.metric-delta svg { width: 13px; height: 13px; }
.metric-delta.up   { color: var(--success-text); }
.metric-delta.down { color: var(--danger-text); }
.metric-delta.flat, .metric-delta.muted { color: var(--text-muted); font-weight: 500; }
.metric-chart { height: 240px; position: relative; }
.metric-legend { display: flex; gap: 22px; margin-top: 12px; padding-left: 6px; flex-wrap: wrap; }
.metric-leg { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--text-secondary); }
.metric-leg .ln { width: 22px; height: 0; display: inline-block; }
.metric-leg .ln.solid  { border-top: 2px solid var(--primary); }
.metric-leg .ln.dashed { border-top: 2px dashed var(--primary); opacity: 0.6; }
.metric-leg-range { color: var(--text-muted); }
@media (max-width: 640px) {
  .metricpanel { padding: 4px 14px 16px; }
  .metric-tabs { grid-template-columns: repeat(2, 1fr); border-bottom: none; }
  .metric-tab { border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 3px; }
  .metric-tab + .metric-tab { border-left: 1px solid var(--border); }
  .metric-val { font-size: var(--text-xl); }
}

/* Cierres de mensajería */
.cierre-aviso {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 16px; margin-bottom: 20px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warning) 10%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
  font-size: var(--text-sm); color: var(--text-secondary);
}
.cierre-aviso svg { width: 18px; height: 18px; color: var(--warning-text); flex: none; margin-top: 1px; }
.cierre-aviso b { color: var(--warning-text); }
.cierre-aviso-chip {
  display: inline-block; margin: 4px 6px 0 0; padding: 3px 10px;
  border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600;
  background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning-text);
}
.cierre-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 24px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.cierre-notes { flex: 1; min-width: 220px; }
.cierre-total {
  text-align: right; padding: 12px 20px;
  background: var(--aurora), linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-inner-light), var(--shadow-xs);
}
.cierre-total-label { display: block; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.cierre-total-num { display: block; font-size: 26px; font-weight: 700; color: var(--primary-text); letter-spacing: -0.5px; margin: 2px 0; }
.cierre-total-sub { display: block; font-size: var(--text-xs); color: var(--text-muted); }
.btn-lg { padding: 12px 22px; font-size: var(--text-base); }
.cierre-mini-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border-light);
  text-decoration: none; transition: background var(--transition);
}
.cierre-mini-row:hover { background: var(--border-light); }
.cierre-mini-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cierre-mini-name { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }
.cierre-mini-range { font-size: var(--text-xs); color: var(--text-muted); }
.cierre-mini-total { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); flex: none; }

/* Pestañas de Reportes */
.report-tabs {
  display: inline-flex; gap: 4px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 4px; margin-bottom: 20px;
}
.report-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 15px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 500; text-decoration: none;
  color: var(--text-secondary); transition: all var(--transition);
}
.report-tab svg { width: 16px; height: 16px; }
.report-tab:hover { background: var(--border-light); color: var(--text-primary); }
.report-tab.active { background: var(--primary); color: #fff; box-shadow: var(--glow-primary); }
.report-tab.active svg { color: #fff; }

/* =============================================
   SHELL MODERNO DE PÁGINA (header compacto + toolbar + stats inline)
   ============================================= */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head-text { min-width: 0; }
.page-head .page-title { margin: 0; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.page-head .page-sub { margin: 3px 0 0; }
.page-count { font-size: var(--text-sm); color: var(--text-muted); font-weight: 400; }
.page-head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.btn-plain {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border: none; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-secondary); font-size: var(--text-base); font-weight: 500;
  transition: all var(--transition); white-space: nowrap;
}
.btn-plain:hover { background: var(--border-light); color: var(--text-primary); }
.btn-plain svg { width: 15px; height: 15px; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-xs);
  padding: 6px 8px; margin-bottom: 14px;
}
.seg { display: inline-flex; background: var(--border-light); border-radius: 9px; padding: 2px; gap: 1px; }
.seg-item {
  padding: 6px 12px; border-radius: 7px;
  /* reset para que funcione igual como <a> (Stock, Envíos, Ventas) o <button> */
  border: none; background: transparent; cursor: pointer; font-family: inherit;
  font-size: var(--text-sm); font-weight: 500; color: var(--text-secondary);
  white-space: nowrap; transition: all var(--transition);
}
.seg-item:hover { color: var(--text-primary); }
.seg-item.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: var(--glow-primary); }

.chip-select {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--card-bg);
  color: var(--text-secondary); font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.chip-select:hover { border-color: var(--text-muted); color: var(--text-primary); }
.chip-select.chip-active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--glow-primary); }

.toolbar-search { flex: 1; min-width: 160px; display: flex; align-items: center; gap: 7px; margin: 0; padding: 0 10px; color: var(--text-muted); }
.toolbar-search svg { width: 15px; height: 15px; flex-shrink: 0; }
.toolbar-search input {
  border: none; background: transparent; width: 100%;
  font-size: var(--text-sm); color: var(--text-primary);
  outline: none; padding: 8px 0; font-family: var(--font);
}
.toolbar-search input::placeholder { color: var(--text-muted); }

.tb-period { position: relative; }
.tb-pop {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 300px; max-width: calc(100vw - 32px);
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 6px; z-index: 60; display: none;
}
.tb-pop.open { display: block; }
.tb-opt {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-secondary);
  transition: background var(--transition);
}
.tb-opt:hover { background: var(--border-light); color: var(--text-primary); }
.tb-opt.active { background: var(--primary-light); color: var(--primary-text); font-weight: 600; }
.tb-divider { height: 1px; background: var(--border); margin: 6px 4px; }
.tb-pop form { padding: 4px 8px 8px; }
.tb-pop-title { font-size: var(--text-xs); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; }
/* min-width:0 es lo que permite que los <input type="date"> se achiquen dentro del
   flex: sin esto no bajan de su ancho intrínseco, se desbordan y corren la página. */
.tb-field { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--text-muted); font-weight: 600; }
.tb-field .input { width: 100%; min-width: 0; }

.stat-strip { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin: 0 2px 14px; }
.stat-strip .stat { display: inline-flex; align-items: baseline; gap: 7px; font-size: var(--text-sm); color: var(--text-secondary); }
.stat-strip b { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; align-self: center; flex-shrink: 0; }

/* Barra filtro + toggle de moneda (pestañas de reportes) */
.filterbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px;
}
.filterbar .datefilter { margin-bottom: 0; }
.cval-page[hidden] { display: none !important; }

/* Tabla expandible por modelo (Reportes → Productos) */
.model-row { cursor: pointer; }
.model-row:hover { background: var(--border-light); }
.model-chev { transition: transform var(--transition); }
.model-row.open .model-chev { transform: rotate(90deg); }
.flavor-row { background: var(--border-light); }
.flavor-row[hidden] { display: none !important; }

/* Feed de ventas recientes */
.feed { display: flex; flex-direction: column; }
.feed-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 2px;
  border-bottom: 1px solid var(--border-light); text-decoration: none;
  transition: background var(--transition);
}
.feed-row:last-child { border-bottom: none; }
.feed-row:hover { background: var(--border-light); }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-muted); }
.feed-dot.status-completada, .feed-dot.status-cobrado { background: var(--success); }
.feed-dot.status-pendiente, .feed-dot.status-pendiente_aprobacion { background: var(--warning); }
.feed-dot.status-en_envio { background: var(--info); }
.feed-dot.status-cancelada { background: var(--danger); }
.feed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.feed-title { font-size: var(--text-sm); color: var(--text-primary); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-sub { font-size: var(--text-xs); color: var(--text-muted); }
.feed-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.feed-amount { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }

/* Barras de ranking (top modelos) */
.rankbars { display: flex; flex-direction: column; gap: 14px; }
.rankbar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.rankbar-name { font-size: var(--text-sm); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rankbar-stats { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; flex: none; }
.rankbar-track { height: 7px; background: var(--border-light); border-radius: var(--radius-pill); overflow: hidden; }
.rankbar-fill { height: 100%; background: var(--primary); border-radius: var(--radius-pill); transition: width var(--transition); }
.rankbar-fill.dim { background: color-mix(in srgb, var(--primary) 60%, var(--card-bg)); }

/* Stat en el header de una card (ej: capital en stock) */
.card-headright { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.card-headstat { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-sm); color: var(--text-secondary); }
.card-headstat svg { width: 15px; height: 15px; color: var(--text-muted); }
.card-headstat b { color: var(--text-primary); font-weight: 700; }

/* Grilla de stock bajo con barra de nivel */
.stockgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 28px; }
.stockrow { display: flex; align-items: center; gap: 14px; }
.stockrow-info { flex: 1; min-width: 0; }
.stockrow-name { font-size: var(--text-sm); color: var(--text-primary); display: block; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stockrow-track { height: 6px; background: var(--border-light); border-radius: var(--radius-pill); overflow: hidden; }
.stockrow-fill { height: 100%; border-radius: var(--radius-pill); }
.stockrow-fill.zero, .stockrow-fill.crit { background: var(--danger); }
.stockrow-fill.low { background: var(--warning); }
.stockrow-qty { font-size: var(--text-sm); font-weight: 600; min-width: 38px; text-align: right; flex: none; }
.stockrow-qty.zero, .stockrow-qty.crit { color: var(--danger-text); }
.stockrow-qty.low { color: var(--warning-text); }

/* =============================================
   TENDENCIA MENSUAL (reportes)
   ============================================= */
.trend-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.tl-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.tl-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.tl-swatch.ing  { background: var(--chart-1); }
.tl-swatch.neto { background: var(--success); }
.tl-swatch.mgn  { background: var(--chart-4); border-radius: 50%; }
.trend-note { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; font-size: 12.5px; color: var(--text-muted); }
.trend-note svg { width: 15px; height: 15px; flex: none; }

.trend-strip { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.trend-mcard {
  flex: 0 0 auto; min-width: 156px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px;
}
.trend-mcard.current {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 10%, transparent);
}
.trend-mcard-head {
  font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: capitalize;
  display: flex; align-items: center; gap: 6px; margin-bottom: 8px;
}
.pill-prov {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 6px; border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning-text);
}
.trend-mcard-ing { font-size: 19px; font-weight: 800; color: var(--text-primary); letter-spacing: -.5px; }
.trend-mcard-row { display: flex; align-items: center; gap: 9px; margin: 5px 0 9px; }
.trend-mom { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; }
.trend-mom svg { width: 13px; height: 13px; }
.trend-mom.up   { color: var(--success-text); }
.trend-mom.down { color: var(--danger-text); }
.trend-mom.flat { color: var(--text-muted); }
.trend-mcard-mgn { font-size: 11.5px; color: var(--text-muted); }
.trend-mcard-neto {
  font-size: 12.5px; color: var(--text-secondary);
  border-top: 1px solid var(--border-light); padding-top: 9px;
}
.trend-mcard-neto b { font-weight: 700; }

.bubble-legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.tl-ring { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--text-muted); flex: none; }

/* Ranking de categorías de gasto */
.catrank { display: flex; flex-direction: column; gap: 14px; }
.catrank-row { display: flex; align-items: center; gap: 12px; }
.catrank-icon {
  flex: none; width: 34px; height: 34px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
}
.catrank-icon svg { width: 17px; height: 17px; }
.catrank-main { flex: 1; min-width: 0; }
.catrank-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.catrank-name { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.catrank-amt { font-size: var(--text-sm); font-weight: 700; color: var(--text-primary); flex: none; }
.catrank-track { height: 8px; background: var(--border-light); border-radius: var(--radius-pill); overflow: hidden; }
.catrank-fill { height: 100%; border-radius: var(--radius-pill); transition: width var(--transition); }

/* =============================================
   DASHBOARD SHELL — una pantalla, sin scroll
   ============================================= */
.content.content-dash { padding: 14px 16px; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.dsh {
  flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 13px;
  background: var(--page-bg); background-image: var(--aurora);
  border: 1px solid var(--border); border-radius: 16px; padding: 16px 20px;
  /* tratamiento de card del sistema, reutilizado por todas las piezas internas */
  --card-fill: linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
}

/* Header del shell: título | filtro centrado | moneda */
.dsh-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; flex: none; }
.dsh-title h1 { font-size: 19px; font-weight: 800; letter-spacing: -.3px; color: var(--text-primary); }
.dsh-title p { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.dsh-filter { justify-self: center; }
.dsh-head .metric-cur { justify-self: end; }
.dsh-filter .datefilter-pill, .dsh-filter .datefilter-custom { padding: 5px 11px; font-size: 12px; }

/* KPIs (5 en fila) — cada métrica con su color: delineado + aura + ícono */
.dsh-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; flex: none; }
.kcard {
  --kc: var(--primary);
  border-radius: 13px; padding: 14px; min-width: 0;
  border: 1px solid var(--border); border-top-color: var(--card-border-top);
  background: var(--card-fill);
  box-shadow: var(--card-inner-light), var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.kcard:hover { box-shadow: var(--card-inner-light), var(--shadow-md); }
.kcard.k1 { --kc: var(--primary); }
.kcard.k2 { --kc: var(--success); }
.kcard.k3 { --kc: var(--info); }
.kcard.k4 { --kc: var(--warning); }
.kcard.k5 { --kc: #ec4899; }
.kcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.kcard-ic {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex: none;
  background: color-mix(in srgb, var(--kc) 15%, transparent); color: var(--kc);
}
.kcard-ic svg { width: 17px; height: 17px; }
.kcard-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard-val { font-size: 23px; font-weight: 700; letter-spacing: -.6px; color: var(--text-primary); line-height: 1.05; white-space: nowrap; }
.kcard-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; min-height: 20px; }
.kcard-spark { height: 26px; margin-top: 10px; }
.kcard-spark svg { display: block; width: 100%; height: 100%; }
.kd { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; }
.kd svg { width: 12px; height: 12px; }
.kd.up   { color: var(--success-text); background: color-mix(in srgb, var(--success) 12%, transparent); }
.kd.down { color: var(--danger-text);  background: color-mix(in srgb, var(--danger) 12%, transparent); }
.kd.flat { color: var(--text-muted);    background: color-mix(in srgb, var(--text-muted) 14%, transparent); }

/* Atención + salud */
.dsh-status { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 18px; flex: none; }
.dsh-glabel { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }
.att-row { display: flex; gap: 10px; }
.att-row .acard { flex: 1; }
.acard {
  --at: var(--border);
  display: flex; gap: 10px; align-items: center; min-height: 74px;
  border: 1px solid var(--border); border-top-color: var(--card-border-top);
  border-radius: 12px;
  padding: 10px 13px; min-width: 0; background: var(--card-fill);
  box-shadow: var(--card-inner-light), var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}
.acard.danger  { --at: var(--danger); }
.acard.warn    { --at: var(--warning); }
.acard.info    { --at: var(--info); }
.acard.success, .acard.ok { --at: var(--success); }
a.acard:hover { transform: translateY(-1px); box-shadow: var(--card-inner-light), var(--shadow-md); }
.acard-ic { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.acard-ic svg { width: 16px; height: 16px; }
.acard.danger  .acard-ic { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger-text); }
.acard.warn    .acard-ic { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning-text); }
.acard.info    .acard-ic { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info-text); }
.acard.success .acard-ic, .acard.ok .acard-ic { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success-text); }
.att-row .acard.ok { align-items: center; }
.acard-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acard-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.acard-link { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--primary); }
.acard-link svg { width: 12px; height: 12px; }
.acard-link.muted { color: var(--text-muted); }
/* Salud del negocio: un solo bloque con las 4 métricas divididas por hairlines */
.salud-block {
  display: flex; align-items: stretch; height: 74px; overflow: hidden;
  background: var(--card-fill); border: 1px solid var(--border); border-top-color: var(--card-border-top);
  border-radius: 12px; box-shadow: var(--card-inner-light), var(--shadow-sm);
}
.salud-item {
  flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 0 16px; border-left: 1px solid var(--border-light);
}
.salud-item:first-child { border-left: none; }
.scard-ic { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex: none; }
.scard-ic svg { width: 15px; height: 15px; }
.scard-ic.pos  { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success-text); }
.scard-ic.neg  { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger-text); }
.scard-ic.warn { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning-text); }
.scard-ic.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info-text); }
.scard-ic.prim { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.scard-body { min-width: 0; }
.scard-label { font-size: 11.5px; color: var(--text-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scard-val { font-size: 18px; font-weight: 700; letter-spacing: -.4px; color: var(--text-primary); white-space: nowrap; }

/* Filas de paneles */
.dsh-mid { flex: 1.15 1 0; min-height: 0; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }
.dsh-bottom { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dcard {
  background: var(--card-fill); border: 1px solid var(--border); border-top-color: var(--card-border-top);
  border-radius: 12px; box-shadow: 0 4px 12px -9px rgba(20,16,40,0.5), var(--card-inner-light);
  padding: 12px 14px; display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.dcard-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex: none; }
.dcard-head h3 { font-size: 13px; font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 7px; }
.dcard-head h3 svg { width: 15px; height: 15px; color: var(--text-muted); }
.dcard-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.dcard-link svg { width: 12px; height: 12px; }
.dcard-body { flex: 1; min-height: 0; }
.dcard-body.chartfill { position: relative; }
.dcard-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; flex: none; }
.tl-dash { width: 18px; border-top: 2px dashed color-mix(in srgb, var(--chart-1) 55%, transparent); flex: none; }

/* Ventas por modelo (barras finas) */
.tm-rows { display: flex; flex-direction: column; justify-content: flex-start; gap: 14px; padding-top: 8px; }
.tm-row { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tm-rank { flex: none; width: 14px; text-align: center; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.tm-name { flex: 0 0 34%; font-size: 12.5px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-bar { flex: 1; height: 6px; background: var(--border-light); border-radius: var(--radius-pill); overflow: hidden; }
.tm-bar > div { height: 100%; background: var(--primary); border-radius: var(--radius-pill); }
.tm-units { flex: none; font-size: 12.5px; font-weight: 700; color: var(--text-primary); min-width: 24px; text-align: right; }
.tm-pct { flex: none; font-size: 12px; color: var(--text-muted); min-width: 36px; text-align: right; }
.tm-row.otros .tm-name { color: var(--text-muted); }
.tm-row.otros .tm-bar > div { background: color-mix(in srgb, var(--primary) 40%, transparent); }

/* =============================================
   ESTADO DE RESULTADOS 2.0
   ============================================= */
.er-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.er-head-left { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.er-head-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.er-pager { display: inline-flex; align-items: center; gap: 10px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; }
.er-pager-month { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.er-pager-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; color: var(--text-secondary); }
.er-pager-btn:hover { background: var(--border-light); color: var(--text-primary); }
.er-pager-btn.disabled { color: var(--text-muted); opacity: 0.4; pointer-events: none; }
.er-pager-btn svg { width: 18px; height: 18px; }

.er-banner { display: flex; align-items: center; gap: 11px; background: color-mix(in srgb, var(--warning) 10%, var(--card-bg)); border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border)); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 18px; font-size: 14px; color: var(--text-secondary); }
.er-banner svg { width: 19px; height: 19px; color: var(--warning-text); flex: none; }
.er-banner b { color: var(--text-primary); }

/* KPIs del ER: cards anchas (3 por fila) → tipografía a escala de pantalla */
.er-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
@media (max-width: 720px) { .er-kpis { grid-template-columns: 1fr; } }
.er-kpis .kcard { padding: 17px 19px; }
.er-kpis .kcard-top { gap: 10px; margin-bottom: 13px; }
.er-kpis .kcard-ic { width: 38px; height: 38px; border-radius: 11px; }
.er-kpis .kcard-ic svg { width: 20px; height: 20px; }
.er-kpis .kcard-label { font-size: 14px; }
.er-kpis .kcard-val { font-size: 30px; letter-spacing: -.8px; }
.er-kpis .kcard-foot { margin-top: 12px; min-height: 24px; }
.er-kpis .kd { font-size: 13px; padding: 4px 11px; gap: 4px; }
.er-kpis .kd svg { width: 14px; height: 14px; }
.er-margin { margin-left: auto; font-size: 16px; font-weight: 800; padding: 5px 12px; border-radius: 20px; letter-spacing: -.2px; color: var(--text-muted); }
.er-kpis .kcard.k3 .er-margin { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info-text); }
.er-kpis .kcard.k2.er-pos .er-margin { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success-text); }
.er-kpis .kcard.k2.er-loss .er-margin { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger-text); }
.er-vs { font-size: 13px; color: var(--text-muted); }
.kcard.er-pos {
  border-color: color-mix(in srgb, var(--success) 30%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--success) 9%, var(--card-bg)) 0%, var(--card-bg) 70%);
}
.kcard.er-loss {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 9%, var(--card-bg)) 0%, var(--card-bg) 70%);
}
.kcard.er-loss .kcard-ic { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger-text); }

/* Recorrido del ER: spine con operadores +/−/= */
.er-neg { color: var(--danger-text); }
.erflow { position: relative; }
.erflow::before { content: ''; position: absolute; left: 20px; top: 24px; bottom: 24px; width: 2px; background: var(--border); z-index: 0; }
.ef-step { position: relative; z-index: 1; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 16px; padding: 13px 0; }
.ef-badge { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--card-bg); border: 2px solid var(--sc, var(--border)); color: var(--sc, var(--text-muted)); flex: none; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.ef-badge svg { width: 18px; height: 18px; }
.ef-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.ef-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.ef-amt { text-align: right; }
.ef-amt-val { font-size: 19px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; color: var(--text-primary); white-space: nowrap; }
.ef-amt-val.neg { color: var(--danger-text); }
.ef-amt-cap { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.ef-step.checkpoint { margin: 0 -20px; padding: 14px 20px; border-radius: 10px; background: color-mix(in srgb, var(--sc) 8%, transparent); }
.ef-step.checkpoint .ef-title { font-weight: 800; }
.ef-step.final { margin: 10px -20px -18px; padding: 22px 20px 26px; border-radius: 14px; background: color-mix(in srgb, var(--sc) 12%, transparent); border: 1px solid color-mix(in srgb, var(--sc) 32%, var(--border)); }
.ef-step.final .ef-badge { width: 46px; height: 46px; }
.ef-step.final .ef-badge svg { width: 21px; height: 21px; }
.ef-step.final .ef-title { font-size: 19px; }
.ef-step.final .ef-amt-val { font-size: 30px; color: var(--sc); }
.ef-step.final .ef-amt-cap { font-size: 13px; font-weight: 600; color: var(--sc); }
.ef-breakdown { margin: 2px 0 10px 56px; padding-left: 19px; border-left: 2px dashed var(--border); position: relative; z-index: 1; }
.ef-group { background: color-mix(in srgb, var(--text-primary) 3%, transparent); border-radius: 10px; padding: 11px 14px; margin-bottom: 8px; }
.ef-group:last-child { margin-bottom: 0; }
.ef-group-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 700; color: var(--text-primary); letter-spacing: -.1px; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border-light); }
.ef-group-head .ef-pct { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-left: 7px; }
.ef-group-amt { font-size: 13.5px; font-weight: 700; color: var(--danger-text); font-variant-numeric: tabular-nums; }
.ef-item { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 13.5px; line-height: 1.5; color: var(--text-secondary); }
.ef-item .amt { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-primary); }
@media (max-width: 760px) { .ef-step { grid-template-columns: 36px 1fr; grid-template-areas: "ic tt" "amt amt"; row-gap: 6px; } .ef-step > .ef-amt { grid-area: amt; text-align: left; } }

/* Quién te debe (mini tabla) */
.dt-head, .dt-row { display: grid; grid-template-columns: minmax(0, 1fr) 92px 108px; gap: 10px; align-items: center; }
.dt-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-muted); padding-bottom: 6px; border-bottom: 1px solid var(--border-light);
}
.dt-head span:not(:first-child) { text-align: right; }
.dt-row { padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: 12.5px; }
.dt-row:last-child { border-bottom: none; }
.dt-row:hover .dt-name { color: var(--primary); }
.dt-name { font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-amt { font-weight: 700; color: var(--text-primary); text-align: right; white-space: nowrap; }
.dt-days { color: var(--text-muted); font-size: 12px; text-align: right; white-space: nowrap; }
.dt-days.cold { color: var(--warning-text); font-weight: 600; }

/* Estado de pedidos (donut) */
.pd-wrap { display: flex; align-items: center; gap: 14px; height: 100%; }
.pd-donut { position: relative; width: 112px; height: 112px; flex: none; }
.pd-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.pd-center b { font-size: 19px; font-weight: 800; color: var(--text-primary); line-height: 1; }
.pd-center span { font-size: 10px; color: var(--text-muted); }
.pd-legend { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.pd-leg { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.pd-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.pd-name { flex: 1; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-count { font-weight: 700; color: var(--text-primary); }
.pd-pct { color: var(--text-muted); min-width: 32px; text-align: right; }

.dsh-empty { display: flex; align-items: center; justify-content: center; gap: 8px; height: 100%; color: var(--text-muted); font-size: 12.5px; }
.dsh-empty svg { width: 16px; height: 16px; }
.dsh-empty.ok svg { color: var(--success); }

/* Fallback: pantallas chicas → scroll normal */
@media (max-width: 1150px), (max-height: 700px) {
  .content.content-dash { height: auto; overflow: auto; }
  .dsh { display: block; }
  .dsh > * + * { margin-top: 12px; }
  .dsh-head { display: flex; flex-wrap: wrap; }
  .dsh-filter, .dsh-head .metric-cur { justify-self: auto; }
  .dsh-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .dsh-status, .dsh-mid, .dsh-bottom { grid-template-columns: 1fr; }
  .dcard-body.chartfill { height: 240px; }
}

/* =============================================
   CONFIG (navegación por secciones)
   ============================================= */
.config-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 20px;
  align-items: start;
}
.config-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 72px;
}
.config-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border: none; background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-md); font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer; text-align: left;
  transition: all var(--transition);
}
.config-nav-item svg { width: 17px; height: 17px; }
.config-nav-item:hover { background: var(--border-light); color: var(--text-primary); }
.config-nav-item.active { background: var(--primary-light); color: var(--primary); }
.config-section { display: none; }
.config-section.active { display: block; }
@media (max-width: 720px) {
  .config-layout { grid-template-columns: 1fr; }
  .config-nav { flex-direction: row; flex-wrap: wrap; position: static; }
}

/* =============================================
   ACCOUNT CARDS (saldo del revendedor)
   ============================================= */
.account-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.account-card {
  background: var(--aurora), linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--card-inner-light), var(--shadow-xs);
}
.account-card-label { font-size: var(--text-base); color: var(--text-secondary); }
.account-card-value {
  font-size: var(--text-2xl); font-weight: 700;
  letter-spacing: -0.5px; margin-top: 4px;
}
.account-card-positive {
  background: var(--success-light);
  border-color: var(--success);
}
.account-card-positive .account-card-label,
.account-card-positive .account-card-value { color: var(--success-text); }
.account-card-negative {
  background: var(--danger-light);
  border-color: var(--danger);
}
.account-card-negative .account-card-label,
.account-card-negative .account-card-value { color: var(--danger-text); }
@media (max-width: 640px) {
  .account-cards { grid-template-columns: 1fr; }
}

/* =============================================
   PEDIDO FOOTER (aprobación de revendedores)
   ============================================= */
/* Franja horizontal de info (envío + nota) */
.pedido-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 24px;
  padding: 11px 18px;
  background: var(--border-light);
  border-top: 1px solid var(--border);
}
.pedido-strip-item {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-base); line-height: 1.4;
}
.pedido-strip-item svg { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }
.pedido-strip-strong { color: var(--text-primary); font-weight: 600; }

/* Bloque de envío legible (detalle de pedido revendedor + aprobaciones).
   Sin fondo propio: se integra a la card y se separa con una línea, para no
   quedar como una franja de color en el medio. */
.ship-box { padding: 14px 18px; border-top: 1px solid var(--border); }
.ship-box-head { display: flex; align-items: center; gap: 7px; font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); margin-bottom: 10px; }
.ship-box-head i, .ship-box-head svg { width: 15px; height: 15px; color: var(--text-muted); }
.ship-box-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 24px; }
.ship-box-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ship-lbl { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.ship-val { font-size: var(--text-base); color: var(--text-primary); word-break: break-word; }
.ship-notes { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: var(--text-sm); color: var(--text-secondary); display: flex; gap: 8px; align-items: flex-start; }
.ship-notes i, .ship-notes svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; margin-top: 2px; }

/* Recibo económico alineado a la derecha */
.pedido-receipt-wrap {
  display: flex;
  justify-content: flex-end;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}
.pedido-receipt { width: 340px; }
.pedido-receipt .total-row { border-bottom: none; padding: 5px 0; }
.pedido-receipt-ship {
  align-items: center;
  border-top: 1px solid var(--border) !important;
  margin-top: 4px; padding-top: 8px !important;
}
.pedido-ship-controls { display: flex; gap: 6px; }
.pedido-ship-controls .input { width: auto; }
.pedido-receipt .total-row-final {
  align-items: baseline;
  border-top: 1px solid var(--border);
  margin-top: 4px; padding-top: 10px;
}
@media (max-width: 560px) {
  .pedido-receipt { width: 100%; }
}

/* =============================================
   DETAIL PAGE
   ============================================= */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: var(--text-base);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-weight: 500; }
.detail-row-total {
  padding-top: 12px;
  font-weight: 700;
}

/* =============================================
   DOLLAR PAGE
   ============================================= */
.dollar-info-card {
  background: linear-gradient(135deg, #1d1929 0%, #33235e 100%);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}
.dollar-info-row {
  display: flex; align-items: center; gap: 12px;
  color: white;
}
.dollar-info-row svg { width: 24px; height: 24px; color: #c7a9ff; }
.dollar-info-label { font-size: var(--text-xs); color: #c7a9ff; font-weight: 500; }
.dollar-info-value { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.5px; }

.dollar-status {
  display: flex; align-items: center; gap: 12px;
}
.dollar-status-icon { width: 28px; height: 28px; }
.dollar-status-title { font-size: var(--text-base); font-weight: 600; }
.dollar-status-value { font-size: var(--text-xl); font-weight: 800; color: var(--success-text); }
.dollar-status-sub { font-size: var(--text-sm); color: var(--text-muted); }

/* =============================================
   FLASH MESSAGES
   ============================================= */
.flash-container {
  margin-bottom: 16px;
  display: flex; flex-direction: column; gap: 8px;
}

.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-base); font-weight: 500;
  transition: opacity 0.4s ease;
}
.flash svg { width: 16px; height: 16px; flex-shrink: 0; }
.flash-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.6; display: flex; align-items: center;
}
.flash-close:hover { opacity: 1; }
.flash-close svg { width: 14px; height: 14px; }

.flash-success { background: var(--success-light); color: var(--success-text); border: 1px solid #a7f3d0; }
.flash-error   { background: var(--danger-light);  color: var(--danger-text); border: 1px solid #fca5a5; }
.flash-info    { background: var(--info-light);    color: var(--info-text); border: 1px solid #93c5fd; }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: 40px 20px; text-align: center;
  gap: 8px;
}
.empty-state.large { padding: 64px 20px; }
.empty-icon {
  width: 40px !important; height: 40px !important;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.empty-state p { font-size: var(--text-base); color: var(--text-muted); max-width: 260px; }

/* =============================================
   UTILITIES
   ============================================= */
.text-muted    { color: var(--text-muted); }
.text-danger   { color: var(--danger); }
.text-green    { color: var(--success); }
.text-sm       { font-size: var(--text-sm); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.link-muted    { color: var(--text-muted); text-decoration: underline; font-size: var(--text-sm); }

/* =============================================
   PERIOD TABS
   ============================================= */
.period-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
  box-shadow: var(--shadow-xs);
}

.period-tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
  white-space: nowrap;
}

.period-tab:hover { color: var(--text-primary); background: var(--border-light); }

.period-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 32%, transparent);
}

/* =============================================
   MONTH SELECTOR (Estado de Resultados)
   ============================================= */
.month-selector {
  margin-bottom: 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Year stepper on the left */
.month-year-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.month-year-current {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  min-width: 48px;
  text-align: center;
}

.month-year-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}

.month-year-btn:not(.disabled):hover {
  background: var(--primary-light);
  color: var(--primary);
}

.month-year-btn.disabled {
  opacity: 0;
  pointer-events: none;
}

.month-year-btn svg { width: 16px; height: 16px; }

/* Months as a connected pill row */
.month-grid {
  display: flex;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.month-tab {
  flex: 1;
  min-width: 38px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all var(--transition);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

a.month-tab:hover { color: var(--text-primary); background: var(--primary-light); }

.month-tab.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 32%, transparent);
}

.month-tab.disabled {
  color: var(--text-muted);
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

/* =============================================
   KPI CARDS
   ============================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--aurora), linear-gradient(180deg, var(--card-sheen-top) 0%, var(--card-bg) 45%);
  border: 1px solid var(--border);
  border-top-color: var(--card-border-top);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--card-inner-light), var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover { box-shadow: var(--card-inner-light), var(--shadow-md); transform: translateY(-1px); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-primary::before  { background: var(--primary); }
.kpi-success::before  { background: var(--success); }
.kpi-danger::before   { background: var(--danger); }
.kpi-warn::before     { background: var(--warning); }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  width: 28px; height: 28px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.kpi-icon svg { width: 14px; height: 14px; }
.kpi-primary .kpi-icon  { background: var(--primary-light); color: var(--primary); }
.kpi-success .kpi-icon  { background: var(--success-light); color: var(--success); }

.kpi-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.8px;
  line-height: 1.1;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* =============================================
   CHARTS
   ============================================= */
.chart-container { position: relative; width: 100%; }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
  margin-bottom: 16px;
}

.chart-card-main { min-width: 0; }
.chart-card-side  { min-width: 0; }

.chart-insight {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.insight-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}
.insight-green { background: var(--success-light); color: var(--success-text); }
.insight-red   { background: var(--danger-light);  color: var(--danger-text); }

/* =============================================
   DONUT LEGEND
   ============================================= */
.donut-legend { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
}

.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-val {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-primary);
}

/* =============================================
   PRODUCT RANK (dashboard)
   ============================================= */
.product-rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.product-rank-row:last-child { border-bottom: none; }
.product-rank-row:hover { background: #faf8ff; }

.rank-num {
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--primary);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.rank-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rank-name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-code {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}

.rank-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}

.rank-units {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.rank-revenue {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--primary);
}

/* =============================================
   HIGHLIGHT CARDS
   ============================================= */
.highlights-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.highlight-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
}

.highlight-card svg { width: 22px; height: 22px; flex-shrink: 0; }

.highlight-green  { background: var(--success-light); border-color: #a7f3d0; color: var(--success-text); }
.highlight-blue   { background: var(--info-light);    border-color: #93c5fd; color: var(--info-text); }
.highlight-orange { background: var(--warning-light); border-color: #fcd34d; color: var(--warning-text); }
.highlight-purple { background: var(--primary-light); border-color: color-mix(in srgb, var(--primary) 40%, transparent); color: var(--primary); }
.highlight-red    { background: var(--danger-light);  border-color: #fca5a5; color: var(--danger); }

.highlight-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.75; }
.highlight-value { font-size: 18px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; }
.highlight-sub   { font-size: var(--text-xs); opacity: 0.7; margin-top: 1px; }

/* =============================================
   PRODUCT TABLE EXTRAS
   ============================================= */
.margin-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
}
.margin-high { background: var(--success-light); color: var(--success-text); }
.margin-mid  { background: var(--warning-light); color: var(--warning-text); }
.margin-low  { background: var(--danger-light);  color: var(--danger-text); }

.mini-bar-wrap {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.mini-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

/* =============================================
   PAYMENT DETAIL ROWS (reports)
   ============================================= */
.payment-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: var(--text-sm);
}

.legend-dot-sm {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pd-method { font-weight: 600; width: 110px; flex-shrink: 0; color: var(--text-primary); }

.pd-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}
.pd-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; min-width: 2px; }

.pd-pct { width: 36px; text-align: right; color: var(--text-muted); font-weight: 600; }
.pd-val { width: 80px; text-align: right; font-weight: 700; color: var(--text-primary); }

/* =============================================
   TOTALS ROW (table footer)
   ============================================= */
.totals-row td {
  background: var(--border-light);
  border-top: 2px solid var(--border);
}

/* =============================================
   EXPENSES MODULE
   ============================================= */

.expense-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.expense-add-card { position: sticky; top: 72px; }

.cat-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border-light);
}
.cat-summary-row:last-of-type { border-bottom: none; }

.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-summary-info {
  flex: 1;
  min-width: 0;
}

.cat-summary-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  display: block;
  margin-bottom: 3px;
}

.cat-bar-wrap {
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  overflow: hidden;
}

.cat-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.cat-summary-total {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--danger);
  flex-shrink: 0;
}

.cat-summary-total-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--border-light);
  font-size: var(--text-sm);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* Expense category badge */
.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  background: color-mix(in srgb, var(--cat-color) 15%, white);
  color: var(--cat-color);
  border: 1px solid color-mix(in srgb, var(--cat-color) 30%, white);
}

.cat-dot-inline {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  flex-shrink: 0;
}

/* Color input */
.color-input {
  width: 36px; height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  background: white;
}

.text-xs { font-size: var(--text-xs); }
.text-danger-light { color: #fca5a5; }
.mt-3 { margin-top: 12px; }

/* =============================================
   ESTADO DE RESULTADOS
   ============================================= */

/* Result banner */
.result-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-radius: var(--radius-xl);
  margin-bottom: 20px;
  gap: 24px;
}

.result-positive {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 50%, #047857 100%);
  box-shadow: 0 4px 20px rgba(16,185,129,0.25);
}

.result-negative {
  background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 50%, #b91c1c 100%);
  box-shadow: 0 4px 20px rgba(239,68,68,0.25);
}

.result-banner-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.7);
  margin-bottom: 6px;
}

.result-banner-value {
  font-size: var(--text-3xl);
  font-weight: 900;
  color: white;
  letter-spacing: -1.5px;
  line-height: 1;
}

.result-banner-usd {
  font-size: var(--text-base);
  color: rgba(255,255,255,0.65);
  margin-top: 5px;
}

.result-banner-rate {
  font-size: var(--text-xs);
  opacity: 0.7;
  margin-left: 4px;
}

.result-banner-right {
  display: flex;
  gap: 28px;
}

.result-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.result-kpi-val {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}

.result-kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
}

/* Layout */
.results-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 16px;
  align-items: start;
}

.results-main { min-width: 0; }
.results-aside { min-width: 0; position: sticky; top: 72px; }

/* P&L Card */
.pnl-card { overflow: visible; }

.pnl-section {
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 4px;
  margin-bottom: 0;
}

.pnl-section:last-child { border-bottom: none; }

.pnl-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 20px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
.pnl-section-title svg { color: var(--primary); }

.pnl-section-title svg { width: 13px; height: 13px; }

.pnl-row {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

.pnl-row:last-child { border-bottom: none; }
.pnl-item:hover { background: #fafafa; }

.pnl-detail {
  background: var(--border-light);
  padding: 5px 20px 5px 36px;
  border-bottom: 1px solid var(--border-light);
}

.pnl-detail .pnl-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
}

.negative-item { background: #fffafa; }
.negative-item:hover { background: #fff5f5; }

.pnl-label {
  flex: 1;
  font-size: var(--text-base);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pnl-pct {
  width: 52px;
  text-align: right;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-right: 16px;
  flex-shrink: 0;
}

.pnl-amount {
  width: 130px;
  text-align: right;
  font-size: var(--text-base);
  font-weight: 500;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.pnl-amount.positive { color: var(--success); }
.pnl-amount.negative { color: var(--danger); }

/* Subtotals */
.pnl-subtotal {
  background: var(--border-light) !important;
  border-top: 2px solid var(--border) !important;
  border-bottom: 2px solid var(--border) !important;
  padding: 12px 20px !important;
}

.pnl-subtotal .pnl-label {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pnl-subtotal-val {
  font-size: var(--text-lg) !important;
  font-weight: 800 !important;
}

/* Net result row */
.pnl-result-row {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  border-top: 3px double var(--border);
}

.pnl-result-positive { background: linear-gradient(to right, #f0fdf4, #dcfce7); }
.pnl-result-negative { background: linear-gradient(to right, #fef2f2, #fee2e2); }

.pnl-result-label {
  flex: 1;
  font-size: var(--text-md);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.pnl-result-pct {
  width: 52px;
  text-align: right;
  font-size: var(--text-base);
  font-weight: 700;
  margin-right: 16px;
  color: var(--text-secondary);
}

.pnl-result-amount {
  width: 130px;
  text-align: right;
  font-size: var(--text-2xl);
  font-weight: 900;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.pnl-result-positive .pnl-result-amount { color: var(--success-text); }
.pnl-result-negative .pnl-result-amount { color: var(--danger-text); }

/* Empty expenses notice */
.pnl-empty-expenses {
  padding: 12px 20px;
  background: var(--warning-light);
  border-left: 3px solid var(--warning);
}

/* Summary box */
.pnl-summary-box { overflow: hidden; }

.pnl-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border-light);
}
.pnl-summary-row:last-of-type { border-bottom: none; }

.pnl-summary-sub {
  padding: 10px 0;
  border-bottom: 2px solid var(--border) !important;
  font-weight: 600;
}

.pnl-summary-total {
  padding-top: 12px !important;
  font-size: 15px;
  font-weight: 800;
  border-top: 2px double var(--border) !important;
}

.pnl-summary-usd {
  text-align: right;
  font-size: var(--text-xs);
  color: var(--text-muted);
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

/* ── P&L section badge (Automáticos / Manuales) ── */
.pnl-section-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: var(--border-light);
  color: var(--text-muted);
  vertical-align: middle;
}

/* ── Total egresos separator ── */
.pnl-section-flat { border-top: 2px solid var(--border); }
.pnl-total-egresos { background: #fff8f0 !important; }
.pnl-total-egresos .pnl-label { color: var(--warning-text); font-size: var(--text-base); }

/* ── Summary box indent ── */
.pnl-summary-indent {
  padding-left: 16px !important;
}
.pnl-summary-indent span:first-child {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.pnl-summary-indent span:last-child {
  font-size: var(--text-sm);
}

/* ── Expense type badges ── */
.badge-type {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-fijo     { background: var(--primary-light); color: var(--primary-text); }
.badge-variable { background: var(--warning-light); color: var(--warning-text); }

/* ── Inline fixed-expense edit form ── */
.inline-edit-form { display: contents; }

.input-prefix-sm { gap: 0; }
.input-prefix-sm span {
  padding: 0 2px 0 10px;
  font-size: var(--text-base); font-weight: 500;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.input-prefix-sm .input-sm {
  padding: 5px 8px 5px 4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.input-sm  { padding: 5px 10px; font-size: var(--text-base); height: 32px; }
.btn-xs    { padding: 4px 10px; font-size: var(--text-xs); }
.input-xs  { padding: 3px 8px;  font-size: var(--text-sm); height: 28px; }

/* =============================================
   MISC COMPONENTS
   ============================================= */

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 3px;
}
.form-hint.text-warning { color: var(--warning); }

.info-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--info-light);
  border: 1px solid #93c5fd;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--info-text);
  margin-top: 4px;
}
.info-note svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Fila de KPIs del encabezado (ej. movimientos de stock): alineados arriba para
   que todos los rótulos arranquen a la misma altura, y cada valor en una fila de
   alto fijo para que el badge y los textos compartan línea aunque midan distinto. */
.head-stats { display: flex; align-items: flex-start; gap: 26px; }
.head-stats .stat-val {
  display: inline-flex; align-items: center; justify-content: flex-end;
  height: 26px; line-height: 1;
}

.stat-mini {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.stat-mini-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.stock-badge-lg {
  width: auto;
  min-width: 36px;
  height: 26px;
  padding: 0 10px;
  font-size: var(--text-md);
}

.ml-2 { margin-left: 6px; }
.text-green { color: var(--success); }

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* =============================================
   RESPONSIVE (tablet)
   ============================================= */
@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1200px) {
  .kpi-grid       { grid-template-columns: repeat(3, 1fr); }
  .stats-grid     { grid-template-columns: repeat(2, 1fr); }
  .two-col        { grid-template-columns: 1fr; }
  .form-layout    { grid-template-columns: 1fr; }
  .charts-row     { grid-template-columns: 1fr; }
  .highlights-row { grid-template-columns: repeat(2, 1fr); }
  .expense-layout { grid-template-columns: 1fr; }
  .results-layout { grid-template-columns: 1fr; }
  .results-aside  { position: static; }
  .result-banner  { flex-direction: column; align-items: flex-start; gap: 16px; }
  .result-banner-right { flex-wrap: wrap; gap: 16px; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 60px; }
  .sidebar .logo-text, .sidebar .nav-item span,
  .sidebar .nav-label, .sidebar .badge-soon,
  .sidebar .dollar-widget { display: none; }
  .sidebar .nav-item { justify-content: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* =============================================
   MOBILE — OVERLAY SIDEBAR + FULL LAYOUT
   Target: phones 430px and under
   ============================================= */
@media (max-width: 480px) {
  /* Sidebar becomes a full-height overlay, hidden off-screen by default */
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
    z-index: 200;
  }
  /* Restore text/labels inside the overlay sidebar */
  .sidebar .nav-item span,
  .sidebar .nav-label,
  .sidebar .badge-soon,
  .sidebar .sidebar-identity-info { display: block !important; }
  .sidebar .nav-item { justify-content: flex-start !important; padding: 10px 12px !important; }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.35);
  }

  /* Backdrop when sidebar is open */
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 199;
  }
  .sidebar-backdrop.visible { display: block; }

  /* Main takes full width */
  .main { margin-left: 0 !important; }
  .layout.sidebar-collapsed .main { margin-left: 0 !important; }

  /* Topbar en mobile: barra mínima con el hamburguesa */
  .topbar { display: flex; }
  .sidebar-toggle { display: flex; }          /* mobile: hamburguesa abre el drawer */

  /* Content */
  .content { padding: 12px; }

  /* Page header stacks */
  .page-header, .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-head-actions { width: 100%; justify-content: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { width: 100%; justify-content: center; }

  /* Cards */
  .card-body { padding: 14px; }
  .card-footer { padding: 12px 14px; }

  /* Tables: horizontal scroll */
  .card-body.p-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ── Revendedor: items table on mobile ── */
  .items-table thead { display: none; }
  .items-table tbody tr {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
  }
  .items-table tbody tr td {
    border: none;
    padding: 0;
  }
  /* Show qty input full-width */
  .items-table td input[name="quantity[]"] {
    width: 100% !important;
    height: 44px;
    font-size: var(--text-lg);  /* prevents iOS zoom */
  }
  /* Search input full-width */
  .items-table td .r-search {
    height: 44px;
    font-size: var(--text-lg);
  }
  /* Trash button aligned right */
  .items-table td .btn-icon { display: flex; justify-content: flex-end; }

  /* Form layout: aside goes below main */
  .form-layout { grid-template-columns: 1fr !important; }
  .form-aside { order: 2; }

  /* Sticky submit button */
  .form-actions-sticky {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    z-index: 100;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  }
  /* Add bottom padding so content isn't hidden under sticky bar */
  .form-main { padding-bottom: 80px; }

  /* Inputs: larger touch targets */
  .input { height: 44px; font-size: var(--text-lg); }
  textarea.input { height: auto; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Mis pedidos table: simplify */
  .table th:nth-child(4),
  .table td:nth-child(4) { display: none; } /* hide "Productos" column to save space */

  /* Stats grid: 1 col on very small screens */
  .stats-grid { grid-template-columns: 1fr; }

  /* Breadcrumb: smaller */
  .breadcrumb { font-size: var(--text-sm); }

  /* Flash messages: full width */
  .flash { font-size: var(--text-base); }
}

/* =============================================
   QUICK FILTERS
   ============================================= */
.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.qf-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.qf-btn svg { width: 13px; height: 13px; }
.qf-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.qf-btn.qf-active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 32%, transparent);
}

[data-theme="dark"] .qf-btn { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .qf-btn:hover { background: var(--primary-light); }

/* =============================================
   SALE ROWS — date, code, status, total
   ============================================= */
.sale-date {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}
.sale-date-day {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.sale-date-month {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sale-code {
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Code', monospace;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-text);
  letter-spacing: -0.2px;
  transition: color var(--transition);
}
.sale-code:hover { color: var(--primary); }

.td-date { color: var(--text-primary); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.td-num { color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.sale-total {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.usd-tag {
  font-size: 9px;
  font-weight: 700;
  background: var(--warning-light);
  color: var(--warning-text);
  border-radius: 3px;
  padding: 1px 4px;
  margin-right: 3px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* Sale status badges — rich colors */
.sale-status-badge,
select.status-select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
select.status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  outline: none;
  cursor: pointer;
  display: inline-block;
  line-height: 1.4;
}

/* Pastilla de rendición de envío (mismo look que el selector de estado) */
.rendicion-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; white-space: nowrap;
}
.rendicion-pill.rendido    { background: var(--success-light); color: var(--success-text); }
.rendicion-pill.pendiente  { background: var(--danger-light);  color: var(--danger-text); }
.rendicion-pill .monto { font-size: var(--text-sm); font-weight: 700; }
[data-theme="dark"] .rendicion-pill.rendido   { background: rgba(16,185,129,0.2); color: #6ee7b7; }
[data-theme="dark"] .rendicion-pill.pendiente { background: rgba(239,68,68,0.2);  color: #fca5a5; }

.sale-status-completada  { background: var(--success-light); color: var(--success-text); }
.sale-status-pendiente   { background: var(--warning-light); color: var(--warning-text); }
.sale-status-en_envio    { background: var(--info-light); color: var(--info-text); }
.sale-status-cancelada   { background: #f1f5f9; color: #64748b; text-decoration: line-through; opacity: 0.7; }

[data-theme="dark"] .sale-status-completada  { background: rgba(16,185,129,0.2);  color: #6ee7b7; }
[data-theme="dark"] .sale-status-pendiente   { background: rgba(245,158,11,0.2);  color: #fcd34d; }
[data-theme="dark"] .sale-status-en_envio    { background: rgba(59,130,246,0.2);  color: #93c5fd; }
[data-theme="dark"] .sale-status-cancelada   { background: rgba(100,116,139,0.15); color: #64748b; }

.pay-method-efectivo     { background: var(--success-light); color: var(--success-text); }
.pay-method-transferencia{ background: var(--info-light); color: var(--info-text); }
.pay-method-mercadopago   { background: var(--primary-light); color: var(--primary-text); }
.pay-method-dolares       { background: var(--warning-light); color: var(--warning-text); }
.pay-method-otro          { background: #f1f5f9; color: #64748b; }
.pay-method-ars_transferencia { background: var(--info-light); color: var(--info-text); }
.pay-method-ars_efectivo      { background: var(--success-light); color: var(--success-text); }
.pay-method-usd_efectivo      { background: var(--warning-light); color: var(--warning-text); }
.pay-method-cc                { background: #fdf2f8; color: #9d174d; }

[data-theme="dark"] .pay-method-efectivo      { background: rgba(16,185,129,0.2);  color: #6ee7b7; }
[data-theme="dark"] .pay-method-transferencia { background: rgba(59,130,246,0.2);  color: #93c5fd; }
[data-theme="dark"] .pay-method-mercadopago   { background: rgba(145,85,255,0.2);  color: #c7a9ff; }
[data-theme="dark"] .pay-method-dolares       { background: rgba(245,158,11,0.2);  color: #fcd34d; }
[data-theme="dark"] .pay-method-otro          { background: rgba(100,116,139,0.15); color: #64748b; }
[data-theme="dark"] .pay-method-ars_transferencia { background: rgba(59,130,246,0.2);  color: #93c5fd; }
[data-theme="dark"] .pay-method-ars_efectivo      { background: rgba(16,185,129,0.2);  color: #6ee7b7; }
[data-theme="dark"] .pay-method-usd_efectivo      { background: rgba(245,158,11,0.2);  color: #fcd34d; }
[data-theme="dark"] .pay-method-cc                { background: rgba(236,72,153,0.2);  color: #f9a8d4; }

/* Row-level tinting — el color de estado vive solo en la pastilla, no en la fila entera */
.sale-row.sale-cancelada  { opacity: 0.6; }

/* Correo Argentino button */
.btn-outline-correo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #1a73e8;
  color: #1a73e8;
  font-size: var(--text-sm);
  font-weight: 600;
  background: rgba(26,115,232,0.05);
  transition: all var(--transition);
}
.btn-outline-correo:hover { background: rgba(26,115,232,0.12); color: #1557b0; }
[data-theme="dark"] .btn-outline-correo { border-color: #60a5fa; color: #60a5fa; background: rgba(96,165,250,0.08); }

/* =============================================
   THEME TOGGLE BUTTON
   ============================================= */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  margin-right: 4px;
}
.theme-toggle:hover { background: var(--border-light); color: var(--text-primary); }
.theme-toggle svg { width: 16px; height: 16px; }

/* =============================================
   P&L TYPE TAGS (F / V / A)
   ============================================= */
.pnl-type {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 4px;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}
.pnl-type.fijo     { background: var(--primary-light); color: var(--primary-text); }
.pnl-type.variable { background: var(--warning-light); color: var(--warning-text); }
.pnl-type.ajuste   { background: var(--danger-light); color: var(--danger-text); }

[data-theme="dark"] .pnl-type.fijo     { background: rgba(145,85,255,0.25); color: #c7a9ff; }
[data-theme="dark"] .pnl-type.variable { background: rgba(251,146,60,0.2);  color: #fdba74; }
[data-theme="dark"] .pnl-type.ajuste   { background: rgba(239,68,68,0.2);   color: #fca5a5; }

/* =============================================
   SHIPMENT STATUS BADGES
   ============================================= */
.status-ship-pendiente   { background: #f1f5f9; color: #64748b; }
.status-ship-preparando  { background: var(--warning-light); color: var(--warning-text); }
.status-ship-en_camino   { background: var(--info-light); color: var(--info-text); }
.status-ship-entregado   { background: var(--success-light); color: var(--success-text); }
.status-ship-con_novedad { background: var(--danger-light); color: var(--danger-text); }

[data-theme="dark"] .status-ship-pendiente   { background: rgba(100,116,139,0.2); color: #94a3b8; }
[data-theme="dark"] .status-ship-preparando  { background: rgba(245,158,11,0.2);  color: #fcd34d; }
[data-theme="dark"] .status-ship-en_camino   { background: rgba(59,130,246,0.2);  color: #93c5fd; }
[data-theme="dark"] .status-ship-entregado   { background: rgba(16,185,129,0.2);  color: #6ee7b7; }
[data-theme="dark"] .status-ship-con_novedad { background: rgba(239,68,68,0.2);   color: #fca5a5; }

/* =============================================
   CUSTOMER AUTOCOMPLETE
   ============================================= */
.customer-suggestions {
  position: fixed;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  z-index: 9999;
  max-height: 220px;
  overflow-y: auto;
}
.cust-suggestion {
  padding: 9px 12px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 1px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.cust-suggestion:last-child { border-bottom: none; }
.cust-suggestion:hover { background: var(--primary-light); }
.cust-suggestion strong { font-size: var(--text-base); color: var(--text-primary); }
.cust-suggestion span   { font-size: var(--text-xs); color: var(--text-muted); }

/* Ensure parent is position:relative for the dropdown */
#recipient_name { position: relative; }
.form-group { position: relative; }

/* =============================================
   WHATSAPP MESSAGE PREVIEW
   ============================================= */
.wa-preview {
  font-family: 'Inter', sans-serif;
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 12px;
  color: #14532d;
  max-height: 220px;
  overflow-y: auto;
}

.btn-success {
  background: #10b981;
  color: white;
  border: none;
}
.btn-success:hover { background: #059669; color: white; }

/* =============================================
   DOLLAR WIDGET — IMPROVED
   ============================================= */
.dollar-value-empty {
  font-size: var(--text-md);
  color: rgba(255,255,255,0.35);
  font-weight: 500;
}
.dollar-link {
  font-size: var(--text-xs);
  color: var(--sidebar-accent);
  font-weight: 600;
  margin-top: 2px;
  display: block;
}
.dollar-link:hover { color: var(--primary-text); }

/* =============================================
   ALERT BOXES
   ============================================= */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}
.alert-success {
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.3);
  color: #059669;
}
.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #dc2626;
}

/* =============================================
   FORM HINT
   ============================================= */
.form-hint {
  margin: 3px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =============================================
   BTN FULL WIDTH
   ============================================= */
.btn-full { width: 100%; justify-content: center; }

/* =============================================
   CORREO ARGENTINO CARD (detail)
   ============================================= */
[data-theme="dark"] #correo-api-card {
  background: var(--card-bg);
}

/* =============================================
   BULK SELECTION
   ============================================= */
.th-check, .td-check {
  width: 44px;
  padding-left: 16px !important;
  padding-right: 4px !important;
  text-align: left;
}

/* Custom checkbox — clean, on-brand */
.row-check {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--border);
  border-radius: 5px;
  background: var(--card-bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color var(--transition), background var(--transition);
  vertical-align: middle;
}
.row-check:hover { border-color: var(--primary); }
.row-check:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.row-check:checked::after {
  content: '';
  position: absolute;
  left: 5px; top: 1px;
  width: 5px; height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.row-check:indeterminate {
  background: var(--primary);
  border-color: var(--primary);
}
.row-check:indeterminate::after {
  content: '';
  position: absolute;
  left: 3px; top: 7px;
  width: 10px; height: 2px;
  background: #fff;
  border-radius: 1px;
}

tr.row-selected { background: var(--primary-light) !important; }

.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 12px 10px 18px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
  white-space: nowrap;
}
.bulk-bar.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.bulk-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* =============================================
   MISSING UTILITIES
   ============================================= */
.mb-5 { margin-bottom: 28px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.font-mono { font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace; }

.card-subtitle {
  margin: 3px 0 0;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 460px;
}

/* Card header that stacks a title + subtitle on the left */
.card-header > div:first-child { min-width: 0; }

/* =============================================
   SEARCH BAR (clean, icon-led — no redundant label)
   ============================================= */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}
.search-bar > i,
.search-bar > svg {
  position: absolute;
  left: 12px;
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-bar .input {
  padding-left: 36px;
}

/* =============================================
   SWITCH (toggle estilo iOS)
   ============================================= */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  transition: background var(--transition, .2s);
}
.switch .switch-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform var(--transition, .2s);
}
.switch input:checked + .switch-slider {
  background: var(--success, #10b981);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}
.switch input:disabled + .switch-slider {
  opacity: .5;
  cursor: not-allowed;
}

/* =============================================
   ESTANDARIZACIÓN DE TABLAS (módulos comerciales)
   ============================================= */
/* Hover de fila más sutil y neutro (el lila queda reservado para la selección) */
.table-hover tbody tr:hover { background: color-mix(in srgb, var(--text-primary) 4%, transparent); }

/* Chips y selects de estado: centrados y de ancho uniforme dentro de su columna */
.table .badge { justify-content: center; text-align: center; min-width: 92px; }
.table select.status-select { text-align: center; text-align-last: center; min-width: 108px; }

/* Acciones de fila: varios botones-ícono alineados de forma consistente */
.row-actions { display: inline-flex; align-items: center; gap: 4px; }

/* Códigos, fechas y montos no se parten en dos líneas */
.table .sale-code, .table .td-date, .table .money { white-space: nowrap; }

/* Medio de pago como texto plano editable (sin color por método) */
.table select.status-select.pay-neutral {
  background: transparent; color: var(--text-primary);
  min-width: 0; text-align: left; text-align-last: left;
  font-size: var(--text-md); font-weight: 600; padding: 4px 6px;
}

/* La tabla de ventas se ajusta al ancho disponible: todas las columnas entran
   sin scroll horizontal. Las columnas de ancho fijo (fecha, total, estado…) se
   fijan en el thead; Código/Cliente/Productos reparten el resto y truncan. */
.sales-table { table-layout: fixed; width: 100%; }
.sales-table td, .sales-table th { overflow: hidden; }
.sales-table .sale-code, .sales-table .prod-main, .sales-table .font-medium { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Columna Productos: resumen en una línea + popover con la lista al pasar el mouse */
.prod-td { position: relative; }
.prod-cell { display: flex; align-items: center; gap: 7px; position: relative; min-width: 0; }
.prod-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; flex: 1; min-width: 0; }
.prod-more { flex: none; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.prod-pop {
  display: none; position: absolute; top: calc(100% + 5px); left: 0; z-index: 50; min-width: 212px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); padding: 8px 10px;
}
.prod-pop-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 5px; }
.prod-pop-item { display: flex; justify-content: space-between; gap: 20px; font-size: 13px; padding: 3px 0; white-space: nowrap; }
.prod-pop-item .q { color: var(--text-muted); }
.prod-cell:hover .prod-pop { display: block; }
/* La card no recorta el popover; la tabla se mantiene contenida y scrollea en
   horizontal si no entra (el popover escapa vía posición fixed por JS). */
.card-pop, .card-pop .card-body { overflow: visible; }
.card-pop .table-scroll { overflow-x: auto; overflow-y: visible; }

/* Separador en la barra de selección masiva */
.bulk-bar .bulk-div { width: 1px; height: 22px; background: var(--border); flex: none; }


/* ══════════════════════════════════════════════════════════════════════════
   NUEVA VENTA — flujo ágil (buscador único + carrito). Todo scopeado en
   .salenew para no colisionar con clases globales. Reusa .card .btn .input
   .seg/.seg-item .empty-state .badge .form-group/.form-label.
   ══════════════════════════════════════════════════════════════════════════ */

/* dólar de referencia (pill en el encabezado, al lado del toggle de moneda) */
.nvx-dollar-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); background: var(--card-bg);
  border-radius: var(--radius-pill); padding: 6px 13px; font-size: var(--text-sm);
}
.nvx-dollar-pill i, .nvx-dollar-pill svg { width: 15px; height: 15px; color: var(--success-text); }
.nvx-dollar-pill .lab { color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; font-size: var(--text-xs); }
.nvx-dollar-pill .v { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }

/* franja de contexto: Fecha · Canal · Cliente */
.salenew .nvx-ctx { display: flex; align-items: center; gap: 18px; padding: 11px 16px; flex-wrap: wrap; }
.salenew .nvx-ctx-block { display: flex; align-items: center; gap: 9px; }
.salenew .nvx-ctx-label { font-size: var(--text-sm); font-weight: 700; letter-spacing: .02em; color: var(--text-secondary); }
.salenew .nvx-ctx-sep { width: 1px; align-self: stretch; background: var(--border-light); margin: 2px 0; }
.salenew .nvx-ctx .cust { flex: 1; min-width: 180px; }
.salenew .nvx-date { width: auto; padding: 7px 10px; font-size: var(--text-sm); }

/* input con ícono (cliente) */
.salenew .nvx-inp-icon { position: relative; flex: 1; }
.salenew .nvx-inp-icon i, .salenew .nvx-inp-icon svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.salenew .nvx-inp-icon .input { padding-left: 34px; }

/* HERO — buscador de productos */
.salenew .nvx-hero { padding: 16px; position: relative; overflow: visible; z-index: 20; }
.salenew .nvx-search { position: relative; }
.salenew .nvx-search > i, .salenew .nvx-search > svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--primary); pointer-events: none; z-index: 1; }
.salenew .nvx-search input {
  width: 100%; font-family: inherit; font-size: 15px; font-weight: 500; color: var(--text-primary);
  background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 15px 12px 44px; transition: var(--transition);
}
.salenew .nvx-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.salenew .nvx-search input::placeholder { color: var(--text-muted); font-weight: 400; }
.salenew .nvx-hint { margin-top: 9px; font-size: var(--text-xs); color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap; }
.salenew .nvx-hint kbd { font-family: ui-monospace, monospace; font-size: 10px; background: var(--border-light); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; color: var(--text-secondary); margin: 0 2px; }

/* dropdown de resultados */
.nvx-dd {
  position: absolute; z-index: 200; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 340px; overflow-y: auto; padding: 5px;
}
.nvx-dd-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; }
.nvx-dd-item:hover, .nvx-dd-item.active { background: var(--primary-light); }
.nvx-dd-name { font-size: var(--text-base); font-weight: 500; color: var(--text-primary); }
.nvx-dd-name mark { background: transparent; color: var(--primary-text); font-weight: 700; }
.nvx-dd-price { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; text-align: right; }
.nvx-dd-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: var(--text-sm); }

/* chip de stock */
.nvx-stk { font-size: var(--text-xs); font-weight: 600; padding: 2px 8px; border-radius: var(--radius-pill); white-space: nowrap; font-variant-numeric: tabular-nums; }
.nvx-stk.ok { background: var(--success-light); color: var(--success-text); }
.nvx-stk.low { background: var(--warning-light); color: var(--warning-text); }
.nvx-stk.no { background: var(--danger-light); color: var(--danger-text); }

/* repetir pedido */
.salenew .nvx-repeat {
  display: none; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px;
  background: var(--primary-light); border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent);
}
.salenew .nvx-repeat.on { display: flex; }
.salenew .nvx-repeat-ic { width: 36px; height: 36px; border-radius: var(--radius-md); background: var(--card-bg); display: grid; place-items: center; flex: none; }
.salenew .nvx-repeat-ic i, .salenew .nvx-repeat-ic svg { width: 18px; height: 18px; color: var(--primary); }
.salenew .nvx-repeat-txt { flex: 1; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.salenew .nvx-repeat-txt strong { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.salenew .nvx-repeat-txt span { font-size: var(--text-sm); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* carrito */
.salenew .nvx-cart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-light); }
.salenew .nvx-cart-head h3 { margin: 0; font-size: var(--text-base); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.salenew .nvx-cart-head h3 i, .salenew .nvx-cart-head h3 svg { width: 16px; height: 16px; color: var(--text-muted); }
.salenew .nvx-count { font-size: var(--text-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.salenew .nvx-colhead {
  display: grid; grid-template-columns: 1fr 108px 132px 96px 34px; gap: 12px; align-items: center;
  padding: 9px 16px; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-secondary); border-bottom: 1px solid var(--border); background: var(--border-light);
}
.salenew .nvx-colhead .r { text-align: right; }
.salenew .nvx-colhead .c { text-align: center; }
.salenew .nvx-line { display: grid; grid-template-columns: 1fr 108px 132px 96px 34px; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border-light); }
.salenew .nvx-line:last-child { border-bottom: 0; }
.salenew .nvx-line-name { font-size: var(--text-base); font-weight: 500; line-height: 1.35; }
.salenew .nvx-line-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; }

/* stepper cantidad */
.salenew .nvx-step { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--card-bg); }
.salenew .nvx-step button { width: 30px; height: 32px; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; display: grid; place-items: center; font-family: inherit; transition: var(--transition); }
.salenew .nvx-step button:hover { background: var(--primary-light); color: var(--primary-text); }
.salenew .nvx-step button i, .salenew .nvx-step button svg { width: 15px; height: 15px; }
.salenew .nvx-step input { width: 40px; text-align: center; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: transparent; font-family: inherit; font-size: var(--text-base); color: var(--text-primary); padding: 6px 0; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.salenew .nvx-step input::-webkit-outer-spin-button, .salenew .nvx-step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.salenew .nvx-step input:focus { outline: none; }

/* precio unitario */
.salenew .nvx-price { position: relative; display: flex; align-items: center; }
.salenew .nvx-price .cur { position: absolute; left: 10px; font-size: var(--text-sm); color: var(--text-muted); font-weight: 600; pointer-events: none; }
.salenew .nvx-price input { width: 100%; font-family: inherit; font-size: var(--text-base); color: var(--text-primary); text-align: right; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 7px 10px 7px 40px; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.salenew .nvx-price input::-webkit-outer-spin-button, .salenew .nvx-price input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.salenew .nvx-price input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.salenew .nvx-sub { text-align: right; font-size: var(--text-base); font-weight: 600; font-variant-numeric: tabular-nums; }

/* aside (totales + pago pegados) */
.salenew .nvx-aside { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 10px; }
.salenew .nvx-aside .nvx-actions { margin-top: 6px; display: flex; flex-direction: column; gap: 9px; }
.salenew .nvx-trow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: var(--text-base); color: var(--text-secondary); }
.salenew .nvx-trow .val { font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.salenew .nvx-trow.final { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 13px; }
.salenew .nvx-trow.final span:first-child { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.salenew .nvx-trow.final .val { font-size: var(--text-xl); font-weight: 700; color: var(--primary-text); }
.salenew .nvx-trow .input, .salenew .nvx-trow .nvx-price { width: 150px; flex: none; }
/* aviso chico (envío en pesos) */
.salenew .nvx-note { display: none; align-items: center; gap: 7px; margin-top: 8px; font-size: var(--text-sm); color: var(--text-muted); }
.salenew .nvx-note.on { display: flex; }
.salenew .nvx-note i, .salenew .nvx-note svg { width: 14px; height: 14px; flex: none; }
/* estado vacío del carrito (círculo como el resto del sistema) */
.salenew #cart-empty { padding: 40px 20px; }
.salenew #cart-empty .empty-icon { width: 52px !important; height: 52px !important; border-radius: 50%; background: var(--primary-light); display: grid; place-items: center; margin: 0 auto 12px; }
.salenew #cart-empty .empty-icon i, .salenew #cart-empty .empty-icon svg { width: 24px !important; height: 24px !important; color: var(--primary); }
.salenew #cart-empty h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.salenew #cart-empty p { font-size: var(--text-sm); color: var(--text-muted); max-width: none; }

/* aviso USD dentro de Productos (banda) */
.salenew .nvx-usdbar { display: none; align-items: center; gap: 8px; padding: 10px 16px; background: var(--success-light); color: var(--success-text); font-size: var(--text-sm); font-weight: 500; border-bottom: 1px solid var(--border-light); }
.salenew .nvx-usdbar.on { display: flex; }
.salenew .nvx-usdbar i, .salenew .nvx-usdbar svg { width: 16px; height: 16px; flex: none; }

/* layout dos columnas */
.salenew .nvx-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .salenew .nvx-layout { grid-template-columns: 1fr; } .salenew .nvx-aside { position: static; } }
@media (max-width: 520px) { .salenew .nvx-colhead { display: none; } .salenew .nvx-line { grid-template-columns: 1fr auto; } }

/* toggle de envío */
.salenew .nvx-ship-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; background: transparent; border: 1px dashed var(--border); color: var(--text-secondary); font-family: inherit; font-size: var(--text-sm); font-weight: 500; border-radius: var(--radius-md); padding: 10px 14px; cursor: pointer; transition: var(--transition); }
.salenew .nvx-ship-toggle:hover { border-color: var(--primary); color: var(--primary); }
.salenew .nvx-ship-toggle i, .salenew .nvx-ship-toggle svg { width: 16px; height: 16px; }
.salenew .nvx-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .salenew .nvx-grid2 { grid-template-columns: 1fr; } }
