/* =====================================================================
   AYLLU - Design System 2026
   Senior UI/UX guidance, accessibility WCAG 3.0, fluid responsive

   Decisiones de diseño:
   ────────────────────────────────────────────────────────────────────
   1. TOKENS: variables CSS con fallback chain (--primary → :root → color-scheme)
      → Permite tematización por componente sin reflow.
   2. MODO CLARO/OSCURO: prefers-color-scheme + .theme-dark/.theme-light
      con view-transition (Chrome 111+) para morphing visual fluido.
   3. BREATHING SPACE: padding usa clamp() con viewport units,
      escala automáticamente en plegables/triple-pantalla.
   4. CONTAINER QUERIES: layouts adaptan según el contenedor padre,
      no la viewport. Esencial para foldables.
   5. REDUCED MOTION: respeta prefers-reduced-motion estrictamente,
      ofrece transiciones sin transform en su lugar.
   6. INTERACCIÓN MIXTA: hover-only en :hover @media, focus-visible
      para teclado, pointer:coarse aumenta touch targets a 44×44.
   7. COLOR-CONTRAST: ratios WCAG AAA (7:1 texto normal, 4.5:1 grande).
   ───────────────────────────────────────────────────────────────────── */

/* ─── 0. Fonts ─────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── 1. Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Fondos — neutros con cálido sutil para identidad de marca, pero sin opacar el texto */
  --bg:           #f5f4f2;        /* Off-white neutro */
  --bg-elevated:  #ffffff;
  --surface:      #ffffff;
  --surface-2:    #ebe9e6;        /* Headers tabla, hover suave */
  --surface-hover:#e0ddd8;
  --overlay:      rgba(28,24,20,.55);

  /* Sidebar — alto contraste */
  --sidebar-bg:   #1a1612;
  --sidebar-fg:   rgba(255,255,255,.92);
  --sidebar-muted:rgba(255,255,255,.62);

  /* Marca — más vibrante para destacar sin saturar */
  --brand:        #c0392b;
  --brand-2:      #9c2f24;
  --brand-soft:   #fbe6e4;
  --gold:         #c89432;
  --gold-soft:    #fbeed4;

  /* Estados — colores legibles sobre blanco */
  --success:      #15803d;
  --success-soft: #d4f4dd;
  --warning:      #a35d10;
  --warning-soft: #ffeec7;
  --danger:       #b9311f;
  --danger-soft:  #fce0db;
  --info:         #1e4ea3;
  --info-soft:    #d8e6fa;

  /* Texto — WCAG AAA garantizado en blanco/off-white */
  --text:         #1a1715;        /* Casi negro, no #000 puro */
  --text-2:       #36302a;
  --text-muted:   #4a423a;        /* Más oscuro para mejor legibilidad */
  --text-faint:   #6e655c;        /* Aún visible */
  --text-on-brand:#ffffff;
  --text-on-dark: #f5efe5;

  /* Bordes — más definidos */
  --border:       #d6d2cc;
  --border-strong:#a8a39c;
  --border-focus: var(--brand);

  /* Radios — variados (no uniformes) */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Sombras — sutiles, capas distintas */
  --shadow-1: 0 1px 2px rgba(20,17,13,.04), 0 1px 3px rgba(20,17,13,.06);
  --shadow-2: 0 4px 6px -2px rgba(20,17,13,.06), 0 2px 4px -2px rgba(20,17,13,.05);
  --shadow-3: 0 12px 20px -8px rgba(20,17,13,.10), 0 4px 8px -2px rgba(20,17,13,.06);
  --shadow-focus: 0 0 0 3px rgba(192,57,43,.18);

  /* Espaciado fluido — clamp(min, fluid, max) */
  --space-1: clamp(.25rem, .5vw, .35rem);
  --space-2: clamp(.5rem,  1vw,  .75rem);
  --space-3: clamp(.75rem, 1.5vw, 1rem);
  --space-4: clamp(1rem,  2vw,  1.5rem);
  --space-5: clamp(1.5rem, 3vw, 2.25rem);
  --space-6: clamp(2rem,   4vw, 3rem);

  /* Tipografía fluida */
  --fs-xs:   clamp(.72rem, .68rem + .15vw, .8rem);
  --fs-sm:   clamp(.82rem, .78rem + .2vw, .92rem);
  --fs-base: clamp(.92rem, .88rem + .25vw, 1.04rem);
  --fs-lg:   clamp(1.08rem, 1rem + .4vw, 1.25rem);
  --fs-xl:   clamp(1.3rem, 1.2rem + .55vw, 1.65rem);
  --fs-2xl:  clamp(1.7rem, 1.5rem + .9vw, 2.4rem);
  --fs-3xl:  clamp(2.2rem, 1.8rem + 1.4vw, 3.5rem);

  /* Líneas y letterspacing */
  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-base:  1.55;
  --lh-loose: 1.7;

  /* Familias tipográficas */
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Anim curves & duraciones */
  --ease-out:     cubic-bezier(.22, 1, .36, 1);
  --ease-in-out:  cubic-bezier(.65, 0, .35, 1);
  --ease-emph:    cubic-bezier(.2, 0, 0, 1);
  --d-fast:   120ms;
  --d-base:   220ms;
  --d-slow:   380ms;

  /* Layout */
  --sidebar-w:    272px;
  --sidebar-w-mini: 76px;
  --topbar-h:     64px;
  --content-max:  1600px;

  /* Theme color (status bar mobile) */
  color-scheme: light dark;
}

