/* ============================================================
   CRM Águila Real — sistema visual «cuaderno de taller»
   Papel crema · tinta negra · filo dorado · café/tierra. Ver DISENO-CRM.md.
   Capas: 1 tokens · 2 base · 3 estructura · 4 botones · 5 tarjetas/KPI/badges/avisos
          6 formularios · 7 tablas · 8 diálogos y toasts · 9 pantallas · 10 responsive y movimiento
   ============================================================ */

/* ---------- 1 · tokens ---------- */
:root {
  color-scheme: light;
  /* superficies y texto: blanco, crema y negro cálido */
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --surface-3: #f1ede3;
  --line: #e7e1d3;
  --line-strong: #d3cab6;
  --text: #14110d;
  --text-2: #46403a;
  --muted: #655e54;
  --zebra: rgba(20, 17, 13, .025);
  /* marca: primario = tinta negra; acento único = dorado; secundario = café/tierra */
  --primary: #14110d;
  --primary-hover: #2b251d;
  --primary-active: #000000;
  --primary-soft: #efe8da;
  --primary-ink: #5a4a35;
  --on-primary: #ffffff;
  --accent: #dea202;
  --accent-soft: #fbf0cc;
  --accent-ink: #6b4e00;
  --on-accent: #1a1400;
  --earth: #78634a;
  --earth-soft: #efe8da;
  --chart-1: #78634a;
  --hero-bg: #14110d;
  --hero-fg: #ffffff;
  /* estados (texto sobre su fondo suave: AA) */
  --ok: #2d7a50;     --ok-soft: #e4efe6;     --ok-ink: #1d5a37;
  --warn: #b26a00;   --warn-soft: #fbead0;   --warn-ink: #6b4000;
  --err: #b3261e;    --err-soft: #fbe8e5;    --err-ink: #8a1d17;
  --info: #3a5f8a;   --info-soft: #e6edf5;   --info-ink: #2a4a6e;
  --focus: #14110d;
  --ring: 0 0 0 3px rgba(222, 162, 2, .38);
  --link: #5a4a35;
  --tab-ink: var(--primary);
  --money: var(--primary);
  /* barra lateral */
  --side-bg: #14110d;
  --side-line: rgba(255, 255, 255, .08);
  --side-text: #cbc3b4;
  --side-muted: #968c7b;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(222, 162, 2, .13);
  /* conversación */
  --chat-bg: #efe9dc;
  --wa-in: #ffffff;
  --wa-out: #eadfc6;
  --scrim: rgba(20, 17, 13, .5);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23655e54' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  /* tipografía */
  --font-ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Oswald", "Arial Narrow", Impact, sans-serif;
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-base: .875rem; --fs-md: 1rem; --fs-lg: 1.25rem; --fs-xl: 1.5rem; --fs-2xl: 1.875rem;
  /* espacio, radios, sombras, movimiento */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;
  --shadow-1: 0 1px 2px rgba(20, 17, 13, .05), 0 0 0 1px rgba(20, 17, 13, .02);
  --shadow-2: 0 1px 2px rgba(20, 17, 13, .06), 0 6px 16px rgba(20, 17, 13, .07);
  --shadow-3: 0 2px 4px rgba(20, 17, 13, .08), 0 16px 40px rgba(20, 17, 13, .18);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --dur-fast: 140ms;
  --dur: 200ms;
  --side-w: 244px;
  --head-h: 56px;
  /* alias heredados (vistas con estilos en línea y piezas antiguas) */
  --ink: var(--text); --ink-2: var(--text-2);
  --forest: var(--primary); --forest-2: var(--primary-hover);
  --gold: var(--accent); --gold-2: var(--accent);
  --cream: var(--bg); --paper: var(--surface);
  --red: var(--err); --red-bg: var(--err-soft);
  --green-bg: var(--ok-soft); --amber-bg: var(--warn-soft);
  --blue: var(--info); --blue-bg: var(--info-soft);
  --radius: var(--r-lg); --shadow: var(--shadow-1); --shadow-lg: var(--shadow-3);
  --ease: var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0d0a; --surface: #17140f; --surface-2: #1c1812; --surface-3: #251f17;
    --line: #2e271d; --line-strong: #43392b; --text: #f1ebdd; --text-2: #cfc6b4; --muted: #a1967f;
    --zebra: rgba(255, 255, 255, .018);
    --primary: #ece4d2; --primary-hover: #f7f1e3; --primary-active: #d8cfba; --primary-soft: rgba(165, 139, 104, .17); --primary-ink: #dcc9a5; --on-primary: #14110d;
    --accent: #e8ae08; --accent-soft: rgba(232, 174, 8, .15); --accent-ink: #f2cd63; --on-accent: #1a1400;
    --earth: #a58b68; --earth-soft: rgba(165, 139, 104, .17); --chart-1: #a58b68; --hero-bg: #2a2218; --hero-fg: #f1ebdd;
    --ok: #4fb07c; --ok-soft: rgba(79, 176, 124, .14); --ok-ink: #8fd6ae;
    --warn: #e0953a; --warn-soft: rgba(224, 149, 58, .15); --warn-ink: #f0be85;
    --err: #ef6a5e; --err-soft: rgba(239, 106, 94, .15); --err-ink: #ffa39a;
    --info: #6d9bcf; --info-soft: rgba(109, 155, 207, .15); --info-ink: #aecbec;
    --focus: #e8ae08; --ring: 0 0 0 3px rgba(232, 174, 8, .3); --link: var(--primary-ink); --tab-ink: var(--accent); --money: var(--text);
    --side-bg: #0a0806; --side-line: rgba(255, 255, 255, .06);
    --chat-bg: #120f0b; --wa-in: #211b14; --wa-out: #3a2f20; --scrim: rgba(0, 0, 0, .62);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .35); --shadow-3: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .55);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1967f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0d0a; --surface: #17140f; --surface-2: #1c1812; --surface-3: #251f17;
  --line: #2e271d; --line-strong: #43392b; --text: #f1ebdd; --text-2: #cfc6b4; --muted: #a1967f;
  --zebra: rgba(255, 255, 255, .018);
  --primary: #ece4d2; --primary-hover: #f7f1e3; --primary-active: #d8cfba; --primary-soft: rgba(165, 139, 104, .17); --primary-ink: #dcc9a5; --on-primary: #14110d;
  --accent: #e8ae08; --accent-soft: rgba(232, 174, 8, .15); --accent-ink: #f2cd63; --on-accent: #1a1400;
  --earth: #a58b68; --earth-soft: rgba(165, 139, 104, .17); --chart-1: #a58b68; --hero-bg: #2a2218; --hero-fg: #f1ebdd;
  --ok: #4fb07c; --ok-soft: rgba(79, 176, 124, .14); --ok-ink: #8fd6ae;
  --warn: #e0953a; --warn-soft: rgba(224, 149, 58, .15); --warn-ink: #f0be85;
  --err: #ef6a5e; --err-soft: rgba(239, 106, 94, .15); --err-ink: #ffa39a;
  --info: #6d9bcf; --info-soft: rgba(109, 155, 207, .15); --info-ink: #aecbec;
  --focus: #e8ae08; --ring: 0 0 0 3px rgba(232, 174, 8, .3); --link: var(--primary-ink); --tab-ink: var(--accent); --money: var(--text);
  --side-bg: #0a0806; --side-line: rgba(255, 255, 255, .06);
  --chat-bg: #120f0b; --wa-in: #211b14; --wa-out: #3a2f20; --scrim: rgba(0, 0, 0, .62);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4); --shadow-2: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 20px rgba(0, 0, 0, .35); --shadow-3: 0 2px 6px rgba(0, 0, 0, .5), 0 18px 48px rgba(0, 0, 0, .55);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a1967f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- 2 · base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h3 { font-size: var(--fs-md); font-weight: 600; }
p { margin: 0 0 .6em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
::selection { background: rgba(217, 164, 4, .32); }
code { font: .85em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
kbd { font: inherit; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .tbl .num { font-variant-numeric: tabular-nums; }

/* ---------- 3 · estructura ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column;
  padding: 16px 12px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none;
}
.side::-webkit-scrollbar { width: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 16px; margin-bottom: 10px; border-bottom: 1px solid var(--side-line); }
.brand img { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.brand strong { display: block; font: 600 1.06rem/1.1 var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: #fff; }
.brand small { display: block; margin-top: 3px; color: var(--side-muted); font-size: var(--fs-xs); letter-spacing: .02em; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav-group { margin: 14px 0 4px; padding: 0 12px; font-size: var(--fs-xs); font-weight: 500; color: var(--side-muted); }
.nav-group:first-child { margin-top: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 12px; border-radius: var(--r-md);
  color: var(--side-text); text-decoration: none; font-weight: 500; position: relative;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; transition: color var(--dur-fast), opacity var(--dur-fast); }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; }
.nav a[aria-current="page"] svg { color: var(--accent); opacity: 1; }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .tag { margin-left: auto; font-size: .65rem; font-weight: 600; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, .09); color: var(--side-text); }
.side-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 12px 6px 0 8px; border-top: 1px solid var(--side-line); font-size: var(--fs-sm); }
.side-foot .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0; color: var(--side-text); }
.side-foot .who .av { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(255, 255, 255, .1); color: #fff; font-weight: 600; font-size: var(--fs-xs); flex-shrink: 0; text-transform: uppercase; }
.side-foot .who .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.side-foot button { background: none; border: 1px solid transparent; color: var(--side-text); border-radius: var(--r-sm); height: 30px; padding: 0 8px; font-size: var(--fs-sm); transition: background var(--dur-fast), color var(--dur-fast); }
.side-foot button:hover { background: var(--side-hover); color: #fff; }
.side-foot button:focus-visible { outline: 2px solid var(--accent); }
.side-foot .theme-btn { width: 30px; padding: 0; display: grid; place-items: center; }
.side-foot .theme-btn svg { width: 16px; height: 16px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.head-sticky { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar { position: static; display: flex; align-items: center; gap: 10px; min-height: var(--head-h); padding: 8px 32px; }
.topbar h1 { font: 600 1.4rem/1.35 var(--font-display); letter-spacing: .01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-md); }
.menu-btn svg { width: 20px; height: 20px; }
.view { padding: 24px 32px 64px; max-width: 1440px; width: 100%; }
.section-tabs { position: relative; display: flex; gap: 2px; padding: 0 28px; overflow-x: auto; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs a { display: inline-flex; align-items: center; gap: 7px; height: 42px; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--fs-base); white-space: nowrap; border-radius: var(--r-sm); transition: color var(--dur-fast) var(--ease-out); }
.section-tabs a:hover { color: var(--text); }
.section-tabs a:focus-visible { outline-offset: -2px; }
.section-tabs a[aria-current="page"] { color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--tab-ink); }
.has-gsap .section-tabs a[aria-current="page"] { box-shadow: none; }
.section-tabs a.soon { opacity: .75; }
.tab-ink { position: absolute; left: 0; bottom: 0; height: 2px; width: 40px; background: var(--tab-ink); border-radius: 2px 2px 0 0; pointer-events: none; transform-origin: 0 0; }
.section-tabs .tag { font-size: .65rem; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-ink); }
.section-tabs .tag.partial { background: var(--info-soft); color: var(--info-ink); }
.section-tabs .tag.pending { background: var(--accent-soft); color: var(--accent-ink); }

.side-scrim { display: none; }

/* ---------- 4 · botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: var(--r-md);
  font-weight: 500; font-size: var(--fs-base); line-height: 1; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-1);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform 120ms var(--ease-out), color var(--dur-fast);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: color-mix(in srgb, var(--line-strong) 70%, var(--text)); }
.btn:active:not(:disabled) { transform: scale(.98); box-shadow: none; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(20, 17, 13, .25), inset 0 1px 0 rgba(255, 255, 255, .1); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:active:not(:disabled) { background: var(--primary-active); }
.btn.gold { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 2px rgba(111, 82, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.gold:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #fff); border-color: color-mix(in srgb, var(--accent) 88%, #fff); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn.danger { color: var(--err); }
.btn.danger:hover:not(:disabled) { background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 40%, var(--line-strong)); }
.btn.danger.primary { background: var(--err); border-color: var(--err); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 6px; }
.btn.sm svg { width: 14px; height: 14px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: var(--fs-md); }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
.publish-btn .count { background: var(--on-accent); color: var(--accent); border-radius: 99px; padding: 2px 7px; font-size: var(--fs-xs); font-weight: 700; line-height: 1; }
.publish-btn.idle { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); font-weight: 500; }
.publish-btn.idle:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }
.publish-btn.idle svg { color: var(--ok); }
.site-btn { color: var(--text-2); }
.search-btn { justify-content: flex-start; min-width: 232px; background: var(--surface-2); color: var(--muted); box-shadow: none; }
.search-btn .txt { flex: 1; text-align: left; }
.search-btn kbd { font-size: var(--fs-xs); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--link); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- 5 · tarjetas, KPI, badges, avisos ---------- */
.card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -.005em; }
.card-head a { font-size: var(--fs-sm); font-weight: 500; }
.card-body { padding: 18px; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.grid > *, .panel-exec > *, .mod-view > *, .org-view > * { min-width: 0; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(166px, 1fr)); }
.kpis-6 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { padding: 16px 18px 15px; position: relative; overflow: hidden; transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.kpi { display: flex; flex-direction: column; container-type: inline-size; }
.kpi .value { order: 1; font-size: clamp(1.15rem, 11.5cqw, var(--fs-2xl)); font-weight: 600; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .label { order: 2; margin-top: 8px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; line-height: 1.3; }
.kpi .sub { order: 3; margin-top: 3px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.kpi.accent { background: var(--hero-bg); color: var(--hero-fg); border-color: var(--hero-bg); box-shadow: 0 1px 2px rgba(20, 17, 13, .3), 0 8px 20px rgba(20, 17, 13, .16); }
.kpi.accent .label, .kpi.accent .sub { color: #fff; }
.kpi.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: var(--warn-soft); }
.kpi.warn .label, .kpi.warn .sub { color: var(--warn-ink); }
.kpi-link { text-decoration: none; color: inherit; }
.kpi-link .value { font-size: clamp(1.1rem, 11.5cqw, 1.65rem); }
a.kpi-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); transform: translateY(-1px); }
a.kpi-link.accent:hover { border-color: var(--accent); }
.kpi-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.two { grid-template-columns: 1.3fr 1fr; }
.panel-row { align-items: start; }
.panel-row > .card { min-width: 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: var(--fs-xs); font-weight: 600; line-height: 1; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge.green { background: var(--ok-soft); color: var(--ok-ink); }
.badge.amber { background: var(--warn-soft); color: var(--warn-ink); }
.badge.blue { background: var(--info-soft); color: var(--info-ink); }
.badge.red { background: var(--err-soft); color: var(--err-ink); }
.badge.dark { background: var(--text); color: var(--bg); }
.badge.green::before, .badge.red::before, .badge.amber::before, .badge.blue::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty::before { content: ""; display: block; width: 48px; height: 48px; margin: 0 auto 14px; border-radius: var(--r-lg); border: 1px solid var(--line); background-color: var(--surface-2); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23DEA202' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 13h5l1.5 3h5L16 13h5'/%3E%3Cpath d='M5.5 5h13L21 13v6H3v-6z'/%3E%3C/svg%3E"); background-size: 26px; background-position: center; background-repeat: no-repeat; }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: var(--fs-md); }
.empty p { margin-left: auto; margin-right: auto; max-width: 52ch; }
.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); color: var(--warn-ink); font-size: var(--fs-base); }
.notice.info { border-color: color-mix(in srgb, var(--info) 30%, var(--line)); background: var(--info-soft); color: var(--info-ink); }
.notice.error { border-color: color-mix(in srgb, var(--err) 35%, var(--line)); background: var(--err-soft); color: var(--err-ink); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); background: var(--ok-soft); color: var(--ok-ink); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); background: var(--warn-soft); color: var(--warn-ink); }
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.notice a { color: inherit; font-weight: 600; }

.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: var(--r-md); min-height: 16px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 6 · formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > .lbl { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .err { font-size: var(--fs-sm); color: var(--err); font-weight: 600; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=tel], input[type=email], input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=month], select, textarea {
  width: 100%; height: 36px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); font: inherit; line-height: 1.3;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast);
}
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 11px center; cursor: pointer; text-overflow: ellipsis; }
textarea { height: auto; min-height: 96px; padding: 9px 12px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--text)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); }
.field.invalid input:focus, .field.invalid select:focus, .field.invalid textarea:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 22%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; min-height: 28px; }
.check input { width: 18px; height: 18px; flex-shrink: 0; }
.check input[type=checkbox] { transition: transform 120ms var(--ease-out); }
.check input[type=checkbox]:active { transform: scale(.88); }
.inline-check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-base); white-space: nowrap; min-height: 28px; }
.inline-check input { width: 16px; height: 16px; }
.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 99px; transition: background var(--dur) var(--ease-out); cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--dur) var(--ease-out); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* selector segmentado y pestañas internas (misma familia) */
.seg, .tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--surface-3); border: 0; border-radius: var(--r-lg); max-width: 100%; }
.tabs { overflow-x: auto; margin-bottom: 18px; scrollbar-width: none; flex-wrap: nowrap; }
.tabs::-webkit-scrollbar { display: none; }
.seg button, .tabs button { background: none; border: 0; height: 30px; padding: 0 14px; border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; color: var(--muted); white-space: nowrap; transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast), box-shadow var(--dur-fast); }
.seg button:hover:not([aria-pressed="true"]):not([aria-checked="true"]), .tabs button:hover:not([aria-selected="true"]) { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"], .tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-2); }
.seg button:focus-visible, .tabs button:focus-visible { outline-offset: 0; }

/* ---------- 7 · tablas ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 200px; }
/* Botones de barra de herramientas: misma altura que los campos y el botón principal (36 px), aunque la vista los pida «sm». */
.toolbar > .btn.sm:not(.icon) { height: 36px; padding: 0 14px; font-size: var(--fs-base); border-radius: var(--r-md); gap: 8px; }
.toolbar > .btn.sm:not(.icon) svg { width: 16px; height: 16px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type=search] { width: 100%; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.card > .table-wrap { border-radius: inherit; }
table.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 12px; height: 38px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl thead th:first-child { border-top-left-radius: calc(var(--r-lg) - 1px); }
.tbl thead th:last-child { border-top-right-radius: calc(var(--r-lg) - 1px); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.tbl tbody tr:nth-child(even) td { background: var(--zebra); }
.tbl tbody tr { transition: background var(--dur-fast); }
.tbl tbody tr:hover td { background: var(--surface-3); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr[style*="cursor:pointer"]:active td { background: color-mix(in srgb, var(--surface-3) 80%, var(--text) 6%); }
.tbl code { white-space: nowrap; }
.tbl .thumb { width: 54px; height: 40px; border-radius: var(--r-sm); object-fit: cover; background: var(--surface-3); display: block; }
.tbl .name strong { display: block; font-weight: 600; }
.tbl .name span { color: var(--muted); font-size: var(--fs-sm); }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl th.num { text-align: right; }
.card-body .table-wrap + h3, .card-body .table-wrap + p + h3 { margin-top: 18px; }
.tbl tr.dim td { opacity: .55; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; font-size: var(--fs-sm); }
.pager .btns { display: flex; gap: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list.compact li { padding: 6px 0; font-size: var(--fs-sm); }
.list.compact a { color: inherit; }
.lines-ed td { padding: 6px 8px; }
.lines-ed input, .lines-ed select { height: 32px; padding: 0 8px; font-size: var(--fs-sm); }
.lines-ed td:nth-child(2) input { min-width: 160px; }
.org-tbl input, .org-tbl select { width: 100%; min-width: 110px; }
.org-tbl tr.inactive td { opacity: .55; }

/* ---------- 8 · diálogos, toasts ---------- */
.overlay { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 100; display: flex; justify-content: flex-end; animation: fade var(--dur) var(--ease-out); }
.overlay.center { justify-content: center; align-items: center; padding: 20px; }
.panel { background: var(--surface); width: min(640px, 100%); height: 100%; overflow-y: auto; display: flex; flex-direction: column; box-shadow: var(--shadow-3); border-left: 1px solid var(--line); animation: slide 280ms var(--ease-out); }
.overlay.center .panel { height: auto; max-height: min(92vh, 100%); border-radius: var(--r-xl); border: 1px solid var(--line); width: min(560px, 100%); animation: pop 220ms var(--ease-out); }
.panel.wide { width: min(880px, 100%); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 58px; padding: 12px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.panel-head h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.panel-body { padding: 20px 22px; flex: 1; }
.panel-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

#toasts { position: fixed; right: 20px; top: 68px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; background: var(--text); color: var(--bg); padding: 11px 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-3); font-size: var(--fs-base); line-height: 1.4; animation: toast-in 260ms var(--ease-out); }
.toast::before { content: ""; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.toast.error::before { background: var(--err); }
.toast.ok::before { background: var(--ok); }
@keyframes toast-in { from { transform: translateY(-8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 9 · pantallas ---------- */
/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.login-art { position: relative; background: var(--side-bg); color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 40px 48px; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -140px; width: 460px; height: 460px; background: url("/img/logo.png") center / contain no-repeat; opacity: .06; pointer-events: none; }
.login-art .brand { border: 0; padding: 0; margin: 0; }
.login-art .brand img { width: 44px; height: 44px; }
.login-art .brand strong { font-size: 1.25rem; }
.login-art p { margin: 0; max-width: 24ch; font: 500 clamp(1.7rem, 3vw, 2.5rem)/1.1 var(--font-display); letter-spacing: .01em; color: #fff; }
.login-art small { color: var(--side-muted); font-size: var(--fs-sm); }
.login-main { display: grid; place-items: center; padding: 32px 20px; }
.login .box { width: min(380px, 100%); }
.login .box h1 { font: 600 1.6rem/1.15 var(--font-display); margin-bottom: 4px; }
.login .box .lead { color: var(--muted); margin-bottom: 22px; }
.login .box .field { margin-bottom: 16px; }
.login .box input { height: 42px; }
.login .box .btn { height: 44px; }

/* editor de producto */
.uploader { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 14px; display: flex; gap: 14px; align-items: center; background: var(--surface-2); }
.uploader.drag { border-color: var(--primary); background: var(--primary-soft); }
.uploader img { width: 120px; height: 90px; object-fit: cover; border-radius: var(--r-md); background: var(--surface-3); flex-shrink: 0; }
.uploader .none { width: 120px; height: 90px; border-radius: var(--r-md); background: var(--surface-3); display: grid; place-items: center; color: var(--muted); font-size: var(--fs-xs); text-align: center; flex-shrink: 0; }
.preview-card { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); max-width: 260px; }
.preview-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--surface-3); }
.preview-card .b { padding: 10px 12px; }
.preview-card .p { font-weight: 600; font-size: 1.1rem; letter-spacing: -.01em; }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.col { background: var(--surface-3); border-radius: var(--r-lg); display: flex; flex-direction: column; max-height: calc(100vh - 230px); min-height: 160px; }
.col.over { outline: 2px dashed var(--primary); background: var(--primary-soft); }
.col h3 { font-size: var(--fs-sm); font-weight: 600; padding: 12px 14px 8px; display: flex; justify-content: space-between; align-items: center; }
.col .cards { padding: 4px 10px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.lead-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-1); text-align: left; width: 100%; }
.lead-card:hover { border-color: var(--primary); }
.lead-card.dragging { opacity: .4; }
.lead-card strong { display: block; }
.lead-card .meta { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.lead-card .money { font-weight: 600; color: var(--money); font-size: var(--fs-sm); margin-top: 6px; }

/* conversaciones */
.chat-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.conv-list { max-height: calc(100vh - 230px); overflow-y: auto; }
.conv-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; transition: background var(--dur-fast); }
.conv-item:hover { background: var(--surface-3); }
.conv-item[aria-current="true"] { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--accent); }
.conv-item .top { display: flex; justify-content: space-between; gap: 8px; }
.conv-item .last { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread { display: flex; flex-direction: column; gap: 8px; padding: 18px; max-height: calc(100vh - 380px); min-height: 240px; overflow-y: auto; background: var(--chat-bg); }
.bubble { max-width: 76%; padding: 8px 12px; border-radius: 12px; font-size: .92rem; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); }
.bubble.customer { background: var(--wa-in); align-self: flex-start; border-top-left-radius: 3px; }
.bubble.agent { background: var(--wa-out); align-self: flex-end; border-top-right-radius: 3px; }
.bubble.human { background: var(--accent-soft); align-self: flex-end; border-top-right-radius: 3px; }
.bubble.system { background: transparent; align-self: center; color: var(--muted); font-size: var(--fs-sm); box-shadow: none; }
.bubble .who { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.bubble .at { display: block; text-align: right; font-size: .68rem; color: var(--muted); margin-top: 2px; }

/* agente */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; gap: 10px; align-items: center; font-size: var(--fs-base); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex-shrink: 0; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--err); }
.faq-row { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--primary-soft); color: var(--primary-ink); border-radius: 99px; padding: 3px 4px 3px 11px; font-size: var(--fs-sm); font-weight: 500; }
.chip button { background: color-mix(in srgb, var(--primary-ink) 14%, transparent); border: 0; border-radius: 50%; width: 20px; height: 20px; line-height: 1; color: var(--primary-ink); display: grid; place-items: center; }
.chip button svg { width: 12px; height: 12px; }

/* gráficos simples */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.bars .fill { width: 100%; max-width: 44px; background: var(--accent); border-radius: 5px 5px 0 0; min-height: 3px; transition: height .4s ease; }
.bars .bar span { font-size: var(--fs-xs); color: var(--muted); }
.bars .bar b { font-size: var(--fs-sm); }
.hbar { display: grid; grid-template-columns: 120px 1fr 36px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: var(--fs-sm); }
.hbar .track { background: var(--surface-3); border-radius: 99px; height: 8px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--chart-1); border-radius: 99px; transition: width .4s ease; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }
a.hbar { text-decoration: none; color: inherit; }
a.hbar:hover .fill { background: var(--accent); }
.sub-h { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin: 16px 0 6px; }

/* avatar, chips de tipo, tarjetas de estado */
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; font-size: var(--fs-sm); flex-shrink: 0; text-transform: uppercase; }
.who { display: flex; align-items: center; gap: 12px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-pill { background: var(--surface-3); color: var(--text-2); border-radius: 99px; padding: 2px 9px; font-size: var(--fs-xs); font-weight: 500; }
.type-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.type-chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 99px; padding: 0 14px; font-weight: 500; font-size: var(--fs-sm); transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast); }
.type-chip b { background: var(--surface-3); border-radius: 99px; padding: 1px 8px; font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.type-chip:hover { border-color: var(--primary); }
.type-chip[aria-pressed="true"] { background: var(--hero-bg); border-color: var(--hero-bg); color: var(--hero-fg); }
.type-chip[aria-pressed="true"] b { background: rgba(255, 255, 255, .2); color: #fff; }

.st-NEW { --st: #1f5fa8; } .st-CONTACTED { --st: #7b8076; } .st-QUALIFIED { --st: #b7791f; }
.st-QUOTED { --st: #d9a404; } .st-NEGOTIATION { --st: #c0620c; } .st-WON { --st: #1f7a4d; }
.st-LOST { --st: #b3261e; } .st-CLOSED { --st: #9a9a90; } .st-ALL { --st: var(--text); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 12px; }
.stat-tile { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; min-height: 92px; padding: 14px 16px 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); text-align: left; overflow: hidden; transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), background var(--dur); }
.stat-tile::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--st); }
.stat-tile .n { font-size: 1.75rem; font-weight: 600; letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-tile .l { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.stat-tile .s { font-size: var(--fs-xs); color: var(--muted); }
.stat-tile:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.stat-tile[aria-pressed="true"] { background: var(--text); border-color: var(--text); }
.stat-tile[aria-pressed="true"] .n { color: var(--bg); }
.stat-tile[aria-pressed="true"] .l, .stat-tile[aria-pressed="true"] .s { color: color-mix(in srgb, var(--bg) 72%, transparent); }

.lead-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.lead-tile { position: relative; min-height: 240px; display: flex; flex-direction: column; gap: 10px; padding: 14px 14px 12px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--st, var(--line)); border-radius: var(--r-lg); box-shadow: var(--shadow-1); cursor: pointer; overflow: hidden; transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.lead-tile:hover, .lead-tile:focus-visible { box-shadow: var(--shadow-2); border-color: var(--line-strong); border-top-color: var(--st, var(--line-strong)); transform: translateY(-2px); }
.lt-top { display: flex; align-items: center; gap: 10px; }
.lt-top .badge { margin-left: auto; align-self: flex-start; }
.lt-who { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.lt-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-who span { color: var(--muted); font-size: var(--fs-sm); }
.lt-need { flex: 1; min-height: 0; overflow: hidden; }
.lt-need p { margin: 4px 0 0; color: var(--text-2); font-size: var(--fs-base); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lt-prod { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--primary-ink); background: var(--primary-soft); border-radius: var(--r-sm); padding: 2px 8px; max-width: 100%; }
.lt-prod svg { width: 14px; height: 14px; flex-shrink: 0; }
.lt-money { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; color: var(--money); font-variant-numeric: tabular-nums; }
.lt-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; font-size: var(--fs-xs); }
.lt-actions { display: flex; gap: 6px; align-items: center; }
.mini-select { width: auto; height: 28px; padding: 0 26px 0 8px; font-size: var(--fs-xs); border-radius: var(--r-sm); max-width: 118px; background-position: right 8px center; }

/* asistente (vista) */
.ai-btn { color: var(--primary-ink); border-color: color-mix(in srgb, var(--primary) 35%, var(--line-strong)); background: var(--primary-soft); box-shadow: none; }
.ai-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface-3)); }
.ai-quick { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; height: auto; padding: 16px; text-align: left; white-space: normal; transition: border-color var(--dur), box-shadow var(--dur), transform 120ms; }
.ai-quick svg { width: 22px; height: 22px; color: var(--accent); margin-bottom: 4px; }
.ai-quick:hover:not(:disabled) { box-shadow: var(--shadow-2); }
.ai-log { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; max-height: 52vh; overflow-y: auto; }
.ai-log:empty { display: none; }
.ai-msg { max-width: 92%; border-radius: var(--r-lg); padding: 10px 14px; }
.ai-msg.user { align-self: flex-end; background: var(--hero-bg); color: var(--hero-fg); }
.ai-msg.user p { margin: 0; }
.ai-msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.ai-meta { font-size: var(--fs-xs); margin-top: 6px; }
.ai-answer p { margin: 0 0 8px; }
.ai-answer ul { margin: 0 0 8px; padding-left: 20px; }
.ai-answer li { margin-bottom: 4px; }
.ai-answer h4 { margin: 10px 0 6px; font-size: var(--fs-md); }
.ai-answer > :last-child { margin-bottom: 0; }
.typing .spinner { margin: 6px auto; width: 18px; height: 18px; }

/* buscador global */
.gs-results { max-height: 60vh; overflow: auto; margin-top: 12px; }
.gs-h { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.gs-h svg { width: 16px; height: 16px; }
.gs-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 44px; text-align: left; padding: 8px 12px; border-radius: var(--r-md); border: 0; background: transparent; cursor: pointer; }
.gs-item:hover, .gs-item:focus-visible { background: var(--surface-3); }
.gs-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* asistente flotante */
.af-win { position: fixed; left: auto; top: auto; right: 20px; bottom: 20px; width: 380px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3); display: flex; flex-direction: column; z-index: 60; overflow: hidden; transition: width .42s cubic-bezier(.22, 1, .36, 1), left .42s cubic-bezier(.22, 1, .36, 1), top .42s cubic-bezier(.22, 1, .36, 1), box-shadow .3s, border-radius .3s; will-change: width, filter; }
.af-win.af-min { width: 210px; border-radius: 99px; box-shadow: var(--shadow-2); }
.af-win.af-anim { animation: afBlur .46s cubic-bezier(.22, 1, .36, 1); }
@keyframes afBlur { 0% { filter: blur(0); } 35% { filter: blur(7px); opacity: .85; } 100% { filter: blur(0); opacity: 1; } }
.af-body-wrap { overflow: hidden; max-height: 480px; opacity: 1; transition: max-height .42s cubic-bezier(.22, 1, .36, 1), opacity .3s; }
.af-win.af-min .af-body-wrap { max-height: 0; opacity: 0; }
.af-body-wrap > .af-body { height: min(470px, calc(100vh - 150px)); }
.af-win.af-dragging { opacity: .92; user-select: none; transition: none; }
.af-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--side-bg); color: #fff; cursor: grab; touch-action: none; font-weight: 600; }
.af-dragging .af-head { cursor: grabbing; }
.af-head svg { width: 16px; height: 16px; opacity: .8; }
.af-spacer { flex: 1; }
.af-dot { width: 8px; height: 8px; border-radius: 50%; background: #8a8071; }
.af-dot.on { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .2); }
.af-ctl { background: rgba(255, 255, 255, .12); border: 0; color: #fff; border-radius: var(--r-sm); width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer; transition: background var(--dur-fast); }
.af-ctl:hover { background: rgba(255, 255, 255, .24); }
.af-ctl:focus-visible { outline: 2px solid var(--accent); }
.af-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.af-banner { margin: 8px 10px 0; padding: 8px 10px; border-radius: var(--r-md); background: var(--warn-soft); color: var(--warn-ink); font-size: var(--fs-sm); }
.af-log { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.af-msg { max-width: 92%; padding: 9px 12px; border-radius: var(--r-lg); font-size: var(--fs-base); line-height: 1.4; }
.af-msg p { margin: 0; white-space: pre-wrap; }
.af-msg.user { align-self: flex-end; background: var(--hero-bg); color: var(--hero-fg); }
.af-msg.assistant, .af-msg.bot { align-self: flex-start; background: var(--surface-3); }
.af-meta { font-size: var(--fs-xs); margin-top: 4px; }
.af-quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 8px; }
.af-chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px; padding: 5px 11px; font-size: var(--fs-sm); cursor: pointer; transition: background var(--dur-fast); }
.af-chip:hover:not(:disabled) { background: var(--surface-3); }
.af-chip:disabled { opacity: .5; cursor: default; }
.af-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); align-items: flex-end; }
.af-input { flex: 1; resize: none; min-height: 52px; max-height: 120px; }

