/* =====================================================================
   Estudio Contable — Sistema de diseño
   1. Tokens (primitivos → semánticos)   2. Base y accesibilidad
   3. Layout   4. Componentes   5. Módulos   6. Estados de carga
   7. Responsive, movimiento reducido e impresión
   Contraste verificado para WCAG 2.2 AA (texto ≥ 4.5:1, UI ≥ 3:1).
   ===================================================================== */

/* ---------- Tipografía auto-alojada (sin terceros, sin salto de diseño) ---------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fuente de respaldo con métricas ajustadas a Inter: el texto no "salta" al cargar la fuente. */
@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial'), local('Helvetica'), local('Liberation Sans');
  size-adjust: 107.1%;
  ascent-override: 90.4%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}

/* ---------- 1. Tokens ---------- */
:root {
  /* Primitivos */
  --navy-950: #081627;
  --navy-900: #0f2744;
  --navy-800: #16345a;
  --teal-700: #0a6670;
  --teal-600: #0e7c86;
  --teal-500: #14b8a6;
  --teal-50: #e6f4f5;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #5b6b80;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --green-700: #15803d;
  --green-200: #b7e4c7;
  --green-50: #ecfdf3;
  --amber-800: #92400e;
  --amber-700: #a14a06;
  --amber-200: #f6d9a8;
  --amber-50: #fff7e6;
  --red-700: #b91c1c;
  --red-200: #f5c2c2;
  --red-50: #fdecec;
  --blue-700: #1d4ed8;
  --blue-200: #c3d4f7;
  --blue-50: #eef3fe;

  /* Semánticos: color */
  --color-bg: #f4f6fa;
  --color-surface: var(--white);
  --color-surface-sunken: var(--slate-50);
  --color-surface-muted: var(--slate-100);
  --color-border: var(--slate-200);
  --color-border-strong: var(--slate-300);
  --color-text: var(--slate-900);
  --color-text-secondary: var(--slate-700);
  --color-text-muted: var(--slate-500);
  --color-heading: var(--navy-900);
  --color-primary: var(--teal-600);
  --color-primary-hover: var(--teal-700);
  --color-primary-soft: var(--teal-50);
  --color-on-primary: var(--white);
  --color-brand: var(--navy-900);
  --color-brand-hover: var(--navy-800);
  --color-success: var(--green-700);
  --color-success-bg: var(--green-50);
  --color-success-border: var(--green-200);
  --color-warning: var(--amber-700);
  --color-warning-strong: var(--amber-800);
  --color-warning-bg: var(--amber-50);
  --color-warning-border: var(--amber-200);
  --color-danger: var(--red-700);
  --color-danger-bg: var(--red-50);
  --color-danger-border: var(--red-200);
  --color-info: var(--blue-700);
  --color-info-bg: var(--blue-50);
  --color-info-border: var(--blue-200);
  --color-focus: #2563eb;
  --color-sidebar-text: var(--slate-300);
  --color-sidebar-muted: #93a7c2;

  /* Tipografía (escala 1.2) */
  --font-sans: 'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-heavy: 800;
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --tracking-caps: 0.06em;

  /* Espaciado (base 4 px) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Forma, elevación, capas */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 39, 68, .06), 0 4px 16px rgba(15, 39, 68, .05);
  --shadow-md: 0 8px 24px rgba(15, 39, 68, .10);
  --shadow-lg: 0 20px 50px rgba(15, 39, 68, .25);
  --z-sticky: 20;
  --z-sidebar: 50;
  --z-modal: 100;
  --z-toast: 200;

  /* Movimiento */
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 260ms;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);

  /* Componentes */
  --control-height: 2.5rem;
  --control-height-sm: 2rem;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, .45);
  --sidebar-width: 256px;

  /* Alias (usados por estilos en línea de las pantallas) */
  --navy: var(--color-brand);
  --primary: var(--color-primary);
  --primary-50: var(--color-primary-soft);
  --border: var(--color-border);
  --muted: var(--color-text-muted);
  --green: var(--color-success);
  --yellow: var(--color-warning);
  --red: var(--color-danger);
  --blue: var(--color-info);
  --grey-bg: var(--color-surface-muted);
}

/* ---------- 2. Base y accesibilidad ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (min-width: 861px) { html { scrollbar-gutter: stable; } }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--color-primary-hover); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--color-brand); }
h1, h2, h3, h4 { margin: 0; color: var(--color-heading); line-height: var(--leading-tight); letter-spacing: -0.015em; }
h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); }
h2 { font-size: var(--text-lg); font-weight: var(--weight-bold); }
h3 { font-size: var(--text-md); font-weight: var(--weight-semibold); }
small, .muted { color: var(--color-text-muted); }
code { font-size: var(--text-sm); background: var(--color-surface-muted); padding: 1px 6px; border-radius: var(--radius-sm); }
.hidden { display: none !important; }
.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; }

/* Foco visible para navegación con teclado */
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible, .stat:focus-visible, .tab:focus-visible, .att:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.nav a:focus-visible { outline: 2px solid var(--teal-500); outline-offset: -2px; }
.content:focus { outline: none; }

.skip-link {
  position: absolute; left: var(--space-4); top: -60px; z-index: var(--z-toast);
  background: var(--color-brand); color: var(--white); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-weight: var(--weight-semibold); text-decoration: none; transition: top var(--duration-base) var(--ease-out);
}
.skip-link:focus { top: var(--space-3); color: var(--white); }

