/* =====================================================================
   VIRAL LAB · ADMIN — Sistema de diseño v1 (diciembre 2026)
   Tema oscuro por defecto. Tema claro con <html data-theme="light">.
   Rutas de assets: relativas «/assets/» (ver DISENO.md).
   ===================================================================== */

/* ---------- 1. Fuentes (locales, variables) ---------- */
@font-face {
  font-family: "Unbounded";
  src: url("/assets/fonts/Unbounded.ttf") format("truetype");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Space Grotesk";
  src: url("/assets/fonts/SpaceGrotesk.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- 2. Tokens ---------- */
:root {
  /* Marca (fijos, no cambian con el tema) */
  --vl-rojo: #FF1F4B;
  --vl-rojo-fuerte: #E0103A;   /* relleno de botones con texto blanco (AA) */
  --vl-naranja: #FF6A3D;
  --vl-negro: #0B0A0C;
  --vl-crema: #F4EFE7;
  --vl-gris: #6B6670;
  --vl-grad: linear-gradient(90deg, #FF1F4B, #FF6A3D);

  /* Superficies (oscuro) — escalones cálidos */
  --bg: #0B0A0C;
  --surface: #131115;
  --surface-2: #1A181C;
  --surface-3: #232025;
  --overlay: rgba(6, 5, 7, .72);

  /* Líneas */
  --line: #262328;
  --line-strong: #37333A;

  /* Texto */
  --text: #F4EFE7;
  --text-2: #B3ADB2;   /* secundario: 8.6:1 sobre --bg */
  --text-3: #8A848C;   /* etiquetas y ayudas: 5.2:1 sobre --bg */
  --text-on-accent: #FFFFFF;

  /* Acentos (como texto/trazo sobre el fondo del tema) */
  --accent: #FF1F4B;          /* rojo: lo importante */
  --accent-2: #FF6A3D;        /* naranja: secundario */
  --accent-fill: #E0103A;     /* rojo para rellenos con texto blanco */
  --accent-fill-hover: #C70C33;

  /* Funcionales (solo estados, no decoración) */
  --ok: #7CC29A;              /* pagado / entregado / positivo */
  --warn: #FF6A3D;            /* pendiente / en curso */
  --danger: #FF4D6D;          /* vencido / pérdida / alerta (texto) */
  --neutral: #B3ADB2;

  /* Tintes de fondo para badges / alertas */
  --tint-accent: rgba(255, 31, 75, .12);
  --tint-accent-2: rgba(255, 106, 61, .12);
  --tint-ok: rgba(124, 194, 154, .12);
  --tint-neutral: rgba(244, 239, 231, .06);
  --tint-strong: rgba(244, 239, 231, .10);

  /* Gráficos */
  --chart-a: #F4EFE7;   /* serie principal (ingresos) */
  --chart-b: #FF6A3D;   /* serie comparada (gasto) */
  --chart-c: #FF1F4B;   /* línea clave (ganancia) */
  --chart-grid: #262328;

  /* Tipografía */
  --font-display: "Unbounded", "Space Grotesk", system-ui, sans-serif;
  --font-body: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;

  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 17px;
  --fs-lg: 20px;
  --fs-xl: 26px;
  --fs-2xl: 34px;
  --fs-3xl: 44px;

  /* Espacios (base 4) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* Radios */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Medidas */
  --sidebar-w: 248px;
  --topbar-h: 72px;
  --tabbar-h: 64px;
  --content-max: 1360px;

  /* Movimiento y foco */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms;
  --t: 200ms;
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--vl-crema);
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, .45);  /* solo modales/menús; negra, nunca de color */

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F4EFE7;
  --surface: #FCFAF6;
  --surface-2: #F1ECE3;
  --surface-3: #E7E0D4;
  --overlay: rgba(11, 10, 12, .45);

  --line: #E0D9CD;
  --line-strong: #CFC6B8;

  --text: #0B0A0C;
  --text-2: #4E4A52;
  --text-3: #6B6670;   /* gris de marca: 5.0:1 sobre crema */

  --accent: #C40E38;   /* rojo oscurecido para texto sobre crema (AA) */
  --accent-2: #B8461F;
  --accent-fill: #E0103A;
  --accent-fill-hover: #C70C33;

  --ok: #2F7A52;
  --warn: #B8461F;
  --danger: #C40E38;
  --neutral: #4E4A52;

  --tint-accent: rgba(224, 16, 58, .09);
  --tint-accent-2: rgba(255, 106, 61, .14);
  --tint-ok: rgba(47, 122, 82, .10);
  --tint-neutral: rgba(11, 10, 12, .05);
  --tint-strong: rgba(11, 10, 12, .08);

  --chart-a: #0B0A0C;
  --chart-b: #FF6A3D;
  --chart-c: #E0103A;
  --chart-grid: #E0D9CD;

  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--vl-negro);
  --shadow-pop: 0 16px 40px rgba(11, 10, 12, .16);
  color-scheme: light;
}