/* WhatsApp IA */
.wa-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.wa-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.wa-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.wa-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wa-mode { display: flex; gap: 6px; flex-wrap: wrap; }
.bc-preview { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; white-space: pre-wrap; font-size: var(--fs-base); }
.wa-pill { display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.wa-pill .n { font-weight: 600; font-size: 1.05rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.wa-pill .l { color: var(--muted); font-size: var(--fs-sm); }
.bc-count { font-weight: 600; color: var(--text); }
.bc-progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bc-progress > div { height: 100%; background: var(--chart-1); transition: width .2s; }

/* productos */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 16px; }
.prod-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-1); transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.prod-tile:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); transform: translateY(-2px); }
.prod-tile.dim { opacity: .7; }
.pt-img { position: relative; aspect-ratio: 4 / 3; background: var(--surface-3); overflow: hidden; }
.pt-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease-out); }
.prod-tile:hover .pt-img img { transform: scale(1.04); }
.pt-ribbon { position: absolute; top: 14px; left: -36px; transform: rotate(-35deg); background: var(--err); color: #fff; font-size: .7rem; font-weight: 700; padding: 3px 40px; letter-spacing: .06em; }
.pt-badges { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.pt-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.pt-title { font-size: var(--fs-base); line-height: 1.3; font-weight: 600; }
.pt-prices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pt-prices label { display: flex; flex-direction: column; font-size: var(--fs-xs); color: var(--muted); gap: 3px; }
.pt-actions { display: flex; gap: 6px; padding: 10px 14px 14px; flex-wrap: wrap; border-top: 1px dashed var(--line); }
.inline-edit { width: 100%; min-width: 80px; height: 30px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); font: inherit; font-variant-numeric: tabular-nums; }
.inline-edit:focus { border-color: var(--primary); outline: none; box-shadow: var(--ring); }
.inline-edit.saving { opacity: .6; }
.inline-edit.saved { border-color: var(--ok); background: var(--ok-soft); }
.thumb.nophoto, .nophoto { display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: var(--fs-xs); width: 100%; height: 100%; }
.row-err { color: var(--err); font-size: var(--fs-sm); }

/* venta */
.sell-product { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 12px; }
.sale-summary { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; margin: 12px 0; }
.ss-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.ss-row.big { font-size: 1.1rem; font-weight: 600; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
.kv { display: grid; gap: 4px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }

/* finanzas */
.fin-chart { display: flex; gap: 14px; align-items: flex-end; height: 200px; padding: 10px 4px 0; overflow-x: auto; }
.fin-col { flex: 1; min-width: 56px; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.fin-bars { display: flex; gap: 4px; align-items: flex-end; height: 150px; width: 100%; justify-content: center; }
.fb { width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.fb.rev { background: var(--chart-1); }
.fb.exp { background: var(--accent); }
.fin-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--line-strong); }
.fin-legend .rev::before { background: var(--chart-1); } .fin-legend .exp::before { background: var(--accent); } .fin-legend .res::before { background: var(--ok); }
.fin-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); margin-top: 8px; }
.fin-list strong.pos { color: var(--ok); }
.fin-list strong.neg { color: var(--err); }