/* ---------- 3. Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-950) 100%);
  color: var(--color-sidebar-text); padding: var(--space-5) var(--space-3); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--space-1);
}
.brand { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-1) var(--space-2) var(--space-5); }
.brand-logo {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; background: linear-gradient(135deg, var(--teal-500), var(--teal-600));
  display: grid; place-items: center; color: var(--white); font-weight: var(--weight-heavy); font-size: var(--text-md);
}
.brand-name { color: var(--white); font-weight: var(--weight-bold); font-size: var(--text-base); line-height: 1.25; }
.brand-sub { font-size: var(--text-xs); color: var(--color-sidebar-muted); }
.nav-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-sidebar-muted); padding: var(--space-4) var(--space-3) var(--space-2); font-weight: var(--weight-semibold); }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a {
  display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--color-sidebar-text); font-weight: var(--weight-medium); text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: var(--white); }
.nav a[aria-current="page"] { background: rgba(20, 184, 166, .18); color: var(--white); box-shadow: inset 3px 0 0 var(--teal-500); }
.nav a .ico { width: 20px; text-align: center; flex-shrink: 0; }
.nav a .count { margin-left: auto; background: #dc2626; color: var(--white); font-size: var(--text-2xs); font-weight: var(--weight-bold); padding: 1px 7px; border-radius: var(--radius-full); min-width: 22px; text-align: center; }
.nav .sub a { padding-left: 44px; font-size: var(--text-sm); min-height: 36px; }
.sidebar-footer { margin-top: auto; padding: var(--space-3) var(--space-2) 0; font-size: var(--text-xs); color: var(--color-sidebar-muted); line-height: 1.7; }
.sidebar-footer a { color: var(--color-sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-7); display: flex; align-items: center; gap: var(--space-4); position: sticky; top: 0; z-index: var(--z-sticky); min-height: 60px;
}
.topbar .crumbs { font-size: var(--text-sm); color: var(--color-text-muted); }
.topbar .crumbs b { color: var(--color-heading); font-weight: var(--weight-semibold); }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: var(--space-3); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--color-primary-soft); color: var(--color-primary-hover); display: grid; place-items: center; font-weight: var(--weight-bold); font-size: var(--text-sm); text-decoration: none; }
.user-chip .name { font-weight: var(--weight-semibold); font-size: var(--text-sm); line-height: 1.3; }
.user-chip .role { font-size: var(--text-xs); color: var(--color-text-muted); }
.menu-toggle { display: none; }
.content { padding: var(--space-6) var(--space-7) var(--space-12); max-width: 1520px; width: 100%; min-height: calc(100vh - 60px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.page-head p { margin: var(--space-1) 0 0; color: var(--color-text-muted); max-width: 72ch; }

/* ---------- 4. Componentes ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); flex-wrap: wrap; }
.card-head .title { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.card-head .num { width: 28px; height: 28px; border-radius: var(--radius-md); background: var(--color-primary-soft); color: var(--color-primary-hover); display: grid; place-items: center; font-weight: var(--weight-bold); font-size: var(--text-xs); }
.card-body { padding: var(--space-5); }
.card + .card, .stack > * + * { margin-top: var(--space-5); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-height); padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  border-radius: var(--radius-md); font: inherit; font-weight: var(--weight-semibold); font-size: var(--text-sm); line-height: 1.2;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.btn:hover { background: var(--color-surface-muted); color: var(--color-text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); color: var(--color-on-primary); }
.btn-navy { background: var(--color-brand); border-color: var(--color-brand); color: var(--white); }
.btn-navy:hover { background: var(--color-brand-hover); color: var(--white); }
.btn-success { background: var(--color-success); border-color: var(--color-success); color: var(--white); }
.btn-success:hover { background: #116c33; color: var(--white); }
.btn-danger { background: var(--color-surface); border-color: var(--color-danger-border); color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.btn-warning { background: var(--color-surface); border-color: var(--color-warning-border); color: var(--color-warning); }
.btn-warning:hover { background: var(--color-warning-bg); color: var(--color-warning-strong); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { min-height: 3rem; padding: 0 var(--space-6); font-size: var(--text-md); border-radius: 10px; }
.btn-block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; border: 1px solid transparent; line-height: 1.45; }
.pill-green { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.pill-yellow { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.pill-red { background: var(--color-danger-bg); color: var(--color-danger); border-color: var(--color-danger-border); }
.pill-blue { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }
.pill-grey { background: var(--color-surface-muted); color: var(--slate-600); border-color: var(--color-border); }
.pill-navy { background: var(--color-brand); color: var(--white); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-green { background: #22c55e; } .dot-yellow { background: #f59e0b; } .dot-red { background: #ef4444; } .dot-grey { background: var(--slate-400); }

.alert { padding: var(--space-3) var(--space-4); border-radius: 10px; border: 1px solid; display: flex; gap: var(--space-3); align-items: flex-start; line-height: 1.5; }
.alert + .alert { margin-top: var(--space-3); }
.alert-red { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: #7f1d1d; }
.alert-yellow { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: #713f12; }
.alert-green { background: var(--color-success-bg); border-color: var(--color-success-border); color: #14532d; }
.alert-blue { background: var(--color-info-bg); border-color: var(--color-info-border); color: #1e3a8a; }
.alert b { display: block; margin-bottom: 2px; }

/* Indicadores (jerarquía: etiqueta → valor → icono) */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.stats.alta-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  cursor: pointer; text-align: left; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; font: inherit; color: inherit;
  display: block; text-decoration: none; min-height: 104px; width: 100%;
  transition: transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.stat::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--color-primary)); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: inherit; }
.stat[aria-pressed="true"], .stat.active { border-color: var(--accent, var(--color-primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, var(--color-primary)) 22%, transparent); }
.stat .label { font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); padding-right: 32px; }
.stat .value { font-size: var(--text-4xl); font-weight: var(--weight-heavy); color: var(--color-heading); margin-top: var(--space-2); line-height: 1; letter-spacing: -0.02em; }
.stat .icon { position: absolute; right: var(--space-4); top: var(--space-4); font-size: var(--text-xl); }

/* Tablas */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--slate-600); font-weight: var(--weight-bold);
  padding: var(--space-3); background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
.table td { padding: var(--space-3); border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.table tbody tr { transition: background-color var(--duration-fast) var(--ease-out); }
.table tbody tr:hover { background: #f6fafb; }
.table .name { font-weight: var(--weight-semibold); color: var(--color-heading); }
.table .sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.table .num { text-align: right; }
.table.compact td { padding: 10px; font-size: var(--text-sm); }
.table.compact th { padding: 10px; }
.table .nowrap, .table td .pill { white-space: nowrap; }
.empty { padding: var(--space-10) var(--space-6); text-align: center; color: var(--color-text-muted); }

.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.toolbar .search { flex: 1; min-width: 240px; }
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  border: 1px solid var(--color-border-strong); background: var(--color-surface); border-radius: var(--radius-full); min-height: 32px; padding: 0 var(--space-3);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); cursor: pointer; color: var(--color-text-secondary); font-family: inherit;
  display: inline-flex; align-items: center; text-decoration: none; transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}
.chip:hover { border-color: var(--color-brand); color: var(--color-brand); }
.chip.active, .chip[aria-pressed="true"], .chip[aria-current="page"] { background: var(--color-brand); color: var(--white); border-color: var(--color-brand); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); flex-wrap: wrap; }

