/* ============================================================================
   PACHOCAMBIOS — Sistema de diseño
   ----------------------------------------------------------------------------
   Fuente única de verdad visual. Ningún archivo CSS debe declarar colores,
   tamaños ni sombras propios: todo sale de estas variables.

   Los colores de marca de cada empresa se inyectan desde PHP sobrescribiendo
   --brand-h / --brand-s / --brand-l en :root (ver layouts/app.php).

   Índice
     1. Fuentes
     2. Tokens: color, tipografía, espaciado, radios, sombras, movimiento
     3. Tema oscuro
     4. Reset y base
     5. Primitivas: superficies, botones, formularios, tablas, badges, etc.
     6. Estructura: sidebar, topbar, contenido
     7. Utilidades y accesibilidad
   ========================================================================== */

/* ── 1. Fuentes ─────────────────────────────────────────────────────────── */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../vendor/inter/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('../vendor/inter/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('../vendor/inter/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../vendor/inter/inter-latin-700-normal.woff2') format('woff2'); }

/* ── 2. Tokens ──────────────────────────────────────────────────────────── */
:root {
  /* Marca — sobrescribible por empresa desde PHP */
  --brand-h: 231;
  --brand-s: 72%;
  --brand-l: 54%;

  --c-primary:        hsl(var(--brand-h) var(--brand-s) var(--brand-l));
  --c-primary-hover:  hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 7%));
  --c-primary-active: hsl(var(--brand-h) var(--brand-s) calc(var(--brand-l) - 13%));
  --c-primary-soft:   hsl(var(--brand-h) var(--brand-s) 96%);
  --c-primary-border: hsl(var(--brand-h) var(--brand-s) 86%);
  --c-primary-fg:     #ffffff;

  /* Neutros */
  --c-bg:            #f6f7f9;
  --c-surface:       #ffffff;
  --c-surface-2:     #fbfbfc;
  --c-surface-3:     #f1f2f5;
  --c-border:        #e3e5ea;
  --c-border-strong: #cfd2da;
  --c-text:          #16181d;
  --c-text-2:        #494f5a;
  --c-muted:         #757d8a;
  --c-inverse:       #ffffff;

  /* Semánticos */
  --c-success:      #0f9d58;  --c-success-soft: #e6f6ee;  --c-success-border: #b9e4cd;
  --c-warning:      #c77700;  --c-warning-soft: #fdf3e2;  --c-warning-border: #f0dbb2;
  --c-danger:       #d92d20;  --c-danger-soft:  #fdecea;  --c-danger-border:  #f5c3bd;
  --c-info:         #0b76d1;  --c-info-soft:    #e8f2fc;  --c-info-border:    #b8d8f5;

  /* Negocio */
  --c-buy:   var(--c-success);   /* compra  */
  --c-sell:  var(--c-info);      /* venta   */
  --c-void:  var(--c-danger);    /* anulado */

  /* Tipografía */
  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;

  --fs-xs:   0.75rem;   /* 12 */
  --fs-sm:   0.8125rem; /* 13 */
  --fs-base: 0.875rem;  /* 14 — base de un sistema denso de datos */
  --fs-md:   1rem;      /* 16 */
  --fs-lg:   1.125rem;  /* 18 */
  --fs-xl:   1.375rem;  /* 22 */
  --fs-2xl:  1.75rem;   /* 28 */
  --fs-3xl:  2.25rem;   /* 36 */

  --lh-tight: 1.2;
  --lh-base:  1.5;

  /* Espaciado — escala de 4px */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 48px; --sp-10: 64px; --sp-11: 80px; --sp-12: 96px;

  /* Radios */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* Sombras */
  --sh-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --sh-2: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .05);
  --sh-3: 0 20px 32px -8px rgba(16, 24, 40, .16), 0 4px 8px -4px rgba(16, 24, 40, .08);
  --sh-focus: 0 0 0 3px hsl(var(--brand-h) var(--brand-s) var(--brand-l) / .22);

  /* Cristal (glassmorphism sutil) */
  --glass-bg:     rgba(255, 255, 255, .72);
  --glass-blur:   blur(14px) saturate(160%);
  --glass-border: rgba(255, 255, 255, .55);

  /* Movimiento */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: 120ms var(--ease);
  --t-base: 180ms var(--ease);
  --t-slow: 260ms var(--ease);

  /* Estructura */
  --sidebar-w:          260px;
  --sidebar-w-collapsed: 72px;
  --topbar-h:           60px;
  --z-sidebar: 1030; --z-topbar: 1020; --z-dropdown: 1040;
  --z-modal: 1060; --z-toast: 1080;
}