/* ─── 2. Modo Oscuro automático y manual ───────────────────────────── */
/* ─── Modo Oscuro: Paleta Windows 11 (Fluent Design / Mica) ──────────
   Los grises de Windows 11 son neutros, no marrones — para que la
   información se distinga limpiamente sin tintes que compitan con
   los colores de los datos (estados, badges, gráficos).
   ─────────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    /* Fondos neutros estilo Windows 11 (gris azulado) */
    --bg:           #1f1f1f;     /* App background */
    --bg-elevated:  #2b2b2b;     /* Topbar, modals */
    --surface:      #2b2b2b;     /* Cards primary */
    --surface-2:    #323232;     /* Subtle surface (table headers, hover) */
    --surface-hover:#3d3d3d;     /* Hover states */
    --overlay:      rgba(0,0,0,.55);

    /* Sidebar — más oscuro para jerarquía clara */
    --sidebar-bg:   #1a1a1a;
    --sidebar-fg:   #ffffff;
    --sidebar-muted:#c8c6c4;

    /* Tintes suaves para badges y chips — neutros, no compiten con datos */
    --brand-soft:   rgba(220, 80, 65, .15);
    --gold-soft:    rgba(255, 200, 100, .12);
    --success-soft: rgba(108, 203, 95, .15);
    --warning-soft: rgba(252, 191, 73, .15);
    --danger-soft:  rgba(255, 99, 99, .15);
    --info-soft:    rgba(100, 167, 245, .15);

    /* Texto — alta legibilidad WCAG AAA en gris neutro */
    --text:         #ffffff;       /* Texto principal — blanco puro */
    --text-2:       #e6e6e6;       /* Texto secundario */
    --text-muted:   #b8b8b8;       /* Hints, labels */
    --text-faint:   #8a8a8a;       /* Placeholders */

    /* Bordes neutros */
    --border:       #404040;
    --border-strong:#5a5a5a;

    /* Acentos vibrantes para mejor visibilidad */
    --brand:        #e74c3c;       /* Rojo más vibrante */
    --brand-2:      #c0392b;
    --gold:         #ffc870;
    --success:      #6ccb5f;
    --warning:      #fcbf49;
    --danger:       #ff6363;
    --info:         #64a7f5;

    /* Sombras más suaves (estilo Windows 11) */
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 4px 12px rgba(0,0,0,.5);
    --shadow-3: 0 12px 28px rgba(0,0,0,.6);
    --shadow-focus: 0 0 0 2px rgba(231, 76, 60, .35);
  }
}

.theme-dark {
  /* Fondos */
  --bg:           #1f1f1f;
  --bg-elevated:  #2b2b2b;
  --surface:      #2b2b2b;
  --surface-2:    #323232;
  --surface-hover:#3d3d3d;
  --overlay:      rgba(0,0,0,.55);

  /* Sidebar */
  --sidebar-bg:   #1a1a1a;
  --sidebar-fg:   #ffffff;
  --sidebar-muted:#c8c6c4;

  /* Texto */
  --text:         #ffffff;
  --text-2:       #e6e6e6;
  --text-muted:   #b8b8b8;
  --text-faint:   #8a8a8a;

  /* Bordes */
  --border:       #404040;
  --border-strong:#5a5a5a;

  /* Acentos */
  --brand:        #e74c3c;
  --brand-2:      #c0392b;
  --gold:         #ffc870;
  --success:      #6ccb5f;
  --warning:      #fcbf49;
  --danger:       #ff6363;
  --info:         #64a7f5;

  /* Tintes suaves */
  --brand-soft:   rgba(220, 80, 65, .15);
  --gold-soft:    rgba(255, 200, 100, .12);
  --success-soft: rgba(108, 203, 95, .15);
  --warning-soft: rgba(252, 191, 73, .15);
  --danger-soft:  rgba(255, 99, 99, .15);
  --info-soft:    rgba(100, 167, 245, .15);

  /* Sombras */
  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 4px 12px rgba(0,0,0,.5);
  --shadow-3: 0 12px 28px rgba(0,0,0,.6);
  --shadow-focus: 0 0 0 2px rgba(231, 76, 60, .35);
}

/* View transition para cambio de tema fluido (no flash) */
@supports (view-transition-name: root) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 380ms;
    animation-timing-function: var(--ease-emph);
  }
}

/* ─── 3. Reset moderno ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 4; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
}
img, picture, video, canvas, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-tight);
  color: var(--text);
  letter-spacing: -.015em;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
small, .small { font-size: var(--fs-sm); }

/* ─── 4. Sidebar ───────────────────────────────────────────────────── */
.ayllu-sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
  transition: transform var(--d-base) var(--ease-out),
              width var(--d-base) var(--ease-out);
  border-right: 1px solid rgba(255,255,255,.04);
}
.ayllu-sidebar::-webkit-scrollbar { width: 4px; }
.ayllu-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.sidebar-brand {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-3) var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.brand-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-radius: var(--r-md) var(--r-sm) var(--r-md) var(--r-md);
  display: grid; place-items: center;
  color: #fff; font-size: 1.05rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(192,57,43,.35);
}
.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: #ffffff;
  letter-spacing: .04em; flex: 1;
  font-style: italic;
}

