/* ============================================================================
   MISE — Sistema de diseño
   Cristal profundo + rigor editorial.
   Capa 1 primitivos · Capa 2 semánticos · Capa 3 componente.
   Paleta de series validada con dataviz/validate_palette.js (dark y light PASS).
   ========================================================================== */

/* ---------- Capa 1: primitivos ---------- */
:root {
  /* Curvas — de la tabla de animate, no inventadas */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* Duraciones */
  --d-press: 160ms;
  --d-hover: 180ms;
  --d-pop:   200ms;
  --d-menu:  220ms;
  --d-modal: 250ms;
  --d-move:  260ms;
  --d-draw:  620ms;

  /* Escala tipográfica */
  --t-xs:  11px;
  --t-sm:  12px;
  --t-md:  13px;
  --t-base:14px;
  --t-lg:  16px;
  --t-xl:  20px;
  --t-2xl: 26px;
  --t-3xl: 34px;
  --t-4xl: 44px;

  /* Espaciado */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 30px; --s-8: 36px; --s-10: 44px; --s-12: 60px;

  /* Radios */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  --sidebar-w: 246px;
  --topbar-h: 62px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- Capa 2: semánticos — TEMA OSCURO (por defecto) ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:        #070B14;
  --bg-deep:   #050810;
  --surface:   #0F1729;   /* la superficie contra la que se validó la paleta */
  --glass:     rgba(20, 29, 49, 0.66);
  --glass-2:   rgba(28, 39, 63, 0.55);
  --glass-hi:  rgba(255, 255, 255, 0.055);
  --raise:     rgba(255, 255, 255, 0.035);

  --ink:   #E8EFFB;
  --ink-2: #94A5C4;
  --ink-3: #5C6C8A;

  --line:      rgba(148, 170, 214, 0.14);
  --line-soft: rgba(148, 170, 214, 0.08);

  --acc:    #22D3EE;
  --acc-2:  #A78BFA;
  --acc-ink:#04121A;
  --acc-wash: rgba(34, 211, 238, 0.12);
  --acc-2-wash: rgba(167, 139, 250, 0.12);

  --good: #34D399;  --good-wash: rgba(52, 211, 153, 0.13);
  --warn: #FBBF24;  --warn-wash: rgba(251, 191, 36, 0.13);
  --sers: #FB923C;  --sers-wash: rgba(251, 146, 60, 0.13);
  --crit: #F87171;  --crit-wash: rgba(248, 113, 113, 0.13);

  /* Series de gráfica — orden fijo, nunca cíclico (dataviz) */
  --c1: #0EA5C4; --c2: #8B5CF6; --c3: #D97706;
  --c4: #059669; --c5: #3B82F6; --c6: #EC4899;

  --grid: rgba(148, 170, 214, 0.10);
  --shadow-card: 0 1px 0 var(--glass-hi) inset, 0 18px 44px -22px rgba(0, 0, 0, 0.9);
  --shadow-pop:  0 24px 60px -20px rgba(0, 0, 0, 0.85);
  --atm-1: rgba(34, 211, 238, 0.13);
  --atm-2: rgba(167, 139, 250, 0.13);
  --atm-3: rgba(59, 130, 246, 0.10);
}

/* ---------- Capa 2: semánticos — TEMA CLARO (elegido, no invertido) ---------- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:        #EEF2F9;
  --bg-deep:   #E4EAF4;
  --surface:   #FFFFFF;
  --glass:     rgba(255, 255, 255, 0.78);
  --glass-2:   rgba(255, 255, 255, 0.92);
  --glass-hi:  rgba(255, 255, 255, 0.9);
  --raise:     rgba(15, 23, 42, 0.025);

  --ink:   #0B1220;
  --ink-2: #4A5A73;
  --ink-3: #8494AC;

  --line:      rgba(15, 23, 42, 0.11);
  --line-soft: rgba(15, 23, 42, 0.06);

  --acc:    #0891B2;
  --acc-2:  #7C3AED;
  --acc-ink:#FFFFFF;
  --acc-wash: rgba(8, 145, 178, 0.10);
  --acc-2-wash: rgba(124, 58, 237, 0.10);

  --good: #059669;  --good-wash: rgba(5, 150, 105, 0.11);
  --warn: #B45309;  --warn-wash: rgba(180, 83, 9, 0.11);
  --sers: #C2410C;  --sers-wash: rgba(194, 65, 12, 0.11);
  --crit: #DC2626;  --crit-wash: rgba(220, 38, 38, 0.10);

  --c1: #0891B2; --c2: #7C3AED; --c3: #D97706;
  --c4: #059669; --c5: #2563EB; --c6: #DB2777;

  --grid: rgba(15, 23, 42, 0.075);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.06), 0 18px 38px -22px rgba(15, 23, 42, 0.42);
  --shadow-pop:  0 26px 56px -18px rgba(15, 23, 42, 0.38);
  /* El claro también lleva color: sin esto se lee como plantilla blanca. */
  --atm-1: rgba(8, 145, 178, 0.26);
  --atm-2: rgba(124, 58, 237, 0.22);
  --atm-3: rgba(217, 119, 6, 0.16);
}
:root[data-theme="light"] .atmosphere { opacity: 1; filter: blur(90px); }

/* ============================ Base ============================ */
* { box-sizing: border-box; touch-action: pan-x pan-y; }
@media (pointer: coarse) { input, select, textarea { font-size: 16px !important; } }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* El cambio de tema no transiciona color por color (quedaban a destiempo
   entre fondos, sombras y glass — se veía sucio, E-055). Se vela toda la
   pantalla, se cambia el tema de un golpe por debajo, se destapa: el mismo
   patrón que el swap de idioma, ver .lang-swapping. */
body {
  transition: opacity 170ms var(--ease-in-out), filter 170ms var(--ease-in-out);
}
html.theme-swapping body {
  opacity: 0.25;
  filter: blur(3px);
}

::selection { background: var(--acc-wash); color: var(--ink); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.018em; }
p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-xs);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Barra de desplazamiento propia — el detalle que delata una plantilla */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--r-full);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

/* ====================== Atmósfera de fondo ====================== */
.atmosphere {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.85;
}
.atmosphere span {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
}
.atmosphere .a1 {
  width: 46vw; height: 46vw; left: 4%; top: 2%;
  background: var(--atm-1);
  animation: drift-a 34s var(--ease-in-out) infinite alternate;
}
.atmosphere .a2 {
  width: 40vw; height: 40vw; right: 6%; top: 18%;
  background: var(--atm-2);
  animation: drift-b 41s var(--ease-in-out) infinite alternate;
}
.atmosphere .a3 {
  width: 38vw; height: 38vw; left: 34%; bottom: 0%;
  background: var(--atm-3);
  animation: drift-c 47s var(--ease-in-out) infinite alternate;
}
@keyframes drift-a { to { transform: translate3d(7%, 5%, 0) scale(1.12); } }
@keyframes drift-b { to { transform: translate3d(-8%, 8%, 0) scale(0.9); } }
@keyframes drift-c { to { transform: translate3d(5%, -7%, 0) scale(1.08); } }