/* ── 3. Tema oscuro ─────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --c-bg:            #0e1116;
    --c-surface:       #161a21;
    --c-surface-2:     #1b2029;
    --c-surface-3:     #222834;
    --c-border:        #2a303b;
    --c-border-strong: #3a4250;
    --c-text:          #e8eaee;
    --c-text-2:        #b3b9c4;
    --c-muted:         #838b98;

    --c-primary-soft:   hsl(var(--brand-h) 40% 18%);
    --c-primary-border: hsl(var(--brand-h) 40% 30%);

    --c-success-soft: #10281c; --c-success-border: #1d5138;
    --c-warning-soft: #2a1f0d; --c-warning-border: #5c441a;
    --c-danger-soft:  #2c1512; --c-danger-border:  #642722;
    --c-info-soft:    #0d1f2f; --c-info-border:    #1b4870;

    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 4px 10px rgba(0, 0, 0, .45);
    --sh-3: 0 20px 36px rgba(0, 0, 0, .6);

    --glass-bg:     rgba(22, 26, 33, .72);
    --glass-border: rgba(255, 255, 255, .07);

    color-scheme: dark;
  }
}

/* El interruptor de tema del usuario siempre manda sobre el sistema. */
:root[data-theme='dark'] {
  --c-bg: #0e1116; --c-surface: #161a21; --c-surface-2: #1b2029; --c-surface-3: #222834;
  --c-border: #2a303b; --c-border-strong: #3a4250;
  --c-text: #e8eaee; --c-text-2: #b3b9c4; --c-muted: #838b98;
  --c-primary-soft: hsl(var(--brand-h) 40% 18%);
  --c-primary-border: hsl(var(--brand-h) 40% 30%);
  --c-success-soft: #10281c; --c-success-border: #1d5138;
  --c-warning-soft: #2a1f0d; --c-warning-border: #5c441a;
  --c-danger-soft:  #2c1512; --c-danger-border:  #642722;
  --c-info-soft:    #0d1f2f; --c-info-border:    #1b4870;
  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 4px 10px rgba(0,0,0,.45);
  --sh-3: 0 20px 36px rgba(0,0,0,.6);
  --glass-bg: rgba(22,26,33,.72); --glass-border: rgba(255,255,255,.07);
  color-scheme: dark;
}
:root[data-theme='light'] { color-scheme: light; }

/* ── 4. Reset y base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;              /* el body NUNCA scrollea en horizontal */
}

h1, h2, h3, h4, h5, h6 { margin: 0 0 var(--sp-3); font-weight: 600; line-height: var(--lh-tight); letter-spacing: -.011em; }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); } h5, h6 { font-size: var(--fs-base); }
p { margin: 0 0 var(--sp-3); }

a { color: var(--c-primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--c-primary-hover); text-decoration: underline; }

img, svg, video { max-width: 100%; height: auto; display: block; }
code, kbd, pre, .mono { font-family: var(--font-mono); font-size: .92em; }

/* Todo importe monetario usa cifras de ancho fijo y se alinea a la derecha. */
.amount, .money, td.amount, .num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  text-align: right;
  white-space: nowrap;
}
.amount--pos { color: var(--c-success); }
.amount--neg { color: var(--c-danger); }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: var(--r-full); border: 2px solid var(--c-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted); }

/* ── 5. Primitivas ──────────────────────────────────────────────────────── */

/* Superficies */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t-base), transform var(--t-base), border-color var(--t-base);
}
.card--hover:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); }
.card__title { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.card__body { padding: var(--sp-5); }
.card__foot { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); }

.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

/* Tarjeta de indicador (KPI) */
.stat {
  position: relative; overflow: hidden;
  padding: var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t-base), transform var(--t-base);
}
.stat:hover { box-shadow: var(--sh-2); transform: translateY(-2px); }
.stat::after {                      /* filo de color según el tipo de dato */
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--stat-accent, var(--c-primary));
}
.stat__label { font-size: var(--fs-xs); font-weight: 500; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: var(--sp-2); }
.stat__value { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat__meta { display: flex; align-items: center; gap: var(--sp-1);
  margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-muted); }
.stat__delta--up   { color: var(--c-success); }
.stat__delta--down { color: var(--c-danger); }
.stat__icon { position: absolute; top: var(--sp-4); right: var(--sp-4);
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--c-primary-soft); color: var(--c-primary); font-size: var(--fs-md); }