.btn-sidebar-toggle {
  color: rgba(255,255,255,.65);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  transition: color var(--d-fast), background var(--d-fast);
}
.btn-sidebar-toggle:hover { color: #ffffff; background: rgba(255,255,255,.1); }

.sidebar-nav { list-style: none; padding: var(--space-2) 0; flex: 1; }
.sidebar-nav .nav-separator {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: .65rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.5);
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: var(--space-2);
  padding: .58rem var(--space-3);
  color: rgba(255,255,255,.78);
  font-size: var(--fs-sm); font-weight: 450;
  border-left: 3px solid transparent;
  transition: color var(--d-fast), background var(--d-fast),
              border-color var(--d-fast), padding var(--d-fast);
  position: relative;
  white-space: nowrap;
}
.sidebar-nav .nav-link:hover {
  color: #ffffff;
  background: rgba(255,255,255,.06);
  border-left-color: rgba(192,57,43,.5);
  padding-left: calc(var(--space-3) + 4px);
}
.sidebar-nav .nav-link.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(192,57,43,.22), transparent);
  border-left-color: var(--brand);
  font-weight: 600;
}
.sidebar-nav .nav-link i {
  width: 18px; text-align: center;
  font-size: .9rem;
  color: rgba(255,255,255,.7);
  flex-shrink: 0;
  transition: color var(--d-fast);
}
.sidebar-nav .nav-link.active i,
.sidebar-nav .nav-link:hover i { color: #ffffff; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(255,255,255,.07);
  color: rgba(255,255,255,.55);
  font-size: var(--fs-xs);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(2px);
  z-index: 1039;
  animation: fadeIn var(--d-base) var(--ease-out);
}
.sidebar-overlay.show { display: block; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ─── 5. Main layout & topbar ──────────────────────────────────────── */
.ayllu-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  transition: margin-left var(--d-base) var(--ease-out);
}

.ayllu-topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-4);
  position: sticky; top: 0;
  z-index: 1030;
  height: var(--topbar-h);
  backdrop-filter: saturate(180%) blur(10px);
  background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
}
.ayllu-topbar > .btn-sidebar-toggle {
  color: var(--text-muted); display: none;
  width: 40px; height: 40px;
}
.topbar-breadcrumb {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: var(--space-2); }
.topbar-clock {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  display: flex; align-items: center; gap: .35rem;
}
.btn-topbar-icon {
  color: var(--text-muted);
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r);
  transition: background var(--d-fast), color var(--d-fast);
}
.btn-topbar-icon:hover { background: var(--surface-2); color: var(--text); }

.btn-user {
  border: 1px solid var(--border);
  border-radius: var(--r);
  display: flex; align-items: center; gap: var(--space-2);
  padding: .25rem var(--space-2) .25rem .25rem;
  transition: background var(--d-fast), border-color var(--d-fast);
}
.btn-user:hover { background: var(--surface-2); border-color: var(--border-strong); }
.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  border-radius: var(--r-sm) var(--r-md) var(--r-sm) var(--r-md);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.user-name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; }
.user-role { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.2; }

/* ─── 6. Content & containers ──────────────────────────────────────── */
.ayllu-content {
  padding: var(--space-4);
  flex: 1;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  container-type: inline-size;
  container-name: content;
}
.flash-container { margin-bottom: var(--space-3); }

/* ─── 7. Card ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: box-shadow var(--d-base) var(--ease-out),
              border-color var(--d-base) var(--ease-out);
  overflow: clip;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--text);
  display: flex; align-items: center; gap: .55rem;
}
.card-header i { color: var(--brand); }
.card-body { color: var(--text); padding: var(--space-4); }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: var(--space-3) var(--space-4); }

/* ─── 8. KPI Cards ─────────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: clip;
  transition: transform var(--d-base) var(--ease-out),
              box-shadow var(--d-base) var(--ease-out),
              border-color var(--d-base) var(--ease-out);
}
.kpi-card::before {
  content: '';
  position: absolute; inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(to bottom, var(--brand), var(--gold));
  opacity: 0;
  transition: opacity var(--d-base) var(--ease-out);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); border-color: var(--border-strong); }
.kpi-card:hover::before { opacity: 1; }

.kpi-icon {
  position: absolute; right: var(--space-3); top: 50%;
  transform: translateY(-50%);
  font-size: clamp(2rem, 5cqw, 2.8rem);
  opacity: .08;
  color: var(--text);
  pointer-events: none;
}
.kpi-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}
.kpi-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  line-height: 1;
  color: var(--text);
  font-feature-settings: "tnum" 1;
}
.kpi-change { font-size: var(--fs-sm); font-weight: 600; margin-top: var(--space-1); }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--brand); }
.kpi-change.neutral { color: var(--text-muted); }

/* ─── 9. Tables ────────────────────────────────────────────────────── */
.ayllu-table, .table {
  font-size: var(--fs-sm);
  color: var(--text);
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  --bs-table-color: var(--text);
  --bs-table-bg: var(--surface);
  --bs-table-hover-color: var(--text);
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-border-color: var(--border);
}
.ayllu-table thead th, .table thead th {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border) !important;
  padding: .65rem var(--space-3);
  white-space: nowrap;
  text-align: left;
  position: sticky; top: 0;
  z-index: 1;
}
.ayllu-table tbody td, .table tbody td {
  padding: .7rem var(--space-3);
  vertical-align: middle;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.ayllu-table tbody tr:hover td, .table tbody tr:hover td { background: var(--surface-2); }
.ayllu-table tbody tr:last-child td { border-bottom: 0; }

/* ─── 10. Forms ────────────────────────────────────────────────────── */
.form-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
  display: block;
}

.form-control, .form-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  padding: .55rem .75rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--d-fast), box-shadow var(--d-fast), background var(--d-fast);
  min-height: 40px;  /* WCAG touch target */
}
.form-control:hover, .form-select:hover { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: 0;
  background: var(--surface);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid { border-color: var(--success); }
.invalid-feedback { font-size: var(--fs-xs); color: var(--danger); margin-top: .25rem; }

.form-check-input { width: 18px; height: 18px; cursor: pointer; }
.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}
.form-check-input:focus-visible {
  box-shadow: var(--shadow-focus);
}

