/* ==========================================================================
   Dicofar CRM · Sistema de diseño
   App B2B densa (referentes: Attio, HubSpot, Linear, Pipedrive) con la marca Dicofar.
   Índice
     1. Tokens (claro / oscuro)      8. Chips, tags, badges, avatares
     2. Base                         9. Tarjetas, KPI, listas, callouts
     3. Utilidades de layout/texto  10. Tablas
     4. Shell (sidebar, topbar,     11. Tabs, menús, popovers, tooltips
        tabbar)                     12. Modales, drawers, sheets, toasts
     5. Página (.page, header…)     13. Skeleton, empty, spinner, kbd
     6. Botones                     14. Login · Palette · Notificaciones
     7. Formularios                 15. Formularios compartidos · Gráficos
                                    16. Responsive · Reduced motion
   Escala de espacio: múltiplos de 4 (--sp-1 = 4px … --sp-16 = 64px).
   Tipografía: 12 / 13 / 14 / 16 / 20 / 24 / 32.
   ========================================================================== */

/* 1. TOKENS -------------------------------------------------------------- */
:root {
  color-scheme: light;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-16: 16px; --fs-20: 20px; --fs-24: 24px; --fs-32: 32px;
  --lh-tight: 1.25; --lh: 1.45; --lh-loose: 1.6;
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  --radius: 6px; --radius-sm: 4px; --radius-lg: 10px; --radius-full: 999px;

  --z-base: 1; --z-sticky: 20; --z-topbar: 30; --z-sidebar: 40; --z-tabbar: 45; --z-scrim: 50;
  --z-drawer: 70; --z-modal: 80; --z-palette: 90; --z-dropdown: 95; --z-toast: 100; --z-tooltip: 110;

  --ease: cubic-bezier(.2, 0, .2, 1);
  --ease-out: cubic-bezier(0, 0, .2, 1);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 260ms;

  --sidebar-w: 248px; --sidebar-w-collapsed: 64px; --topbar-h: 56px; --tabbar-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);

  /* Marca */
  --brand: #3c5ea8; --brand-hover: #334f91; --brand-active: #2a437b; --brand-text: #3c5ea8;
  --brand-soft: #eef2fa; --brand-soft-2: #dde5f5; --on-brand: #ffffff;
  --teal: #19dcd8; --navy: #0e1a33;

  /* Superficies y texto */
  --bg: #f4f5f8; --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #f0f2f6; --surface-raised: #ffffff;
  --hover: #f1f3f7; --active: #e8ebf1; --selected: #eef2fa;
  --border: #e2e5eb; --border-strong: #cbd0da; --border-focus: #3c5ea8;
  --text: #151a26; --text-2: #3b4252; --text-3: #5d6576; --text-4: #687082; --text-inverse: #ffffff; /* text-4 ≥ 4.5:1 sobre --bg (AA) */
  --link: #3559a3;

  /* Estados */
  --success: #1f8f4e; --success-text: #17703d; --success-soft: #e6f4eb;
  --warning: #c27803; --warning-text: #8a5300; --warning-soft: #fcf1dc;
  --danger: #c93a3a; --danger-hover: #b03030; --danger-text: #b42323; --danger-soft: #fbeaea;
  --info: #3c5ea8; --info-text: #2f4c8c; --info-soft: #eaf0fb;

  /* Embudo (color de la marca + variante de texto con contraste AA) */
  --tofu: #0e9f9b; --tofu-text: #08706d; --tofu-soft: #e2f4f3;
  --mofu: #3c5ea8; --mofu-text: #34549a; --mofu-soft: #e9eefa;
  --bofu: #c27803; --bofu-text: #8a5300; --bofu-soft: #fcf1dc;
  --won: #1f8f4e; --won-text: #17703d; --won-soft: #e6f4eb;
  --lost: #8a90a0; --lost-text: #5c6272; --lost-soft: #eef0f3;

  /* Tonos de badge */
  --gray-bg: #eef0f4; --gray-fg: #4a5163;
  --blue-bg: #e8eefa; --blue-fg: #2f4c8c;
  --teal-bg: #e2f4f3; --teal-fg: #08706d;
  --green-bg: #e6f4eb; --green-fg: #17703d;
  --amber-bg: #fcf1dc; --amber-fg: #8a5300;
  --red-bg: #fbeaea; --red-fg: #b42323;
  --purple-bg: #f0ebfa; --purple-fg: #5b3fa3;

  /* Gráficos (paleta categórica validada para daltonismo; orden fijo) */
  --chart-1: #3c5ea8; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
  --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #4a3aa7; --chart-8: #e34948;
  --chart-grid: #e9ecf1; --chart-axis: #cbd0da;

  /* Sidebar (siempre oscura) */
  --sb-bg: #0e1a33; --sb-bg-2: #13213f; --sb-text: #c3cbdd; --sb-strong: #ffffff; --sb-muted: #8794b0;
  --sb-hover: rgba(255, 255, 255, .06); --sb-active: rgba(255, 255, 255, .11); --sb-border: rgba(255, 255, 255, .08);

  /* Sombras */
  --shadow-1: 0 1px 2px rgba(14, 26, 51, .06), 0 1px 1px rgba(14, 26, 51, .03);
  --shadow-2: 0 4px 12px rgba(14, 26, 51, .08), 0 1px 3px rgba(14, 26, 51, .06);
  --shadow-3: 0 16px 40px rgba(14, 26, 51, .16), 0 2px 8px rgba(14, 26, 51, .08);
  --scrim: rgba(10, 16, 30, .44);
  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--border-focus);
  --skeleton: #eceef3; --skeleton-hi: #f6f7f9;
}

[data-theme="dark"] {
  color-scheme: dark;
  --brand: #4a6cc0; --brand-hover: #5677c8; --brand-active: #3f60b0; --brand-text: #8ea8ea;
  --brand-soft: #1b2847; --brand-soft-2: #22335a; --on-brand: #ffffff;
  --bg: #0b1120; --surface: #111a2c; --surface-2: #0e1627; --surface-3: #18233a; --surface-raised: #16213a;
  --hover: #18233a; --active: #1f2c47; --selected: #1b2847;
  --border: #233049; --border-strong: #33425f; --border-focus: #8ea8ea;
  --text: #e7eaf1; --text-2: #bfc6d4; --text-3: #939db2; --text-4: #808aa0; --text-inverse: #0b1120;
  --link: #9db4ee;
  --success: #3bb071; --success-text: #5fcf8f; --success-soft: rgba(59, 176, 113, .14);
  --warning: #e0a030; --warning-text: #eab45a; --warning-soft: rgba(224, 160, 48, .14);
  --danger: #e25c5c; --danger-hover: #ea7070; --danger-text: #f08a8a; --danger-soft: rgba(226, 92, 92, .14);
  --info: #8ea8ea; --info-text: #a9bdf0; --info-soft: rgba(142, 168, 234, .14);
  --tofu: #22bdb8; --tofu-text: #5ad6d2; --tofu-soft: rgba(34, 189, 184, .14);
  --mofu: #6283d0; --mofu-text: #9fb5ec; --mofu-soft: rgba(98, 131, 208, .16);
  --bofu: #d9921f; --bofu-text: #eab45a; --bofu-soft: rgba(217, 146, 31, .15);
  --won: #3bb071; --won-text: #5fcf8f; --won-soft: rgba(59, 176, 113, .14);
  --lost: #7b8397; --lost-text: #a8afbf; --lost-soft: rgba(123, 131, 151, .16);
  --gray-bg: rgba(148, 160, 184, .14); --gray-fg: #c0c7d5;
  --blue-bg: rgba(98, 131, 208, .18); --blue-fg: #a9bdf0;
  --teal-bg: rgba(34, 189, 184, .15); --teal-fg: #5ad6d2;
  --green-bg: rgba(59, 176, 113, .15); --green-fg: #5fcf8f;
  --amber-bg: rgba(217, 146, 31, .16); --amber-fg: #eab45a;
  --red-bg: rgba(226, 92, 92, .16); --red-fg: #f08a8a;
  --purple-bg: rgba(144, 133, 233, .18); --purple-fg: #b9b0f3;
  --chart-1: #6283d0; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
  --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
  --chart-grid: #1e2a42; --chart-axis: #33425f;
  --sb-bg: #0a1326; --sb-bg-2: #0f1a31; --sb-border: rgba(255, 255, 255, .07);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-3: 0 18px 44px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .35);
  --scrim: rgba(2, 6, 14, .62);
  --skeleton: #18233a; --skeleton-hi: #1f2c47;
}