/* Botones */
.btn {
  --btn-bg: var(--c-surface); --btn-fg: var(--c-text); --btn-bd: var(--c-border);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 0 var(--sp-4); height: 38px;
  font: 500 var(--fs-base)/1 var(--font-ui);
  color: var(--btn-fg); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-md);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--c-surface-3); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--sh-focus); outline: none; }
.btn:disabled, .btn.is-loading { opacity: .55; cursor: not-allowed; pointer-events: none; }

.btn--primary { --btn-bg: var(--c-primary); --btn-fg: var(--c-primary-fg); --btn-bd: var(--c-primary); }
.btn--primary:hover:not(:disabled) { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn--success { --btn-bg: var(--c-success); --btn-fg: #fff; --btn-bd: var(--c-success); }
.btn--danger  { --btn-bg: var(--c-danger);  --btn-fg: #fff; --btn-bd: var(--c-danger); }
.btn--info    { --btn-bg: var(--c-info);    --btn-fg: #fff; --btn-bd: var(--c-info); }
.btn--success:hover:not(:disabled), .btn--danger:hover:not(:disabled), .btn--info:hover:not(:disabled) { filter: brightness(.93); }
.btn--ghost   { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--c-text-2); }
.btn--soft    { --btn-bg: var(--c-primary-soft); --btn-fg: var(--c-primary); --btn-bd: var(--c-primary-border); }
.btn--sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-md); }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--block { width: 100%; }
.btn.is-loading::before {
  content: ''; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: pc-spin .6s linear infinite;
}
@keyframes pc-spin { to { transform: rotate(360deg); } }

/* Formularios */
.field { margin-bottom: var(--sp-4); }
.label { display: block; margin-bottom: var(--sp-2); font-size: var(--fs-sm); font-weight: 500; color: var(--c-text-2); }
.label .req { color: var(--c-danger); margin-left: 2px; }

.input, .select, .textarea {
  display: block; width: 100%; height: 38px;
  padding: 0 var(--sp-3);
  font: 400 var(--fs-base)/1 var(--font-ui);
  color: var(--c-text); background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  appearance: none;
}
.textarea { height: auto; min-height: 92px; padding: var(--sp-3); line-height: var(--lh-base); resize: vertical; }
.select {
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23757d8a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right var(--sp-3) center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--c-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--c-primary); box-shadow: var(--sh-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--c-muted); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-surface-3); color: var(--c-muted); cursor: not-allowed; }
.input--amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

.is-invalid { border-color: var(--c-danger) !important; }
.is-invalid:focus { box-shadow: 0 0 0 3px rgba(217, 45, 32, .2) !important; }
.field__error { display: block; margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-danger); }
.field__hint  { display: block; margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--c-muted); }

.input-group { display: flex; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group__addon {
  display: inline-flex; align-items: center; padding: 0 var(--sp-3);
  font-size: var(--fs-sm); font-weight: 500; color: var(--c-muted);
  background: var(--c-surface-3); border: 1px solid var(--c-border-strong);
  border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0;
}

/* Tablas — densas, legibles, con scroll propio */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs); font-weight: 600; text-align: left; white-space: nowrap;
  color: var(--c-muted); text-transform: uppercase; letter-spacing: .04em;
  background: var(--c-surface-2); border-bottom: 1px solid var(--c-border);
}
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table--striped tbody tr:nth-child(even) { background: var(--c-surface-2); }
.table th.amount, .table td.amount { text-align: right; }
.table .row-actions { display: flex; gap: var(--sp-1); justify-content: flex-end; opacity: .35; transition: opacity var(--t-fast); }
.table tbody tr:hover .row-actions { opacity: 1; }

/* Etiquetas de estado */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 3px var(--sp-2);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.4;
  border-radius: var(--r-full); border: 1px solid transparent; white-space: nowrap;
}
.badge--neutral { background: var(--c-surface-3); color: var(--c-text-2); border-color: var(--c-border); }
.badge--success { background: var(--c-success-soft); color: var(--c-success); border-color: var(--c-success-border); }
.badge--warning { background: var(--c-warning-soft); color: var(--c-warning); border-color: var(--c-warning-border); }
.badge--danger  { background: var(--c-danger-soft);  color: var(--c-danger);  border-color: var(--c-danger-border); }
.badge--info    { background: var(--c-info-soft);    color: var(--c-info);    border-color: var(--c-info-border); }
.badge--dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Alertas */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-4);
  border: 1px solid var(--c-border); border-radius: var(--r-md); font-size: var(--fs-sm); }