/* Touch device — larger targets */
@media (pointer: coarse) {
  .form-control, .form-select { min-height: 44px; padding: .65rem .8rem; }
  .form-check-input { width: 22px; height: 22px; }
}

/* ─── 11. Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .45rem;
  font-weight: 600;
  font-size: var(--fs-sm);
  padding: .5rem 1rem;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--d-fast), color var(--d-fast),
              border-color var(--d-fast), box-shadow var(--d-fast),
              transform var(--d-fast);
  white-space: nowrap;
  min-height: 38px;
  position: relative;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

@media (pointer: coarse) {
  .btn { min-height: 44px; padding: .6rem 1.1rem; }
}

.btn-primary {
  background: var(--brand);
  color: #fff !important;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }

.btn-outline-primary {
  color: var(--brand);
  border-color: var(--brand);
  background: transparent;
}
.btn-outline-primary:hover { background: var(--brand); color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #176c3b; border-color: #176c3b; color: #fff; }

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

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

.btn-sm { font-size: var(--fs-xs); padding: .35rem .7rem; min-height: 32px; }
@media (pointer: coarse) { .btn-sm { min-height: 36px; padding: .4rem .75rem; } }

.btn-xs { font-size: .68rem; padding: .2rem .5rem; min-height: 26px; }

/* ─── 12. Badges & Status ──────────────────────────────────────────── */
.badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: .3rem;
  letter-spacing: .02em;
}
.bg-success { background: var(--success-soft) !important; color: var(--success) !important; }
.bg-danger { background: var(--danger-soft) !important; color: var(--danger) !important; }
.bg-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }
.bg-info { background: var(--info-soft) !important; color: var(--info) !important; }
.bg-secondary { background: var(--surface-2) !important; color: var(--text-muted) !important; }
.bg-accent { background: var(--brand) !important; color: #fff !important; }

.status-pendiente { background: var(--warning-soft); color: var(--warning); }
.status-confirmado, .status-disponible, .status-abierta { background: var(--success-soft); color: var(--success); }
.status-cancelado, .status-ocupada { background: var(--danger-soft); color: var(--danger); }
.status-completado, .status-cerrada { background: var(--surface-2); color: var(--text-muted); }
.status-reservada { background: var(--info-soft); color: var(--info); }

/* ─── 13. Pagination ───────────────────────────────────────────────── */
.pagination .page-link {
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-sm);
  padding: .35rem .65rem;
  border-radius: var(--r-sm) !important;
  margin: 0 2px;
  background: var(--surface);
  transition: all var(--d-fast);
  min-width: 36px;
}
.pagination .page-link:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.pagination .page-item.active .page-link {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.pagination .page-item.disabled .page-link { opacity: .4; }

/* ─── 14. Alerts ───────────────────────────────────────────────────── */
.alert {
  border-radius: var(--r);
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  border-left: 4px solid;
  padding: .8rem var(--space-3);
}
.alert-success { background: var(--success-soft); color: var(--success); border-left-color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-danger  { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-left-color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-info    { background: var(--info-soft); color: var(--info); border-left-color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-light   { background: var(--surface-2); color: var(--text); border-left-color: var(--border-strong); border-color: var(--border); }

/* ─── 15. Progress ─────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-bar { border-radius: var(--r-pill); transition: width var(--d-slow) var(--ease-emph); }

/* ─── 16. Login page ───────────────────────────────────────────────── */
body.login-body {
  background: radial-gradient(ellipse at 25% 30%, #2a201a 0%, var(--sidebar-bg) 60%);
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--space-3);
  position: relative;
  overflow: hidden;
}
body.login-body::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 25% 65%, rgba(192,57,43,.25) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 15%, rgba(212,168,83,.18) 0%, transparent 50%);
  pointer-events: none;
  animation: drift 28s ease-in-out infinite alternate;
}
@keyframes drift {
  to { background-position: 80% 30%, 30% 90%; }
}
.login-wrapper { width: 100%; max-width: 440px; position: relative; z-index: 1; }
.login-card {
  background: rgba(255,255,255,.05);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-lg);
  padding: var(--space-6) var(--space-5) var(--space-5);
  box-shadow: 0 24px 48px -12px rgba(0,0,0,.4);
}
.login-brand { text-align: center; margin-bottom: var(--space-5); }
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border-radius: var(--r-lg) var(--r-md) var(--r-lg) var(--r-lg);
  display: grid; place-items: center;
  color: #fff; font-size: 1.6rem;
  margin: 0 auto var(--space-3);
  box-shadow: 0 8px 24px rgba(192,57,43,.5);
}
.login-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  color: #fff; margin: 0 0 .35rem;
  letter-spacing: .04em;
  font-style: italic;
}
.login-subtitle {
  color: rgba(255,255,255,.5);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.login-card .form-label { color: rgba(255,255,255,.78); }
.login-card .form-control,
.login-card .form-control-lg {
  background: rgba(255,255,255,.06) !important;
  border: 1px solid rgba(255,255,255,.12) !important;
  color: #fff !important;
  font-size: .95rem;
}
.login-card .form-control::placeholder { color: rgba(255,255,255,.32) !important; }
.login-card .form-control:focus {
  background: rgba(255,255,255,.1) !important;
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(192,57,43,.25) !important;
  color: #fff !important;
}
.login-card .input-group-text {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.5);
}
.login-card .btn-outline-secondary {
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.5);
}
.btn-login {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)) !important;
  border: 0 !important;
  color: #fff !important;
  font-weight: 600;
  letter-spacing: .03em;
  padding: .8rem 1rem;
  border-radius: var(--r-sm);
  font-size: 1rem;
  box-shadow: 0 6px 18px rgba(192,57,43,.4);
  width: 100%;
  transition: box-shadow var(--d-fast), transform var(--d-fast);
}
.btn-login:hover { box-shadow: 0 8px 24px rgba(192,57,43,.55); }
.btn-login:active { transform: scale(.98); }
.login-demo-info {
  text-align: center;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(255,255,255,.08);
}
.login-demo-info small { color: rgba(255,255,255,.5); }
.login-demo-info strong { color: rgba(255,255,255,.85); }
.login-footer { text-align: center; margin-top: var(--space-3); color: rgba(255,255,255,.25); font-size: var(--fs-xs); }