/* 2. BASE --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; scrollbar-gutter: stable; }
html.is-locked, html.is-locked body { overflow: hidden; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; font-family: var(--font); font-size: var(--fs-14); line-height: var(--lh);
  color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}
h1, h2, h3, h4, h5, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3, h4 { font-weight: var(--fw-semibold); line-height: var(--lh-tight); color: var(--text); letter-spacing: -.005em; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; margin: 0; }
button:disabled { cursor: not-allowed; }
input, select, textarea { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
table { border-collapse: collapse; border-spacing: 0; }
::selection { background: var(--brand-soft-2); }
mark { background: none; color: var(--brand-text); font-weight: var(--fw-semibold); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
[hidden] { display: none !important; }
code, kbd, samp, .mono { font-family: var(--mono); }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon--xs { width: 12px; height: 12px; } .icon--sm { width: 14px; height: 14px; } .icon--md { width: 18px; height: 18px; }
.icon--lg { width: 20px; height: 20px; } .icon--xl { width: 24px; height: 24px; } .icon--2xl { width: 32px; height: 32px; stroke-width: 1.5; }
.skip-link { position: fixed; left: var(--sp-3); top: -80px; z-index: var(--z-toast); background: var(--brand); color: #fff; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); font-weight: var(--fw-medium); }
.skip-link:focus { top: calc(var(--sp-3) + var(--safe-top)); text-decoration: none; }

/* 3. UTILIDADES --------------------------------------------------------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--text-3); } .subtle { color: var(--text-4); } .text-2 { color: var(--text-2); }
.text-xs { font-size: var(--fs-12); } .text-sm { font-size: var(--fs-13); } .text-md { font-size: var(--fs-14); } .text-lg { font-size: var(--fs-16); }
.text-xl { font-size: var(--fs-20); } .text-2xl { font-size: var(--fs-24); } .text-3xl { font-size: var(--fs-32); }
.fw-medium { font-weight: var(--fw-medium); } .fw-semibold, .strong { font-weight: var(--fw-semibold); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nowrap { white-space: nowrap; } .text-right { text-align: right; } .text-center { text-align: center; }
.text-success { color: var(--success-text); } .text-danger { color: var(--danger-text); } .text-warning { color: var(--warning-text); } .text-brand { color: var(--brand-text); }
.uppercase-label, .eyebrow { font-size: var(--fs-12); font-weight: var(--fw-medium); letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.link { color: var(--link); cursor: pointer; } .link:hover { text-decoration: underline; }
.link-plain { color: inherit; } .link-plain:hover { color: var(--link); text-decoration: none; }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-xs { display: flex; flex-direction: column; gap: var(--sp-1); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--sp-6); }
.row { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.row-sm { display: flex; align-items: center; gap: var(--sp-1); }
.row-lg { display: flex; align-items: center; gap: var(--sp-4); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-width: 0; }
.row-top { align-items: flex-start; }
.wrap { flex-wrap: wrap; }
.spacer, .grow { flex: 1 1 auto; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.p-0 { padding: 0 !important; } .w-full { width: 100%; }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--sp-4) 0; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-4)); flex: none; }
.dot--sm { width: 6px; height: 6px; }
.show-mobile { display: none !important; }

/* 4. SHELL -------------------------------------------------------------- */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: var(--bg); color: var(--text-3); }
.boot__inner { display: flex; flex-direction: column; align-items: center; gap: var(--sp-4); font-size: var(--fs-13); }
.boot__mark { width: 40px; height: 44px; color: var(--brand); }

.app { min-height: 100vh; min-height: 100dvh; }
.app__col { min-width: 0; margin-left: var(--sidebar-w); transition: margin-left var(--dur-2) var(--ease); display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app[data-sidebar="collapsed"] .app__col { margin-left: var(--sidebar-w-collapsed); }
.main { flex: 1 1 auto; min-width: 0; position: relative; }
.main:focus { outline: none; }
.view { min-width: 0; }

/* Sidebar */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: var(--z-sidebar); width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--sb-bg); color: var(--sb-text); border-right: 1px solid var(--sb-border);
  transition: width var(--dur-2) var(--ease), transform var(--dur-3) var(--ease);
  padding-top: var(--safe-top); padding-left: var(--safe-left);
}
.sidebar__brand { height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-2) 0 var(--sp-4); flex: none; }
.sidebar__home { display: flex; align-items: center; gap: 10px; color: var(--sb-strong); min-width: 0; border-radius: var(--radius); padding: var(--sp-1); margin-left: calc(var(--sp-1) * -1); }
.sidebar__home:hover { text-decoration: none; }
.sidebar__mark { width: 22px; height: 26px; flex: none; color: #fff; }
.sidebar__name { font-weight: var(--fw-semibold); font-size: var(--fs-16); letter-spacing: .01em; white-space: nowrap; }
.sidebar__product { font-family: var(--mono); font-size: var(--fs-12); color: var(--teal); letter-spacing: .08em; border: 1px solid rgba(25, 220, 216, .35); border-radius: var(--radius-sm); padding: 0 5px; line-height: 18px; }
.sidebar__collapse { margin-left: auto; color: var(--sb-muted); width: 32px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; }
.sidebar__collapse:hover { background: var(--sb-hover); color: var(--sb-strong); }
.sidebar__close { display: none; }
.sidebar__nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: var(--sp-2) var(--sp-3) var(--sp-4); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group + .nav-group { margin-top: var(--sp-4); }
.nav-group__title { font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--sb-muted); padding: 0 var(--sp-2) var(--sp-1); letter-spacing: .02em; white-space: nowrap; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 var(--sp-2);
  border-radius: var(--radius); color: var(--sb-text); font-size: var(--fs-14); font-weight: var(--fw-regular); text-align: left; white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.nav-item:hover { background: var(--sb-hover); color: var(--sb-strong); text-decoration: none; }
.nav-item .icon { width: 18px; height: 18px; color: var(--sb-muted); transition: color var(--dur-1) var(--ease); }
.nav-item:hover .icon { color: var(--sb-strong); }
.nav-item[aria-current="page"], .nav-item[data-active="true"] { background: var(--sb-active); color: var(--sb-strong); font-weight: var(--fw-medium); }
.nav-item[aria-current="page"] .icon, .nav-item[data-active="true"] > .icon:first-child { color: var(--teal); }
.nav-item[aria-expanded="true"][data-active="true"] { background: transparent; }
.app[data-sidebar="collapsed"] .nav-item[data-active="true"] { background: var(--sb-active); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--teal); }
.nav-item:focus-visible { outline-color: var(--teal); outline-offset: -2px; }
.nav-item__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item__chev { width: 14px !important; height: 14px !important; transition: transform var(--dur-2) var(--ease); }
.nav-item[aria-expanded="true"] .nav-item__chev { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 var(--sp-1); padding-left: 28px; position: relative; }
.nav-sub::before { content: ""; position: absolute; left: 17px; top: 2px; bottom: 2px; width: 1px; background: var(--sb-border); }
.nav-sub .nav-item { min-height: 32px; font-size: var(--fs-13); }
.nav-sub .nav-item[aria-current="page"]::before { left: -12px; }
.nav-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-full); font-size: var(--fs-12); font-weight: var(--fw-medium);
  display: inline-grid; place-items: center; background: rgba(255, 255, 255, .12); color: var(--sb-strong); font-variant-numeric: tabular-nums; line-height: 1;
}
.nav-badge--alert { background: #c93a3a; color: #fff; }
.nav-badge--accent { background: var(--teal); color: var(--navy); }
.sidebar__footer { flex: none; padding: var(--sp-3); border-top: 1px solid var(--sb-border); display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: calc(var(--sp-3) + var(--safe-bottom)); }
.demo-chip {
  display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); color: var(--sb-text); padding: 6px var(--sp-2);
  border: 1px dashed rgba(255, 255, 255, .18); border-radius: var(--radius); white-space: nowrap; overflow: hidden;
}
.demo-chip .dot { background: #f0b429; }
.user-card { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px var(--sp-2); border-radius: var(--radius); text-align: left; color: var(--sb-strong); min-height: 44px; }
.user-card:hover { background: var(--sb-hover); }
.user-card__text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.user-card__name { font-size: var(--fs-13); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card__role { font-size: var(--fs-12); color: var(--sb-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .icon { color: var(--sb-muted); }

/* Sidebar colapsada (íconos) */
.app[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }
.app[data-sidebar="collapsed"] .sidebar__brand { padding: 0; justify-content: center; flex-direction: column; gap: 0; height: auto; padding-top: var(--sp-3); }
.app[data-sidebar="collapsed"] .sidebar__name,
.app[data-sidebar="collapsed"] .sidebar__product,
.app[data-sidebar="collapsed"] .nav-item__label,
.app[data-sidebar="collapsed"] .nav-item__chev,
.app[data-sidebar="collapsed"] .user-card__text,
.app[data-sidebar="collapsed"] .user-card > .icon,
.app[data-sidebar="collapsed"] .demo-chip__text,
.app[data-sidebar="collapsed"] .nav-sub { display: none; }
.app[data-sidebar="collapsed"] .sidebar__collapse { margin: var(--sp-2) 0 0; transform: rotate(180deg); }
.app[data-sidebar="collapsed"] .sidebar__nav { padding: var(--sp-2) 10px; }
.app[data-sidebar="collapsed"] .nav-group__title { height: 1px; padding: 0; margin: 0 6px var(--sp-2); background: var(--sb-border); overflow: hidden; color: transparent; }
.app[data-sidebar="collapsed"] .nav-group + .nav-group { margin-top: var(--sp-2); }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; padding: 0; min-height: 40px; }
.app[data-sidebar="collapsed"] .nav-item[aria-current="page"]::before { left: -10px; }
.app[data-sidebar="collapsed"] .nav-badge { position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
.app[data-sidebar="collapsed"] .sidebar__footer { padding: var(--sp-2); align-items: center; }
.app[data-sidebar="collapsed"] .demo-chip { width: 40px; justify-content: center; padding: 6px 0; }
.app[data-sidebar="collapsed"] .user-card { justify-content: center; padding: 6px 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar); height: calc(var(--topbar-h) + var(--safe-top)); padding-top: var(--safe-top);
  display: flex; align-items: center; gap: var(--sp-3); padding-inline: var(--sp-6); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
}
.topbar__lead { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; flex: 1 1 auto; }
.topbar__back { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-14); color: var(--text-3); }
.crumbs ol { display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs li { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
/* El "/" y los niveles anteriores (cortos: Clientes, Blog, Bandeja…) no se encogen: antes se superponían.
   Se trunca el nivel actual; un nivel anterior muy largo se corta a 160 px. */
.crumbs li:not(:last-child) { flex: none; max-width: 160px; }
.crumbs li:last-child { flex: 0 1 auto; }
.crumbs li + li::before { content: "/"; color: var(--text-4); flex: none; }
.crumbs a { color: var(--text-3); border-radius: var(--radius-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: var(--text); text-decoration: none; }
.crumbs [aria-current="page"] { color: var(--text); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: var(--sp-2); flex: none; }
.search-trigger {
  display: flex; align-items: center; gap: var(--sp-2); width: 300px; height: 36px; padding: 0 6px 0 10px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-4); font-size: var(--fs-13); text-align: left;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--surface); }
.search-trigger span { flex: 1 1 auto; min-width: 0; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn-badge { position: relative; }
.bell-badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-full);
  background: #c93a3a; color: #fff; font-size: 10px; font-weight: var(--fw-semibold); display: grid; place-items: center; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface); font-variant-numeric: tabular-nums; pointer-events: none;
}
.is-ringing .icon { animation: ring 900ms var(--ease) 1; transform-origin: 50% 10%; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-12deg); } 45% { transform: rotate(8deg); } 60% { transform: rotate(-5deg); } 75% { transform: rotate(2deg); } }