/* Formularios */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-secondary); margin-bottom: var(--space-1); }
.field .req { color: var(--color-danger); }
input, select, textarea {
  width: 100%; font: inherit; min-height: var(--control-height); padding: var(--space-2) var(--space-3);
  border: 1px solid var(--slate-400); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
input::placeholder, textarea::placeholder { color: #6b7a8f; }
input:hover, select:hover, textarea:hover { border-color: var(--slate-500); }
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); outline: none; }
input:disabled, select:disabled, textarea:disabled { background: var(--color-surface-muted); color: var(--color-text-muted); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--color-primary); padding: 0; }
textarea { min-height: 88px; resize: vertical; }
.hint { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer; font-weight: var(--weight-semibold); min-height: 32px; }
.switch input { appearance: none; width: 42px; height: 24px; min-height: 0; border-radius: 24px; background: var(--slate-500); position: relative; cursor: pointer; transition: background-color var(--duration-base) var(--ease-out); border: 0; padding: 0; flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--white); transition: left var(--duration-base) var(--ease-out); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked { background: var(--color-primary); }
.switch input:checked::after { left: 21px; }
.switch input:disabled { opacity: .5; }

.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.kv.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv .k { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-semibold); }
.kv .v { font-weight: var(--weight-semibold); margin-top: 2px; word-break: break-word; }
.kv .v.missing { color: var(--color-warning); }

.money-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.money { background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: 10px; padding: var(--space-3) var(--space-4); }
.money .k { font-size: var(--text-2xs); color: var(--color-text-muted); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .04em; }
.money .v { font-size: var(--text-md); font-weight: var(--weight-heavy); color: var(--color-heading); margin-top: var(--space-1); white-space: nowrap; }
.money.hl { background: var(--color-primary-soft); border-color: #b9e0e3; }

/* ---------- 5. Módulos ---------- */
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-5); align-items: start; }
.review-aside { position: sticky; top: 76px; display: flex; flex-direction: column; gap: var(--space-4); }
.client-hero { display: flex; gap: var(--space-5); align-items: center; padding: var(--space-5); flex-wrap: wrap; }
.client-hero .big-avatar { width: 60px; height: 60px; border-radius: 14px; background: linear-gradient(135deg, var(--navy-900), var(--teal-600)); color: var(--white); display: grid; place-items: center; font-weight: var(--weight-heavy); font-size: var(--text-xl); flex-shrink: 0; }
.client-hero .meta { display: flex; gap: var(--space-4); flex-wrap: wrap; color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-1); }
.client-hero .actions { margin-left: auto; }