/* Rejilla estructural: da el aire de consola de trabajo */
.gridlines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 100% 92px, 92px 100%;
  mask-image: radial-gradient(ellipse 110% 70% at 50% 0%, #000 6%, transparent 62%);
  opacity: 0.4;
}

/* ====================== Estructura ====================== */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Cristal: un solo patrón, reutilizado ---------- */
.glass {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg,
    var(--glass-hi) 0%,
    transparent 34%,
    transparent 66%,
    rgba(255, 255, 255, 0.03) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}
:root[data-theme="light"] .glass { border: 1px solid var(--line); }
:root[data-theme="light"] .glass::before { opacity: 0.5; }

/* ---------- Barra lateral ---------- */
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-4);
  background: linear-gradient(180deg, var(--glass) 0%, var(--glass-2) 100%);
  backdrop-filter: blur(26px) saturate(150%);
  -webkit-backdrop-filter: blur(26px) saturate(150%);
  border-right: 1px solid var(--line);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 var(--s-2) var(--s-1); }
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--acc), var(--acc-2));
  color: var(--acc-ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.04em;
  box-shadow: 0 6px 18px -8px var(--acc);
  transition: transform var(--d-press) var(--ease-out);
}
.brand:hover .brand-mark { transform: rotate(-6deg) scale(1.04); }
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -0.03em; }
.brand-sub { font-size: 10px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }

/* Selector de organización (multi-empresa) */
.org { position: relative; }
.org-btn {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: left;
  transition:
    background-color var(--d-hover) var(--ease-out),
    border-color var(--d-hover) var(--ease-out),
    transform var(--d-press) var(--ease-out);
}
.org-btn:active { transform: scale(0.985); }
.org-avatar {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
}
.org-meta { min-width: 0; flex: 1; }
.org-name {
  font-size: var(--t-md); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.org-role { font-size: 10px; color: var(--ink-3); }
.org-caret {
  color: var(--ink-3);
  transition: transform var(--d-menu) var(--ease-out);
}
.org-btn[aria-expanded="true"] .org-caret { transform: rotate(180deg); }

.org-menu {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  z-index: 60;
  padding: 6px;
  background: var(--glass-2);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  transform-origin: top center;      /* nace del disparador */
  transition:
    opacity var(--d-menu) var(--ease-out),
    transform var(--d-menu) var(--ease-out),
    visibility 0s linear var(--d-menu);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95) translateY(-4px);
}
.org-menu[data-open="true"] {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
  transition-delay: 0s;
}
.org-item {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px;
  border: 0; background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer; text-align: left;
  transition: background-color var(--d-hover) var(--ease-out);
}
.org-item:hover { background: var(--raise); }
.org-item[aria-selected="true"] { background: var(--acc-wash); }
.org-item-name { font-size: var(--t-md); font-weight: 550; }
.org-item-sub { font-size: 10px; color: var(--ink-3); }

/* Navegación con indicador deslizante */
.nav { position: relative; flex: 1; overflow-y: auto; padding-top: var(--s-2); }
.nav-group + .nav-group { margin-top: var(--s-5); }
.nav-title { padding: 0 10px var(--s-2); }
.nav-list { position: relative; display: flex; flex-direction: column; gap: 2px; }

.nav-pill {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  border-radius: var(--r-md);
  background: linear-gradient(100deg, var(--acc-wash), var(--acc-2-wash));
  border: 1px solid var(--line);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--d-move) var(--ease-in-out),
    height var(--d-move) var(--ease-in-out),
    opacity var(--d-hover) var(--ease-out);
}
.nav-pill[data-ready="true"] { opacity: 1; }

.nav-link {
  position: relative;
  z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: var(--t-md);
  font-weight: 520;
  cursor: pointer;
  transition:
    color var(--d-hover) var(--ease-out),
    background-color var(--d-hover) var(--ease-out),
    transform var(--d-press) var(--ease-out);
}
.nav-link svg { flex: 0 0 17px; opacity: 0.72; transition: opacity var(--d-hover) var(--ease-out); }
.nav-link:active { transform: scale(0.985); }
.nav-link[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav-link[aria-current="page"] svg { opacity: 1; color: var(--acc); }

.sidebar-foot {
  padding: var(--s-3) 10px 0;
  border-top: 1px solid var(--line-soft);
}
.plan-chip {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2);
  font-size: var(--t-xs);
  color: var(--ink-3);
}

/* ---------- Barra superior ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-6);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

/* Interruptores */
.switch-group { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }

.lang-switch {
  position: relative;
  display: flex;
  padding: 3px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
}
.lang-switch .knob {
  position: absolute;
  top: 3px; left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: var(--r-full);
  background: linear-gradient(120deg, var(--acc), var(--acc-2));
  box-shadow: 0 4px 12px -6px var(--acc);
  transition: transform var(--d-move) var(--ease-in-out);
}
.lang-switch[data-lang="en"] .knob { transform: translateX(100%); }
.lang-switch button {
  position: relative; z-index: 1;
  width: 34px;
  padding: 4px 0;
  border: 0; background: transparent;
  font-size: var(--t-xs); font-weight: 650; letter-spacing: 0.04em;
  color: var(--ink-3);
  cursor: pointer;
  transition: color var(--d-move) var(--ease-out);
}
.lang-switch button[aria-pressed="true"] { color: var(--acc-ink); }

.theme-switch {
  position: relative;
  width: 54px; height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--raise);
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--d-hover) var(--ease-out);
}
.theme-switch .t-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--acc), var(--acc-2));
  box-shadow: 0 4px 12px -4px var(--acc);
  display: grid; place-items: center;
  color: var(--acc-ink);
  /* muelle suave: rebote controlado, el único de la interfaz */
  transition: transform 420ms cubic-bezier(0.34, 1.4, 0.5, 1);
}
:root[data-theme="light"] .theme-switch .t-knob { transform: translateX(26px); }
/* Los dos iconos ocupan el mismo hueco y se cruzan; si no, se ponen en fila
   y se salen del botón. */
.theme-switch .t-knob > span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity 200ms var(--ease-out), transform 300ms var(--ease-out);
}
.theme-switch .i-moon { opacity: 1; transform: rotate(0deg) scale(1); }
.theme-switch .i-sun  { opacity: 0; transform: rotate(-90deg) scale(0.6); }
:root[data-theme="light"] .theme-switch .i-moon { opacity: 0; transform: rotate(90deg) scale(0.6); }
:root[data-theme="light"] .theme-switch .i-sun  { opacity: 1; transform: rotate(0deg) scale(1); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--t-xs); font-weight: 700;
  background: linear-gradient(145deg, var(--c2), var(--c5));
  color: #fff;
  cursor: pointer;
  transition: transform var(--d-press) var(--ease-out), box-shadow var(--d-hover) var(--ease-out);
}
.avatar:active { transform: scale(0.94); }

/* ---------- Lienzo ---------- */
.canvas {
  flex: 1;
  padding: var(--s-6) var(--s-6) var(--s-12);
  max-width: 1560px;
  width: 100%;
}

/* Ritmo vertical de la vista. Los bloques son hermanos sueltos: sin esto la
   fila de KPIs y la tarjeta de debajo se tocan. El aire entre secciones es
   mayor que el aire entre tarjetas de una misma fila, para que se lean como
   grupos y no como una rejilla continua. */