/* Scrim y tabbar móvil */
.scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--scrim); opacity: 0; transition: opacity var(--dur-3) var(--ease); }
.scrim.is-visible { opacity: 1; }
.tabbar { display: none; }

/* 5. PÁGINA ------------------------------------------------------------ */
.page { padding: var(--sp-6) var(--sp-8) var(--sp-12); min-width: 0; }
.page--narrow { max-width: 960px; margin-inline: auto; }
.page--medium { max-width: 1200px; margin-inline: auto; }
.page--flush { padding: 0; }
.page--fill { display: flex; flex-direction: column; min-height: calc(100dvh - var(--topbar-h)); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.page-header__main { min-width: 0; flex: 1 1 320px; display: flex; flex-direction: column; gap: var(--sp-1); }
.page-title { font-size: var(--fs-24); line-height: 32px; font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.page-subtitle { color: var(--text-3); font-size: var(--fs-14); }
.page-header__meta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; color: var(--text-3); font-size: var(--fs-13); }
.page-header__actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.page-toolbar { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.page-toolbar__right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.page-section + .page-section { margin-top: var(--sp-8); }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.section-title { font-size: var(--fs-16); font-weight: var(--fw-semibold); line-height: 24px; }
.section-subtitle { font-size: var(--fs-13); color: var(--text-3); }
.layout-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-6); align-items: start; }
.layout-sidebar--left { grid-template-columns: 300px minmax(0, 1fr); }
.state-page { display: grid; place-items: center; min-height: calc(100dvh - var(--topbar-h) - 96px); padding: var(--sp-8) var(--sp-4); }

/* 6. BOTONES ----------------------------------------------------------- */
.btn {
  --btn-h: 36px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--btn-h); padding: 0 14px;
  border-radius: var(--radius); border: 1px solid transparent; font-size: var(--fs-14); font-weight: var(--fw-medium); line-height: 1;
  white-space: nowrap; user-select: none; text-decoration: none !important; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 1px 1px rgba(14, 26, 51, .12), inset 0 1px 0 rgba(255, 255, 255, .08); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-1); }
.btn--secondary:hover { background: var(--hover); }
.btn--secondary:active { background: var(--active); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--hover); color: var(--text); }
.btn--ghost:active, .btn--ghost[aria-expanded="true"], .btn--ghost[aria-pressed="true"] { background: var(--active); color: var(--text); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
.btn--danger-ghost { background: transparent; color: var(--danger-text); }
.btn--danger-ghost:hover { background: var(--danger-soft); }
.btn--link { background: none; border: 0; padding: 0; height: auto; color: var(--link); font-weight: var(--fw-medium); }
.btn--link:hover { text-decoration: underline !important; }
.btn--sm { --btn-h: 30px; padding: 0 10px; font-size: var(--fs-13); gap: 5px; }
.btn--xs { --btn-h: 24px; padding: 0 8px; font-size: var(--fs-12); gap: 4px; border-radius: var(--radius-sm); }
.btn--xs .icon { width: 14px; height: 14px; }
.btn--lg { --btn-h: 44px; padding: 0 20px; font-size: var(--fs-16); }
.btn--icon { width: var(--btn-h); padding: 0; }
.btn--block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; color: var(--text-3);
}
.btn--primary.is-loading::after, .btn--danger.is-loading::after { color: #fff; border-color: rgba(255, 255, 255, .9); border-right-color: transparent; }
.btn__kbd { font-family: var(--mono); font-size: var(--fs-12); opacity: .7; margin-left: 2px; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn--primary + .btn--primary { border-left: 1px solid rgba(255, 255, 255, .25); margin-left: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 7. FORMULARIOS ------------------------------------------------------- */
.input, .select, .textarea {
  display: block; width: 100%; height: 36px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: var(--fs-14); line-height: 20px;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus) 22%, transparent); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input[readonly] { background: var(--surface-2); }
.input--sm, .select--sm { height: 30px; font-size: var(--fs-13); }
.input--lg { height: 44px; font-size: var(--fs-16); }
.textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; line-height: var(--lh); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6576' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23939db2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
input[type="date"].input, input[type="time"].input, input[type="datetime-local"].input { min-width: 0; }
[data-theme="dark"] input[type="date"], [data-theme="dark"] input[type="time"], [data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }
.input-group { position: relative; display: flex; align-items: center; min-width: 0; }
.input-group > .input { flex: 1 1 auto; }
.input-group__icon { position: absolute; left: 10px; color: var(--text-4); pointer-events: none; display: flex; }
.input-group__icon + .input { padding-left: 32px; }
.input-group__suffix { position: absolute; right: 4px; display: flex; align-items: center; gap: 2px; }
.input-group--suffix > .input { padding-right: 40px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix__text { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-3); font-size: var(--fs-13); white-space: nowrap; }
.input-affix__text:first-child { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-affix__text:last-child { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-affix > .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-affix > .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-2); display: flex; align-items: center; gap: var(--sp-1); }
.field__req { color: var(--danger-text); }
.field__optional { color: var(--text-4); font-weight: var(--fw-regular); }
.field__hint { font-size: var(--fs-12); color: var(--text-3); }
.field__error { font-size: var(--fs-12); color: var(--danger-text); display: flex; align-items: center; gap: 4px; }
.field__error .icon { width: 13px; height: 13px; }
.field--inline { flex-direction: row; align-items: center; justify-content: space-between; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-4); }
.form-grid > .field--full, .form-grid > .span-all { grid-column: 1 / -1; }
.form-section + .form-section { margin-top: var(--sp-6); padding-top: var(--sp-6); border-top: 1px solid var(--border); }
.form-section__title { font-size: var(--fs-14); font-weight: var(--fw-semibold); margin-bottom: var(--sp-3); }
.form-error { display: flex; gap: var(--sp-2); align-items: flex-start; padding: 10px var(--sp-3); border-radius: var(--radius); background: var(--danger-soft); color: var(--danger-text); font-size: var(--fs-13); }

.checkbox, .radio { display: inline-flex; align-items: flex-start; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-14); color: var(--text); line-height: 20px; min-height: 20px; }
.checkbox input, .radio input, input.checkbox-input {
  appearance: none; -webkit-appearance: none; flex: none; width: 16px; height: 16px; margin: 2px 0 0; border: 1.5px solid var(--border-strong);
  background: var(--surface) center / 12px no-repeat; border-radius: var(--radius-sm); cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1);
}
.radio input { border-radius: 50%; }
.checkbox input:hover, .radio input:hover, input.checkbox-input:hover { border-color: var(--brand); }
.checkbox input:checked, input.checkbox-input:checked {
  background-color: var(--brand); border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.checkbox input:indeterminate, input.checkbox-input:indeterminate {
  background-color: var(--brand); border-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
.radio input:checked { border-color: var(--brand); border-width: 5px; }
.checkbox input:focus-visible, .radio input:focus-visible, input.checkbox-input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.checkbox input:disabled, .radio input:disabled { opacity: .5; cursor: not-allowed; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-14); min-height: 24px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { position: relative; width: 34px; height: 20px; flex: none; border-radius: var(--radius-full); background: var(--border-strong); transition: background var(--dur-2) var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--dur-2) var(--ease); }
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }
.switch input:disabled + .switch__track { opacity: .5; }