/* tareas */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); transition: background var(--dur-fast); }
.task:hover { background: var(--surface-2); }
.task:last-child { border-bottom: 0; }
.task.done .task-main strong { text-decoration: line-through; color: var(--muted); }
.task-check input { width: 20px; height: 20px; margin-top: 2px; }
.task-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.task .tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* cotizaciones: impresión (siempre sobre papel blanco) */
.print-doc { display: none; }
@media print {
  body.printing > *:not(.print-doc) { display: none !important; }
  body.printing .print-doc { display: block; color: #000; background: #fff; padding: 24px; font-family: Arial, sans-serif; }
  .print-doc .pd-head { display: flex; justify-content: space-between; border-bottom: 2px solid #14110d; padding-bottom: 12px; margin-bottom: 16px; }
  .print-doc h1 { font-size: 1.6rem; margin: 0; color: #14110d; }
  .print-doc h2 { font-size: 1.2rem; margin: 0; }
  .print-doc table { width: 100%; border-collapse: collapse; margin: 16px 0; }
  .print-doc th, .print-doc td { border: 1px solid #999; padding: 6px 8px; text-align: left; font-size: .9rem; }
  .print-doc tfoot td { font-weight: 700; text-align: right; }
  .print-doc .pd-total td { font-size: 1.05rem; background: #f0f0f0; }
  .print-doc .pd-terms { font-size: .8rem; color: #444; margin-top: 24px; white-space: pre-wrap; }
  .print-doc .pd-notes { white-space: pre-wrap; }
}

/* demo WhatsApp */
.demo-grid { display: grid; grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); gap: 18px; align-items: start; }
.demo-phone { display: flex; flex-direction: column; height: 560px; max-height: 70vh; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-2); background: var(--chat-bg); }
.demo-phone-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #075e54; color: #fff; }
.demo-phone-head div { display: flex; flex-direction: column; line-height: 1.2; }
.demo-phone-head span:not(.demo-avatar):not(.af-spacer) { font-size: .72rem; opacity: .8; }
.demo-phone-head .btn { background: rgba(255, 255, 255, .15); color: #fff; border-color: transparent; box-shadow: none; }
.demo-avatar { width: 34px; height: 34px; border-radius: 50%; background: #25d366; display: grid; place-items: center; }
.demo-avatar svg { width: 20px; height: 20px; }
.demo-log { flex: 1; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.demo-log .bubble.customer { align-self: flex-end; background: var(--wa-out); border-top-left-radius: 12px; border-top-right-radius: 3px; }
.demo-log .bubble.agent { align-self: flex-start; background: var(--wa-in); border-top-right-radius: 12px; border-top-left-radius: 3px; position: relative; padding-right: 30px; }
.demo-why { position: absolute; right: 4px; top: 4px; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 2px; border-radius: var(--r-sm); }
.demo-why:hover { color: var(--primary); background: var(--surface-3); }
.demo-why svg { width: 15px; height: 15px; }
.demo-compose { display: flex; gap: 8px; padding: 10px; background: var(--surface-3); align-items: flex-end; }
.demo-input { flex: 1; resize: none; border-radius: 18px; padding: 9px 14px; max-height: 110px; }
.demo-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.demo-side { display: grid; gap: 16px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: demoDot 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes demoDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.demo-log .bubble.photo { padding: 4px; margin: 0; max-width: 78%; }
.demo-log .bubble.photo img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: var(--surface-3); border-radius: 9px; }
.demo-log .bubble.photo figcaption { padding: 6px 8px 4px; font-size: var(--fs-sm); white-space: pre-wrap; }
.typing-note { font-size: var(--fs-xs); color: var(--muted); margin-left: 8px; }

/* editor de personalidad */
.pe { display: grid; gap: 10px; }
.pe-sec { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur); }
.pe-sec[open] { border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); box-shadow: var(--shadow-2); }
.pe-sec > summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; cursor: pointer; list-style: none; background: var(--surface-2); font-weight: 600; }
.pe-sec > summary::-webkit-details-marker { display: none; }
.pe-sec > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .25s var(--ease-out); margin-left: 6px; flex: none; }
.pe-sec[open] > summary::after { transform: rotate(-135deg); }
.pe-sec > summary .muted { font-size: var(--fs-sm); font-weight: 400; margin-left: auto; text-align: right; }
.pe-body { padding: 14px 16px 16px; border-top: 1px solid var(--line); animation: fade .3s var(--ease-out); }
.pe-list { display: grid; gap: 8px; }
.pe-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pe-row input { flex: 1; min-width: 0; }
.pe-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pe-actions select { width: auto; max-width: 100%; }
.demo-side .pe-sec > summary .muted { display: none; }

/* Panel ejecutivo */
.panel-exec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; transition: opacity .2s; }
.panel-exec.loading { opacity: .55; pointer-events: none; }
.panel-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.panel-filters .pf { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.panel-filters select { height: 32px; font-size: var(--fs-sm); width: auto; }
.panel-filters select:disabled { opacity: .65; cursor: help; }
.panel-filters .pf-range { margin-left: auto; font-variant-numeric: tabular-nums; }
.today-list { list-style: none; margin: 0; padding: 6px 8px; }
.today-list li a { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; align-items: center; padding: 9px 10px; border-radius: var(--r-md); text-decoration: none; color: inherit; transition: background var(--dur-fast); }
.today-list li a:hover { background: var(--surface-3); }
.today-list li a:focus-visible { outline-offset: -2px; }
.today-list li.urgent svg { color: var(--err); }
.today-list svg { width: 18px; height: 18px; color: var(--muted); }
.tl-main { min-width: 0; display: grid; }
.tl-main strong { font-size: var(--fs-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-main small { color: var(--muted); font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; gap: 16px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 4px; }
.legend .lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .lg.sales::before, .db-bar.sales { background: var(--accent); }
.legend .lg.paid::before, .db-bar.paid { background: var(--chart-1); }
.dual-bars { display: flex; align-items: stretch; gap: 8px; height: 150px; padding-top: 8px; }
.db-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.db-pair { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.db-bar { width: 42%; max-width: 22px; min-height: 2px; border-radius: 4px 4px 0 0; transition: height .4s ease; }
.db-col span { font-size: var(--fs-xs); color: var(--muted); text-transform: capitalize; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.mini-stat { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-lg); text-decoration: none; color: inherit; background: var(--surface); transition: border-color var(--dur-fast), background var(--dur-fast); }
a.mini-stat:hover { border-color: var(--line-strong); background: var(--surface-2); }
.mini-stat b { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.mini-stat span { font-size: var(--fs-xs); color: var(--muted); }
.mini-stat.warn { border-color: color-mix(in srgb, var(--err) 40%, var(--line)); background: var(--err-soft); }
.mini-stat.warn b { color: var(--err-ink); }
.mini-stats + .mini-stats { margin-top: 8px; }
.pm-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.pm { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 8px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r-md); font-size: var(--fs-sm); }
.pm small { grid-column: 1 / -1; font-size: var(--fs-xs); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li > a, .timeline .tl-static { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 8px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.timeline li:last-child > * { border-bottom: 0; }
.timeline li > a:hover { background: var(--surface-3); }
.timeline svg { width: 16px; height: 16px; margin-top: 2px; color: var(--muted); }
.timeline strong { font-size: var(--fs-sm); font-weight: 600; display: block; }
.timeline small { color: var(--muted); font-size: var(--fs-xs); }

/* módulos parciales y configuración */
.mod-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 900px; }
.mod-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 18px 20px; }
.mod-head h2 { margin: 0 0 4px; font-size: 1.1rem; }
.mod-head p { margin: 0; }
.mod-list { list-style: none; margin: 0; padding: 4px 10px; }
.mod-feat { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; align-items: center; padding: 11px 8px; border-bottom: 1px solid var(--line); }
.mod-feat:last-child { border-bottom: 0; }
.mod-feat > svg { width: 18px; height: 18px; }
.mod-feat.ready > svg { color: var(--ok); }
.mod-feat.pending > svg { color: var(--warn); }
.mf-main { display: grid; min-width: 0; }
.mf-main strong { font-weight: 600; font-size: var(--fs-base); }
.mf-main small { color: var(--muted); font-size: var(--fs-sm); }
.mod-feat .btn svg { width: 14px; height: 14px; }
.org-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 1000px; }
.org-card .card-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.org-grid, .org-card .card-body.org-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 18px; }
/* Inventario: Artículo con ancho legible, código sin cortes y acciones compactas. */
.tbl-stock th:nth-child(1), .tbl-stock td:first-child { white-space: nowrap; }
.tbl-stock th, .tbl-stock td { padding-left: 10px; padding-right: 10px; }
.tbl-stock th:nth-child(2) { min-width: 190px; }
.tbl-stock th:nth-child(3) { min-width: 108px; }
.tbl-stock .actions { flex-wrap: wrap; min-width: 128px; max-width: 168px; margin-left: auto; }
/* Columnas secundarias (reservada / comprometida): se ocultan por debajo de 1500 px; «Disponible» ya las descuenta. */
@media (max-width: 1500px) { .tbl-stock .c-sec { display: none; } }
.org-card .card-body > .btn { justify-self: start; }
.org-actions { display: flex; justify-content: flex-end; position: sticky; bottom: 12px; }
.org-row-actions { white-space: nowrap; text-align: right; }
.pref-row { display: grid; gap: 2px; align-content: start; }
.pref-row > .badge { justify-self: start; margin: -4px 0 8px; }

/* tipo de cambio oficial (BCB) */
.fx-official-main { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 28px; align-items: center; padding-bottom: 6px; }
.fx-official-value { display: grid; gap: 2px; padding: 14px 20px; border-radius: var(--r-lg); background: var(--hero-bg); color: var(--hero-fg); min-width: 170px; }
.fx-official-value small { color: var(--accent); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; }
.fx-official-value strong { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.fx-official-meta { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; min-width: 0; }
.fx-official-meta li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); }
.fx-official-meta li span { color: var(--muted); }
.fx-official-meta li b { font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.fx-official-msg { margin: 6px 0 2px; font-size: var(--fs-base); font-weight: 500; }
.fx-official-msg.fallo { color: var(--err-ink); }
.fx-official-msg.desactualizado { color: var(--warn-ink); }
.fx-official-auto { margin-top: 8px; display: grid; gap: 2px; }
.fx-official-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 4px; }
.fx-official-use { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 10px; }
@media (max-width: 640px) { .fx-official-main { grid-template-columns: minmax(0, 1fr); } .fx-official-value { min-width: 0; } }

/* agenda, documentos, selector de vínculo */
.agenda-bar { align-items: center; gap: 10px; flex-wrap: wrap; }
.agenda-nav { display: inline-flex; align-items: center; gap: 8px; }
.agenda-label { min-width: 150px; font-weight: 600; font-variant-numeric: tabular-nums; }
.agenda-body { padding: 4px 0; }
.agenda-day { padding: 10px 16px 6px; border-bottom: 1px solid var(--line); }
.agenda-day:last-child { border-bottom: 0; }
.agenda-day.today { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.agenda-day h3 { margin: 0 0 6px; font-size: var(--fs-base); display: flex; align-items: center; gap: 8px; }
.agenda-day h3 .btn { margin-left: auto; }
.agenda-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; }
.agenda-item { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; }
.agenda-item.cancelled .agenda-main a, .agenda-item.cancelled .agenda-main .linklike { text-decoration: line-through; color: var(--muted); }
.agenda-time { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; padding-top: 2px; font-variant-numeric: tabular-nums; }
.agenda-main .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }
.doc-list .doc-icon { width: 28px; color: var(--earth); padding-top: 2px; }
.doc-list .doc-icon svg { width: 22px; height: 22px; }
.entity-picker .hint { color: var(--muted); }

/* ---------- 10 · responsive y movimiento ---------- */
html:not(.has-gsap) .view > * { animation: viewIn 320ms var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (hover: none) { .lead-tile:hover, .prod-tile:hover, a.kpi-link:hover { transform: none; } }

@media (max-width: 1100px) {
  .two { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 24px; min-height: 0; gap: 28px; }
  .login-art::after { width: 240px; height: 240px; right: -40px; bottom: -60px; }
}
@media (max-width: 980px) { .demo-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .26s var(--ease-out); z-index: 80; box-shadow: none; }
  .side.open { transform: none; box-shadow: var(--shadow-3); }
  body.nav-open .side-scrim { display: block; position: fixed; inset: 0; background: var(--scrim); z-index: 70; animation: fade var(--dur) var(--ease-out); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .topbar h1 { font-size: 1.2rem; }
  .view { padding: 16px 14px 72px; }
  .section-tabs { padding: 0 8px; }
  .chat-layout { grid-template-columns: 1fr; }
  .search-btn { min-width: 0; }
  .search-btn .txt, .search-btn kbd, .publish-btn .txt, .site-btn .txt { display: none; }
  .search-btn, .site-btn, .publish-btn { width: 40px; padding: 0; }
  .publish-btn:not(.idle) { width: auto; padding: 0 12px; }
  #toasts { top: 64px; right: 12px; left: 12px; max-width: none; }
}
@media (max-width: 700px) {
  .panel-filters .pf-range { margin-left: 0; width: 100%; }
  .kpis-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-link .value { font-size: clamp(1.1rem, 11.5cqw, 1.35rem); }
  .kpi-link { padding: 12px 14px; }
  .mod-head { flex-direction: column; }
  .mod-feat { grid-template-columns: 20px 1fr; }
  .mod-feat > :last-child { grid-column: 2; justify-self: start; }
}
@media (max-width: 640px) {
  .row2, .row3 { grid-template-columns: 1fr; }
  .agenda-item { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 520px) {
  .lead-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .lead-tile { min-height: 0; }
  .af-win { right: 8px; bottom: 8px; }
  .overlay.center { padding: 10px; }
  .panel-head, .panel-body, .panel-foot { padding-left: 16px; padding-right: 16px; }
  .panel-foot { flex-wrap: wrap; }
  .hbar { grid-template-columns: 96px 1fr 30px; }
  .mini-select { max-width: 104px; }
}
/* objetivos táctiles ≥ 40 px en pantallas pequeñas o táctiles */
@media (max-width: 900px), (pointer: coarse) {
  .btn, .btn.sm { min-height: 40px; height: auto; }
  .btn.icon, .btn.icon.sm { width: 40px; height: 40px; }
  input[type=text], input[type=search], input[type=number], input[type=password], input[type=tel], input[type=email], input[type=url], input[type=date], input[type=time], input[type=datetime-local], input[type=month], select { height: 42px; font-size: 16px; }
  textarea { font-size: 16px; }
  .mini-select, .inline-edit, .lines-ed input, .lines-ed select, .panel-filters select { height: 40px; font-size: 16px; }
  .seg button, .tabs button { height: 36px; min-width: 40px; }
  .type-chip { height: 40px; }
  .nav a { min-height: 44px; }
  .section-tabs a { height: 44px; }
  .check, .inline-check { min-height: 40px; }
  .chip button { width: 28px; height: 28px; }
  .af-ctl { width: 36px; height: 36px; }
  .gs-item, .today-list li a { min-height: 44px; }
  .tbl td { padding: 10px 12px; }
  .tbl th { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  html:not(.has-gsap) .view > * { animation: none; }
}

/* Lenis (solo si se activa con localStorage crm.lenis = "1"; ver DISENO-CRM.md) */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: clip; }

/* ritmo vertical entre bloques sin margen propio */
.notice + .card, .notice + .grid, .notice + .toolbar, .notice + .tabs, .notice + .table-wrap { margin-top: 14px; }
@media (max-width: 640px) { .pe-actions select, .pe-actions .btn { width: 100%; } .pe-actions { min-width: 0; } }
.panel-body h3 { margin: 20px 0 8px; }
.panel-body h3:first-child { margin-top: 0; }
@media (max-width: 700px) {
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: clamp(1.15rem, 11.5cqw, 1.5rem); }
}

/* iconos sin tamaño propio: se ajustan al texto (especificidad 0: cualquier regla concreta gana) */
svg { flex-shrink: 0; }
:where(button, a, span, div, label, h2, h3, h4, li, td, summary) > svg:not([width]) { width: 1.15em; height: 1.15em; }
.seg button, .tabs button { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 700px) {
  .panel-filters .pf { flex: 1 1 140px; justify-content: space-between; }
  .panel-filters .pf select { flex: 1; min-width: 0; }
}