/* ─── 17. POS / Caja ───────────────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-3);
  height: calc(100vh - 110px);
  overflow: hidden;
}
.pos-products { overflow-y: auto; padding-right: 4px; }
.pos-cart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-2);
}
.pos-cart-header { padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--border); font-weight: 600; }
.pos-cart-items { flex: 1; overflow-y: auto; padding: var(--space-2); }
.pos-cart-footer { border-top: 1px solid var(--border); padding: var(--space-3); }
.cart-item { display: flex; align-items: center; gap: .6rem; padding: .55rem; border-radius: var(--r-sm); transition: background var(--d-fast); }
.cart-item:hover { background: var(--surface-2); }
.cart-item-qty { width: 28px; height: 28px; background: var(--brand); color: #fff; border-radius: var(--r-xs); display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex-shrink: 0; }
.cart-item-name { font-size: var(--fs-sm); font-weight: 500; flex: 1; }
.cart-item-price { font-size: var(--fs-sm); font-weight: 700; color: var(--brand); }
.cart-item-remove { width: 24px; height: 24px; background: transparent; border: 1px solid var(--border); border-radius: 50%; color: var(--text-muted); display: grid; place-items: center; transition: all var(--d-fast); flex-shrink: 0; }
.cart-item-remove:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.pos-grand-total {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-display); font-size: var(--fs-xl);
  border-top: 1px solid var(--border); padding-top: var(--space-2); margin-top: var(--space-1);
}
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--space-3) var(--space-2);
  cursor: pointer; transition: all var(--d-base) var(--ease-out); text-align: center;
}
.product-card:hover { border-color: var(--brand); box-shadow: var(--shadow-3); transform: translateY(-2px); }
.product-card-emoji { font-size: 2rem; margin-bottom: .3rem; display: block; }
.product-card-name { font-size: var(--fs-sm); font-weight: 600; }
.product-card-price { font-size: var(--fs-base); font-weight: 700; color: var(--brand); }
.cat-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: .35rem var(--space-3);
  font-size: var(--fs-sm); font-weight: 500; color: var(--text-muted);
  transition: all var(--d-fast); white-space: nowrap;
}
.cat-btn:hover, .cat-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ─── 18. Calendar ─────────────────────────────────────────────────── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); cursor: pointer;
  transition: background var(--d-fast); min-height: 52px;
}
.cal-day:hover { background: var(--surface-2); }
.cal-day.today { background: var(--brand-soft); font-weight: 700; color: var(--brand); }
.cal-day.has-reservas::after { content: ''; width: 6px; height: 6px; background: var(--brand); border-radius: 50%; margin-top: 2px; }
.cal-day.other-month { opacity: .35; }
.cal-day-header { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

/* ─── 19. Recipe ingredient rows ───────────────────────────────────── */
.ing-row {
  display: grid; grid-template-columns: 1fr 90px 120px auto;
  gap: .5rem; align-items: center;
  padding: .45rem .55rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: .45rem;
  background: var(--surface-2);
}
.ing-row:hover { background: var(--surface); border-color: var(--border-strong); }
.btn-remove-ing {
  width: 30px; height: 30px;
  background: transparent; border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-muted); display: grid; place-items: center; transition: all var(--d-fast);
}
.btn-remove-ing:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ─── 20. Pulse / animations ───────────────────────────────────────── */
.alert-dot {
  width: 8px; height: 8px; background: var(--brand);
  border-radius: 50%; display: inline-block;
  animation: pulse-dot 1.6s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.45); opacity: .55; }
}

/* ─── 21. Utility ──────────────────────────────────────────────────── */
.text-accent  { color: var(--brand) !important; }
.text-gold    { color: var(--gold) !important; }
.text-muted   { color: var(--text-muted) !important; }
.bg-surface   { background: var(--surface) !important; }
.fw-600       { font-weight: 600; }
.cursor-pointer { cursor: pointer; }

/* Bootstrap component sync */
.dropdown-menu { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3); border-radius: var(--r-md); padding: .35rem; }
.dropdown-item { color: var(--text); font-size: var(--fs-sm); padding: .45rem .75rem; border-radius: var(--r-xs); }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.text-danger { color: var(--danger) !important; }
.dropdown-divider { border-color: var(--border); }
.breadcrumb-item a { color: var(--brand); }
.breadcrumb-item.active { color: var(--text-muted); }
.modal-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.modal-header, .modal-footer { border-color: var(--border); }
hr { border-color: var(--border); margin: var(--space-3) 0; }

/* ─── 22. Container Queries — adapt by container, not viewport ─────── */
@container content (max-width: 720px) {
  .ayllu-content .row.g-4 { gap: var(--space-3); }
  .kpi-card { padding: var(--space-3); }
  .kpi-value { font-size: var(--fs-xl); }
}
@container content (max-width: 540px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .ing-row { grid-template-columns: 1fr 80px auto; }
}