.semaforo { padding: var(--space-5); border-radius: var(--radius-lg); color: var(--white); text-align: center; }
.semaforo.green { background: linear-gradient(135deg, #16a34a, #15803d); }
.semaforo.yellow { background: linear-gradient(135deg, #b45309, #92400e); }
.semaforo.red { background: linear-gradient(135deg, #dc2626, #991b1b); }
.semaforo.grey { background: linear-gradient(135deg, #64748b, #475569); }
.semaforo .lights { display: inline-flex; gap: var(--space-2); background: rgba(0, 0, 0, .25); padding: var(--space-2) var(--space-3); border-radius: 30px; margin-bottom: var(--space-3); }
.semaforo .lights span { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.semaforo .lights span.on-green { background: #4ade80; box-shadow: 0 0 12px #4ade80; }
.semaforo .lights span.on-yellow { background: #fde047; box-shadow: 0 0 12px #fde047; }
.semaforo .lights span.on-red { background: #fca5a5; box-shadow: 0 0 12px #fca5a5; }
.semaforo .label { font-size: var(--text-lg); font-weight: var(--weight-heavy); letter-spacing: .02em; }
.semaforo .sub { font-size: var(--text-sm); margin-top: var(--space-1); }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: var(--space-3); align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed #e8edf3; font-size: var(--text-sm); }
.checklist li:last-child { border-bottom: 0; }
.checklist li .i { width: 20px; flex-shrink: 0; text-align: center; }
.checklist li a { color: inherit; cursor: pointer; text-decoration: none; }
.checklist li a:hover { text-decoration: underline; }
.checklist li.ok { color: var(--color-text-secondary); }
.checklist li.pending, .checklist li.review { color: var(--color-warning); font-weight: var(--weight-semibold); }
.checklist li.error { color: var(--color-danger); font-weight: var(--weight-semibold); }
.blockers { margin: var(--space-2) 0 0; padding: 0; list-style: none; }
.blockers li { padding: var(--space-1) 0; }

.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-1) 0 var(--space-4); }
.step { text-align: center; position: relative; padding-top: var(--space-1); }
.step .circle { width: 36px; height: 36px; margin: 0 auto var(--space-2); border-radius: 50%; display: grid; place-items: center; font-size: var(--text-md); background: var(--color-surface-muted); border: 2px solid var(--slate-400); color: var(--slate-600); position: relative; z-index: 1; }
.step.done .circle { background: var(--color-success-bg); border-color: #4fb477; color: var(--color-success); }
.step.error .circle { background: var(--color-danger-bg); border-color: #e57373; color: var(--color-danger); }
.step.review .circle { background: var(--color-info-bg); border-color: #7fa2ee; color: var(--color-info); }
.step::after { content: ''; position: absolute; top: 22px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; background: var(--color-border-strong); }
.step:last-child::after { display: none; }
.step.done::after { background: #86d3a1; }
.step .t { font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.step .d { font-size: var(--text-2xs); color: var(--color-text-muted); }

.doc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-4); }
.doc-card { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); box-shadow: var(--shadow-sm); }
.doc-card .doc-ico { width: 44px; height: 52px; border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--white), #eef2f7); border: 1px solid var(--color-border); display: grid; place-items: center; font-size: var(--text-xl); flex-shrink: 0; }
.doc-card .top { display: flex; gap: var(--space-3); align-items: center; }

.upload-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid #edf1f5; flex-wrap: wrap; }
.upload-row:last-child { border-bottom: 0; }
.upload-row .info { flex: 1; min-width: 200px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid #f0f3f7; font-size: var(--text-sm); }
.timeline .when { color: var(--color-text-muted); font-size: var(--text-xs); }
.timeline .what b { color: var(--color-heading); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); padding: 0 var(--space-3); overflow-x: auto; }
.tab { padding: var(--space-3) var(--space-4); font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--slate-600); border: 0; background: none; cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit; white-space: nowrap; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.tab:hover { color: var(--color-heading); }
.tab.active, .tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--color-primary-hover); border-color: var(--color-primary); }

.attention-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-3); }
.att { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); border-radius: var(--radius-lg); border: 1px solid var(--color-border); background: var(--color-surface); cursor: pointer; text-decoration: none; color: var(--color-text); min-height: 76px; transition: border-color var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out); }
.att:hover { border-color: var(--color-primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--color-text); }
.att .n { font-size: var(--text-3xl); font-weight: var(--weight-heavy); min-width: 48px; text-align: center; line-height: 1; }
.att .l { font-weight: var(--weight-semibold); font-size: var(--text-sm); line-height: 1.35; }
.att.red .n { color: var(--color-danger); } .att.yellow .n { color: var(--color-warning); } .att.green .n { color: var(--color-success); } .att.blue .n { color: var(--color-info); }
.att.zero { background: var(--color-surface-sunken); }
.att.zero .n { color: var(--slate-500); }
.summary-text { font-size: var(--text-md); line-height: 1.95; margin: 0; padding-left: var(--space-5); }
.summary-text b { color: var(--color-heading); }
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--space-5); margin-top: var(--space-5); }

.fu-group h3 { margin: var(--space-1) 0 var(--space-3); display: flex; gap: var(--space-2); align-items: center; }
.fu-item { display: flex; gap: var(--space-4); align-items: center; padding: var(--space-3) var(--space-4); border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-surface); margin-bottom: var(--space-3); flex-wrap: wrap; }
.fu-item .who { flex: 1; min-width: 220px; }
.fu-item .who .n { font-weight: var(--weight-bold); color: var(--color-heading); }
.fu-item .who .r { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 2px; }

/* Modal y avisos */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: grid; place-items: center; z-index: var(--z-modal); padding: var(--space-5); animation: fade var(--duration-base) var(--ease-out); }
.modal { background: var(--color-surface); border-radius: var(--radius-xl); width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop var(--duration-slow) var(--ease-out); }
.modal.lg { max-width: 820px; }
.modal-head { padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.modal-body { padding: var(--space-5) var(--space-6); overflow-y: auto; }
.modal-foot { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: var(--space-3); background: var(--color-surface-sunken); border-radius: 0 0 var(--radius-xl) var(--radius-xl); flex-wrap: wrap; }
.close-x { border: 0; background: none; font-size: 24px; cursor: pointer; color: var(--slate-600); line-height: 1; width: 36px; height: 36px; border-radius: var(--radius-md); }
.close-x:hover { background: var(--color-surface-muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

.toast-wrap { position: fixed; right: var(--space-5); bottom: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); z-index: var(--z-toast); }
.toast { background: var(--color-brand); color: var(--white); padding: var(--space-3) var(--space-4); border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 420px; animation: pop var(--duration-slow) var(--ease-out); font-weight: var(--weight-medium); }
.toast.ok { background: #14532d; } .toast.err { background: #7f1d1d; } .toast.warn { background: #78350f; }

.confirm-final .row { display: grid; grid-template-columns: 120px minmax(0, 1fr); padding: 6px 0; }
.confirm-final .row .k { color: var(--color-text-muted); }
.confirm-final .row .v { font-weight: var(--weight-bold); }
.success-hero { text-align: center; padding: var(--space-3) 0; }
.success-hero .big { font-size: 56px; }
.success-hero h2 { color: var(--color-success); font-size: var(--text-2xl); margin: var(--space-2) 0; }

/* Ingreso */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, rgba(20, 184, 166, .55) 0, transparent 42%), linear-gradient(135deg, var(--navy-900), var(--navy-950)); color: var(--white); padding: var(--space-12); display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { color: var(--white); font-size: var(--text-4xl); line-height: 1.15; max-width: 480px; }
.login-art p { color: var(--slate-300); max-width: 460px; line-height: 1.65; }
.login-art .features { display: grid; gap: var(--space-3); margin-top: var(--space-8); }
.login-art .features div { display: flex; gap: var(--space-3); align-items: center; color: #e2e8f0; }
.login-art small { color: var(--color-sidebar-muted); }
.login-form { display: grid; place-items: center; padding: var(--space-10); background: var(--color-surface); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }

.section-anchor { scroll-margin-top: 80px; }
.flash { animation: flash 1.4s var(--ease-out); }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 4px rgba(245, 158, 11, .45); } }
.lock-note { display: inline-flex; gap: 6px; align-items: center; font-size: var(--text-xs); color: var(--color-text-muted); }
.divider { height: 1px; background: var(--color-border); margin: var(--space-4) 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.grid-2 > .card, .grid-2 > .card + .card { margin-top: 0; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.disclaimer { font-size: var(--text-xs); color: var(--color-text-muted); border-left: 3px solid var(--color-border-strong); padding: 6px var(--space-3); margin-top: var(--space-4); }
.loading-row td { opacity: .45; transition: opacity var(--duration-fast); }

/* ---------- 6. Esqueletos de carga (misma geometría que el contenido final: sin saltos) ---------- */
.skeleton { position: relative; overflow: hidden; background: #e6ebf1; border-radius: var(--radius-md); }
.skeleton::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  animation: shimmer 1.4s var(--ease-in-out) infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-head { margin-bottom: var(--space-6); min-height: 58px; }
.sk-title { height: 29px; width: 300px; max-width: 70%; margin-bottom: var(--space-2); }
.sk-sub { height: 16px; width: 440px; max-width: 90%; }
.sk-card { min-height: 104px; border-radius: var(--radius-lg); }
.sk-block { height: 420px; border-radius: var(--radius-lg); }
.sk-row { height: 46px; border-radius: 0; margin-top: 1px; }

/* ---------- 7. Responsive, movimiento reducido, alto contraste, impresión ---------- */
@media (max-width: 1180px) {
  .review-grid { grid-template-columns: minmax(0, 1fr); }
  .review-aside { position: static; }
  .money-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .stats.alta-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: calc(-1 * var(--sidebar-width) - 20px); width: var(--sidebar-width); z-index: var(--z-sidebar); transition: left var(--duration-slow) var(--ease-out); }
  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }
  .menu-toggle { display: inline-flex; }
  .content { padding: var(--space-4) var(--space-4) var(--space-10); }
  .topbar { padding: var(--space-2) var(--space-4); }
  .form-grid, .form-grid.cols-3, .kv, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .money-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .step::after { display: none; }
  .login-wrap { grid-template-columns: minmax(0, 1fr); }
  .login-art { display: none; }
  .user-chip .name, .user-chip .role { display: none; }
  .stat .value { font-size: var(--text-3xl); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
}
@media (forced-colors: active) {
  .btn, .chip, .pill, .stat, .card { border: 1px solid CanvasText; }
  .stat::before { background: CanvasText; }
}
@media print {
  .sidebar, .topbar, .no-print, .btn, .skip-link { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

.login-art .art-title { color: var(--white); font-size: var(--text-4xl); line-height: 1.15; max-width: 480px; font-weight: var(--weight-bold); letter-spacing: -0.02em; margin: 0 0 var(--space-4); }
.login-card h1 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
.h-sm { font-size: var(--text-md); font-weight: var(--weight-bold); }
.fu-title { margin: var(--space-1) 0 var(--space-3); display: flex; gap: var(--space-2); align-items: center; }
.login-brand { display: none; padding: 0 0 var(--space-6); }
.login-brand .brand-name { color: var(--color-heading); }
.login-brand .brand-sub { color: var(--color-text-muted); }
@media (max-width: 860px) { .login-brand { display: flex; } .login-form { padding: var(--space-8) var(--space-5); align-items: start; } }

/* ---------- Módulo de atención ---------- */
.pill-orange { background: #fff1e6; color: #9a3412; border-color: #fdc9a2; }
.type-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: var(--weight-semibold); background: color-mix(in srgb, var(--type) 12%, white); color: color-mix(in srgb, var(--type) 80%, black); border: 1px solid color-mix(in srgb, var(--type) 35%, white); white-space: nowrap; }
.type-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--type); }
.progress { display: flex; align-items: center; gap: var(--space-2); min-width: 120px; }
.progress-track { flex: 1; height: 8px; background: var(--color-surface-muted); border-radius: var(--radius-full); overflow: hidden; border: 1px solid var(--color-border); }
.progress-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--duration-slow) var(--ease-out); }
.progress-fill.tone-green { background: var(--color-success); } .progress-fill.tone-blue { background: var(--color-info); }
.progress-fill.tone-teal { background: var(--color-primary); } .progress-fill.tone-yellow { background: #d97706; }
.progress-label { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--color-text-secondary); min-width: 36px; text-align: right; }
.progress.compact { min-width: 90px; }

/* Barra superior: buscador global, crear rápido, notificaciones */
.global-search { position: relative; flex: 1; max-width: 560px; }
.global-search input { padding-left: 36px; background: var(--color-surface-sunken); }
.global-search .gs-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.gs-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: var(--z-modal); max-height: 70vh; overflow-y: auto; padding: var(--space-2); }
.gs-item { display: block; padding: var(--space-3); border-radius: var(--radius-md); text-decoration: none; color: var(--color-text); }
.gs-item:hover, .gs-item[aria-selected="true"] { background: var(--color-primary-soft); color: var(--color-text); }
.gs-item .t { font-weight: var(--weight-bold); color: var(--color-heading); }
.gs-item .m { font-size: var(--text-xs); color: var(--color-text-muted); display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: 2px; }
.gs-empty { padding: var(--space-4); color: var(--color-text-muted); text-align: center; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-2); z-index: var(--z-modal); }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 0; background: none; border-radius: var(--radius-md); font: inherit; font-weight: var(--weight-medium); color: var(--color-text); cursor: pointer; text-decoration: none; min-height: 40px; text-align: left; }
.menu button:hover, .menu a:hover { background: var(--color-surface-muted); }
.bell { position: relative; }
.bell .badge { position: absolute; top: -4px; right: -4px; background: #dc2626; color: #fff; font-size: 10px; font-weight: var(--weight-bold); min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.notif-panel { width: min(420px, 92vw); max-height: 70vh; overflow-y: auto; }
.notif-item { padding: var(--space-3); border-radius: var(--radius-md); display: flex; gap: var(--space-3); text-decoration: none; color: var(--color-text); }
.notif-item:hover { background: var(--color-surface-muted); color: var(--color-text); }
.notif-item.unread { background: var(--color-info-bg); }
.notif-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-dot.red { background: #dc2626; } .notif-dot.yellow { background: #d97706; } .notif-dot.blue { background: #2563eb; } .notif-dot.green { background: #16a34a; }

/* Acciones rápidas grandes */
.quick-actions { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.quick-actions .btn { min-height: 56px; font-size: var(--text-md); border-radius: var(--radius-lg); }
.hero-search { position: relative; margin-bottom: var(--space-5); }
.hero-search input { min-height: 56px; font-size: var(--text-md); padding-left: 48px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.hero-search .gs-ico { left: 18px; font-size: var(--text-lg); }
.result-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-4); align-items: center; padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); margin-bottom: var(--space-3); }
.result-card .meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2) var(--space-4); margin-top: var(--space-2); font-size: var(--text-sm); }
.result-card .meta .k { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-semibold); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.kpi { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); text-decoration: none; color: inherit; display: block; min-height: 88px; position: relative; transition: border-color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out); }
a.kpi:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); color: inherit; }
.kpi .k { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-bold); }
.kpi .v { font-size: var(--text-3xl); font-weight: var(--weight-heavy); color: var(--color-heading); line-height: 1.1; margin-top: var(--space-1); }
.kpi.tone-red .v { color: var(--color-danger); } .kpi.tone-green .v { color: var(--color-success); } .kpi.tone-yellow .v { color: var(--color-warning); } .kpi.tone-blue .v { color: var(--color-info); }
.compare { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.compare .box { padding: var(--space-4); border-radius: var(--radius-lg); background: var(--color-surface-sunken); border: 1px solid var(--color-border); }
.compare .delta { font-weight: var(--weight-bold); font-size: var(--text-sm); }
.delta.up { color: var(--color-success); } .delta.down { color: var(--color-danger); } .delta.flat { color: var(--color-text-muted); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.chart-box { position: relative; height: 260px; }
.chart-data summary { cursor: pointer; font-size: var(--text-xs); color: var(--color-primary-hover); margin-top: var(--space-2); }
.chart-data table { font-size: var(--text-xs); margin-top: var(--space-2); }
.summary-block { font-size: var(--text-md); line-height: 1.7; }
.seg-tabs { display: inline-flex; background: var(--color-surface-muted); border-radius: var(--radius-md); padding: 3px; gap: 2px; }
.seg-tabs button, .seg-tabs a { border: 0; background: none; padding: 6px 14px; border-radius: 6px; font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-secondary); cursor: pointer; text-decoration: none; min-height: 32px; }
.seg-tabs [aria-pressed="true"], .seg-tabs [aria-current="page"] { background: var(--color-surface); color: var(--color-heading); box-shadow: var(--shadow-sm); }

/* Perfil del cliente */
.profile-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-5); align-items: center; padding: var(--space-5); }
.profile-head .facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); margin-top: var(--space-2); font-size: var(--text-sm); color: var(--color-text-secondary); }
.profile-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; }
.tabpanel { padding: var(--space-5); }
.svc-card { border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-4); background: var(--color-surface); }
.svc-card + .svc-card { margin-top: var(--space-3); }
.svc-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); flex-wrap: wrap; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--color-border); }
.tl li { position: relative; padding: 0 0 var(--space-4) var(--space-6); }
.tl li::before { content: ''; position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--color-surface); border: 3px solid var(--color-primary); }
.tl .d { font-size: var(--text-xs); color: var(--color-text-muted); }
.tl .a { font-weight: var(--weight-semibold); color: var(--color-heading); }