.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius); background: var(--surface-3); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented--block { display: flex; width: 100%; }
.segmented--block .segmented__item { flex: 1 1 0; }
.segmented__item { position: relative; display: flex; }
.segmented__item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented__item > span, .segmented > button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 30px; padding: 0 12px; border-radius: 4px;
  font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-3); cursor: pointer; white-space: nowrap; transition: background var(--dur-1), color var(--dur-1);
}
.segmented__item > span:hover, .segmented > button:hover { color: var(--text); }
.segmented__item input:checked + span, .segmented > button[aria-pressed="true"], .segmented > button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
[data-theme="dark"] .segmented__item input:checked + span, [data-theme="dark"] .segmented > button[aria-pressed="true"] { background: var(--active); }
.segmented__item input:focus-visible + span, .segmented > button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
.segmented__item input:disabled + span { opacity: .45; cursor: not-allowed; }
.segmented .icon { width: 14px; height: 14px; }

/* Combobox (select con búsqueda: DF.ui.combobox) */
.combo { position: relative; min-width: 0; }
.combo__btn { display: flex; align-items: center; gap: var(--sp-2); text-align: left; }
.combo__btn .combo__value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: var(--sp-2); }
.combo__btn .combo__placeholder { color: var(--text-4); }
.combo-pop { display: flex; flex-direction: column; max-height: min(360px, 60vh); }
.combo-pop__search { padding: var(--sp-2); border-bottom: 1px solid var(--border); flex: none; }
.combo-pop__list { overflow-y: auto; padding: var(--sp-1); flex: 1 1 auto; }
.combo-pop__empty { padding: var(--sp-4); color: var(--text-3); font-size: var(--fs-13); text-align: center; }

/* Tag input */
.tag-input { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; padding: 4px 6px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: text; }
.tag-input:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--border-focus) 22%, transparent); }
.tag-input input { flex: 1 1 100px; min-width: 80px; border: 0; background: none; height: 26px; outline: none; font-size: var(--fs-14); }
.tag-input__suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* 8. CHIPS, TAGS, BADGES, AVATARES ------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--radius-full); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-13); font-weight: var(--fw-medium); white-space: nowrap; cursor: pointer;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
.chip:hover { background: var(--hover); color: var(--text); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: var(--brand-text); }
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chip .icon { width: 14px; height: 14px; }
.chip__count { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
.chip.is-active .chip__count { color: inherit; opacity: .8; }
.chip--sm { height: 26px; padding: 0 10px; font-size: var(--fs-12); }
.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips--scroll::-webkit-scrollbar { display: none; }

.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-12); font-weight: var(--fw-medium); white-space: nowrap; max-width: 100%; }
.tag__remove { display: grid; place-items: center; width: 16px; height: 16px; margin-right: -4px; border-radius: 3px; color: var(--text-3); }
.tag__remove:hover { background: var(--active); color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--radius-full); font-size: var(--fs-12); font-weight: var(--fw-medium);
  line-height: 1; white-space: nowrap; background: var(--gray-bg); color: var(--gray-fg); vertical-align: middle; max-width: 100%;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2.2; }
.badge--sm { height: 18px; padding: 0 6px; font-size: 11px; }
.badge--square { border-radius: var(--radius-sm); }
.badge--gray, .badge--neutral { background: var(--gray-bg); color: var(--gray-fg); }
.badge--blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge--teal { background: var(--teal-bg); color: var(--teal-fg); }
.badge--green { background: var(--green-bg); color: var(--green-fg); }
.badge--amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge--red { background: var(--red-bg); color: var(--red-fg); }
.badge--purple { background: var(--purple-bg); color: var(--purple-fg); }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); color: var(--text-2); }
.badge--solid { background: var(--brand); color: #fff; }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--tofu { background: var(--tofu-soft); color: var(--tofu-text); } .badge--tofu .badge__dot { background: var(--tofu); }
.badge--mofu { background: var(--mofu-soft); color: var(--mofu-text); } .badge--mofu .badge__dot { background: var(--mofu); }
.badge--bofu { background: var(--bofu-soft); color: var(--bofu-text); } .badge--bofu .badge__dot { background: var(--bofu); }
.badge--cliente { background: var(--won-soft); color: var(--won-text); } .badge--cliente .badge__dot { background: var(--won); }
.badge--perdido { background: var(--lost-soft); color: var(--lost-text); } .badge--perdido .badge__dot { background: var(--lost); }
.badge--funnel { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; border-radius: var(--radius-sm); height: 20px; padding: 0 6px; }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; line-height: 1; }
.count--alert { background: #c93a3a; color: #fff; } /* fijo: con --danger del tema oscuro el blanco no llega a AA */
.count--brand { background: var(--brand); color: #fff; }

.avatar {
  --av: #5d6576; --av-size: 28px;
  --av-bg: color-mix(in srgb, var(--av) 16%, var(--surface)); --av-fg: color-mix(in srgb, var(--av) 82%, var(--text)); --av-ring: color-mix(in srgb, var(--av) 22%, transparent);
  display: inline-grid; place-items: center; flex: none; width: var(--av-size); height: var(--av-size); border-radius: 50%;
  background: var(--av-bg); color: var(--av-fg);
  font-size: max(9px, calc(var(--av-size) * .38)); font-weight: var(--fw-semibold); letter-spacing: .02em; line-height: 1; user-select: none; overflow: hidden;
  box-shadow: inset 0 0 0 1px var(--av-ring);
}
/* Oscuro: fondo más presente e iniciales claras (antes quedaban en el tono de la marca sobre fondo casi negro). */
[data-theme="dark"] .avatar {
  --av-bg: color-mix(in srgb, var(--av) 30%, var(--surface)); --av-fg: color-mix(in srgb, var(--av) 30%, #ffffff); --av-ring: color-mix(in srgb, var(--av) 45%, transparent);
}
.avatar--solid { background: var(--av); color: #fff; box-shadow: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--xs { --av-size: 20px; } .avatar--sm { --av-size: 24px; } .avatar--md { --av-size: 32px; } .avatar--lg { --av-size: 40px; } .avatar--xl { --av-size: 56px; }
.avatar--square { border-radius: var(--radius); }
.avatar--empty { background: transparent; color: var(--text-4); box-shadow: inset 0 0 0 1.5px var(--border-strong); border: 0; }
.avatar--empty .icon { width: 55%; height: 55%; }
.sidebar .avatar { background: var(--av); color: #fff; box-shadow: none; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.person { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.person__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 9. TARJETAS, KPI, LISTAS, CALLOUTS ----------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); min-width: 0; }
.card--flat { box-shadow: none; }
.card--hover { transition: border-color var(--dur-1), box-shadow var(--dur-1); cursor: pointer; }
.card--hover:hover { border-color: var(--border-strong); box-shadow: var(--shadow-2); }
.card--pad { padding: var(--sp-4); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); min-height: 52px; }
.card__header--plain { border-bottom: 0; padding-bottom: 0; min-height: 0; padding-top: var(--sp-4); }
.card__title { font-size: var(--fs-14); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.card__subtitle { font-size: var(--fs-12); color: var(--text-3); }
.card__actions { display: flex; align-items: center; gap: var(--sp-1); flex: none; }
.card__body { padding: var(--sp-4); }
.card__body--flush { padding: 0; }
.card__footer { padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-13); }

.kpi { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4); min-width: 0; }
.kpi__label { font-size: var(--fs-13); color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi__value { font-size: var(--fs-24); line-height: 32px; font-weight: var(--fw-semibold); letter-spacing: -.01em; color: var(--text); }
.kpi__meta { font-size: var(--fs-12); color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi__delta { display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.kpi__delta .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.kpi__delta.is-up { color: var(--success-text); } .kpi__delta.is-down { color: var(--danger-text); } .kpi__delta.is-flat { color: var(--text-3); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: hidden; }
.kpis > .kpi { border-right: 1px solid var(--border); margin-right: -1px; border-bottom: 1px solid var(--border); margin-bottom: -1px; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-4); min-height: 48px; border-bottom: 1px solid var(--border); min-width: 0; color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover, button.list-item:hover, .list-item--interactive:hover { background: var(--hover); text-decoration: none; cursor: pointer; }
button.list-item { width: 100%; text-align: left; }
.list-item__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-item__title { font-weight: var(--fw-medium); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { font-size: var(--fs-12); color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.list-item__side { flex: none; display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); color: var(--text-3); }

.callout { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); background: var(--info-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--info) 22%, transparent); font-size: var(--fs-13); }
.callout > .icon { color: var(--info-text); margin-top: 2px; }
.callout__title { font-weight: var(--fw-semibold); margin-bottom: 2px; }
.callout--success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); } .callout--success > .icon { color: var(--success-text); }
.callout--warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 28%, transparent); } .callout--warning > .icon { color: var(--warning-text); }
.callout--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); } .callout--danger > .icon { color: var(--danger-text); }
.callout--neutral { background: var(--surface-2); border-color: var(--border); } .callout--neutral > .icon { color: var(--text-3); }