#view {
  display: flex;
  flex-direction: column;
  gap: var(--s-7);
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: 0;   /* lo lleva el gap de #view */
  flex-wrap: wrap;
}
.page-title { font-size: var(--t-2xl); letter-spacing: -0.03em; }
.page-sub { color: var(--ink-2); font-size: var(--t-md); margin-top: 2px; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; max-width: 100%; min-width: 0; }

/* Buscador dentro de page-actions (p. ej. Insumos): lupa fija a la
   izquierda, el input le deja hueco con padding — el ícono no es clicable
   (pointer-events:none), es solo la pista visual de qué hace el campo. */
.ins-search-wrap { position: relative; display: flex; align-items: center; }
.ins-search-wrap svg { position: absolute; left: 10px; color: var(--ink-3); pointer-events: none; }
/* Especificidad a propósito (dos clases): la regla ".input, .select" de más
   abajo pone "padding" en las cuatro esquinas con el mismo peso — si esta
   perdiera el empate por orden de aparición, el hueco para la lupa se
   cierra y el texto empieza debajo del ícono. */
.ins-search-wrap .ins-search-input { padding-left: 34px; width: 220px; }
@media (max-width: 720px) {
  .ins-search-wrap, .ins-search-wrap .ins-search-input { width: 100%; }
}

/* ====================== Componentes ====================== */

/* Botones */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--line);
  background: var(--raise);
  color: var(--ink);
  font-size: var(--t-md);
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition:
    transform var(--d-press) var(--ease-out),
    background-color var(--d-hover) var(--ease-out),
    border-color var(--d-hover) var(--ease-out),
    box-shadow var(--d-hover) var(--ease-out);
}
.btn:active { transform: scale(0.97); }

@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: color-mix(in srgb, var(--acc) 40%, var(--line)); }
}

/* Rejillas — align-items:start para que ninguna tarjeta se estire con medio
   cuerpo vacío al lado de otra más alta. */
.grid { display: grid; gap: var(--s-5); align-items: start; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-8-4 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-5-7 { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }

/* Tarjeta */
.card { padding: var(--s-6); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.card-title { font-size: var(--t-lg); letter-spacing: -0.02em; }
.card-note { font-size: var(--t-sm); color: var(--ink-3); margin-top: 2px; }

/* Tarjeta de KPI */
.kpi { padding: var(--s-6); overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s-3); }
.kpi-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; }
.kpi-label { font-size: var(--t-sm); color: var(--ink-2); font-weight: 520; }
.kpi-value {
  font-size: var(--t-3xl);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: var(--s-3); }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: var(--t-sm); font-weight: 620;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: var(--r-full);
}
.delta.up   { color: var(--good); background: var(--good-wash); }
.delta.down { color: var(--crit); background: var(--crit-wash); }
.delta.flat { color: var(--ink-3); background: var(--raise); }
.delta-note { font-size: var(--t-xs); color: var(--ink-3); }

@media (hover: hover) and (pointer: fine) {
  .kpi { transition: transform var(--d-hover) var(--ease-out), box-shadow var(--d-hover) var(--ease-out); }
  .kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); }
}

/* Etiquetas de estado — nunca solo color: llevan punto e icono textual */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 600;
  letter-spacing: 0.01em;
  /* Corto = una línea; largo (p. ej. "El puente no responde...") = se parte
     en vez de salirse de la pantalla. */
  max-width: 100%; min-width: 0;
}
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: 0 0 5px; }
.tag.good { color: var(--good); background: var(--good-wash); }
.tag.warn { color: var(--warn); background: var(--warn-wash); }
.tag.sers { color: var(--sers); background: var(--sers-wash); }
.tag.crit { color: var(--crit); background: var(--crit-wash); }
.tag.neut { color: var(--ink-2); background: var(--raise); }
.tag.acc  { color: var(--acc);  background: var(--acc-wash); }

.tag.crit::before { animation: pulse-dot 1.9s var(--ease-in-out) infinite; }
@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: 0.5; }
}

/* Lista de movimientos / eventos */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 11px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition:
    background-color var(--d-hover) var(--ease-out),
    border-color var(--d-hover) var(--ease-out),
    padding-left var(--d-hover) var(--ease-out);
}
.row:last-child { border-bottom: 0; }
@media (hover: hover) and (pointer: fine) {
  .row:hover { background: var(--raise); border-left-color: var(--acc); padding-left: 9px; }
}
.row-ico {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--raise);
  color: var(--ink-2);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 550; font-size: var(--t-md); }
.row-sub { font-size: var(--t-xs); color: var(--ink-3); }
/* Una etiqueta dentro de la línea de datos (p. ej. "vence en 5 días"): va con
   el texto, NO a la derecha. A la derecha compite por el ancho y en móvil
   parte el título palabra por palabra. */
.row-sub .tag { margin-left: 5px; transform: translateY(-1px); }

/* Acciones a la derecha de una fila (monto + borrar) */
.row-actions { display: flex; align-items: center; gap: var(--s-3); flex: 0 0 auto; }
.row-amount { font-weight: 640; font-variant-numeric: tabular-nums; white-space: nowrap; }

.icon-btn {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition:
    background-color var(--d-hover) var(--ease-out),
    color var(--d-hover) var(--ease-out),
    transform var(--d-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover { background: var(--crit-wash); color: var(--crit); }
}
.icon-btn:active { transform: scale(0.9); }

/* Fila reemplazada por su confirmación de borrado — mismo alto, sin salto */
.row-confirm { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex: 1; min-width: 0; }
.row-confirm span { font-size: var(--t-sm); color: var(--ink-2); }

/* Botones de acento y de peligro */
.btn.acc { border-color: transparent; background: var(--acc); color: var(--acc-ink); }
@media (hover: hover) and (pointer: fine) {
  .btn.acc:hover { background: var(--acc); filter: brightness(1.08); }
}
.btn.danger { border-color: color-mix(in srgb, var(--crit) 45%, var(--line)); color: var(--crit); }
@media (hover: hover) and (pointer: fine) {
  .btn.danger:hover { background: var(--crit-wash); border-color: var(--crit); }
}

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--t-xs); color: var(--ink-2); font-weight: 560; letter-spacing: 0.01em; }
.input, .select {
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--raise);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-md);
  transition: border-color var(--d-hover) var(--ease-out), background-color var(--d-hover) var(--ease-out);
}
.input:focus, .select:focus { outline: none; border-color: var(--acc); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); margin-bottom: var(--s-5); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2); }

.seg-toggle { display: inline-flex; gap: 4px; padding: 3px; border-radius: var(--r-full); background: var(--raise); border: 1px solid var(--line); width: fit-content; max-width: 100%; }
.seg-toggle button {
  min-width: 0;
  padding: 6px 14px; border: 0; background: transparent; border-radius: var(--r-full);
  font: inherit; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: background-color var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out);
}
.seg-toggle button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow-card); }
.seg-toggle button.tone-crit[aria-pressed="true"] { color: var(--crit); }
.seg-toggle button.tone-good[aria-pressed="true"] { color: var(--good); }
.seg-toggle button.tone-acc[aria-pressed="true"] { color: var(--acc); }
.seg-toggle button.tone-warn[aria-pressed="true"] { color: var(--warn); }