/* Ajustes puntuales del tema claro (superficies invertidas donde se lee mejor) */
[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea,
[data-theme="light"] .input-group { background-color: #FFFFFF; }
[data-theme="light"] .input-group .input { background: transparent; }
[data-theme="light"] .kanban__col { background: var(--surface-2); }
[data-theme="light"] .kcard { background: var(--surface); }

/* ---------- 3. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
::selection { background: var(--vl-rojo); color: #fff; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }

/* ---------- 4. Tipografía ---------- */
.display, h1, .h1 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.05;
}
h1, .h1 { font-size: var(--fs-2xl); }
h2, .h2 { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-lg); letter-spacing: -.01em; line-height: 1.2; }
h3, .h3 { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-md); line-height: 1.3; }
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lead { font-size: var(--fs-md); color: var(--text-2); }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.num, .tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.num-display {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.text-accent { color: var(--accent); }
.text-accent-2 { color: var(--accent-2); }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.lab {   /* «LAB» y detalles pequeños con degradado de marca */
  background: var(--vl-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 5. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
  padding: var(--s-6) var(--s-4) var(--s-5);
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.sidebar__brand { display: block; padding: var(--s-2) var(--s-3) 0; }
.sidebar__brand img { width: 152px; height: auto; }
.sidebar__section { display: flex; flex-direction: column; gap: 2px; }
.sidebar__label { padding: 0 var(--s-3) var(--s-2); }
.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-3); }

.logo-on-light { display: none; }
[data-theme="light"] .logo-on-dark { display: none; }
[data-theme="light"] .logo-on-light { display: block; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 40px;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 700; }
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--vl-grad);
}
.nav-item__count {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .02em;
}
.avatar--lg { width: 48px; height: 48px; font-size: var(--fs-base); }

/* Main + topbar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-height: var(--topbar-h);
  padding: var(--s-4) var(--s-10);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.topbar__title h1 { font-size: var(--fs-xl); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.topbar__mark { display: none; width: 28px; height: auto; }

.content {
  width: 100%;
  max-width: var(--content-max);
  padding: var(--s-8) var(--s-10) var(--s-16);
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
}

/* Barra inferior (móvil) */
.tabbar {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
}
.tabbar a svg { width: 20px; height: 20px; }
.tabbar a[aria-current="page"] { color: var(--text); font-weight: 700; }
.tabbar a[aria-current="page"] svg { color: var(--accent); }

/* Grillas utilitarias */
.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-6); }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- 6. Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--accent-fill); color: var(--text-on-accent); }
.btn-primary:hover { background: var(--accent-fill-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger); }
.btn-danger:hover { background: var(--tint-accent); }
.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-xs); }
.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* Grupo segmentado (vista kanban/lista, rangos de fecha) */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px;
  padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-3);
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); font-weight: 700; }