.progress { --p: 0; --c: var(--brand); height: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress::after { content: ""; display: block; height: 100%; width: calc(var(--p) * 1%); background: var(--c); border-radius: inherit; transition: width var(--dur-3) var(--ease); }

.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: var(--sp-2) var(--sp-3); font-size: var(--fs-13); }
.dl dt { color: var(--text-3); }
.dl dd { color: var(--text); min-width: 0; overflow-wrap: anywhere; }

/* 10. TABLAS ----------------------------------------------------------- */
.table-wrap { position: relative; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); -webkit-overflow-scrolling: touch; }
.table-wrap--fill { max-height: calc(100dvh - var(--table-offset, 220px)); }
.table-wrap--flat { border: 0; box-shadow: none; border-radius: 0; }
.table { width: 100%; font-size: var(--fs-13); color: var(--text); }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3); font-weight: var(--fw-medium); font-size: var(--fs-12);
  text-align: left; white-space: nowrap; height: 36px; padding: 0 var(--sp-3); border-bottom: 1px solid var(--border); letter-spacing: .01em;
}
.table td { height: 44px; padding: 6px var(--sp-3); border-bottom: 1px solid var(--border); vertical-align: middle; min-width: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr.is-selected { background: var(--selected); }
.table tbody tr.is-clickable { cursor: pointer; }
.table--dense td { height: 36px; padding-top: 4px; padding-bottom: 4px; }
.table th:first-child, .table td:first-child { padding-left: var(--sp-4); }
.table th:last-child, .table td:last-child { padding-right: var(--sp-4); }
.table .col-check { width: 40px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table__num, .table .table__num, .table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__primary { font-weight: var(--fw-medium); color: var(--text); }
.table__primary a { color: inherit; } .table__primary a:hover { color: var(--link); }
.table__sub { font-size: var(--fs-12); color: var(--text-3); font-weight: var(--fw-regular); }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; font: inherit; border-radius: var(--radius-sm); }
.th-sort:hover { color: var(--text); }
.th-sort .icon { width: 12px; height: 12px; opacity: .6; }
.th-sort[aria-sort="ascending"] .icon, .th-sort[aria-sort="descending"] .icon { opacity: 1; color: var(--brand-text); }
.table-bulkbar {
  position: sticky; bottom: calc(var(--sp-4) + var(--safe-bottom)); z-index: var(--z-sticky); margin: var(--sp-3) auto 0; width: max-content; max-width: 100%;
  display: flex; align-items: center; gap: var(--sp-2); padding: 6px 6px 6px var(--sp-4); border-radius: var(--radius); background: var(--navy); color: #fff; box-shadow: var(--shadow-3); font-size: var(--fs-13);
}
.table-bulkbar .btn--ghost { color: #dfe5f2; } .table-bulkbar .btn--ghost:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); font-size: var(--fs-13); color: var(--text-3); border-top: 1px solid var(--border); }

/* 11. TABS, MENÚS, POPOVERS, TOOLTIPS --------------------------------- */
/* La línea base va como sombra interior: con overflow-x:auto un border-bottom recortaba el indicador activo a 1 px. */
.tabs { display: flex; gap: var(--sp-5); box-shadow: inset 0 -1px 0 var(--border); overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 2px; color: var(--text-3); font-size: var(--fs-14);
  font-weight: var(--fw-medium); white-space: nowrap; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"], .tab.is-active { color: var(--text); }
.tab[aria-selected="true"]::after, .tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--brand); border-radius: 2px 2px 0 0; }
.tab:focus-visible { outline-offset: -2px; }
.tab .count { font-weight: var(--fw-medium); }
.tabs--sm .tab { height: 34px; font-size: var(--fs-13); }
.tab-panel:focus-visible { outline: none; }

.popover {
  position: fixed; z-index: var(--z-dropdown); min-width: 180px; max-width: calc(100vw - 16px); background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-3); overflow: hidden;
  animation: pop-in var(--dur-2) var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu { padding: var(--sp-1); max-height: min(420px, 70vh); overflow-y: auto; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 5px 10px; border-radius: var(--radius-sm); color: var(--text);
  font-size: var(--fs-14); text-align: left; white-space: nowrap; cursor: pointer; text-decoration: none !important;
}
.menu__item .icon { color: var(--text-3); width: 16px; height: 16px; }
.menu__item:hover, .menu__item.is-active, .menu__item:focus-visible { background: var(--hover); outline: none; }
.menu__item[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.menu__item--danger { color: var(--danger-text); } .menu__item--danger .icon { color: var(--danger-text); }
.menu__item--danger:hover { background: var(--danger-soft); }
.menu__label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu__desc { display: block; font-size: var(--fs-12); color: var(--text-3); white-space: normal; }
.menu__kbd { margin-left: auto; font-family: var(--mono); font-size: var(--fs-12); color: var(--text-4); }
.menu__check { margin-left: auto; color: var(--brand-text); }
.menu__sep { height: 1px; background: var(--border); margin: var(--sp-1) calc(var(--sp-1) * -1); }
.menu__header { padding: 8px 10px 4px; font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--text-3); }
.menu__header--sheet { font-size: var(--fs-14); color: var(--text); font-weight: var(--fw-semibold); padding: 12px 10px 8px; }
.menu__option-rich { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; padding: 4px 0; }

.tooltip {
  position: fixed; z-index: var(--z-tooltip); max-width: 260px; padding: 6px 8px; border-radius: var(--radius-sm); background: #151c2e; color: #f1f3f8;
  font-size: var(--fs-12); line-height: 1.4; pointer-events: none; box-shadow: var(--shadow-2); opacity: 0; transition: opacity var(--dur-1) var(--ease);
}
[data-theme="dark"] .tooltip { background: #e7eaf1; color: #0e1627; }
.tooltip.is-visible { opacity: 1; }
.tooltip kbd { margin-left: 6px; background: rgba(255, 255, 255, .14); color: inherit; border: 0; box-shadow: none; }
.tooltip__value { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }

/* 12. MODALES, DRAWERS, SHEETS, TOASTS -------------------------------- */
.layer { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: center; justify-content: center; padding: var(--sp-6); }
.layer--drawer { z-index: var(--z-drawer); justify-content: flex-end; align-items: stretch; padding: 0; }
.layer--drawer-left { justify-content: flex-start; }
.layer__scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade-in var(--dur-2) var(--ease-out); }
.layer.is-closing .layer__scrim { animation: fade-out var(--dur-2) var(--ease) forwards; }
@keyframes fade-in { from { opacity: 0; } } @keyframes fade-out { to { opacity: 0; } }

.modal {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: min(88dvh, 880px); background: var(--surface-raised);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-3); animation: modal-in var(--dur-3) var(--ease-out); outline: none;
}
.layer.is-closing .modal { animation: modal-out var(--dur-2) var(--ease) forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(6px) scale(.985); } }
.modal--sm { max-width: 420px; } .modal--md { max-width: 560px; } .modal--lg { max-width: 760px; } .modal--xl { max-width: 1040px; }
.modal--full { max-width: none; height: 100%; max-height: none; }
.modal__header { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3); flex: none; }
.modal__heading { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.modal__title { font-size: var(--fs-16); line-height: 24px; font-weight: var(--fw-semibold); }
.modal__subtitle { font-size: var(--fs-13); color: var(--text-3); }
.modal__close { margin: -6px -8px 0 0; flex: none; }
.modal__body { padding: var(--sp-2) var(--sp-5) var(--sp-5); overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.modal__footer { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); flex: none; flex-wrap: wrap; background: var(--surface-raised); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal__footer-start { margin-right: auto; display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.modal__grabber { display: none; }

.drawer {
  position: relative; display: flex; flex-direction: column; width: min(var(--drawer-w, 480px), 100vw); height: 100%; background: var(--surface-raised);
  box-shadow: var(--shadow-3); animation: drawer-in var(--dur-3) var(--ease-out); outline: none; padding-top: var(--safe-top);
}
.layer--drawer-left .drawer { animation-name: drawer-in-left; }
.layer.is-closing .drawer { animation: drawer-out var(--dur-2) var(--ease) forwards; }
.layer--drawer-left.is-closing .drawer { animation-name: drawer-out-left; }
@keyframes drawer-in { from { transform: translateX(100%); } } @keyframes drawer-out { to { transform: translateX(100%); } }
@keyframes drawer-in-left { from { transform: translateX(-100%); } } @keyframes drawer-out-left { to { transform: translateX(-100%); } }
.drawer .modal__header { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-4); }
.drawer .modal__body { padding-top: var(--sp-4); }
.drawer .modal__footer { border-radius: 0; padding-bottom: calc(var(--sp-3) + var(--safe-bottom)); }

.toasts { position: fixed; z-index: var(--z-toast); right: var(--sp-5); bottom: calc(var(--sp-5) + var(--safe-bottom)); display: flex; flex-direction: column; gap: var(--sp-2); width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--sp-3); padding: 12px 12px 12px 14px; border-radius: var(--radius);
  background: #151c2e; color: #eef1f7; box-shadow: var(--shadow-3); font-size: var(--fs-14); animation: toast-in var(--dur-3) var(--ease-out);
  border: 1px solid rgba(255, 255, 255, .06);
}
[data-theme="dark"] .toast { background: #1f2b45; border-color: rgba(255, 255, 255, .08); }
.toast.is-closing { animation: toast-out var(--dur-2) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
.toast__icon { margin-top: 2px; flex: none; }
.toast--success .toast__icon { color: #5fd08f; } .toast--error .toast__icon { color: #ff8f8f; } .toast--warning .toast__icon { color: #f3c05a; } .toast--info .toast__icon { color: #9db4ee; }
.toast__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 20px; }
.toast__title { font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.toast__desc { color: #b9c1d3; font-size: var(--fs-13); overflow-wrap: anywhere; }
.toast__actions { display: flex; align-items: center; gap: 2px; flex: none; margin: -4px -4px -4px 0; }
.toast__action { height: 28px; padding: 0 10px; border-radius: var(--radius-sm); color: #9db4ee; font-weight: var(--fw-semibold); font-size: var(--fs-13); }
.toast__action:hover { background: rgba(255, 255, 255, .08); }
.toast__close { width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-sm); color: #9aa3b8; }
.toast__close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.toast :focus-visible { outline: 2px solid #9db4ee; outline-offset: 1px; }
.toast__actions--below { margin: 6px 0 -2px -10px; flex-wrap: wrap; }
.toast--stacked > .toast__actions { align-self: flex-start; }
/* Con un modal/drawer que ocupa el ancho (o en móvil): avisos arriba, fuera de los botones del pie. */
.toasts.toasts--top { top: calc(var(--sp-4) + var(--safe-top)); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); flex-direction: column-reverse; }

/* 13. SKELETON, EMPTY, SPINNER, KBD ----------------------------------- */
.skeleton { display: block; border-radius: var(--radius-sm); background: var(--skeleton); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-hi), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-text { height: 12px; margin: 4px 0; }
.skeleton-title { height: 24px; width: 40%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-block { height: 88px; }
.skeleton-rows { display: flex; flex-direction: column; }
.skeleton-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.skeleton-page { padding: var(--sp-6) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-4); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-6); max-width: 440px; margin: 0 auto; }
.empty--compact { padding: var(--sp-6) var(--sp-4); }
.empty__icon { width: 48px; height: 48px; border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); margin-bottom: var(--sp-2); }
.empty__icon .icon { width: 22px; height: 22px; }
.empty--compact .empty__icon { width: 40px; height: 40px; margin-bottom: 0; }
.empty__title { font-size: var(--fs-16); font-weight: var(--fw-semibold); color: var(--text); }
.empty--compact .empty__title { font-size: var(--fs-14); }
.empty__body { font-size: var(--fs-13); color: var(--text-3); line-height: var(--lh-loose); }
.empty__actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; justify-content: center; }
.empty__code { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-4); letter-spacing: .06em; }

.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand); animation: spin .7s linear infinite; flex: none; }
.spinner--lg { width: 28px; height: 28px; border-width: 2.5px; }
kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: var(--fw-medium); line-height: 1; color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border-strong); box-shadow: 0 1px 0 var(--border-strong); white-space: nowrap;
}
.kbd-combo { display: inline-flex; align-items: center; gap: 3px; }