/* ─── 23. Responsive — tablet ≤991px ───────────────────────────────── */
@media (max-width: 991.98px) {
  .ayllu-sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .ayllu-sidebar.open { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,.4); }
  .ayllu-main { margin-left: 0 !important; }
  .ayllu-topbar > .btn-sidebar-toggle { display: grid; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { max-height: 480px; }
}

/* ─── 24. Responsive — mobile ≤575px ──────────────────────────────── */
@media (max-width: 575.98px) {
  :root { --sidebar-w: 240px; }
  .ayllu-content { padding: var(--space-3); }
  .ayllu-topbar { padding: 0 var(--space-3); height: 56px; }
  .topbar-actions { gap: var(--space-1); }
  .btn-user .user-info { display: none !important; }
  .ing-row { grid-template-columns: 1fr 80px auto; }
  .cal-day { min-height: 40px; font-size: var(--fs-xs); }
  .login-card { padding: var(--space-4) var(--space-3); }
  .pos-products { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ─── 25. Foldable / dual-screen ───────────────────────────────────── */
@media (horizontal-viewport-segments: 2) {
  .ayllu-content { max-width: env(viewport-segment-right 0 0); }
}

/* ─── 26. Print ────────────────────────────────────────────────────── */
@media print {
  .ayllu-sidebar, .ayllu-topbar, .btn, .pagination, .alert-dot { display: none !important; }
  .ayllu-main { margin: 0 !important; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #999; box-shadow: none; }
}

/* ─── 27. Reduced motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* Mantener fades sutiles para feedback */
  .alert, .flash-container { transition: opacity 200ms !important; }
}

/* ─── 28. Hover only en pointer:fine ───────────────────────────────── */
@media (hover: none) {
  .product-card:hover, .kpi-card:hover, .card:hover {
    transform: none;
    box-shadow: var(--shadow-1);
    border-color: var(--border);
  }
}

/* ─── 29. High contrast (WCAG 3.0 AAA opcional) ────────────────────── */
@media (prefers-contrast: more) {
  :root {
    --border: #6b6259;
    --border-strong: #14110d;
    --text-muted: #3d342b;
  }
  .btn { border-width: 2px; }
}

/* ─── 30. Forced colors (Windows High Contrast) ────────────────────── */
@media (forced-colors: active) {
  .card, .btn, .form-control { border: 1px solid CanvasText; }
  .btn-primary { background: Highlight; color: HighlightText; }
}

/* ═══════════════════════════════════════════════════════════════════
   31. OVERRIDES GLOBALES DE LEGIBILIDAD (override de Bootstrap/varios)
   Aplica a todo el sistema — refuerza el contraste de textos.
   ═══════════════════════════════════════════════════════════════════ */

/* Forzar buen contraste para texto secundario en cualquier contexto */
.text-muted,
.text-secondary,
.form-text,
small.text-muted,
.text-body-secondary {
  color: var(--text-muted) !important;
}

/* Texto faint sólo cuando sea explícito */
.text-faint { color: var(--text-faint) !important; }

/* Placeholders más visibles */
.form-control::placeholder,
.form-select::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-faint) !important;
  opacity: 1 !important;
}

/* Labels de formulario siempre legibles */
.form-label,
label {
  color: var(--text);
  font-weight: 600;
}

/* Card body, paragraphs, list-group, etc. */
.card-body,
.card-body p,
.card-body li,
.card-body span:not(.badge):not([class*="text-"]),
.card-body div:not([class*="text-"]) {
  color: inherit;
}
.card-body { color: var(--text); }

/* Textos pequeños / metadatos */
.text-muted-sm,
.text-meta {
  color: var(--text-muted) !important;
  font-size: var(--fs-sm);
}

/* Headers de tablas y de cards */
.card-header { color: var(--text); }
.table thead th, .ayllu-table thead th { color: var(--text-muted); }

/* Breadcrumbs */
.breadcrumb-item.active { color: var(--text-muted); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-faint); }

/* Disabled */
.form-control:disabled,
.form-select:disabled,
input:disabled,
textarea:disabled {
  background-color: var(--surface-2) !important;
  color: var(--text-muted) !important;
  opacity: 1;
}

/* Iconos junto a texto */
.text-muted i, small i { color: inherit; }

/* Help text bajo inputs */
.form-text { color: var(--text-muted); font-size: var(--fs-xs); }

/* Texto en badges asegurar contraste */
.badge { font-weight: 600; }
.bg-secondary { background: var(--surface-2) !important; color: var(--text-2) !important; }

/* Empty states */
.empty-state, .empty-mesas {
  color: var(--text-muted);
}
.empty-state h3, .empty-mesas h3 { color: var(--text); }

/* Links secundarios */
a.text-muted:hover { color: var(--brand) !important; }

/* Modo oscuro: refuerzos extra */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    /* Asegurar que el texto sobre superficies tenue no se pierda */
  }
  :root:not(.theme-light) .form-control,
  :root:not(.theme-light) .form-select {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
  }
  :root:not(.theme-light) .form-control:focus,
  :root:not(.theme-light) .form-select:focus {
    background-color: var(--surface);
    color: var(--text);
  }
  :root:not(.theme-light) .table,
  :root:not(.theme-light) .ayllu-table {
    --bs-table-color: var(--text);
    --bs-table-bg: var(--surface);
    --bs-table-hover-color: var(--text);
    --bs-table-hover-bg: var(--surface-hover);
  }
  /* Texto en login en oscuro */
  :root:not(.theme-light) .login-card .form-label { color: rgba(255,255,255,.85); }
  :root:not(.theme-light) .login-card .form-control { color: #fff !important; }
}