/* ---------- 7. Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  min-width: 0;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.card--flush .card__head { padding: var(--s-5) var(--s-6) 0; margin-bottom: var(--s-4); }
.card__head h2 { font-size: var(--fs-md); }
.card__foot { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.link { color: var(--text-2); font-size: var(--fs-sm); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.link:hover { color: var(--text); text-decoration-color: currentColor; }

/* ---------- 8. Stat (cifras clave) ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  min-width: 0;
}
.stat__label { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.stat__value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(24px, 2.3vw, var(--fs-2xl));
  letter-spacing: -.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat__value small { font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 4px; }
.stat__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s-2); font-size: var(--fs-sm); color: var(--text-3); }
.stat--key { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.stat--key .stat__value { color: var(--accent); }

.delta { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--danger); }
.delta--flat { color: var(--text-3); }

/* ---------- 9. Badges y chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--badge-line, var(--line-strong));
  border-radius: var(--r-pill);
  background: var(--badge-bg, transparent);
  color: var(--badge-fg, var(--text-2));
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge--plain::before { display: none; }

/* Estados de cliente */
.badge--lead      { --badge-fg: var(--text-2); --badge-bg: transparent; --badge-line: var(--line-strong); }
.badge--demo-proceso { --badge-fg: var(--accent-2); --badge-bg: var(--tint-accent-2); --badge-line: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.badge--demo-enviado { --badge-fg: var(--text); --badge-bg: var(--tint-strong); --badge-line: var(--line-strong); }
.badge--pagado    { --badge-fg: var(--ok); --badge-bg: var(--tint-ok); --badge-line: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge--perdido   { --badge-fg: var(--text-3); --badge-bg: transparent; --badge-line: var(--line); text-decoration: line-through; text-decoration-thickness: 1px; }

/* Estados de pago */
.badge--pago-ok        { --badge-fg: var(--ok); --badge-bg: var(--tint-ok); --badge-line: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge--pago-pendiente { --badge-fg: var(--accent-2); --badge-bg: var(--tint-accent-2); --badge-line: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.badge--pago-vencido   { --badge-fg: var(--accent); --badge-bg: var(--tint-accent); --badge-line: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Estados de producción */
.badge--por-hacer    { --badge-fg: var(--text-2); --badge-line: var(--line-strong); }
.badge--produccion   { --badge-fg: var(--accent-2); --badge-bg: var(--tint-accent-2); --badge-line: color-mix(in srgb, var(--accent-2) 40%, transparent); }
.badge--revision     { --badge-fg: var(--text); --badge-bg: var(--tint-strong); --badge-line: var(--line-strong); }
.badge--entregado    { --badge-fg: var(--ok); --badge-bg: var(--tint-ok); --badge-line: color-mix(in srgb, var(--ok) 40%, transparent); }

/* Genéricos */
.badge--alerta { --badge-fg: var(--accent); --badge-bg: var(--tint-accent); --badge-line: color-mix(in srgb, var(--accent) 45%, transparent); }
.badge--activa { --badge-fg: var(--ok); --badge-bg: var(--tint-ok); --badge-line: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge--pausada { --badge-fg: var(--text-3); --badge-line: var(--line); }

/* Chip: filtro seleccionable o etiqueta neutra (nicho, tipo) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 700; }
.chip__count { font-variant-numeric: tabular-nums; opacity: .7; }
.chip--sm { min-height: 24px; padding: 0 var(--s-2); font-size: var(--fs-xs); }
.tag {  /* etiqueta pasiva sin borde (nicho, tipo de video) */
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-sm);
  background: var(--tint-neutral);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* ---------- 10. Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.table th {
  padding: var(--s-3) var(--s-4);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: var(--s-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.table th:first-child, .table td:first-child { padding-left: var(--s-6); }
.table th:last-child, .table td:last-child { padding-right: var(--s-6); }
.table .t-right { text-align: right; }
.table .t-strong { font-weight: 700; color: var(--text); }
.table .t-muted { color: var(--text-3); }
.table tfoot td { border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 700; }
.cell-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-main b { font-weight: 700; color: var(--text); }
.table .row .cell-main { min-width: 180px; }
.cell-main span { color: var(--text-3); font-size: var(--fs-xs); }
.amount-in { color: var(--ok); font-weight: 700; }
.amount-out { color: var(--text); font-weight: 700; }

/* Lista compacta (bloques del panel) */
.list { list-style: none; padding: 0; display: flex; flex-direction: column; }
.list__item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}
.list__item:first-child { border-top: 0; padding-top: 0; }
.list__item:last-child { padding-bottom: 0; }
.list__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list__title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__meta { font-size: var(--fs-xs); color: var(--text-3); }
.list__aside { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-variant-numeric: tabular-nums; }

/* Fecha en bloque (Por entregar) */
.date-block {
  flex: none;
  width: 48px;
  padding: 6px 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-align: center;
  line-height: 1;
}
.date-block b { display: block; font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.date-block span { display: block; margin-top: 4px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.date-block--soon { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.date-block--soon b { color: var(--accent); }

/* ---------- 11. Formularios ---------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.field__label .opt { font-weight: 400; color: var(--text-3); }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }
.field__error { font-size: var(--fs-xs); font-weight: 700; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-5) var(--s-4); }
.form-grid .span-2 { grid-column: 1 / -1; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .5; cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 96px; padding: var(--s-3) var(--s-4); resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: var(--s-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238A848C' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  cursor: pointer;
}
input[type="date"].input { padding-right: var(--s-3); }
input[type="date"].input::-webkit-calendar-picker-indicator { filter: invert(.6); cursor: pointer; }
[data-theme="light"] input[type="date"].input::-webkit-calendar-picker-indicator { filter: none; }

/* Input con prefijo/sufijo (moneda COP) */
.input-group {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast) var(--ease);
}
.input-group:hover { border-color: var(--text-3); }
.input-group:focus-within { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.input-group .input { border: 0; background: transparent; box-shadow: none; min-width: 0; }
.input-group__affix { padding: 0 var(--s-4); color: var(--text-3); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.input-group__affix:first-child { padding-right: 0; }
.input-group__affix:last-child { padding-left: 0; }
.input--money { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }

/* Búsqueda */
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 40px; }

/* Toggle (interruptor) */
.toggle { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track {
  position: relative;
  width: 40px; height: 24px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease);
}
.toggle__track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--t) var(--ease), background var(--t) var(--ease);
}
.toggle input:checked + .toggle__track { background: var(--accent-fill); border-color: var(--accent-fill); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .toggle__track { box-shadow: var(--focus); }
.toggle input:disabled + .toggle__track { opacity: .4; }
.toggle__text { font-size: var(--fs-sm); font-weight: 500; }

/* Radio como tarjetas (Tipo de movimiento) */
.choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.choice label {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.choice input { position: absolute; opacity: 0; }
.choice label:hover { color: var(--text); border-color: var(--text-3); }
.choice label:has(input:checked) { border-color: var(--text); color: var(--text); background: var(--tint-neutral); }
.choice label:has(input:focus-visible) { box-shadow: var(--focus); }

.checkbox { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent-fill); }

/* ---------- 12. Pestañas ---------- */
.tabs {
  display: flex;
  gap: var(--s-6);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-3) 0 var(--s-4);
  color: var(--text-3);
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 700; }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
}
.tab__count { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- 13. Barra de herramientas / filtros ---------- */
.toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.toolbar .search { flex: 1 1 260px; max-width: 360px; }
.row-between > .toolbar { flex: 1 1 auto; }
.filters { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---------- 14. Progreso ---------- */
.progress {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.progress__bar { height: 100%; border-radius: inherit; background: var(--text); }
.progress--accent .progress__bar { background: var(--accent-fill); }
.progress--ok .progress__bar { background: var(--ok); }
.meter { display: flex; flex-direction: column; gap: var(--s-2); }
.meter__label { display: flex; justify-content: space-between; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* ---------- 15. Kanban ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: var(--s-4);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  scroll-snap-type: x mandatory;
}
.kanban__col {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-width: 0;
  padding: var(--s-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  scroll-snap-align: start;
}
.kanban__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-2) var(--s-1); }
.kanban__title { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; }
.kanban__title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--text-3)); }
.kanban__count { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.kanban__sum { padding: 0 var(--s-2) var(--s-1); font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.kanban__add {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-weight: 500;
}
.kanban__add:hover { color: var(--text); border-color: var(--text-3); }

.kcard {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: grab;
  transition: border-color var(--t-fast) var(--ease);
}
.kcard:hover { border-color: var(--line-strong); }
.kcard--urgent { box-shadow: inset 3px 0 0 var(--accent); }
.kcard__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.kcard__client { font-weight: 700; line-height: 1.3; }
.kcard__type { font-size: var(--fs-sm); color: var(--text-2); }
.kcard__tags { display: flex; gap: 6px; flex-wrap: wrap; }
.kcard__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.kcard__date { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); }
.kcard__date svg { width: 14px; height: 14px; }
.kcard__date--soon { color: var(--accent); font-weight: 700; }
.kcard__price { font-weight: 700; }

/* ---------- 16. Modal y drawer ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-6);
}
.backdrop--drawer { justify-content: flex-end; align-items: stretch; padding: 0; }
.modal, .drawer {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  max-height: 100%;
}
.modal { width: min(560px, 100%); border-radius: var(--r-lg); max-height: calc(100vh - 48px); }
.drawer { width: min(480px, 100%); height: 100%; border-width: 0 0 0 1px; }
.modal__head, .drawer__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-6) var(--s-6) var(--s-4);
  border-bottom: 1px solid var(--line);
}
.modal__head h2, .drawer__head h2 { font-size: var(--fs-lg); }
.modal__body, .drawer__body { flex: 1; overflow-y: auto; padding: var(--s-6); }
.modal__foot, .drawer__foot {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--line);
}
.modal__foot .spacer, .drawer__foot .spacer { flex: 1; }

/* Panel lateral fijo (detalle de cliente en escritorio) */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s-6); align-items: start; }
.side-panel {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-6));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  max-height: calc(100vh - var(--topbar-h) - var(--s-12));
  overflow: hidden;
}
.side-panel__head { padding: var(--s-6); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s-4); }
.side-panel__body { padding: var(--s-6); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-6); }
.side-panel__foot { padding: var(--s-4) var(--s-6); border-top: 1px solid var(--line); display: flex; gap: var(--s-2); }