/* 14. LOGIN ---------------------------------------------------------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; background: var(--surface); }
.login__brand {
  position: relative; background: var(--navy); color: #c9d2e4; padding: var(--sp-10) var(--sp-12); display: flex; flex-direction: column; gap: var(--sp-8); overflow: hidden;
  padding-top: calc(var(--sp-10) + var(--safe-top));
}
.login__brand::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 48px 48px; pointer-events: none; }
.login__brand > * { position: relative; }
.login__logo { width: 164px; height: 44px; color: #fff; }
.login__claim { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-4); max-width: 460px; }
.login__product { font-family: var(--mono); font-size: var(--fs-13); letter-spacing: .1em; color: var(--teal); text-transform: uppercase; }
.login__title { color: #fff; font-size: var(--fs-32); line-height: 40px; font-weight: var(--fw-semibold); letter-spacing: -.015em; }
.login__lead { font-size: var(--fs-16); line-height: 1.55; color: #c9d2e4; }
.login__facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid rgba(255, 255, 255, .12); max-width: 560px; }
.login__fact { padding: var(--sp-4) var(--sp-4) 0 0; display: flex; flex-direction: column; gap: 4px; }
.login__fact + .login__fact { padding-left: var(--sp-4); border-left: 1px solid rgba(255, 255, 255, .12); }
.login__fact strong { color: #fff; font-size: var(--fs-24); line-height: 32px; font-weight: var(--fw-semibold); }
.login__fact span { font-size: var(--fs-13); line-height: 1.45; color: #aab5cc; }
.login__legal { font-size: var(--fs-12); color: #8794b0; margin-top: var(--sp-8); }
.login__panel { display: flex; flex-direction: column; padding: var(--sp-6) var(--sp-8) var(--sp-8); padding-top: calc(var(--sp-6) + var(--safe-top)); padding-bottom: calc(var(--sp-8) + var(--safe-bottom)); min-width: 0; background: var(--surface); }
.login__back { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-13); min-height: 44px; padding: 0 var(--sp-2); margin-left: calc(var(--sp-2) * -1); border-radius: var(--radius); }
.login__back:hover { color: var(--text); text-decoration: none; background: var(--hover); }
.login__form-wrap { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: var(--sp-6); padding: var(--sp-6) 0; }
.login__heading h2 { font-size: var(--fs-24); line-height: 32px; }
.login__heading p { color: var(--text-3); margin-top: var(--sp-1); }
.login__form { display: flex; flex-direction: column; gap: var(--sp-4); }
.login__form .input { height: 44px; font-size: var(--fs-16); }
.login__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.login__row .checkbox { min-height: 44px; align-items: center; }
.login__row .checkbox input { margin: 0; }
.login__forgot { font-size: var(--fs-13); min-height: 44px; display: inline-flex; align-items: center; }
.login__caps { font-size: var(--fs-12); color: var(--warning-text); display: flex; align-items: center; gap: 4px; }
.login__demo { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.login__demo-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.login__demo-head h3 { font-size: var(--fs-13); font-weight: var(--fw-semibold); }
.login__demo-head p { font-size: var(--fs-12); color: var(--text-3); }
.login__demo-head code { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 5px; }
.login__users { display: flex; flex-direction: column; padding: var(--sp-1); }
.login__user { display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: 48px; padding: 6px var(--sp-3); border-radius: var(--radius); text-align: left; }
.login__user:hover { background: var(--hover); }
.login__user.is-selected { background: var(--selected); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 35%, transparent); }
.login__user-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.3; }
.login__user-name { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text); }
.login__user-role { font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login__user code { font-size: var(--fs-12); color: var(--text-3); }

/* Command palette */
.palette-layer { position: fixed; inset: 0; z-index: var(--z-palette); display: flex; justify-content: center; align-items: flex-start; padding: 12vh var(--sp-4) var(--sp-4); }
.palette {
  position: relative; width: 100%; max-width: 640px; max-height: min(560px, 76vh); display: flex; flex-direction: column; background: var(--surface-raised);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-3); overflow: hidden; animation: modal-in var(--dur-2) var(--ease-out);
}
.palette__search { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4); border-bottom: 1px solid var(--border); flex: none; }
.palette__search > .icon { color: var(--text-3); width: 18px; height: 18px; }
.palette__input { flex: 1 1 auto; height: 52px; border: 0; background: none; font-size: var(--fs-16); color: var(--text); outline: none; min-width: 0; }
.palette__input::placeholder { color: var(--text-4); }
.palette__results { overflow-y: auto; padding: var(--sp-2); flex: 1 1 auto; overscroll-behavior: contain; }
.palette__group + .palette__group { margin-top: var(--sp-2); }
.palette__group-title { padding: 6px 10px 4px; font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--text-3); }
.palette__item { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; padding: 6px 10px; border-radius: var(--radius); cursor: pointer; color: var(--text); }
.palette__item[aria-selected="true"] { background: var(--selected); }
[data-theme="dark"] .palette__item[aria-selected="true"] { background: var(--active); }
.palette__item-icon { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: var(--radius); background: var(--surface-3); color: var(--text-3); }
.palette__item-icon .icon { width: 15px; height: 15px; }
.palette__item-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.palette__item-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-14); }
.palette__item-title mark { background: none; color: var(--brand-text); font-weight: var(--fw-semibold); }
.palette__item-sub { font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette__item-side { flex: none; display: flex; align-items: center; gap: var(--sp-2); color: var(--text-4); font-size: var(--fs-12); }
.palette__item-enter { opacity: 0; }
.palette__item[aria-selected="true"] .palette__item-enter { opacity: 1; }
.palette__footer { display: flex; align-items: center; gap: var(--sp-4); padding: 8px var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-12); color: var(--text-3); flex: none; background: var(--surface-2); flex-wrap: wrap; }
.palette__footer span { display: inline-flex; align-items: center; gap: 4px; }
.palette__status { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-3); font-size: var(--fs-13); display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }

/* Notificaciones */
/* El popover es columna flexible: si su alto se limita (poco espacio o sheet móvil), se achica la lista y
   el encabezado y las pestañas quedan siempre visibles. */
.notif-popover { display: flex; flex-direction: column; }
.notif-panel { width: 400px; display: flex; flex-direction: column; max-height: min(620px, calc(100dvh - 80px)); min-height: 0; flex: 1 1 auto; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4) var(--sp-1); min-height: 48px; }
.notif-panel__title { font-size: var(--fs-16); font-weight: var(--fw-semibold); }
.notif-panel .tabs { padding: 0 var(--sp-4); gap: var(--sp-4); flex: none; overflow: visible; }
.notif-panel__head, .notif-panel__foot { flex: none; }
.notif-panel__list { overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.notif.is-unread { padding-right: 36px; }
.notif { position: relative; display: flex; gap: var(--sp-3); width: 100%; padding: var(--sp-3) 32px var(--sp-3) var(--sp-4); text-align: left; border-bottom: 1px solid var(--border); color: var(--text); }
.notif:hover { background: var(--hover); }
.notif:last-child { border-bottom: 0; }
.notif__icon { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.notif__icon .icon { width: 15px; height: 15px; }
.notif__icon--lead { background: var(--teal-bg); color: var(--teal-fg); }
.notif__icon--tarea { background: var(--blue-bg); color: var(--blue-fg); }
.notif__icon--mencion { background: var(--purple-bg); color: var(--purple-fg); }
.notif__icon--etapa, .notif__icon--asignacion { background: var(--amber-bg); color: var(--amber-fg); }
.notif__icon--ganado { background: var(--green-bg); color: var(--green-fg); }
.notif__icon--comentario { background: var(--gray-bg); color: var(--gray-fg); }
.notif__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif__title { font-size: var(--fs-13); line-height: 18px; font-weight: var(--fw-regular); color: var(--text-2); }
.notif.is-unread .notif__title { font-weight: var(--fw-semibold); color: var(--text); }
.notif__text { font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif__time { font-size: var(--fs-12); color: var(--text-4); }
.notif__unread { position: absolute; right: var(--sp-4); top: 18px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.notif-panel__foot { padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-12); color: var(--text-3); }

/* Ayuda de atajos */
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-8); }
.shortcuts h3 { font-size: var(--fs-12); color: var(--text-3); font-weight: var(--fw-medium); grid-column: 1 / -1; margin-top: var(--sp-3); text-transform: uppercase; letter-spacing: .04em; }
.shortcuts h3:first-child { margin-top: 0; }
.shortcut { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-13); }
.shortcut__keys { display: inline-flex; gap: 4px; align-items: center; color: var(--text-4); font-size: var(--fs-12); }

/* 15. FORMULARIOS COMPARTIDOS · GRÁFICOS ------------------------------ */
.type-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.type-picker__item { position: relative; }
.type-picker__item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.type-picker__item span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; padding: 6px 4px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: var(--fs-12); font-weight: var(--fw-medium); text-align: center; cursor: pointer; line-height: 1.2;
}
.type-picker__item span .icon { width: 18px; height: 18px; color: var(--text-3); }
.type-picker__item span:hover { border-color: var(--border-strong); background: var(--hover); }
.type-picker__item input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); box-shadow: inset 0 0 0 1px var(--brand); }
.type-picker__item input:checked + span .icon { color: var(--brand-text); }
.type-picker__item input:focus-visible + span { box-shadow: var(--focus-ring); }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.due-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.due-row .input[type="date"] { width: 160px; flex: 0 0 auto; }
.due-row .input[type="time"] { width: 112px; flex: 0 0 auto; }
@media (max-width: 767px) { .due-row .input[type="date"] { flex: 1 1 55%; width: auto; } .due-row .input[type="time"] { flex: 1 1 35%; width: auto; } .due-row .quick-dates { width: 100%; } }
.compose-preview { font-size: var(--fs-12); color: var(--text-3); font-family: var(--mono); overflow-wrap: anywhere; }
.dup-warning { margin-top: 6px; }