/* Registrar Inventario: fila del checklist sin rellenar todavía — mismo
   filo que ya usa .row al pasar el mouse, pero fijo, no solo al hover. */
.rows .row.reg-incomplete { border-left-color: var(--crit); background: var(--crit-wash); }

/* ====================== Margen — experimentar ====================== */
/* La tarjeta donde se arma un experimento lleva un filo de acento: es la
   única de toda la app que "manejamos el dinero" antes de que el producto
   exista de verdad, y se quiere que se sienta distinta al catálogo fijo. */
.exp-builder { border-color: var(--acc-2-wash); box-shadow: var(--shadow-card), 0 0 0 1px var(--acc-2-wash); }

.exp-lines { display: flex; flex-direction: column; margin: var(--s-4) 0; container-type: inline-size; }
/* El diseño depende del ancho de la TARJETA (container query), no del de la
   pantalla: con el menú lateral abierto una pantalla de 1440 deja a la tarjeta
   con ~700px y las columnas fijas se salían. minmax(0, ..) deja que los
   selects se encojan en vez de empujar el costo fuera de la tarjeta. */
.exp-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(104px, 150px) minmax(64px, 84px) 32px;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.exp-line > * { min-width: 0; }
.exp-line .select { width: 100%; text-overflow: ellipsis; }
.exp-line:last-child { border-bottom: none; }
.exp-line.line-new { animation: rise 340ms var(--ease-out) forwards; }
.exp-line-qty { display: flex; align-items: center; gap: 6px; }
.exp-line-qty .input { flex: 1 1 auto; width: 100%; min-width: 76px; }
.exp-line-unit { font-size: var(--t-sm); color: var(--ink-3); white-space: nowrap; flex: 0 0 auto; }
.exp-line-cost { font-weight: 640; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.exp-builder-foot {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: var(--s-4) var(--s-3);
  margin-top: var(--s-2);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}
.exp-total { display: flex; align-items: baseline; gap: var(--s-2); }
.exp-total span { font-size: var(--t-sm); color: var(--ink-2); }
.exp-total-value {
  font-size: var(--t-2xl); font-variant-numeric: tabular-nums; color: var(--acc);
  transition: color var(--d-hover) var(--ease-out);
}

@container (max-width: 640px) {
  /* Angosto: fila 1 = categoría + insumo; fila 2 = cantidad · costo · quitar. */
  .exp-line { grid-template-columns: minmax(0, 1fr) auto 32px; row-gap: var(--s-2); padding: var(--s-4) 0; }
  .exp-line > .select:nth-child(1), .exp-line > .select:nth-child(2) { grid-column: 1 / -1; }
  .exp-line-qty { grid-column: 1 / 2; }
  .exp-line-cost { grid-column: 2 / 3; }
  .exp-line [data-act$="-line-remove"] { grid-column: 3 / 4; }
}

/* ====================== Margen — costos generales ====================== */
/* Categorías en horizontal (a diferencia de Insumos, que las apila): cada
   una es una columna que se desplaza en bloque, no una tarjeta de ancho
   completo. Así "Açaí bowls" se ve entera sin empujar a "Bebidas" fuera de
   vista. */
.dish-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--s-4); padding: 2px 2px var(--s-3); align-items: start; }
.dish-col { min-width: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.dish-col-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.dish-col-actions { display: flex; gap: var(--s-1); flex: 0 0 auto; }
.dish-col-cards { display: flex; flex-direction: column; gap: var(--s-2); min-height: 4px; }
.dish-card { border: 1px solid var(--line-soft); border-radius: var(--r-md); }
.dish-col-add { width: 100%; justify-content: center; }
.dish-margin-row { display: flex; gap: var(--s-5); flex-wrap: wrap; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: span 2; }
}

/* Alta rápida de una lista (Listas): una fila, sin el peso de un form-grid
   completo — es un solo dato, o dos nombres cortos. */
.quickadd { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.quickadd .input { flex: 1; min-width: 160px; }
.quickadd button { flex: 0 0 auto; }
@media (max-width: 720px) {
  .quickadd { flex-direction: column; }
  .quickadd button { width: 100%; justify-content: center; }
}

/* Tarjeta de cuenta bancaria */

/* Leyenda (dataviz: presente siempre con 2+ series) */
.legend { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-4); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--ink-2); }
.legend-key { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.legend-key.line { height: 3px; border-radius: 2px; }

/* Gráficas */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text { font-size: 10px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }

/* Dibujo de la línea: se traza, no aparece */
.chart .series-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  transition: stroke-dashoffset var(--d-draw) var(--ease-in-out);
}
.chart[data-drawn="true"] .series-line { stroke-dashoffset: 0; }

.chart .series-area {
  opacity: 0;
  transition: opacity 460ms var(--ease-out) 180ms;
}
.chart[data-drawn="true"] .series-area { opacity: 1; }

.chart .series-dashed { stroke-dasharray: 5 5; opacity: 0.85; }

/* Barras: crecen desde la base */
.chart .bar-rect {
  transform-origin: bottom;
  transform: scaleY(0);
  transition: transform 520ms var(--ease-out);
}
.chart[data-drawn="true"] .bar-rect { transform: scaleY(1); }
.chart .bar-rect:hover { filter: brightness(1.14); }

/* Arcos del donut: se rellenan por orden, con aire entre segmentos */
.chart .arc {
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 700ms var(--ease-in-out);
}
.chart[data-drawn="true"] .arc { stroke-dasharray: var(--dash); }

/* Cruceta y globo */
.crosshair {
  stroke: var(--ink-3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0;
  transition: opacity 125ms var(--ease-out);
}
.chart[data-hover="true"] .crosshair { opacity: 0.7; }
.hover-dot {
  opacity: 0;
  transition: opacity 125ms var(--ease-out);
}
.chart[data-hover="true"] .hover-dot { opacity: 1; }

.tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  min-width: 152px;
  padding: 9px 11px;
  background: var(--glass-2);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, -108%) scale(0.97);
  transition:
    opacity 125ms var(--ease-out),
    transform 125ms var(--ease-out);
}
.tip[data-show="true"] { opacity: 1; transform: translate(-50%, -112%) scale(1); }
.tip-title { font-size: var(--t-xs); color: var(--ink-3); margin-bottom: 5px; letter-spacing: 0.04em; text-transform: uppercase; }
.tip-row { display: flex; align-items: center; gap: 7px; font-size: var(--t-sm); }
.tip-row + .tip-row { margin-top: 3px; }
.tip-key { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.tip-val { margin-left: auto; font-weight: 640; font-variant-numeric: tabular-nums; }

/* Aviso flotante */
.toast-dock {
  position: fixed;
  bottom: var(--s-6); right: var(--s-6);
  z-index: 95;
  display: flex; flex-direction: column-reverse; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px;
  min-width: 250px;
  background: var(--glass-2);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--t-md);
  /* transición, no keyframes: se puede disparar dos veces por segundo */
  opacity: 1;
  transform: translateY(0);
  transition: opacity 400ms ease, transform 400ms ease;
}
.toast[data-enter="true"] { opacity: 0; transform: translateY(100%); }