/* Lo mismo para .theme-dark explícito */
.theme-dark .form-control,
.theme-dark .form-select {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.theme-dark .form-control:focus,
.theme-dark .form-select:focus {
  background-color: var(--surface);
  color: var(--text);
}
.theme-dark .table,
.theme-dark .ayllu-table {
  --bs-table-color: var(--text);
  --bs-table-bg: var(--surface);
  --bs-table-hover-color: var(--text);
  --bs-table-hover-bg: var(--surface-hover);
}
.theme-dark .login-card .form-label { color: rgba(255,255,255,.85); }
.theme-dark .login-card .form-control { color: #fff !important; }

/* Login: aumentar contraste de demo info */
.login-card { color: var(--text-on-dark, #f5efe5); }
.login-card .form-label { color: rgba(255,255,255,.88); }
.login-demo-info small { color: rgba(255,255,255,.7); }
.login-demo-info strong { color: rgba(255,255,255,.95); }
.login-footer { color: rgba(255,255,255,.5); }

/* User dropdown en topbar */
.user-name { color: var(--text); }
.user-role { color: var(--text-muted); }

/* Topbar breadcrumb */
.topbar-breadcrumb { color: var(--text-2); }

/* Reservaciones: texto del stepper inactivo */
.res-step:not(.active):not(.complete) { color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════════
   32. UNIFIED PAGE HEADERS, FILTERS & ACTION BUTTONS
   - Remove header duplication (topbar shows breadcrumb only)
   - Standardize section header pattern across all index pages
   - Convert "pill" links to actual bordered buttons
   ═══════════════════════════════════════════════════════════════════ */

/* Topbar breadcrumb: subtle, just for context, NOT a duplicate title */
.topbar-breadcrumb {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.topbar-breadcrumb i {
  font-size: .7rem;
  opacity: .6;
}
.topbar-breadcrumb .crumb-current {
  color: var(--text);
}

/* Page header — the ONE title block per page */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.page-header-content {
  flex: 1 1 auto;
  min-width: 0;
}

.page-header-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  line-height: 1.1;
  color: var(--text);
  margin: 0 0 .35rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  letter-spacing: -.01em;
}
.page-header-title i {
  color: var(--brand);
  font-size: .8em;
  opacity: .85;
}

.page-header-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: var(--lh-snug);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Filter bar: bordered buttons that look like filter chips */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.filter-bar-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-right: .25rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.filter-bar-label i { color: var(--brand); }

/* Filter button — a real button, with visible border */
.btn-filter {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--d-fast),
              border-color var(--d-fast),
              color var(--d-fast),
              box-shadow var(--d-fast);
  white-space: nowrap;
  user-select: none;
}
.btn-filter:hover {
  background: var(--surface);
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}
.btn-filter.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(192,57,43,.18);
}
.btn-filter.active:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: #fff;
}
.btn-filter .badge {
  font-size: .65rem;
  padding: .12rem .45rem;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-filter.active .badge {
  background: rgba(255,255,255,.2);
  color: #fff;
  border-color: rgba(255,255,255,.3);
}
.btn-filter i { font-size: .8em; opacity: .7; }
.btn-filter.active i { opacity: 1; }

@media (pointer: coarse) {
  .btn-filter { padding: .5rem 1rem; min-height: 40px; }
}

/* Hide old patterns to avoid clashes during migration */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  margin: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--text);
}
.section-title i { color: var(--brand); }

/* Stat-pill legacy → ahora se ve como botón con borde */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .85rem;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  text-decoration: none;
  transition: all var(--d-fast);
}
.stat-pill:hover {
  border-color: var(--brand);
  color: var(--brand);
  text-decoration: none;
}
.stat-pill.bg-soft-red,
.stat-pill.active {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
}
.stat-pill .badge {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.stat-pill.bg-soft-red .badge,
.stat-pill.active .badge {
  background: rgba(255,255,255,.22);
  color: #fff;
  border-color: rgba(255,255,255,.3);
}

/* ═══════════════════════════════════════════════════════════════════
   33. WINDOWS 11 DARK MODE REFINEMENTS
   Ajustes específicos para que el modo oscuro se sienta como Windows 11
   con clara jerarquía visual y máxima legibilidad de información.
   ═══════════════════════════════════════════════════════════════════ */

/* Active states de botones primarios en oscuro — estilo Fluent */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .btn-primary {
    background: var(--brand);
    color: #ffffff !important;
    border-color: var(--brand);
    box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
  }
  :root:not(.theme-light) .btn-primary:hover {
    background: var(--brand-2);
  }
  :root:not(.theme-light) .btn-outline-secondary {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-strong);
  }
  :root:not(.theme-light) .btn-outline-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--text-faint);
  }

  /* KPI cards más visibles */
  :root:not(.theme-light) .kpi-card,
  :root:not(.theme-light) .card {
    background: var(--surface);
    border-color: var(--border);
  }
  :root:not(.theme-light) .kpi-icon { opacity: .15; }

  /* Card headers — sutil, sin tinte cálido */
  :root:not(.theme-light) .card-header {
    background: rgba(255,255,255,.02);
    border-bottom-color: var(--border);
  }

  /* Inputs — fondo elevado para distinguirse del card */
  :root:not(.theme-light) .form-control,
  :root:not(.theme-light) .form-select {
    background: var(--bg);
    border-color: var(--border-strong);
    color: var(--text);
  }
  :root:not(.theme-light) .form-control:focus,
  :root:not(.theme-light) .form-select:focus {
    background: var(--bg);
    border-color: var(--brand);
    box-shadow: var(--shadow-focus);
  }
  :root:not(.theme-light) .form-control::placeholder {
    color: var(--text-faint);
  }

  /* Tablas — separación visual clara */
  :root:not(.theme-light) .table thead th,
  :root:not(.theme-light) .ayllu-table thead th {
    background: var(--surface-2);
    color: var(--text-2);
    border-bottom-color: var(--border-strong) !important;
  }
  :root:not(.theme-light) .table tbody td,
  :root:not(.theme-light) .ayllu-table tbody td {
    color: var(--text);
    border-color: var(--border);
  }
  :root:not(.theme-light) .table tbody tr:hover td,
  :root:not(.theme-light) .ayllu-table tbody tr:hover td {
    background: var(--surface-hover);
  }

  /* Sidebar items - alta legibilidad */
  :root:not(.theme-light) .sidebar-nav .nav-link {
    color: rgba(255,255,255,.85);
  }
  :root:not(.theme-light) .sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.08);
    color: #ffffff;
  }
  :root:not(.theme-light) .sidebar-nav .nav-link.active {
    background: rgba(231, 76, 60, .15);
    color: #ffffff;
    border-left-color: var(--brand);
  }
  :root:not(.theme-light) .sidebar-nav .nav-separator {
    color: rgba(255,255,255,.55);
  }

  /* Badges, alerts — bordes visibles */
  :root:not(.theme-light) .badge {
    border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
  }
  :root:not(.theme-light) .alert {
    border-color: color-mix(in srgb, currentColor 25%, transparent);
  }

  /* Topbar */
  :root:not(.theme-light) .ayllu-topbar {
    background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
    border-bottom-color: var(--border);
  }
  :root:not(.theme-light) .topbar-breadcrumb { color: var(--text-muted); }
  :root:not(.theme-light) .topbar-breadcrumb .crumb-current { color: var(--text-2); }

  /* Filter buttons */
  :root:not(.theme-light) .btn-filter {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-2);
  }
  :root:not(.theme-light) .btn-filter:hover {
    background: var(--surface-hover);
    border-color: var(--brand);
    color: var(--brand);
  }
  :root:not(.theme-light) .btn-filter.active {
    background: var(--brand);
    color: #ffffff;
    border-color: var(--brand);
  }

  /* Page header divider */
  :root:not(.theme-light) .page-header { border-bottom-color: var(--border); }
  :root:not(.theme-light) .page-header-title { color: var(--text); }
  :root:not(.theme-light) .page-header-subtitle { color: var(--text-muted); }
}