.alert--success { background: var(--c-success-soft); border-color: var(--c-success-border); color: var(--c-success); }
.alert--warning { background: var(--c-warning-soft); border-color: var(--c-warning-border); color: var(--c-warning); }
.alert--danger  { background: var(--c-danger-soft);  border-color: var(--c-danger-border);  color: var(--c-danger); }
.alert--info    { background: var(--c-info-soft);    border-color: var(--c-info-border);    color: var(--c-info); }

/* Estados de carga, vacío y error */
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-3) 25%, var(--c-border) 37%, var(--c-surface-3) 63%);
  background-size: 400% 100%; border-radius: var(--r-sm);
  animation: pc-shimmer 1.4s ease-in-out infinite;
}
@keyframes pc-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton--text { height: 12px; margin-bottom: var(--sp-2); }
.skeleton--row  { height: 44px; margin-bottom: var(--sp-1); }

.empty-state { padding: var(--sp-9) var(--sp-5); text-align: center; color: var(--c-muted); }
.empty-state__icon { font-size: 2.5rem; opacity: .35; margin-bottom: var(--sp-4); }
.empty-state__title { font-size: var(--fs-md); font-weight: 600; color: var(--c-text); margin-bottom: var(--sp-2); }

/* ── 6. Estructura ──────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar);
  width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--c-surface); border-right: 1px solid var(--c-border);
  transition: width var(--t-base), transform var(--t-base);
}
.sidebar__brand { display: flex; align-items: center; gap: var(--sp-3);
  height: var(--topbar-h); padding: 0 var(--sp-4); border-bottom: 1px solid var(--c-border); flex-shrink: 0; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-6); }
.sidebar__section { margin: var(--sp-5) 0 var(--sp-2); padding: 0 var(--sp-3);
  font-size: var(--fs-xs); font-weight: 600; color: var(--c-muted);
  text-transform: uppercase; letter-spacing: .06em; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3); margin-bottom: 2px;
  color: var(--c-text-2); border-radius: var(--r-md); font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.nav-item.is-active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }
.nav-item__icon { width: 18px; text-align: center; flex-shrink: 0; }
.nav-item__badge { margin-left: auto; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left var(--t-base); }

.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--sp-4);
  height: var(--topbar-h); padding: 0 var(--sp-5);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--c-border);
}
.content { padding: var(--sp-6) var(--sp-5) var(--sp-10); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head__title { margin: 0 0 var(--sp-1); }
.page-head__sub { margin: 0; color: var(--c-muted); font-size: var(--fs-sm); }

.grid { display: grid; gap: var(--sp-4); }
.grid--kpi { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.chart-box { position: relative; height: 300px; }
.chart-box canvas { max-height: 100%; }

/* Estado colapsado (escritorio) */
.is-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.is-collapsed .sidebar__nav .nav-item span:not(.nav-item__icon),
.is-collapsed .sidebar__section,
.is-collapsed .sidebar__brand-text { display: none; }
.is-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

/* Móvil y tablet */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-3); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .content { padding: var(--sp-4) var(--sp-3) var(--sp-9); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
    background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: opacity var(--t-base); }
  .sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }
}
@media (max-width: 575.98px) {
  :root { --fs-2xl: 1.5rem; --fs-3xl: 1.875rem; }
  .grid--kpi { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .page-head { flex-direction: column; align-items: stretch; }
}

/* ── 7. Utilidades y accesibilidad ──────────────────────────────────────── */
.u-muted { color: var(--c-muted); }
.u-small { font-size: var(--fs-sm); }
.u-xs    { font-size: var(--fs-xs); }
.u-bold  { font-weight: 600; }
.u-right { text-align: right; }
.u-center{ text-align: center; }
.u-nowrap{ white-space: nowrap; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-flex  { display: flex; }
.u-between { display: flex; align-items: center; justify-content: space-between; }
.u-gap-1 { gap: var(--sp-1); } .u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); } .u-gap-4 { gap: var(--sp-4); }
.u-mt-3 { margin-top: var(--sp-3); } .u-mt-4 { margin-top: var(--sp-4); }
.u-mb-3 { margin-bottom: var(--sp-3); } .u-mb-4 { margin-bottom: var(--sp-4); }
.u-hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -100px; left: var(--sp-3); z-index: var(--z-toast);
  padding: var(--sp-3) var(--sp-4); background: var(--c-primary); color: #fff; border-radius: var(--r-md);
}
.skip-link:focus { top: var(--sp-3); }

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

/* Impresión: sólo el contenido. */
@media print {
  .sidebar, .topbar, .btn, .row-actions, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .card { box-shadow: none; border-color: #ddd; }
  body { background: #fff; font-size: 11pt; }
}