/* ====================== Entrada de la vista ====================== */
/* Escalonado 40ms: lo ve cada vez que navega, así que corto y sutil */
.enter > * {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 380ms var(--ease-out) forwards;
}
.enter > *:nth-child(1) { animation-delay: 0ms; }
.enter > *:nth-child(2) { animation-delay: 45ms; }
.enter > *:nth-child(3) { animation-delay: 90ms; }
.enter > *:nth-child(4) { animation-delay: 135ms; }
.enter > *:nth-child(5) { animation-delay: 180ms; }
.enter > *:nth-child(6) { animation-delay: 215ms; }
.enter > *:nth-child(n+7) { animation-delay: 250ms; }

@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* Escalonado interno de rejillas de KPI y filas */
.stagger > * {
  opacity: 0;
  transform: translateY(8px);
  animation: rise 340ms var(--ease-out) forwards;
}
.stagger > *:nth-child(1) { animation-delay: 30ms; }
.stagger > *:nth-child(2) { animation-delay: 65ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 135ms; }
.stagger > *:nth-child(5) { animation-delay: 170ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(7) { animation-delay: 225ms; }
.stagger > *:nth-child(n+8) { animation-delay: 250ms; }

/* Cambio de idioma: cruce difuminado, no un salto de texto */
.lang-morph { transition: opacity 170ms ease, filter 170ms ease; }
html.lang-swapping .lang-morph { opacity: 0.25; filter: blur(3px); }

/* ====================== Ventana modal ====================== */
/* Para formularios largos (editar insumo) que no deben forzar scroll a la
   fila de arriba: se abren encima, donde estás. Va después de .enter > *
   en la hoja para ganarle su animación de entrada por cascada (misma
   especificidad, pero declarada más tarde) — si no, el modal heredaría el
   "rise" escalonado de la página en vez de abrirse de una vez.
   OJO (E-058): las tres animaciones necesitan "forwards" — sin él, al
   terminar la animación el elemento vuelve al opacity:0 que le puso
   ".enter > *" (esa regla sigue viva, solo se le ganó la animación) y el
   modal se ve abrirse y cerrarse solo en cuanto termina la entrada. */
.modal-scrim {
  position: fixed; inset: 0; z-index: 110;
  background: color-mix(in srgb, var(--bg-deep) 62%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-5);
  animation: modal-scrim-in 220ms var(--ease-out) forwards;
}
@keyframes modal-scrim-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  width: min(620px, 100%);
  max-height: min(88vh, 780px);
  overflow-y: auto;
  padding: var(--s-6);
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  animation: modal-in 260ms var(--ease-out) forwards;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); margin-bottom: var(--s-5);
}
/* El modal siempre es angosto — el form-grid de 4 columnas se ahoga ahí
   aunque el viewport sea ancho, así que se acota aparte del breakpoint. */
.modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal .form-grid .span-2 { grid-column: span 2; }

@media (max-width: 560px) {
  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%; max-height: 92vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: modal-in-mobile 320ms var(--ease-drawer) forwards;
  }
  .modal .form-grid { grid-template-columns: minmax(0, 1fr); }
}
@keyframes modal-in-mobile { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ====================== Filas y tarjetas desplegables ====================== */
/* Insumos y categorías ya no llevan lápiz/papelera a la vista: se hace clic
   en la fila (o la cabecera de la categoría) y ahí abajo se abre el detalle
   con las acciones. Mismo truco grid 0fr->1fr que un <details> pero con
   transición — sin medir alturas en JS. */
.row-expand-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms var(--ease-out);
}
.row-expand-wrap[data-open="true"] { grid-template-rows: 1fr; }
.row-expand-inner { overflow: hidden; min-height: 0; }
.row-expand {
  padding: var(--s-3) 2px var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.row-detail-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-5);
}
.row-detail-grid > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-detail-label { font-size: var(--t-xs); color: var(--ink-3); }
.row-detail-grid > div > span:last-child { font-size: var(--t-sm); font-weight: 550; }
.row-expand-actions, .cat-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.cat-actions { padding: 2px 2px var(--s-4); }

/* Editar/eliminar de una categoría desplegable: solo a la vista con la
   categoría abierta — si no, compiten visualmente con el gesto de desplegar
   en una cabecera que ya es clicable entera. Se ocultan con opacidad+escala,
   no display:none, para que el cambio no sea un salto seco. */
.card-head-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.card-head-actions .icon-btn {
  opacity: 0; transform: scale(0.85); pointer-events: none;
  transition: opacity var(--d-hover) var(--ease-out), transform var(--d-hover) var(--ease-out);
}
[aria-expanded="true"] .card-head-actions .icon-btn { opacity: 1; transform: scale(1); pointer-events: auto; }

.row-chevron {
  color: var(--ink-3); flex: 0 0 auto; display: inline-flex;
  transition: transform var(--d-menu) var(--ease-out);
}
.row-chevron[data-open="true"], [aria-expanded="true"] .row-chevron { transform: rotate(180deg); }

/* .row ya tiene su propio :hover (fondo + borde) más abajo en la hoja —
   aquí solo se suma el cambio de color en el título/flecha, y el cursor
   para .card-head, que no es .row y no trae hover propio. La flecha ya
   tiene su propia transición de "transform" (rotarla al desplegar) — aquí
   se le AÑADE la de color, nunca se reemplaza el transition entero o se
   pierde el giro suave. */
.row-clickable { cursor: pointer; }
.row-clickable .row-title, .row-clickable .card-title {
  transition: color var(--d-hover) var(--ease-out);
}
.row-clickable .row-chevron {
  transition: color var(--d-hover) var(--ease-out), transform var(--d-menu) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .row-clickable:hover .row-title,
  .row-clickable:hover .card-title,
  .row-clickable:hover .row-chevron { color: var(--acc); }
}

@media (max-width: 560px) {
  .row-detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ====================== Responsive ====================== */
.mobile-bar { display: none; }

@media (max-width: 1180px) {
  .g-3, .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-8-4, .g-5-7 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  :root { --topbar-h: 56px; }

  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 272px;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 380ms var(--ease-drawer), box-shadow 380ms var(--ease-out);
    /* Cerrado no lleva sombra: asomaba como una franja gris en el borde
       izquierdo (muy visible en tema claro). */
    box-shadow: none;
    /* De cajón fijo sobre todo lo demás: cristal sólido, no traslúcido —
       ver por qué en el comentario del scrim de abajo. */
    background: var(--surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .sidebar[data-open="true"] { transform: translateX(0); box-shadow: var(--shadow-pop); }

  .sheet-scrim {
    position: fixed; top: 0; bottom: 0; right: 0; left: 272px; z-index: 39;
    background: color-mix(in srgb, var(--bg-deep) 62%, transparent);
    backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden;
    transition: opacity 300ms var(--ease-out), visibility 0s linear 300ms;
  }
  .sheet-scrim[data-open="true"] { opacity: 1; visibility: visible; transition-delay: 0s; }

  .mobile-bar { display: inline-grid; }
  .burger {
    place-items: center;
    width: 34px; height: 34px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--raise);
    cursor: pointer;
    transition: transform var(--d-press) var(--ease-out);
  }
  .burger:active { transform: scale(0.92); }

  .topbar { padding: 0 var(--s-4); gap: var(--s-2); }

  .canvas { padding: var(--s-4) var(--s-4) var(--s-12); }

  /* En móvil el ritmo se acorta: 30px de separación en una columna estrecha
     obliga a desplazar de más. */
  #view { gap: var(--s-5); }
  .grid { gap: var(--s-4); }

  .g-3, .g-4 { grid-template-columns: minmax(0, 1fr); }

  .page-title { font-size: var(--t-xl); }
  .kpi-value { font-size: var(--t-2xl); }
  .card, .kpi { padding: var(--s-4); }

  .toast-dock { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); }
  .toast { min-width: 0; }

  /* Filas en columna estrecha: el texto manda, lo de la derecha se aprieta.
     Sin esto el título se parte palabra por palabra (una palabra por línea). */
  .row { gap: var(--s-2); padding: 10px 2px; }
  .row-ico { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 9px; }
  .row-actions { gap: var(--s-2); }
  .row-amount { font-size: var(--t-md); }
  .row-confirm { flex-direction: column; align-items: stretch; gap: var(--s-2); }
  .row-confirm .row-actions { justify-content: flex-end; }

  .gridlines { background-size: 100% 76px, 76px 100%; }
}