/* Agenda */
.cal-toolbar { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.cal-title { font-weight: var(--weight-bold); font-size: var(--text-lg); color: var(--color-heading); min-width: 220px; }
.cal-week { display: grid; grid-template-columns: 64px repeat(7, minmax(0, 1fr)); }
.cal-day-col { border-left: 1px solid var(--color-border); min-width: 0; }
.cal-head { padding: var(--space-2); text-align: center; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--slate-600); border-bottom: 1px solid var(--color-border); background: var(--color-surface-sunken); position: sticky; top: 60px; z-index: 2; }
.cal-head.today { color: var(--color-primary-hover); }
.cal-slot { height: 44px; border-bottom: 1px dashed #edf1f5; position: relative; }
.cal-slot.drop { background: var(--color-primary-soft); }
.cal-slot.off { background: repeating-linear-gradient(135deg, #f8fafc, #f8fafc 6px, #f1f5f9 6px, #f1f5f9 12px); }
.cal-hour { height: 44px; font-size: var(--text-2xs); color: var(--color-text-muted); text-align: right; padding: 2px 6px 0 0; border-bottom: 1px dashed transparent; }
.cal-event { position: absolute; left: 3px; right: 3px; top: 2px; border-radius: 6px; padding: 3px 6px; font-size: var(--text-2xs); line-height: 1.3; cursor: grab; overflow: hidden; border-left: 3px solid; z-index: 1; text-align: left; font-family: inherit; }
.cal-event:focus-visible { box-shadow: var(--focus-ring); }
.cal-event.tone-yellow { background: var(--color-warning-bg); border-color: #d97706; color: #713f12; }
.cal-event.tone-blue { background: var(--color-info-bg); border-color: var(--color-info); color: #1e3a8a; }
.cal-event.tone-green { background: var(--color-success-bg); border-color: var(--color-success); color: #14532d; }
.cal-event.tone-red { background: var(--color-danger-bg); border-color: var(--color-danger); color: #7f1d1d; }
.cal-event.tone-grey { background: var(--color-surface-muted); border-color: var(--slate-400); color: var(--slate-600); text-decoration: line-through; }
.cal-event b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-month .cell { min-height: 112px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); padding: var(--space-1); }
.cal-month .cell.other { background: var(--color-surface-sunken); }
.cal-month .cell .num { font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--slate-600); padding: 2px 4px; }
.cal-month .cell.today .num { background: var(--color-primary); color: #fff; border-radius: var(--radius-full); display: inline-block; min-width: 22px; text-align: center; }
.cal-month .cal-event { position: static; display: block; margin-top: 2px; }
.cal-list .row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid #edf1f5; align-items: center; }

@media (max-width: 1180px) {
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .global-search { max-width: none; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .result-card { grid-template-columns: minmax(0, 1fr); }
  .result-card .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-head { grid-template-columns: minmax(0, 1fr); }
  .profile-actions { justify-content: flex-start; }
  .cal-week { grid-template-columns: 48px repeat(7, minmax(90px, 1fr)); overflow-x: auto; }
}

/* ---------- Pantallas del módulo de atención (complementos) ---------- */
.brand-img { width: 36px; height: 36px; border-radius: var(--radius-md); object-fit: contain; background: var(--white); }
.input-affix { position: relative; display: flex; }
.input-affix input { flex: 1; padding-right: 88px; }
.affix-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: var(--color-surface-muted); color: var(--color-text-secondary); font: inherit; font-size: var(--text-xs); font-weight: var(--weight-semibold); border-radius: var(--radius-sm); padding: 6px 10px; cursor: pointer; min-height: 32px; }
.affix-btn:hover { background: var(--color-border); }
.login-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); font-size: var(--text-sm); }
.check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--text-sm); color: var(--color-text-secondary); min-height: 32px; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--color-primary); flex-shrink: 0; }
.label-like { display: block; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-secondary); margin-bottom: var(--space-1); }
.picked { padding: var(--space-2) var(--space-3); background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.picker { position: relative; }
.picker .gs-results { z-index: 5; }
.next-box { border: 1px dashed var(--color-primary); border-radius: var(--radius-lg); padding: var(--space-4); background: var(--color-primary-soft); }
.next-box legend { font-weight: var(--weight-bold); color: var(--color-primary-hover); padding: 0 var(--space-2); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset legend { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-text-secondary); margin-bottom: var(--space-2); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field.inline { display: flex; align-items: center; gap: var(--space-2); }
.field.inline label { margin: 0; white-space: nowrap; }

/* Búsqueda global */
.global-search input { width: 100%; }
.gs-main { min-width: 0; }
.gs-name { font-weight: var(--weight-bold); color: var(--color-heading); display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.gs-sub { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.gs-sub .pill { font-size: var(--text-2xs); padding: 0 8px; }
.gs-all { display: block; text-align: center; padding: var(--space-3); font-weight: var(--weight-semibold); font-size: var(--text-sm); border-top: 1px solid var(--color-border); margin-top: var(--space-1); }
button.gs-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
button.gs-item:focus-visible { background: var(--color-primary-soft); }
.result-card .gs-actions { justify-content: flex-end; }
.hero-search .gs-ico { position: absolute; top: 28px; transform: translateY(-50%); pointer-events: none; }
#hero-results { margin-top: var(--space-3); }

/* Notificaciones */
.notif-panel { right: 0; left: auto; padding: var(--space-3); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 0 var(--space-2) var(--space-2); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-2); }
.notif-group h3 { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); margin: var(--space-3) var(--space-2) var(--space-1); }
.notif-empty { padding: var(--space-6) var(--space-3); text-align: center; color: var(--color-text-muted); }
.notif-more { display: block; padding: var(--space-2) var(--space-3); font-size: var(--text-sm); }
.notif-dot.tone-red { background: #dc2626; } .notif-dot.tone-yellow { background: #d97706; } .notif-dot.tone-blue { background: #2563eb; }
.notif-dot.tone-green { background: #16a34a; } .notif-dot.tone-grey { background: var(--slate-400); }
.notif-page .notif-item { border-bottom: 1px solid #f0f3f7; border-radius: 0; }

/* Dashboard */
.quick-actions .btn { justify-content: center; }
.compare .k-label { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-bold); }
.compare .big { font-size: var(--text-2xl); font-weight: var(--weight-heavy); color: var(--color-heading); margin: var(--space-1) 0; }
.section-title { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-4); }
.chart-card { margin: 0 !important; }
.chart-card .card-body { padding-top: var(--space-3); }
.chart-empty { height: 100%; display: grid; place-items: center; color: var(--color-text-muted); font-size: var(--text-sm); text-align: center; background: var(--color-surface-sunken); border-radius: var(--radius-md); }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.mini-stats > div { background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3); }
.mini-stats b { display: block; font-size: var(--text-xl); color: var(--color-heading); }
.mini-stats span { font-size: var(--text-xs); color: var(--color-text-muted); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid #f0f3f7; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .name { font-weight: var(--weight-semibold); color: var(--color-heading); text-decoration: none; }
.list-plain .name:hover { text-decoration: underline; }
.list-plain .when { font-size: var(--text-xs); color: var(--color-text-secondary); font-weight: var(--weight-semibold); white-space: nowrap; text-align: right; }
.sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.card-body.flush { padding-top: var(--space-2); }
.count-badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--color-surface-muted); color: var(--color-text-secondary); font-size: var(--text-2xs); font-weight: var(--weight-bold); text-align: center; line-height: 18px; vertical-align: middle; }
.chip-n { opacity: .75; font-weight: var(--weight-bold); margin-left: 2px; }
.chip-sep { width: 1px; background: var(--color-border); margin: 0 var(--space-1); align-self: stretch; }
.text-danger { color: var(--color-danger) !important; font-weight: var(--weight-semibold); }
.btn-wa { background: #e7f8ee; border-color: #a7e3bf; color: #11663a; }
.btn-wa:hover { background: #d3f2e0; color: #0b4d2b; }
a.wa { font-size: var(--text-2xs); font-weight: var(--weight-bold); color: #11663a; background: #e7f8ee; border-radius: var(--radius-sm); padding: 1px 5px; text-decoration: none; }
.btn-group.nowrap { flex-wrap: nowrap; }
.adv-filters { padding: var(--space-4) var(--space-5); background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border); }
.table-foot { padding: var(--space-3) var(--space-5); font-size: var(--text-sm); color: var(--color-text-muted); }
.pre { white-space: pre-wrap; margin: var(--space-1) 0 0; }

/* Perfil */
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-xl); }
.profile-name { font-size: var(--text-2xl); margin: 0 0 var(--space-2); }
.chips-inline { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.section-head .h-sm { margin: 0; }
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-5); margin: var(--space-3) 0 0; }
.dl dt { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-bold); }
.dl dd { margin: 2px 0 0; font-size: var(--text-sm); color: var(--color-text); overflow-wrap: anywhere; }
.svc-meta { display: grid; grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-3); font-size: var(--text-sm); align-items: center; }
.svc-meta .k { display: block; font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); font-weight: var(--weight-bold); }
.svc-hist { margin-top: var(--space-3); }
.svc-hist summary { cursor: pointer; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-primary-hover); }
.svc-hist .tl { margin-top: var(--space-3); }
.pill-x { border: 0; background: none; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; color: inherit; }
.note { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3); background: #fffdf5; }
.note + .note { margin-top: var(--space-3); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) 0; border-bottom: 1px solid #f0f3f7; }
.task-list li > label { flex: 1; cursor: pointer; }
.task-list input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin-top: 2px; accent-color: var(--color-success); flex-shrink: 0; }
.task-list li.done b { text-decoration: line-through; color: var(--color-text-muted); }
.task-list.big li { padding: var(--space-3) var(--space-5); }
.role-list { margin: 0; padding-left: var(--space-5); line-height: 1.9; }
.logo-row { display: flex; align-items: center; gap: var(--space-5); }
.logo-preview { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--white); }
.empty-logo { display: grid; place-items: center; color: var(--color-text-muted); font-size: var(--text-xs); }
.audit-detail { max-width: 520px; overflow-wrap: anywhere; }
.legal-note { margin-bottom: 0; }
.ok-note { color: var(--color-success); }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--color-bg) 30%); padding: var(--space-4) 0; z-index: 3; }