.chart { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.chart.chart--spark { display: inline-block; width: auto; vertical-align: middle; }
.chart text { fill: var(--text-3); font-size: 12px; }
.chart .chart__value { fill: var(--text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.chart .chart__label { fill: var(--text-2); }
.chart .chart__grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .chart__axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .chart__mark { transition: opacity var(--dur-1) var(--ease); }
.chart .chart__hit { fill: transparent; cursor: default; }
.chart .chart__hit:focus-visible { outline: none; stroke: var(--border-focus); stroke-width: 2; }
.chart:hover .chart__mark.is-dim, .chart .chart__mark.is-dim { opacity: .35; }
.chart .chart__crosshair { stroke: var(--text-4); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart .chart__col:hover .chart__crosshair, .chart .chart__col:focus-within .chart__crosshair { opacity: 1; }
.chart .chart__center-value { fill: var(--text); font-size: 24px; font-weight: var(--fw-semibold); }
.chart .chart__center-label { fill: var(--text-3); font-size: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-12); color: var(--text-2); margin-top: var(--sp-3); }
.chart-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend__swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--c); flex: none; }
.chart-legend__line { width: 14px; height: 2px; border-radius: 2px; background: var(--c); flex: none; }
.chart-legend__value { color: var(--text-3); font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; }
.chart-donut-layout { display: flex; align-items: center; gap: var(--sp-6); flex-wrap: wrap; }
.chart-donut-layout > svg { width: 160px; flex: none; }
.chart-donut-layout .chart-legend { flex-direction: column; margin: 0; flex: 1 1 160px; }

/* 16. RESPONSIVE ------------------------------------------------------ */
@media (max-width: 1279px) {
  .page { padding: var(--sp-6); padding-bottom: var(--sp-12); }
  .layout-sidebar { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (max-width: 1023px) {
  .topbar { padding-inline: var(--sp-4); }
  .search-trigger { width: 220px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-sidebar, .layout-sidebar--left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  :root { --topbar-h: 52px; }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .app__col, .app[data-sidebar="collapsed"] .app__col { margin-left: 0; padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  /* Sidebar off-canvas */
  .sidebar, .app[data-sidebar="collapsed"] .sidebar { width: min(304px, 86vw); transform: translateX(-102%); box-shadow: none; z-index: var(--z-drawer); visibility: hidden; transition: transform var(--dur-3) var(--ease), visibility 0s linear var(--dur-3); }
  .app.is-nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); visibility: visible; transition: transform var(--dur-3) var(--ease), visibility 0s; }
  .sidebar__collapse { display: none; }
  .sidebar__close { display: grid; margin-left: auto; width: 44px; height: 44px; place-items: center; color: var(--sb-muted); border-radius: var(--radius); }
  .sidebar__close:hover { background: var(--sb-hover); color: #fff; }
  .nav-item { min-height: 44px; font-size: var(--fs-16); }
  .nav-sub .nav-item { min-height: 44px; font-size: var(--fs-14); }
  .nav-item[aria-current="page"]::before { left: -12px; }
  .scrim { z-index: calc(var(--z-drawer) - 1); }
  /* Topbar compacta */
  .topbar { padding-inline: var(--sp-2) var(--sp-2); gap: var(--sp-1); padding-left: calc(var(--sp-2) + var(--safe-left)); padding-right: calc(var(--sp-2) + var(--safe-right)); }
  .topbar__lead { padding-left: var(--sp-2); }
  .topbar__back { display: grid; margin-left: calc(var(--sp-2) * -1); }
  .crumbs li:not(:last-child) { display: none; }
  .crumbs li + li::before { content: none; }
  .crumbs [aria-current="page"] { font-size: var(--fs-16); font-weight: var(--fw-semibold); }
  .topbar__actions { gap: 0; }
  .topbar__actions .btn { --btn-h: 44px; }
  .search-trigger { width: 44px; height: 44px; padding: 0; justify-content: center; background: none; border: 0; color: var(--text-2); }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger .icon { width: 20px; height: 20px; }
  .topbar__new-label, .topbar__new-chev { display: none; }
  .topbar__new { width: 44px; padding: 0; background: transparent; color: var(--text-2); box-shadow: none; border: 0; }
  .topbar__new:hover { background: var(--hover); }
  .topbar__actions .icon { width: 20px; height: 20px; }
  .bell-badge { top: 6px; right: 6px; }
  /* Tabbar */
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-tabbar);
    height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom); padding-inline: var(--safe-left) var(--safe-right);
    background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--border); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  }
  .tabbar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 44px; color: var(--text-3); font-size: var(--fs-12); font-weight: var(--fw-medium); text-decoration: none !important; }
  .tabbar__item .icon { width: 22px; height: 22px; }
  .tabbar__item[aria-current="page"] { color: var(--brand-text); }
  .tabbar__item[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--brand); }
  .tabbar__badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-full); background: #c93a3a; color: #fff; font-size: 10px; font-weight: var(--fw-semibold); display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px var(--surface); }
  .tabbar__badge--neutral { background: var(--brand); }
  /* Página */
  .page { padding: var(--sp-4) calc(var(--sp-4) + var(--safe-right)) var(--sp-8) calc(var(--sp-4) + var(--safe-left)); }
  .page-header { margin-bottom: var(--sp-4); gap: var(--sp-3); }
  .page-header__main { flex-basis: 100%; }
  .page-title { font-size: var(--fs-20); line-height: 28px; }
  .page-header__actions { width: 100%; }
  .page-header__actions > .btn { flex: 1 1 auto; }
  .page-toolbar__right { margin-left: 0; width: 100%; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .btn { --btn-h: 44px; }
  .btn--sm { --btn-h: 36px; }
  .btn--xs { --btn-h: 32px; }
  .input, .select { height: 44px; font-size: var(--fs-16); }
  .textarea, .tag-input input, .palette__input { font-size: var(--fs-16); }
  .chip { height: 36px; }
  .tab { height: 44px; }
  .menu__item { min-height: 48px; font-size: var(--fs-16); padding-block: 8px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi__value { font-size: var(--fs-20); line-height: 28px; }
  .list-item { min-height: 56px; }
  .table td { height: 48px; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: var(--sp-2); }
  .state-page { min-height: calc(100dvh - var(--topbar-h) - var(--tabbar-h) - 64px); }
  .skeleton-page { padding: var(--sp-4); }
  /* Tablas como tarjetas: <table class="table table--cards"> con td[data-label] */
  .table--cards thead { display: none; }
  .table--cards, .table--cards tbody, .table--cards tr, .table--cards td { display: block; width: 100%; }
  .table--cards tr { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); position: relative; }
  .table--cards td { height: auto; padding: 2px 0 !important; border: 0; display: flex; justify-content: space-between; gap: var(--sp-3); text-align: right; }
  .table--cards td::before { content: attr(data-label); color: var(--text-3); font-size: var(--fs-12); text-align: left; flex: none; }
  .table--cards td[data-label=""]::before, .table--cards td:not([data-label])::before { content: none; }
  .table--cards td.table__primary, .table--cards td[data-primary] { display: block; text-align: left; font-size: var(--fs-14); padding: 0 36px 6px 0 !important; }
  .table--cards .col-check { position: absolute; right: var(--sp-4); top: var(--sp-3); width: auto; }
  .table--cards .col-actions { width: 100%; justify-content: flex-end; }
  /* Modales como bottom sheet */
  .layer { padding: 0; align-items: flex-end; }
  .modal, .modal--sm, .modal--md, .modal--lg, .modal--xl {
    max-width: none; width: 100%; max-height: calc(100dvh - 24px - var(--safe-top)); border-radius: 14px 14px 0 0; animation-name: sheet-in;
  }
  .layer.is-closing .modal { animation-name: sheet-out; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
  .modal__grabber { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .modal__header { padding: var(--sp-3) var(--sp-4) var(--sp-2); }
  .modal__close { width: 44px; height: 44px; margin: -8px -10px 0 0; }
  .modal__body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }
  .modal__footer { padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-bottom)); border-radius: 0; }
  .modal__footer > .btn { flex: 1 1 0; }
  .modal__footer-start { width: 100%; margin: 0; order: 2; justify-content: center; }
  .modal__footer-start > .btn { flex: 1 1 auto; }
  .drawer { width: 100vw; }
  .layer--drawer.layer--sheet { align-items: flex-end; }
  /* Popovers como sheet */
  .popover.popover--sheet {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; max-width: none; border-radius: 14px 14px 0 0;
    padding-bottom: var(--safe-bottom); animation: sheet-in var(--dur-3) var(--ease-out); z-index: var(--z-dropdown); max-height: 80dvh; display: flex; flex-direction: column;
  }
  .popover--sheet .menu { max-height: none; padding: var(--sp-2); }
  .popover-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-dropdown) - 1); animation: fade-in var(--dur-2) var(--ease-out); }
  .notif-panel { width: 100%; max-height: none; }
  .popover--sheet .combo-pop { max-height: 70dvh; }
  /* Toasts sobre la tabbar */
  .toasts { left: var(--sp-3); right: var(--sp-3); width: auto; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-3)); }
  .toasts.toasts--top { left: var(--sp-3); right: var(--sp-3); bottom: auto; transform: none; }
  /* Palette a pantalla completa */
  .palette-layer { padding: 0; align-items: stretch; }
  .palette { max-width: none; max-height: none; height: 100%; border-radius: 0; border: 0; padding-top: var(--safe-top); animation: fade-in var(--dur-2) var(--ease-out); }
  .palette__footer { display: none; }
  .palette__close { display: grid !important; }
  .palette__item { min-height: 52px; }
  /* Login */
  .login { grid-template-columns: minmax(0, 1fr); }
  .login__brand { padding: var(--sp-5) var(--sp-4) var(--sp-6); padding-top: calc(var(--sp-5) + var(--safe-top)); gap: var(--sp-4); }
  .login__logo { width: 132px; height: 36px; }
  .login__claim { margin-top: var(--sp-2); gap: var(--sp-2); }
  .login__title { font-size: var(--fs-20); line-height: 28px; }
  .login__lead { display: none; }
  .login__product { font-size: var(--fs-12); }
  .login__facts { display: none; }
  .login__legal { display: none; }
  .login__panel { padding: var(--sp-2) var(--sp-4) calc(var(--sp-8) + var(--safe-bottom)); }
  .login__form-wrap { margin: 0 auto; padding-top: var(--sp-2); gap: var(--sp-5); }
  .login__heading h2 { font-size: var(--fs-20); line-height: 28px; }
  .shortcuts { grid-template-columns: minmax(0, 1fr); }
  .chart-donut-layout { justify-content: center; }
  /* Segmentados de formulario: en pantallas angostas pasan a dos filas en vez de esconder opciones
     (p. ej. "A definir", "Número erróneo" o "En el cliente" quedaban fuera de vista). */
  .segmented__item > span, .segmented > button { min-height: 40px; }
  .field > .segmented { flex-wrap: wrap; overflow: visible; }
  .field > .segmented > .segmented__item { flex: 1 0 auto; }
  /* Objetivos táctiles de avisos, etiquetas y pestañas del panel de notificaciones */
  .toast__actions { margin: -6px -4px -6px 0; }
  .toast__action { height: 36px; padding: 0 12px; }
  .toast__close { width: 36px; height: 36px; }
  .notif-panel .tab { height: 44px; }
  .tag-input .tag { height: 28px; }
  .tag__remove { width: 24px; height: 24px; margin-right: -6px; }
}
@media (min-width: 768px) {
  .palette__close { display: none !important; }
}
@media (hover: none) {
  .tooltip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .skeleton::after { animation: none; }
}
@media (forced-colors: active) {
  .btn, .chip, .badge, .input, .select, .textarea { border: 1px solid CanvasText; }
  .nav-item[aria-current="page"] { outline: 2px solid Highlight; }
  .tabs { border-bottom: 1px solid CanvasText; }
}
@media print {
  .sidebar, .topbar, .tabbar, .toasts { display: none !important; }
  .app__col { margin: 0 !important; }
}