/* ====================== Deuda: avance del pago ====================== */
/* Cuánto llevas pagado de una deuda, de un vistazo y sin leer un número.
   Se rellena de verde según los abonos; llena = pagada. */
.dt-bar {
  margin-top: 6px; height: 4px; border-radius: var(--r-full);
  background: var(--line); overflow: hidden; max-width: 260px;
}
.dt-bar span {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--good);
  transition: width var(--d-slow, 420ms) var(--ease-out);
}
/* El origen de una deuda y sus abonos llevan a su transacción: se ve que
   son pulsables, sin convertirlos en botones. */
.link-like { color: var(--acc); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link-like:hover { opacity: .82; }

/* Destello al llegar a una transacción desde su abono: sin él, en una lista
   larga no sabrías cuál de todas es. */
@keyframes row-flash {
  0%   { background: var(--acc-wash); }
  100% { background: transparent; }
}
.row-flash { animation: row-flash 1.6s var(--ease-out) both; border-radius: var(--r-md, 10px); }

/* Coincidencia del buscador de Insumos: se queda mientras haya texto en el
   campo (a diferencia de .row-flash, que se apaga solo) — mismo tinte de
   acento suave, para no inventar un segundo lenguaje de color. */
@keyframes search-match-in {
  0%   { background: transparent; }
  100% { background: var(--acc-wash); }
}
.ins-search-match { animation: search-match-in 220ms var(--ease-out) both; border-radius: var(--r-md, 10px); }

/* ====================== Movimiento reducido ====================== */
/* Menos y más suave, no cero: se conserva lo que ayuda a entender. */
@media (prefers-reduced-motion: reduce) {
  .atmosphere span { animation: none; }
  .tag.crit::before { animation: none; }
  .dt-bar span { transition: none; }
  .row-flash { animation-duration: 1ms; }
  .ins-search-match { animation-duration: 1ms; }

  .enter > *, .stagger > * {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .chart .series-line { stroke-dasharray: none; stroke-dashoffset: 0; transition: none; }
  .chart .series-area { opacity: 1; transition: none; }
  .chart .bar-rect { transform: scaleY(1); transition: none; }

  .org-menu, .toast, .sidebar {
    transition-property: opacity, visibility;
    transition-duration: 160ms;
  }
  .org-menu { transform: none; }
  .toast[data-enter="true"] { transform: none; }
  .theme-switch .t-knob { transition-duration: 160ms; }
}

/* ===================== Equipo → Fotos de tienda (13/10) ===================== */
.ft-datenav { display: inline-flex; align-items: center; gap: 6px; padding: 4px; border-radius: var(--r-full); background: var(--raise); border: 1px solid var(--line); }
.ft-arrow {
  width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: var(--r-full);
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out), transform 120ms var(--ease-out);
}
.ft-arrow:first-child svg { transform: rotate(90deg); }
.ft-arrow:last-child svg { transform: rotate(-90deg); }
.ft-arrow:hover:not(:disabled) { background: var(--surface); color: var(--acc); }
.ft-arrow:active:not(:disabled) { transform: scale(0.9); }
.ft-arrow:disabled { opacity: 0.35; cursor: default; }
.ft-date { min-width: 150px; text-align: center; font-weight: 600; font-size: 14px; text-transform: capitalize; }

.ft-emps { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.ft-emp { padding: var(--s-4); border-radius: var(--r-lg); background: var(--raise); border: 1px solid var(--line-soft); }
.ft-emp-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-3); }
.ft-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 13px; font-weight: 700; color: var(--acc-ink); background: linear-gradient(135deg, var(--acc), var(--c3, #8B5CF6));
}
.ft-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ft-tile {
  position: relative; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); cursor: zoom-in; font: inherit; color: inherit;
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.ft-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 400ms var(--ease-out); }
.ft-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.ft-tile:hover img { transform: scale(1.04); }
.ft-tile:active { transform: scale(0.98); }
.ft-tile-meta {
  position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; align-items: center; gap: 6px;
  padding: 22px 10px 8px; font-size: 12px; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,.72), transparent);
}
.ft-tile-meta span { display: inline-flex; align-items: center; gap: 4px; font-family: "JetBrains Mono", monospace; }
.ft-missing { cursor: default; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-style: dashed; color: var(--ink-3); background: transparent; }
.ft-missing:hover { transform: none; box-shadow: none; }
.ft-missing b { font-size: 13px; color: var(--ink-2); }
.ft-missing small { font-size: 12px; }