/* Agenda */
.cal-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: var(--space-2) var(--space-5); font-size: var(--text-xs); color: var(--color-text-secondary); border-bottom: 1px solid var(--color-border); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border-left: 3px solid; }
.cal-dot.tone-yellow { background: var(--color-warning-bg); border-color: #d97706; } .cal-dot.tone-blue { background: var(--color-info-bg); border-color: var(--color-info); }
.cal-dot.tone-green { background: var(--color-success-bg); border-color: var(--color-success); } .cal-dot.tone-red { background: var(--color-danger-bg); border-color: var(--color-danger); }
.cal-dot.tone-grey { background: var(--color-surface-muted); border-color: var(--slate-400); }
.cal-wrap { overflow-x: auto; min-height: 420px; }
.cal-toolbar .spacer { flex: 1; }
.cal-hours { min-width: 0; }
.cal-event.dragging { opacity: .5; }
.cal-event[draggable="true"] { cursor: grab; }
.cal-month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border); }
.cal-month-head div { padding: var(--space-2); text-align: center; font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--slate-600); }
.cal-month .cell.drop { background: var(--color-primary-soft); }
.cal-month .num { border: 0; background: none; cursor: pointer; font: inherit; font-size: var(--text-xs); font-weight: var(--weight-bold); }
.more-link { border: 0; background: none; color: var(--color-primary-hover); font: inherit; font-size: var(--text-2xs); font-weight: var(--weight-semibold); cursor: pointer; padding: 2px 4px; }
.cal-list-day { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-caps); color: var(--color-text-muted); margin: 0; padding: var(--space-3) var(--space-5); background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border); }
.cal-list .t { font-weight: var(--weight-bold); color: var(--color-heading); }
.cal-event b { font-weight: var(--weight-bold); }