/* Lista de datos (definiciones) */
.dl { display: grid; grid-template-columns: auto 1fr; gap: var(--s-3) var(--s-4); font-size: var(--fs-sm); }
.dl dt { color: var(--text-3); }
.dl dd { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; margin: 0; }

/* Línea de tiempo (historial del cliente) */
.timeline { list-style: none; padding: 0; display: flex; flex-direction: column; }
.timeline li { position: relative; padding: 0 0 var(--s-4) var(--s-6); font-size: var(--fs-sm); }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::after { display: none; }
.timeline li.is-key::before { background: var(--accent); }
.timeline time { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 2px; }

/* ---------- 17. Estado vacío ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-12) var(--s-6);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
}
.empty-state img { width: 32px; opacity: .5; }
.empty-state h3 { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-md); }
.empty-state p { max-width: 36ch; color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- 18. Toast y alertas ---------- */
.toast-region { position: fixed; z-index: 60; right: var(--s-6); bottom: var(--s-6); display: flex; flex-direction: column; gap: var(--s-2); }
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  min-width: 300px; max-width: 420px;
  padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--toast-c, var(--text));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
}
.toast--ok { --toast-c: var(--ok); }
.toast--error { --toast-c: var(--accent); }
.toast__text { flex: 1; }

.alert {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--alert-c, var(--text-3));
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.alert--accent { --alert-c: var(--accent); }
.alert b { color: var(--text); }