.ft-modal { width: min(880px, 100%); padding: 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); overflow: hidden; }
.ft-modal img { width: 100%; height: 100%; max-height: 80vh; object-fit: cover; display: block; background: #000; }
.ft-modal-info { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.ft-modal-title { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.ft-modal dl { margin: 0; display: grid; gap: 4px 0; }
.ft-modal dt { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.ft-modal dd { margin: 0; font-weight: 550; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  .ft-modal { grid-template-columns: 1fr; overflow-y: auto; }
  .ft-modal img { max-height: 52vh; }
  .ft-date { min-width: 120px; }
}

/* =================== Mise Empleados: login y salir =================== */
.logout-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--raise); color: var(--ink-2);
  font: inherit; font-weight: 550; cursor: pointer;
  transition: border-color var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out), transform 120ms var(--ease-out);
}
.logout-btn:hover { border-color: var(--acc); color: var(--ink); }
.logout-btn:active { transform: scale(0.97); }
.org-btn { cursor: default; }
.org-caret { display: none; }

.login {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 320ms var(--ease-out), visibility 0s linear 320ms;
}
body[data-auth="out"] .login { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
body[data-auth="out"] .app { filter: blur(6px); pointer-events: none; }
.app { transition: filter 320ms var(--ease-out); }

.login-card {
  width: min(380px, 100%);
  display: flex; flex-direction: column; gap: 14px;
  transform: translateY(14px) scale(0.985);
  transition: transform 380ms var(--ease-out);
}
body[data-auth="out"] .login-card { transform: none; }
.login-card .brand-mark { align-self: flex-start; }
.login-title { margin: 4px 0 0; font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.login-field .input { height: 46px; font-size: 16px; }
.login-err { min-height: 18px; margin: 0; font-size: 13px; color: var(--crit, #F87171); }
.login-go { height: 48px; font-size: 15px; justify-content: center; }
.login-card[data-shake="true"] { animation: login-shake 420ms var(--ease-out); }
@keyframes login-shake {
  20% { transform: translateX(-8px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); }
}
@media (max-width: 720px) { .logout-btn #logout-label { display: none; } .logout-btn { padding: 0 11px; } }
@media (prefers-reduced-motion: reduce) { .login, .login-card, .app { transition: none; } .login-card[data-shake="true"] { animation: none; } }

/* ======================= Mise Empleados — app del equipo ======================= */
body[data-auth="boot"] .login { opacity: 0; visibility: hidden; }
body[data-auth="boot"] .app, body[data-auth="boot"] .emp-tabbar { opacity: 0; }
.app, .emp-tabbar { transition: opacity 260ms var(--ease-out), filter 320ms var(--ease-out); }
body[data-auth="out"] .emp-tabbar { opacity: 0; pointer-events: none; }

.emp-who { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 0 0 var(--s-4);
  border-radius: var(--r-lg); background: var(--raise); border: 1px solid var(--line); }
.emp-who .org-meta { display: flex; flex-direction: column; min-width: 0; }
.emp-who .org-name { font-weight: 650; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emp-who .org-role { font-size: 12px; color: var(--ink-3); }
.emp-mobile-brand { display: none; align-items: center; gap: 10px; }
.emp-mobile-brand .brand-mark { width: 30px; height: 30px; font-size: 14px; }
.emp-mobile-title { font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }

/* --- Barra inferior (móvil): tres pestañas con una píldora que se desliza --- */
.emp-tabbar { display: none; }
@media (max-width: 860px) {
  .emp-sidebar { display: none; }
  .emp-mobile-brand { display: inline-flex; }
  .emp-topbar { justify-content: space-between; }
  .canvas { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
  .emp-tabbar {
    display: grid; grid-template-columns: repeat(var(--n, 3), 1fr); position: fixed; z-index: 50;
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    padding: 6px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  }
  .emp-tab-pill {
    position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / var(--n, 3));
    border-radius: 16px; background: var(--acc-wash);
    transition: transform 420ms var(--ease-drawer);
  }
  .emp-tab {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 8px 4px; border-radius: 16px; color: var(--ink-3); text-decoration: none;
    font-size: 11.5px; font-weight: 600; transition: color 220ms var(--ease-out), transform 140ms var(--ease-out);
  }
  .emp-tab[aria-current="page"] { color: var(--acc); }
  .emp-tab { min-width: 0; }
  .emp-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .emp-tab:active { transform: scale(0.92); }
  .emp-tab svg { transition: transform 300ms var(--ease-out); }
  .emp-tab[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }
}

/* --- Hoy --- */
.emp-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; overflow: hidden; }
.emp-hero::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 240px; height: 240px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--acc) 26%, transparent), transparent 70%);
  animation: emp-glow 6s ease-in-out infinite alternate;
}
@keyframes emp-glow { to { transform: translate(-30px, 24px) scale(1.15); } }
.emp-hero .eyebrow { margin: 0 0 6px; color: var(--acc); }
.emp-hero .eyebrow::first-letter { text-transform: uppercase; }
.emp-hero .page-title { margin: 0; }
.emp-hero-store { position: relative; z-index: 1; }
.emp-store-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--r-full);
  background: var(--acc-wash); color: var(--acc); font-weight: 600; font-size: 13px; }

.emp-steps { display: grid; gap: var(--s-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1101px) {
  .emp-steps:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .emp-steps:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) { .emp-steps { grid-template-columns: minmax(0, 1fr); } }
.emp-step { display: flex; gap: var(--s-4); align-items: flex-start; transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out); }
.emp-step.is-active { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--acc) 55%, transparent), var(--shadow-card); }
.emp-step.is-locked { opacity: 0.62; }
.emp-step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.emp-step-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.emp-step-mark {
  flex: none; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; background: var(--raise); border: 1px solid var(--line); color: var(--ink-2);
}
.emp-step.is-active .emp-step-mark { background: var(--acc); color: var(--acc-ink); border-color: transparent; animation: emp-pulse 2.2s var(--ease-out) infinite; }
.emp-step.is-done .emp-step-mark { background: var(--good); color: #fff; border-color: transparent; animation: emp-pop 420ms var(--ease-out); }
@keyframes emp-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--acc) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes emp-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
.emp-cta { align-self: flex-start; min-height: 44px; padding-inline: 16px; }
.emp-cta:disabled { opacity: 0.45; cursor: not-allowed; }
.btn { transition: transform 120ms var(--ease-out), background var(--d-hover) var(--ease-out), border-color var(--d-hover) var(--ease-out), box-shadow var(--d-hover) var(--ease-out); }
.btn:active:not(:disabled) { transform: scale(0.96); }
.emp-step-photo { display: flex; align-items: center; gap: 12px; }
.emp-step-photo img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.emp-step-photo span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13.5px; }

/* --- Anillo de progreso: crece al entrar --- */
.emp-inv-mini { display: flex; align-items: center; gap: var(--s-4); }
.emp-inv-mini > div { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.emp-ring { flex: none; transform: rotate(-90deg); }
.emp-ring text { transform: rotate(90deg); transform-origin: center; font-size: 13px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.emp-ring-bg { fill: none; stroke: var(--line); stroke-width: 6; }
.emp-ring-fg { fill: none; stroke: var(--acc); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease-out); }
.emp-inv-summary { display: flex; justify-content: space-between; align-items: center; gap: var(--s-4); flex-wrap: wrap; }

/* --- Inventario --- */
.emp-progress-sticky {
  position: sticky; top: calc(var(--topbar-h, 64px) + 8px); z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-full); background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.emp-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.emp-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--acc), var(--good)); transition: width 420ms var(--ease-out); }