/* Impresión de la ficha del cliente */
.print-ficha { display: none; }
@media print {
  body.printing-ficha #app .shell > * { display: none !important; }
  body.printing-ficha .print-ficha { display: block !important; }
  body.printing-ficha #app .shell, body.printing-ficha #app .main, body.printing-ficha #view { display: block !important; }
  body.printing-ficha #view > *:not(.print-ficha) { display: none !important; }
  body.printing-ficha .main { display: block !important; }
  .print-ficha h1 { font-size: 18pt; margin: 8pt 0 2pt; }
  .print-ficha h2 { font-size: 14pt; margin: 0 0 8pt; }
  .print-ficha h3 { font-size: 11pt; margin: 12pt 0 4pt; }
  .pf-head { display: flex; justify-content: space-between; border-bottom: 1px solid #999; padding-bottom: 6pt; font-size: 9pt; }
  .pf-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  .pf-table th, .pf-table td { border: 1px solid #bbb; padding: 3pt 5pt; text-align: left; vertical-align: top; }
  .pf-table th[scope=row] { width: 28%; background: #f2f2f2; }
}

@media (max-width: 1180px) {
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .svc-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .svc-meta > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .topbar .crumbs { display: none; }
  .user-chip .who { display: none; }
  .dl, .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .field.inline { flex-direction: column; align-items: stretch; }
}
.cal-wrap .cal-head { position: static; height: 36px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.cal-slot .more-link { position: absolute; z-index: 2; background: var(--color-surface); border-radius: var(--radius-sm); }
.cal-month .cell { min-width: 0; overflow: hidden; }
.cal-month .cal-event { width: 100%; box-sizing: border-box; }
.cal-month .cal-event b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-month .cal-event { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a.wa { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; min-width: 28px; }
.cal-event { min-height: 24px; min-width: 24px; }
.more-link { min-height: 24px; min-width: 24px; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: 60px; row-gap: var(--space-2); padding-top: var(--space-2); padding-bottom: var(--space-2); }
  .topbar .global-search { order: 10; flex: 1 0 100%; max-width: none; }
  .topbar .user-chip { margin-left: auto; }
  #logout { padding-inline: var(--space-2); }
  .quick-actions .btn { min-height: 48px; }
}

/* ---------- Aplicación instalable y uso en el celular ---------- */
[hidden] { display: none !important; }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: calc(var(--z-modal) + 1); background: #7c2d12; color: #fff; text-align: center; font-size: var(--text-sm); font-weight: var(--weight-semibold); padding: 8px 16px calc(8px); padding-top: calc(8px + env(safe-area-inset-top)); }
.install-btn { margin-top: var(--space-3); width: 100%; justify-content: center; background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .25); }
.install-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.install-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-4); }
.install-grid > div { background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.install-grid p { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--color-text-secondary); }
.install-steps { padding-left: var(--space-5); line-height: 1.9; margin: 0; }
.bottom-nav { display: none; }

/* Ventana de la app instalada en la laptop: la barra superior respeta los controles de la ventana */
@media (display-mode: window-controls-overlay) {
  .topbar { padding-left: max(var(--space-4), env(titlebar-area-x, 0px)); -webkit-app-region: drag; app-region: drag; }
  .topbar * { -webkit-app-region: no-drag; app-region: no-drag; }
}

@media (max-width: 860px) {
  /* Barra inferior con los accesos principales (al alcance del pulgar) */
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-sidebar);
    background: var(--color-surface); border-top: 1px solid var(--color-border); box-shadow: 0 -4px 16px rgba(15, 23, 42, .06); padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; border: 0; background: none;
    font: inherit; font-size: var(--text-2xs); font-weight: var(--weight-semibold); color: var(--slate-600); text-decoration: none; cursor: pointer; }
  .bottom-nav [aria-current="page"] { color: var(--color-primary-hover); }
  .bottom-nav [aria-current="page"] .bn-ico { background: var(--color-primary-soft); }
  .bn-ico { position: relative; font-size: 20px; line-height: 1; padding: 4px 14px; border-radius: var(--radius-full); }
  .bn-badge { position: absolute; top: -4px; right: 2px; background: #dc2626; color: #fff; font-size: 10px; font-weight: var(--weight-bold); min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
  .content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .sticky-actions { bottom: calc(58px + env(safe-area-inset-bottom)); }
  .toast-wrap { bottom: calc(70px + env(safe-area-inset-bottom)); }
  .install-grid { grid-template-columns: minmax(0, 1fr); }

  /* Evita el zoom automático de iPhone al escribir */
  input, select, textarea { font-size: 16px !important; }

  /* Ventanas emergentes como hoja a pantalla completa */
  .modal-backdrop { padding: 0; place-items: end stretch; }
  .modal, .modal.lg { max-width: none; width: 100%; max-height: 94vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal-body { padding: var(--space-4); }
  .modal-foot { padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal-foot .btn { flex: 1 1 auto; justify-content: center; min-height: 44px; }

  /* Tablas como tarjetas apiladas */
  .table-wrap { overflow: visible; }
  table.cardify, table.cardify tbody, table.cardify tr, table.cardify td { display: block; width: 100%; }
  table.cardify thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.cardify caption { display: none; }
  table.cardify tbody { padding: var(--space-3); }
  table.cardify tr { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); box-shadow: var(--shadow-sm); }
  table.cardify tr, table.cardify tr:nth-child(odd), table.cardify tr:nth-child(even), table.cardify tr:hover { background: var(--color-surface) !important; }
  table.cardify td { border: 0 !important; padding: 6px 0 !important; display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); text-align: right; min-height: 0; }
  table.cardify td > * { max-width: 100%; }
  table.cardify td::before { content: attr(data-label); flex: 0 0 38%; text-align: left; font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); padding-top: 3px; }
  table.cardify td[data-label=""]::before { display: none; }
  table.cardify td[data-label=""] { justify-content: flex-start; text-align: left; }
  table.cardify td:first-child { display: block; text-align: left; font-size: var(--text-md); padding-bottom: var(--space-2) !important; border-bottom: 1px solid var(--color-border) !important; margin-bottom: var(--space-1); }
  table.cardify td:first-child::before { display: block; margin-bottom: 2px; }
  table.cardify td.empty, table.cardify td[colspan] { display: block; text-align: center; }
  table.cardify td[colspan]::before { display: none; }
  table.cardify .btn-group { justify-content: flex-end; flex-wrap: wrap; }
  table.cardify td[data-label=""] .btn-group { justify-content: flex-start; }
  table.cardify .progress { min-width: 140px; }
  table.cardify.compact td { font-size: var(--text-sm); }
}