/* Mismas reglas para .theme-dark explícito (toggle manual) */
.theme-dark .btn-primary {
  background: var(--brand);
  color: #ffffff !important;
  border-color: var(--brand);
}
.theme-dark .btn-outline-secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.theme-dark .btn-outline-secondary:hover {
  background: var(--surface-hover);
}

.theme-dark .kpi-card,
.theme-dark .card {
  background: var(--surface);
  border-color: var(--border);
}
.theme-dark .kpi-icon { opacity: .15; }

.theme-dark .card-header {
  background: rgba(255,255,255,.02);
  border-bottom-color: var(--border);
}

.theme-dark .form-control,
.theme-dark .form-select {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
}
.theme-dark .form-control:focus,
.theme-dark .form-select:focus {
  background: var(--bg);
  border-color: var(--brand);
}
.theme-dark .form-control::placeholder {
  color: var(--text-faint);
}

.theme-dark .table thead th,
.theme-dark .ayllu-table thead th {
  background: var(--surface-2);
  color: var(--text-2);
  border-bottom-color: var(--border-strong) !important;
}
.theme-dark .table tbody td,
.theme-dark .ayllu-table tbody td {
  color: var(--text);
  border-color: var(--border);
}
.theme-dark .table tbody tr:hover td,
.theme-dark .ayllu-table tbody tr:hover td {
  background: var(--surface-hover);
}

.theme-dark .sidebar-nav .nav-link { color: rgba(255,255,255,.85); }
.theme-dark .sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #ffffff;
}
.theme-dark .sidebar-nav .nav-link.active {
  background: rgba(231, 76, 60, .15);
  color: #ffffff;
  border-left-color: var(--brand);
}
.theme-dark .sidebar-nav .nav-separator { color: rgba(255,255,255,.55); }

.theme-dark .badge {
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
}

.theme-dark .ayllu-topbar {
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  border-bottom-color: var(--border);
}
.theme-dark .topbar-breadcrumb { color: var(--text-muted); }
.theme-dark .topbar-breadcrumb .crumb-current { color: var(--text-2); }

.theme-dark .btn-filter {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-2);
}
.theme-dark .btn-filter:hover {
  background: var(--surface-hover);
  border-color: var(--brand);
  color: var(--brand);
}
.theme-dark .btn-filter.active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
}

.theme-dark .page-header { border-bottom-color: var(--border); }
.theme-dark .page-header-title { color: var(--text); }
.theme-dark .page-header-subtitle { color: var(--text-muted); }

/* Status badges — visibles en ambos modos */
.theme-dark .status-pendiente, .theme-dark .bg-warning {
  background: var(--warning-soft) !important;
  color: var(--warning) !important;
}
.theme-dark .status-confirmada,
.theme-dark .status-disponible,
.theme-dark .status-abierta,
.theme-dark .bg-success {
  background: var(--success-soft) !important;
  color: var(--success) !important;
}
.theme-dark .status-cancelada,
.theme-dark .status-ocupada,
.theme-dark .bg-danger {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
}
.theme-dark .status-completada,
.theme-dark .status-cerrada,
.theme-dark .bg-secondary {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
}
.theme-dark .status-reservada,
.theme-dark .bg-info {
  background: var(--info-soft) !important;
  color: var(--info) !important;
}