/* ---------- 19. Gráfico (SVG inline) ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .bar-a { fill: var(--chart-a); }
.chart .bar-b { fill: var(--chart-b); }
.chart .line-c { fill: none; stroke: var(--chart-c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt-c { fill: var(--surface); stroke: var(--chart-c); stroke-width: 2; }
.chart .bar-a.is-current { fill: var(--chart-a); }
.chart .label-strong { fill: var(--text); font-weight: 700; }
.legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.legend i.line { height: 2px; width: 14px; border-radius: 1px; }

/* ---------- 20. Login ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: var(--s-6);
}
.auth__box {
  align-self: center;
  justify-self: center;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
}
.auth__logo { display: flex; flex-direction: column; align-items: center; gap: var(--s-6); text-align: center; }
.auth__logo img.mark { width: 88px; height: auto; }
.auth__logo .wordmark { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-2xl); letter-spacing: -.02em; line-height: 1; }
.auth__foot { text-align: center; font-size: var(--fs-xs); color: var(--text-3); padding-top: var(--s-6); }

/* ---------- 21. Utilidades ---------- */
.divider { height: 1px; background: var(--line); border: 0; }
.hide-mobile { }
.show-mobile { display: none !important; }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.gap-2 { gap: var(--s-2); } .gap-6 { gap: var(--s-6); }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }

/* ---------- 22. Responsive ---------- */
@media (max-width: 1560px) {
  .hide-lg { display: none !important; }
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr) 340px; }
}

@media (max-width: 1024px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .side-panel { position: static; max-height: none; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .tabbar { display: flex; }
  .main { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .topbar { padding: var(--s-3) var(--s-4); min-height: 60px; gap: var(--s-3); }
  .topbar__mark { display: block; }
  .topbar__title h1 { font-size: var(--fs-lg); }
  .topbar__title .eyebrow { display: none; }
  .content { padding: var(--s-5) var(--s-4) var(--s-12); gap: var(--s-6); }
  .card { padding: var(--s-5); }
  .card--flush { padding: 0; }
  .card--flush .card__head { padding: var(--s-5) var(--s-5) 0; }
  .table th:first-child, .table td:first-child { padding-left: var(--s-5); }
  .table th:last-child, .table td:last-child { padding-right: var(--s-5); }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .toast-region { left: var(--s-4); right: var(--s-4); bottom: calc(var(--tabbar-h) + var(--s-4)); }
  .toast { min-width: 0; max-width: none; }
  .backdrop { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-lg) var(--r-lg) 0 0; border-width: 1px 0 0; }
  .drawer { width: 100%; }
  .kanban { grid-template-columns: repeat(4, 82vw); margin: 0 calc(var(--s-4) * -1); padding: 0 var(--s-4) var(--s-2); scroll-padding: 0 var(--s-4); }
}

@media (max-width: 560px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats-2up { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: var(--s-3); }
  .stats-2up .stat { padding: var(--s-4); gap: var(--s-2); }
  .stats-2up .stat__value { font-size: 20px; }
  .stats-2up .stat__meta { font-size: var(--fs-xs); }
  .stats-2up > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stats-2up .eyebrow { letter-spacing: .08em; }
  .chart text { font-size: 19px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .choice { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  /* Tabla que se vuelve lista en celular: añade .table--cards a la <table> */
  .table--cards thead { display: none; }
  .table--cards tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
  .table--cards tbody tr:last-child { border-bottom: 0; }
  .table--cards tbody td { display: block; padding: 0 !important; border: 0; }
  .table--cards tbody td.t-right { grid-column: 2; grid-row: 1; align-self: center; }
  .table--cards tbody td:not(:first-child):not(.t-right) { grid-column: 1; }
  .table--cards .td-indent { padding-left: 44px !important; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--s-4) * -1); padding: 0 var(--s-4); }
  .filters::-webkit-scrollbar { display: none; }
  .topbar__actions .btn-label { display: none; }
  .topbar__actions .btn:not(.btn-icon) { width: 40px; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}
[hidden]{display:none!important}
.kanban__add svg,.chip svg,.empty-state svg{width:16px;height:16px}.kanban__add{display:flex;align-items:center;justify-content:center;gap:8px}