.emp-bar-label { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.emp-cat { display: flex; align-items: center; gap: 8px; }
.reg-line { transition: background 260ms var(--ease-out), border-color 260ms var(--ease-out); }
.reg-line.is-done { background: color-mix(in srgb, var(--good) 7%, transparent); }
.emp-check {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); color: transparent; transition: background 220ms var(--ease-out), border-color 220ms var(--ease-out), color 220ms var(--ease-out);
}
.reg-line.is-done .emp-check { background: var(--good); border-color: var(--good); color: #fff; }
.reg-line.pop .emp-check { animation: emp-pop 380ms var(--ease-out); }
.reg-line.shake { animation: emp-shake 420ms var(--ease-out); }
@keyframes emp-shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.emp-stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-full); background: var(--raise); padding: 3px; }
.emp-stepper button {
  width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  font-size: 18px; font-weight: 600; cursor: pointer; transition: background 160ms var(--ease-out), transform 110ms var(--ease-out);
}
.emp-stepper button:hover:not(:disabled) { background: var(--surface); }
.emp-stepper button:active:not(:disabled) { transform: scale(0.86); background: var(--acc-wash); }
.emp-stepper .input { width: 64px; height: 34px; border: 0; background: transparent; text-align: center; padding: 0; font-weight: 650; font-size: 15px; -moz-appearance: textfield; }
.emp-stepper .input::-webkit-outer-spin-button, .emp-stepper .input::-webkit-inner-spin-button { -webkit-appearance: none; }
.seg-toggle button { transition: background 200ms var(--ease-out), color 200ms var(--ease-out), box-shadow 200ms var(--ease-out), transform 110ms var(--ease-out); }
.seg-toggle button:active:not(:disabled) { transform: scale(0.94); }
.emp-foot { position: sticky; bottom: 12px; z-index: 5; }
@media (max-width: 860px) { .emp-foot { bottom: calc(96px + env(safe-area-inset-bottom)); } }
@media (max-width: 560px) {
  .reg-line { flex-wrap: wrap; }
  .reg-line .row-main { flex: 1 1 calc(100% - 40px); }
  .reg-line .row-actions { flex: 1 1 100%; justify-content: flex-end; }
}

/* --- Fotos --- */
.emp-photo-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .emp-photo-grid { grid-template-columns: minmax(0, 1fr); } }
.emp-photo-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center;
  min-height: 240px; border-radius: var(--r-lg); border: 1.5px dashed var(--line); color: var(--ink-3); padding: var(--s-5);
}
.emp-photo-empty .emp-cta { align-self: center; }
.emp-photo-big { position: relative; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 4 / 3; animation: emp-reveal 600ms var(--ease-out); }
.emp-photo-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes emp-reveal { from { clip-path: inset(0 0 100% 0 round 16px); } to { clip-path: inset(0 0 0 0 round 16px); } }
.emp-photo-meta {
  position: absolute; inset: auto 0 0 0; display: flex; flex-direction: column; gap: 4px; padding: 28px 14px 12px;
  color: #fff; font-size: 13px; background: linear-gradient(to top, rgba(0,0,0,.75), transparent);
}
.emp-photo-meta span { display: inline-flex; align-items: center; gap: 6px; }
.emp-rules { display: grid; gap: 10px; }
.emp-rules p { margin: 0; display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 14px; }
.emp-rules svg { color: var(--acc); flex: none; }

/* --- Esqueleto mientras carga (en vez de pantalla vacía) --- */
.emp-skel { display: grid; gap: 14px; }
.sk { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--raise) 0%, color-mix(in srgb, var(--acc) 10%, var(--raise)) 50%, var(--raise) 100%);
  background-size: 200% 100%; animation: emp-shimmer 1.2s linear infinite; border: 1px solid var(--line-soft); }
.sk-title { height: 34px; width: 46%; } .sk-sub { height: 16px; width: 70%; }
.sk-card { height: 128px; } .sk-card.short { height: 80px; }
@keyframes emp-shimmer { to { background-position: -200% 0; } }
.emp-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: emp-rot 700ms linear infinite; }
@keyframes emp-rot { to { transform: rotate(360deg); } }

/* --- Cámara a pantalla completa --- */
.cam {
  position: fixed; inset: 0; z-index: 120; background: #000; color: #fff;
  opacity: 0; visibility: hidden; transform: scale(1.03);
  transition: opacity 260ms var(--ease-out), transform 320ms var(--ease-out), visibility 0s linear 320ms;
}
.cam[data-open="true"] { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
body.cam-on { overflow: hidden; }
.cam-stage { position: absolute; inset: 0; }
.cam-stage video, .cam-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-stage video.mirror { transform: scaleX(-1); }
.cam-stage img { opacity: 0; transition: opacity 200ms var(--ease-out); }
.cam[data-stage="review"] .cam-stage img, .cam[data-stage="saved"] .cam-stage img { opacity: 1; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: cam-flash 420ms var(--ease-out); }
@keyframes cam-flash { 0% { opacity: 0.95; } 100% { opacity: 0; } }
.cam-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 28px; background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent);
}
.cam-titlewrap { flex: 1; display: flex; flex-direction: column; }
.cam-titlewrap b { font-size: 16px; }
.cam-clock { font-family: "JetBrains Mono", monospace; font-size: 12.5px; opacity: 0.85; }
.cam-round {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.28); background: rgba(0,0,0,.35);
  color: #fff; display: grid; place-items: center; cursor: pointer; backdrop-filter: blur(8px); transition: transform 120ms var(--ease-out);
}
.cam-round:active { transform: scale(0.9); }
.cam-gps {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: rgba(0,0,0,.45); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.2); transition: background 300ms var(--ease-out);
}
.cam-gps[data-state="wait"] svg { animation: emp-pulse-o 1.1s ease-in-out infinite; }
@keyframes emp-pulse-o { 50% { opacity: 0.3; } }
.cam-gps[data-state="ok"] { background: rgba(5,150,105,.85); }
.cam-gps[data-state="no"] { background: rgba(220,38,38,.85); }
.cam-msg {
  position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); padding: 18px; border-radius: 18px;
  background: rgba(15,23,41,.92); font-size: 15px; line-height: 1.45; text-align: center; max-width: 460px; margin: 0 auto;
}
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 28px 24px calc(28px + env(safe-area-inset-bottom)); background: linear-gradient(to top, rgba(0,0,0,.65), transparent); }
.cam-live-ctrls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.cam-live-ctrls .cam-round { justify-self: end; }
.cam-shutter {
  width: 78px; height: 78px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 5px; cursor: pointer;
  transition: transform 120ms var(--ease-out);
}
.cam-shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform 160ms var(--ease-out); }
.cam-shutter:active span { transform: scale(0.86); }
.cam-review-ctrls { display: none; gap: 12px; justify-content: center; }
.cam-btn { min-height: 50px; min-width: 140px; justify-content: center; font-size: 15px; }
.cam-review-ctrls .btn:not(.acc) { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.25); }
.cam[data-stage="review"] .cam-live-ctrls, .cam[data-stage="saved"] .cam-live-ctrls { display: none; }
.cam[data-stage="review"] .cam-review-ctrls { display: flex; animation: rise 300ms var(--ease-out); }
.cam[data-stage="saved"] .cam-stage::after {
  content: "✓"; position: absolute; left: 50%; top: 50%; width: 96px; height: 96px; margin: -48px 0 0 -48px; border-radius: 50%;
  display: grid; place-items: center; font-size: 48px; font-weight: 700; color: #fff; background: rgba(5,150,105,.92);
  animation: emp-pop 460ms var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .emp-hero::after, .emp-step.is-active .emp-step-mark, .sk, .cam-gps svg { animation: none; }
  .emp-ring-fg, .emp-bar span, .emp-tab-pill, .cam { transition: none; }
}
@media (max-width: 860px) { .toast-dock { bottom: calc(96px + env(safe-area-inset-bottom)); } }

.emp-time { display: flex; flex-direction: column; gap: 2px; }
.emp-time small { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); }
.emp-time b { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.cam-titlewrap { min-width: 0; }
.cam-titlewrap b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .cam-gps { font-size: 11.5px; padding: 6px 9px; } }
