/* ============================================================
   Valtus Conta · sistema de diseño
   ------------------------------------------------------------
   1. Fuente y tokens          8. Tablas (y tarjetas en móvil)
   2. Base                     9. Chips de estado
   3. Botones                 10. Modal, toasts, skeletons
   4. Formularios             11. Componentes de pantalla
   5. Estructura de la app    12. Chat flotante
   6. Login                   13. Responsive
   7. Tarjetas y KPIs         14. Impresión y movimiento reducido
   Marca y paleta: frontend/brand/README.md
   ============================================================ */

/* ---------------------------------------------------------------- 1. FUENTE Y TOKENS */
@font-face {
  font-family: 'Inter';
  src: url('fonts/InterVariable-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Marca */
  --brand-navy: #0E1E3D;
  --brand-navy-2: #15294F;
  --brand-blue: #2457E6;
  --brand-teal: #10B39A;
  --brand-teal-ink: #0B7F6E;

  /* Primario (acciones) */
  --primary: #2457E6;
  --primary-600: #1C46C2;
  --primary-700: #173A9E;
  --primary-50: #EEF3FE;
  --primary-100: #DCE6FD;
  --ring: 0 0 0 3px rgba(36, 87, 230, .22);

  /* Neutros (pizarra azulada) */
  --bg: #F4F6FA;
  --bg-2: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E3E8F0;
  --border-strong: #CBD3E1;
  --text: #0E1E3D;
  --text-2: #3F4D66;
  --muted: #5B6B82;        /* 5.4:1 sobre blanco: legible también como texto */
  --faint: #8A97AB;        /* solo decoración, nunca texto con información */

  /* Semánticos (texto legible sobre blanco ≥ 4.5:1) */
  --ok: #15803D;   --ok-bg: #E8F6EE;   --ok-fg: #0F5F2E;   --ok-border: #BFE5CE;
  --warn: #B45309; --warn-bg: #FEF4E2; --warn-fg: #8A3F06; --warn-border: #F8D9A8;
  --danger: #DC2626; --danger-bg: #FDECEC; --danger-fg: #991B1B; --danger-border: #F7C6C6;
  --info-bg: #EAF0FE; --info-fg: #1C46C2;

  /* Tipografía */
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 28px;
  --fs-input: 14px;

  /* Espaciado (4/8) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;
  --page-x: 32px;
  --page-max: 1480px;

  /* Radios */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(14, 30, 61, .05);
  --shadow-sm: 0 1px 2px rgba(14, 30, 61, .04), 0 1px 3px rgba(14, 30, 61, .06);
  --shadow: 0 4px 12px -2px rgba(14, 30, 61, .08), 0 2px 4px rgba(14, 30, 61, .04);
  --shadow-md: 0 10px 24px -6px rgba(14, 30, 61, .14), 0 2px 6px rgba(14, 30, 61, .05);
  --shadow-lg: 0 24px 56px -12px rgba(14, 30, 61, .28), 0 4px 12px rgba(14, 30, 61, .06);

  /* Capas */
  --z-sticky: 40;
  --z-topbar: 50;
  --z-sidebar: 80;
  --z-float: 90;
  --z-dock: 95;
  --z-modal: 100;
  --z-toast: 200;

  /* Estructura */
  --sidebar-w: 256px;
  --mobilebar-h: 56px;
  --dur: .16s;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Barra lateral */
  --side-bg: #0E1E3D;
  --side-bg-2: #0A1630;
  --side-text: #B9C4D8;
  --side-muted: #7F8DA8;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(59, 111, 245, .22);
  --side-line: rgba(255, 255, 255, .08);

  color-scheme: light;
}

/* ---------------------------------------------------------------- 2. BASE */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
  text-rendering: optimizeLegibility;
}
body.sin-scroll { overflow: hidden; }
img, svg { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.015em; color: var(--text); }
h3 { font-size: var(--fs-lg); font-weight: 650; }
h4 { font-size: var(--fs-md); font-weight: 650; }
p { line-height: 1.55; }
a { color: var(--primary); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
b, strong { font-weight: 650; }
code { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
details > summary { cursor: pointer; }
::selection { background: var(--primary-100); }

.hidden { display: none !important; }
.num, .importe { font-variant-numeric: tabular-nums; }

/* Scrollbar fina */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #A7B2C5; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* Foco accesible */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed; left: 12px; top: 12px; width: auto; height: auto; clip: auto; z-index: var(--z-toast); background: var(--surface); padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }

/* Iconos SVG propios (trazo uniforme, heredan color) */
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------- 3. BOTONES */
button {
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.25;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px;
  padding: 8px 16px;
  margin-top: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(14, 30, 61, .12), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur) var(--ease), transform .06s;
  -webkit-tap-highlight-color: transparent;
}
button:hover { background: var(--primary-600); border-color: var(--primary-600); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
button .ico { width: 16px; height: 16px; vertical-align: 0; margin: 0; }

button.secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover { background: var(--surface-2); border-color: #B5C0D2; color: var(--text); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #B91C1C; border-color: #B91C1C; }
button.small.danger {
  background: var(--surface); color: var(--danger-fg); border-color: var(--danger-border); box-shadow: var(--shadow-xs);
}
button.small.danger:hover { background: var(--danger-bg); border-color: #EFA3A3; }
button.small { min-height: 30px; padding: 4px 10px; font-size: var(--fs-sm); margin-top: 0; border-radius: var(--radius-xs); gap: 4px; }
button.small .ico { width: 15px; height: 15px; }
button.btn-block, .btn-block { width: 100%; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none; }
button.ghost:hover { background: var(--bg-2); color: var(--text); }

.error { color: var(--danger-fg); margin-top: 12px; font-size: var(--fs-sm); }
.error:empty { display: none; }
p.error { background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: var(--radius-sm); padding: 10px 14px; }
.success { color: var(--ok); margin-top: 12px; font-size: var(--fs-sm); }

/* ---------------------------------------------------------------- 4. FORMULARIOS */
label {
  display: block;
  font-weight: 600;
  margin: 14px 0 6px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: var(--fs-input);
  font-family: inherit;
  line-height: 1.4;
  background-color: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 80px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #B5C0D2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background-color: var(--bg-2); color: var(--muted); }
input[type="number"], input.r { font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; min-height: 0; padding: 0; box-shadow: none; accent-color: var(--primary); vertical-align: -3px; cursor: pointer;
}
input[type="color"] { padding: 3px; height: 38px; cursor: pointer; }
input[type="file"] { padding: 6px; }
input[type="date"] { min-width: 0; }
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B6B82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}
select::-ms-expand { display: none; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.form-row > label:has(input[type="checkbox"]), label:has(> input[type="checkbox"]) { font-weight: 500; color: var(--text); }

/* Combobox con buscador */
.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto;
  list-style: none; padding: 4px; margin: 0; display: none;
}
.combo.open .combo-list { display: block; }
.combo-list li {
  padding: 8px 10px; border-radius: var(--radius-xs); cursor: pointer; font-size: var(--fs-base);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.combo-list li:hover, .combo-list li[aria-selected="true"] { background: var(--primary-50); }
.combo-sub { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.combo-empty { color: var(--muted); cursor: default; }
.combo-empty:hover { background: none; }

/* Rango de fechas */
.rango { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rango input[type="date"] { width: auto; min-width: 150px; }
.rango .rango-preset { width: auto; min-width: 150px; }
.rango .rango-sep { color: var(--muted); }

/* Secciones de formularios largos */
#form-empresa h3 { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); font-size: var(--fs-md); }
#form-empresa h3:first-of-type { margin-top: 8px; padding-top: 0; border-top: none; }
.form-secciones h4 {
  margin: 24px 0 10px; padding-top: 16px; border-top: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.form-secciones h4:first-of-type { margin-top: 4px; padding-top: 0; border-top: none; }
.hint { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: 10px; }
.hint code { background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-size: var(--fs-xs); }
.radio-list { display: grid; gap: 8px; }
.radio-list label { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); font-weight: 500; color: var(--text); cursor: pointer; padding: 10px 12px; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.radio-list label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.radio-list input { margin-top: 1px; width: 18px; }
.switch-row input[type="checkbox"] { width: 18px; }
.num-ej { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; min-height: 16px; }
.num-ej.mal { color: var(--danger); }

/* ---------------------------------------------------------------- 5. ESTRUCTURA */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* Barra lateral */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: var(--z-sidebar);
}
.sidebar .logo {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 20px 20px 18px 22px;
  border-bottom: 1px solid var(--side-line);
}
.sidebar .logo img { display: block; height: 31px; width: auto; }
.sidebar-close { display: none; }
.sidebar nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 20px;
  gap: 1px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar nav { scrollbar-color: rgba(255, 255, 255, .16) transparent; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .16); background-clip: padding-box; }
.sidebar nav a {
  position: relative;
  color: var(--side-text);
  text-decoration: none;
  min-height: 36px;
  padding: 7px 12px;
  font-size: var(--fs-base);
  font-weight: 500;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar nav a .ico { width: 18px; height: 18px; opacity: .8; vertical-align: 0; }
.sidebar nav a:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.sidebar nav a:hover .ico { opacity: 1; }
.sidebar nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.sidebar nav a.active .ico { opacity: 1; color: #7FE3D2; }
.sidebar nav a.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand-teal);
}
.sidebar nav a:focus-visible { outline: 2px solid #8FB0FF; outline-offset: -2px; }
.sidebar .nav-section { display: flex; flex-direction: column; margin-top: 6px; }
.sidebar nav .nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--side-muted);
  min-height: 32px;
  padding: 8px 12px;
  margin: 0;
  font-weight: 700;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  width: 100%;
  justify-content: space-between;
  box-shadow: none;
}
.sidebar nav .nav-group:hover { background: var(--side-hover); color: #E2E8F3; }
.sidebar nav .nav-group:focus-visible { box-shadow: 0 0 0 2px #8FB0FF; }
.sidebar nav .nav-group::after {
  content: ''; width: 7px; height: 7px; margin-right: 3px;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease); opacity: .8;
}
.sidebar .nav-section.open .nav-group { color: #C8D2E4; }
.sidebar .nav-section.open .nav-group::after { transform: rotate(45deg) translate(-2px, -2px); }
.sidebar .nav-items { display: none; flex-direction: column; gap: 1px; padding: 2px 0 4px; }
.sidebar .nav-section.open .nav-items { display: flex; }
.sidebar nav a .nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; line-height: 20px;
  text-align: center; border-radius: 10px; padding: 0 6px; font-variant-numeric: tabular-nums;
}

/* Selector de empresa (vive en la barra oscura) */
.empresa-switch { padding: 12px 16px; border-top: 1px solid var(--side-line); }
.empresa-switch label {
  display: block; margin: 0 0 6px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted);
}
.empresa-switch select {
  width: 100%; font-size: var(--fs-sm); min-height: 36px; padding: 7px 30px 7px 10px;
  background-color: rgba(255, 255, 255, .06); color: #E6ECF6;
  border-color: rgba(255, 255, 255, .14); box-shadow: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23B9C4D8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.empresa-switch select option { background: var(--brand-navy); color: #E6ECF6; }

.user-info { padding: 14px 16px 10px; border-top: 1px solid var(--side-line); font-size: var(--fs-sm); color: var(--side-text); }
.user-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-ava {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .08); color: #D5DEEE;
}
.user-ava .ico { width: 17px; height: 17px; vertical-align: 0; }
#user-name { color: #F1F5FB; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.user-info button {
  background: transparent; border: 1px solid rgba(255, 255, 255, .14); color: var(--side-text);
  min-height: 34px; padding: 6px 10px; font-size: var(--fs-sm); margin: 0; width: 100%; box-shadow: none; font-weight: 500;
}
.user-info button .ico { width: 15px; height: 15px; }
.user-info button:hover { background: var(--side-hover); color: #fff; border-color: rgba(255, 255, 255, .24); }
.version-tag { font-size: 11px; color: #5F6E8C; padding: 4px 16px 12px; font-variant-numeric: tabular-nums; }

/* Barra superior móvil y overlay (ocultas en escritorio) */
.mobilebar, .sidebar-overlay { display: none; }

/* Zona principal */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  background: rgba(244, 246, 250, .86);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  min-height: 68px;
  padding: 14px max(var(--page-x), calc((100% - var(--page-max)) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.topbar h2 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; min-width: 0; }
#view-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#view-actions:empty { display: none; }
#view-actions button, #view-actions select, #view-actions input { margin: 0; }
#view-actions select, #view-actions input { width: auto; }
#view-container {
  width: 100%;
  max-width: calc(var(--page-max) + 2 * var(--page-x));
  margin: 0 auto;
  padding: 24px var(--page-x) 96px;
  outline: none;
}
#view-container > * { animation: view-in .22s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Barra «gestionando empresa» */
.gestoria-bar {
  position: sticky; top: 0; z-index: calc(var(--z-topbar) + 1);
  background: var(--brand-navy-2); color: #E2E8F3;
  padding: 8px max(var(--page-x), calc((100% - var(--page-max)) / 2)); font-size: var(--fs-sm);
  display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap;
}
.gestoria-bar b { color: #fff; }
.gestoria-bar .ico { color: #7FE3D2; }
.gestoria-bar button { margin: 0; }
.gestoria-bar:not(.hidden) + .topbar { top: 46px; }

/* ---------------------------------------------------------------- 6. LOGIN */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(380px, 5fr) 7fr;
  background: var(--surface);
}
.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  padding: 48px 56px;
  color: #D5DEEE;
  background:
    radial-gradient(900px 500px at 110% 110%, rgba(16, 179, 154, .28), transparent 60%),
    radial-gradient(700px 520px at -10% -20%, rgba(36, 87, 230, .55), transparent 60%),
    linear-gradient(160deg, #11244A 0%, var(--brand-navy) 55%, #0A1630 100%);
}
.login-brand::after {
  /* anillo decorativo: eco del símbolo */
  content: ''; position: absolute; right: -140px; bottom: -140px; width: 460px; height: 460px;
  border-radius: 50%; border: 56px solid rgba(255, 255, 255, .035); pointer-events: none;
}
.login-brand-logo { height: 40px; width: auto; align-self: flex-start; }
.login-claim { max-width: 460px; position: relative; z-index: 1; }
.login-claim h2 { color: #fff; font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.025em; }
.login-claim p { margin-top: 16px; font-size: 16px; color: #B9C6DC; }
.login-features { list-style: none; margin-top: 28px; display: grid; gap: 12px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: var(--fs-md); color: #E2E8F3; }
.login-features .ico {
  width: 34px; height: 34px; padding: 8px; border-radius: 10px; vertical-align: 0;
  background: rgba(255, 255, 255, .08); color: #7FE3D2;
}
.login-foot { font-size: var(--fs-sm); color: #8193B3; position: relative; z-index: 1; }
.login-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 40px 24px; background: var(--bg); }
.login-card {
  background: var(--surface);
  padding: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
}
.login-logo { display: none; height: 36px; width: auto; margin-bottom: 28px; }
.login-card h1 { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.025em; }
.login-card .subtitle { color: var(--muted); margin: 6px 0 22px; }
.login-card label:first-of-type { margin-top: 0; }
.login-card input { min-height: 44px; }
.login-card button[type="submit"], .login-card #btn-passkey { min-height: 44px; margin-top: 20px; }
.login-alt { text-align: center; margin: 12px 0 0; font-size: var(--fs-sm); }
.login-legal { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- 7. TARJETAS Y KPIs */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  min-width: 0;
}
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-md); font-weight: 650; margin: 4px 0 14px; letter-spacing: -.01em; color: var(--text);
}
.section-title .ico, h3 .ico { color: var(--primary); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  position: relative;
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat-card[onclick], .stat-card[role="link"] { cursor: pointer; }
.stat-card[onclick]:hover, .stat-card[role="link"]:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.stat-card .label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin: 0; }
.stat-card .value {
  font-size: var(--fs-3xl); font-weight: 700; margin-top: 8px; letter-spacing: -.025em; line-height: 1.15;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat-card h3 { font-size: var(--fs-md); margin-bottom: 4px; }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { padding: 18px 20px; }
.chart-box { position: relative; height: 260px; }

/* ---------------------------------------------------------------- 8. TABLAS */
.table-container {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  white-space: nowrap;
}
td { color: var(--text); }
tbody tr { transition: background .1s; }
tbody tr:hover > td { background: #F7F9FD; }
tbody tr:last-child > td { border-bottom: none; }
td button.small, td .badge { vertical-align: middle; }
td > button.small + button.small { margin-left: 4px; }
tfoot td, tr.total td, tr.tot td { font-weight: 650; background: var(--surface-2); }

/* Listados (tablaListado): cabecera fija dentro de su caja en escritorio */
.table-container.listado { max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px); overflow: auto; }
.table-container.listado thead th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--border); border-bottom: 0; }
/* Datos en una línea (fechas, importes, nombres con elipsis); la columna de
   acciones es la que cede: sus botones pasan a otra línea si falta ancho. */
.tabla-listado th, .tabla-listado td { padding-left: 12px; padding-right: 12px; }
.tabla-listado th:first-child, .tabla-listado td:first-child { padding-left: 16px; }
.tabla-listado th:last-child, .tabla-listado td:last-child { padding-right: 16px; }
.tabla-listado td { white-space: nowrap; }
.tabla-listado td:not(:has(button)) { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.tabla-listado td:has(> button) { white-space: normal !important; min-width: 168px; }
@media (max-width: 1024px) { .tabla-listado td:has(> button) { min-width: 116px; } }
.tabla-listado td:has(> button) > button { margin-top: 2px; margin-bottom: 2px; }
.celda-vacia { padding: 0 !important; }
.vacio { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 44px 16px; text-align: center; color: var(--muted); font-size: var(--fs-base); }
.vacio .ico { width: 44px; height: 44px; padding: 11px; border-radius: 50%; background: var(--primary-50); color: var(--primary); vertical-align: 0; }

/* ---------------------------------------------------------------- 9. CHIPS DE ESTADO */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  min-height: 22px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--bg-2);
  color: var(--text-2);
  border: 1px solid transparent;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; flex: none; }
.badge.emitida, .badge.enviado, .badge.enviada { background: var(--info-bg); color: var(--info-fg); }
.badge.cobrada, .badge.ok, .badge.contabilizada, .badge.aceptada, .badge.pagada { background: var(--ok-bg); color: var(--ok-fg); }
.badge.borrador, .badge.no_aplica { background: var(--bg-2); color: var(--text-2); }
.badge.anulada, .badge.error, .badge.rechazada { background: var(--danger-bg); color: var(--danger-fg); }
.badge.pendiente, .badge.revisar, .badge.propuesta { background: var(--warn-bg); color: var(--warn-fg); }
.cartera-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 26px; padding: 0 8px;
  border-radius: var(--radius-pill); background: var(--warn); color: #fff;
  font-weight: 700; font-size: var(--fs-sm); flex: none; font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- 10. MODAL, TOASTS, SKELETONS */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 48, .52);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 48px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: fade-in .15s ease-out;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 800px;
  max-height: calc(100vh - 96px);
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  /* Solo transform: animar la opacidad bajo un velo con backdrop-filter deja la
     caja translúcida en algunos Chrome (se vio en headless). */
  animation: modal-in .2s var(--ease);
}
.modal-content.ancho { max-width: 1040px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  font-weight: 400;
  padding: 0;
  width: 36px;
  height: 36px;
  min-height: 0;
  margin: 0;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.modal-close:hover { background: var(--bg-2); color: var(--text); border: 0; }
.modal-content > #modal-body > h3:first-child,
.modal-content > h3:first-child,
.modal-head { padding-right: 44px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.modal-content h3 { margin: 0 0 8px; font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.02em; }
.modal-content > p:first-of-type { margin-top: 0; }
.modal-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  position: sticky; bottom: -28px; z-index: 5;
  background: var(--surface);
  padding: 14px 0 18px; margin-top: 18px;
  border-top: 1px solid var(--border);
}
.modal-actions button { margin-top: 0; }
/* La misma botonera fija al pie, usada dentro de una vista (p. ej. Configuración) */
#view-container .modal-actions { bottom: 0; padding-bottom: 14px; border-top-color: var(--border); background: rgba(244, 246, 250, .94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { transform: translateY(10px) scale(.985); } to { transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

#toasts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 380px;
  max-width: calc(100vw - 24px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--brand-navy);
  color: #F1F5FB;
  padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in .2s var(--ease);
}
.toast .toast-icon { flex: none; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: #8FB0FF; font-size: 15px; line-height: 1; }
.toast .toast-icon .ico { width: 20px; height: 20px; vertical-align: 0; }
.toast.success .toast-icon { color: #5EE0A1; }
.toast.error .toast-icon { color: #FF8A8A; }
.toast > span:not(.toast-icon) { flex: 1; min-width: 0; padding-top: 1px; }
.toast .toast-accion { margin: 0 0 0 auto; white-space: nowrap; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.toast .toast-accion:hover { background: rgba(255, 255, 255, .18); }
.toast.fade-out { animation: toast-out .22s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px) scale(.98); } }

.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.sk {
  background: linear-gradient(90deg, #E8ECF3 25%, #F5F7FB 37%, #E8ECF3 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
  border-radius: var(--radius-xs);
  display: block;
}
@keyframes sk-shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-line.sm { height: 10px; }
.sk-line.lg { height: 18px; }
.sk-title { height: 20px; width: 40%; margin: 0 0 14px; }
.sk-chip { height: 22px; width: 76px; border-radius: var(--radius-pill); }
.sk-btn { height: 38px; width: 110px; border-radius: var(--radius-sm); }
.sk-input { height: 38px; border-radius: var(--radius-sm); }
.sk-avatar { height: 38px; width: 38px; border-radius: 50%; flex: none; }
.w15 { width: 15%; } .w25 { width: 25%; } .w40 { width: 40%; }
.w55 { width: 55%; } .w70 { width: 70%; } .w90 { width: 90%; }
.sk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.sk-grid { display: grid; gap: 16px; margin-bottom: 18px; }
.sk-grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.sk-grid.dos { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.sk-filtros { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.sk-filtros .sk-input { width: 240px; max-width: 100%; }
.sk-filtros .sk-input.corto { width: 150px; }
.sk-tabla { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.sk-fila { display: grid; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.sk-fila:last-child { border-bottom: 0; }
.sk-fila.head { background: var(--surface-2); }
.sk-fila.head .sk { height: 10px; }

/* ---------------------------------------------------------------- 11. COMPONENTES DE PANTALLA */
/* Filtros y paginador */
.filters { display: flex; gap: 10px 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 180px; margin: 0; }
.filters input:not([type]), .filters input[type="search"], .filters input[type="text"] {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A97AB' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center; background-size: 16px;
}
.filters label { margin: 0; }
.filters button { margin-top: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.pager:empty { display: none; }
.pager .pager-info { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }

/* Pestañas (configuración) */
.cfg-tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.cfg-tabs::-webkit-scrollbar { display: none; }
.cfg-tabs button {
  background: transparent; color: var(--muted); box-shadow: none; margin: 0 0 -1px;
  padding: 10px 14px; min-height: 44px; border-radius: 0; font-weight: 600; font-size: var(--fs-base);
  border: 0; border-bottom: 2px solid transparent; gap: 8px; flex: none;
}
.cfg-tabs button .ico { width: 17px; height: 17px; }
.cfg-tabs button:hover { background: transparent; color: var(--text); border-bottom-color: var(--border-strong); }
.cfg-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.cfg-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
/* Indicador de «hay más pestañas» cuando la tira se desplaza (móvil) */
.cfg-tabs-wrap { position: relative; margin-bottom: 20px; }
.cfg-tabs-wrap > .cfg-tabs { margin-bottom: 0; }
.cfg-tabs-wrap::before, .cfg-tabs-wrap::after {
  content: ''; position: absolute; top: 0; bottom: 1px; width: 44px; pointer-events: none; z-index: 2;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.cfg-tabs-wrap::before { left: 0; background: linear-gradient(90deg, var(--bg) 20%, rgba(244, 246, 250, 0)); }
.cfg-tabs-wrap::after {
  right: 0; background: linear-gradient(270deg, var(--bg) 35%, rgba(244, 246, 250, 0));
  content: '›'; display: flex; align-items: center; justify-content: flex-end; padding-right: 4px;
  color: var(--muted); font-size: 22px; font-weight: 600;
}
.cfg-tabs-wrap.mas-izq::before, .cfg-tabs-wrap.mas-der::after { opacity: 1; }
/* Acciones de Configuración (usuarios, gestoría) */
.fila-accion { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fila-accion > select { width: auto; min-width: 180px; }
.botonera { display: flex; gap: 8px; flex-wrap: wrap; }
.gestor-fila { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.gestor-fila > button { margin-left: auto; }
table.tabla-listado td.titulo-tarjeta { white-space: normal; }

/* Segmentado */
.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { background: transparent; color: var(--text-2); box-shadow: none; border: 0; margin: 0; padding: 6px 14px; min-height: 34px; font-size: var(--fs-sm); border-radius: 8px; }
.seg button:hover { background: rgba(255, 255, 255, .6); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Totales de factura */
.totales {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius);
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.totales .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.totales .value { font-size: var(--fs-lg); font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }

/* Editor de líneas de factura */
.linea-row { display: grid; grid-template-columns: 2fr .7fr 1fr .7fr .7fr 1fr 40px; gap: 8px; align-items: end; margin-bottom: 8px; }
.linea-row label { font-size: 11px; margin: 0; }
.lineas-head, .lf-row {
  display: grid;
  grid-template-columns: 22px minmax(200px, 2.4fr) 70px 100px 62px 84px 66px 104px 34px;
  gap: 8px;
  align-items: center;
}
.lineas-head {
  padding: 0 2px 8px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.lineas-head .r { text-align: right; }
.lf-row { padding: 10px 2px; border-top: 1px solid var(--border); }
.lf-row:first-child { border-top: none; }
.lf-row input, .lf-row select { margin: 0; }
.lf-c { display: contents; }
.lf-l { display: none; }
.lf-prod { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lf-prod .combo-input { font-size: var(--fs-sm); }
.lf-drag { cursor: grab; color: var(--faint); text-align: center; user-select: none; font-size: 16px; }
.lf-drag:active { cursor: grabbing; }
.lf-row.dragging { opacity: .4; }
.lf-row.dragover { box-shadow: inset 0 2px 0 0 var(--primary); }
.lf-row input.r, .lf-row select.r { text-align: right; }
.lf-importe { text-align: right; font-weight: 650; font-size: var(--fs-base); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lf-del {
  background: transparent; color: var(--muted); box-shadow: none; border: 0; margin: 0;
  padding: 0; width: 34px; min-height: 34px; font-size: 18px; line-height: 1; font-weight: 400;
}
.lf-del:hover { background: var(--danger-bg); color: var(--danger-fg); border: 0; }
.rl-grid { grid-template-columns: 22px 1.9fr 1.2fr .55fr .85fr .6fr .6fr .9fr 34px; }

/* Configuración → Factura: ajustes a la izquierda, vista previa real fija a la derecha */
.facfg { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 28px; align-items: start; }
.facfg-vista { position: sticky; top: 16px; z-index: 1; }
.facfg-plegar { display: none; }
.facfg-hoja {
  position: relative; background: var(--bg-2); border-radius: var(--radius); padding: 16px;
  display: flex; justify-content: center;
}
.facfg-hoja img {
  width: 100%; max-width: 420px; aspect-ratio: 210 / 297; display: block; background: #fff;
  border-radius: 2px; box-shadow: 0 10px 30px rgba(14, 30, 61, .16), 0 1px 3px rgba(14, 30, 61, .08);
  transition: opacity var(--dur) var(--ease);
}
.facfg-sk { display: none; width: 100%; max-width: 420px; aspect-ratio: 210 / 297; border-radius: 2px; }
.facfg-hoja.vacia .facfg-sk { display: block; }
.facfg-hoja.vacia img { display: none; }
.facfg-hoja.cargando img { opacity: .55; }
.facfg-pie { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.facfg-estado { color: var(--muted); font-size: var(--fs-sm); }
.facfg-num { margin-top: 28px; }

.tpl-galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tpl-card {
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; text-align: left; margin: 0;
  padding: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: none; min-height: 0; font-weight: 400; white-space: normal;
}
.tpl-card:hover { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.tpl-card.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset, var(--shadow-sm); }
.tpl-card:disabled { opacity: 1; cursor: default; }
.tpl-mini { position: relative; display: block; aspect-ratio: 210 / 297; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.tpl-mini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tpl-mini img:not([src]) { visibility: hidden; }
.tpl-mini .sk { position: absolute; inset: 0; border-radius: 0; display: none; }
.tpl-mini.cargando .sk { display: block; }
.tpl-mini.cargando img[src] { opacity: .6; }
.tpl-txt { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 2px; }
.tpl-txt b { font-size: var(--fs-sm); font-weight: 650; }
.tpl-txt span { font-size: var(--fs-xs); color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-card.sel .tpl-txt b { color: var(--primary); }

.logo-fila { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-caja {
  width: 220px; height: 84px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; padding: 10px; background:
  repeating-conic-gradient(#F4F6FA 0 25%, #fff 0 50%) 0 0 / 14px 14px;
}
.logo-caja img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-vacio { color: var(--muted); font-size: var(--fs-sm); }
.logo-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; min-width: 200px; }
.logo-acciones .hint { flex-basis: 100%; }
.btn-file {
  display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 4px 12px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface); color: var(--text);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.btn-file:hover { background: var(--surface-2); }
input.sr-only:focus-visible + * , .btn-file:focus-within { box-shadow: var(--ring); }

.col-muestras { margin-top: 12px; }
.swatches { display: flex; gap: 18px; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-sm); }
.swatch b { display: block; font-weight: 600; }
.swatch code { font-size: var(--fs-xs); color: var(--muted); }
.swatch-c { width: 36px; height: 36px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(14, 30, 61, .12); flex: none; }
.tonos { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.tono { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(14, 30, 61, .15); }
.col-manual { margin-top: 10px; }
.aviso-contraste { color: var(--warn-fg); }
.chk-fila { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.chk { display: inline-flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; font-weight: 500; color: var(--text); min-height: 32px; }
.chk input { width: 18px; height: 18px; margin: 0; }
.chk-nota { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
.aviso-cobro {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; margin-bottom: 12px;
  background: var(--warn-bg); color: var(--warn-fg); border: 1px solid var(--warn-border); border-radius: var(--radius-sm); font-size: var(--fs-sm);
}

@media (max-width: 1024px) {
  .facfg { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .facfg-vista { position: static; order: -1; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .facfg-plegar {
    display: flex; width: 100%; justify-content: space-between; align-items: center; margin: 0; min-height: 48px;
    background: transparent; color: var(--text); border: 0; box-shadow: none; font-weight: 650; padding: 10px 14px;
  }
  .facfg-plegar:hover { background: var(--surface-2); }
  .facfg-plegar[aria-expanded="false"] .facfg-chev { transform: rotate(-90deg); }
  .facfg-chev { transition: transform var(--dur) var(--ease); }
  .facfg-cuerpo { padding: 0 12px 12px; }
  .facfg-hoja img { max-width: 360px; }
  .facfg-sk { max-width: 360px; }
}
@media (max-width: 640px) {
  .tpl-galeria { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tpl-txt span { -webkit-line-clamp: 2; }
  .logo-caja { width: 100%; }
  .facfg-hoja { padding: 10px; }
  .facfg-pie button { width: 100%; min-height: 44px; }
  .btn-file, .logo-acciones button.small, #col-tomar { min-height: 44px; }
  .seg { width: 100%; }
  .seg button { flex: 1; min-height: 44px; }
  .chk { min-height: 44px; }
}

/* Importadores: zona de arrastre y progreso */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 32px 20px;
  text-align: center; color: var(--text-2); background: var(--surface);
  transition: border-color var(--dur), background var(--dur); cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone .dz-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ico-dz { width: 40px; height: 40px; color: var(--primary); }
.dzc {
  display: flex; align-items: center; gap: 10px; border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; background: var(--surface); min-width: 0; max-width: 100%;
  transition: border-color var(--dur), background var(--dur);
}
.dzc:hover, .dzc.drag { border-color: var(--primary); background: var(--primary-50); }
.dzc-ico svg { width: 20px; height: 20px; color: var(--muted); }
.dzc-txt { color: var(--muted); font-size: var(--fs-sm); }
.dzc.con-archivo { border-style: solid; border-color: var(--primary); }
.dzc.con-archivo .dzc-txt { display: none; }
.dzc-file { font-size: var(--fs-sm); font-weight: 600; word-break: break-all; }
.impbar { height: 8px; background: var(--bg-2); border-radius: var(--radius-pill); overflow: hidden; }
.impbar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-blue), var(--brand-teal)); transition: width .3s ease; }
.import-indicator {
  position: fixed; bottom: 20px; left: calc(var(--sidebar-w) + 20px); z-index: var(--z-float); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  border-radius: var(--radius-pill); padding: 10px 16px; font-size: var(--fs-sm); font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.imp-avisos { margin: 4px 0 0; padding-left: 16px; font-size: var(--fs-xs); color: var(--warn-fg); }
.barra { height: 8px; background: var(--bg-2); border-radius: var(--radius-pill); overflow: hidden; margin: 8px 0 4px; }
.barra-fill { height: 100%; border-radius: var(--radius-pill); transition: width .3s; }

/* Asistente paso a paso */
.wizard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 24px; max-width: 840px; }
.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.steps .step .dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-2); color: var(--muted); font-size: var(--fs-sm); font-weight: 700; }
.steps .step.on { color: var(--text); }
.steps .step.on .dot { background: var(--primary); color: #fff; box-shadow: var(--ring); }
.steps .step.done .dot { background: var(--ok); color: #fff; }
.steps .step-sep { flex: 1; height: 2px; background: var(--border); min-width: 16px; max-width: 60px; }
.wizard-body { min-height: 120px; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; white-space: normal;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 0; box-shadow: none; color: var(--text);
  transition: border-color .12s, box-shadow .12s, transform .06s;
}
.choice:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); background: var(--surface); }
.choice.selected { border-color: var(--primary); background: var(--primary-50); box-shadow: var(--ring); }
.choice-ico { font-size: 24px; }
.choice-ico .ico { width: 30px; height: 30px; color: var(--primary); }
.choice-tit { font-weight: 700; font-size: var(--fs-base); }
.choice-desc { font-size: var(--fs-xs); color: var(--text-2); font-weight: 500; }
.wizard-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; gap: 12px; flex-wrap: wrap; }
.wizard-actions button { margin: 0; }
.resumen { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; margin-top: 16px; display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.resumen > div { display: flex; justify-content: space-between; gap: 16px; font-size: var(--fs-base); }
.resumen > div span { color: var(--muted); }

/* Gestoría / Asesoría IA: lista de tareas */
.duda-task { margin-bottom: 10px; border-left: 3px solid var(--warn); cursor: pointer; transition: box-shadow var(--dur), transform .05s; }
.duda-task:hover { box-shadow: var(--shadow-md); }
.asesoria-adv > summary { list-style: none; }
.asesoria-adv > summary::-webkit-details-marker { display: none; }
.asesoria-adv > summary::before { content: '▸ '; color: var(--muted); }
.asesoria-adv[open] > summary::before { content: '▾ '; }
.task-list { padding: 6px; }
.task-row { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; cursor: pointer; transition: background .12s; min-height: 56px; }
.task-row:hover { background: var(--primary-50); }
.task-row + .task-row { border-top: 1px solid var(--border); }
.task-ic { font-size: 20px; width: 36px; height: 36px; border-radius: 10px; background: var(--primary-50); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.task-ic svg { width: 18px; height: 18px; }
.task-main { min-width: 0; flex: 1; }
.task-top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.task-top b { font-size: var(--fs-sm); }
.task-ref { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-q { color: var(--text); font-size: var(--fs-base); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-ans { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-chev { color: var(--faint); font-size: 22px; flex: none; }
.task-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.task-acts { display: flex; gap: 6px; flex: none; flex-wrap: wrap; }
.task-acts button { margin: 0; }
.task-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 14px 12px 6px; border-top: 1px solid var(--border); }
.task-sep:first-child { border-top: 0; padding-top: 4px; }
.chat-pin { background: var(--primary-50); border-radius: 10px; }
.chat-pin:hover { background: var(--primary-100); }

/* Chat dentro de modales/vistas */
.chat-msgs { max-height: 50vh; overflow-y: auto; padding: 6px 2px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { display: flex; }
.chat-msg.me { justify-content: flex-end; }
.chat-bubble { max-width: 80%; padding: 9px 13px; border-radius: 14px; font-size: var(--fs-base); line-height: 1.45; overflow-wrap: anywhere; }
.chat-msg.ia .chat-bubble { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.me .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 12px; }
.chat-input input { flex: 1; }
.modal-content .chat-input { position: sticky; bottom: -28px; z-index: 5; background: var(--surface); padding: 10px 0 16px; margin-top: 10px; }
.modal-content .chat-input button { margin-top: 0; }
.chat-adj-img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; margin-top: 4px; cursor: zoom-in; }
.msg-hora { display: inline-block; margin-left: 8px; font-size: 10px; opacity: .65; vertical-align: bottom; }
.msg-autor { display: block; font-size: 11px; font-weight: 600; opacity: .75; margin-bottom: 2px; }
.chat-day { text-align: center; margin: 10px 0 6px; }
.chat-day span { background: var(--bg-2); color: var(--text-2); font-size: 11px; padding: 3px 10px; border-radius: 10px; }

/* Iconos en contextos concretos */
.ico-origen { width: 15px; height: 15px; color: var(--muted); cursor: help; vertical-align: -2.5px; margin-left: 4px; }
.ico-ok { color: var(--ok); vertical-align: -3.5px; }
.dock-title .ico { width: 18px; height: 18px; margin-right: 6px; vertical-align: -4px; }

/* ---------------------------------------------------------------- 12. CHAT FLOTANTE */
#chat-launcher {
  position: fixed; bottom: 24px; right: 24px; z-index: var(--z-dock);
  width: 56px; height: 56px; min-height: 0; border-radius: 50%; padding: 0; margin: 0;
  background: linear-gradient(135deg, var(--brand-blue), #1A3FA8);
  border: 0; color: #fff; box-shadow: 0 10px 24px -6px rgba(36, 87, 230, .55), var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
}
#chat-launcher:hover { transform: translateY(-2px); background: linear-gradient(135deg, #2F63F0, var(--primary-600)); }
#chat-launcher .ico-launcher { width: 24px; height: 24px; color: #fff; margin: 0; vertical-align: 0; }
.dock-badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; line-height: 16px; border-radius: 10px; padding: 0 5px;
  border: 2px solid #fff; font-variant-numeric: tabular-nums;
}
.chat-dock {
  position: fixed; bottom: 92px; right: 24px; z-index: var(--z-dock);
  width: 390px; max-width: calc(100vw - 32px); height: 580px; max-height: calc(100vh - 120px); max-height: calc(100dvh - 120px);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop-in .18s var(--ease);
}
.dock-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: linear-gradient(135deg, var(--brand-navy-2), var(--brand-navy)); color: #fff; flex: none; }
.dock-title { font-weight: 700; font-size: var(--fs-md); flex: 1; min-width: 0; }
.dock-sub { display: block; font-weight: 400; font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub a { color: #fff; text-decoration: underline; }
.dock-back, .dock-x {
  background: rgba(255, 255, 255, .1); color: #fff; box-shadow: none; border: 0; margin: 0;
  width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: var(--radius-sm); font-size: 18px; line-height: 1; flex: none;
}
.dock-back:hover, .dock-x:hover { background: rgba(255, 255, 255, .2); }
.dock-body { flex: 1; overflow-y: auto; background: var(--bg); overscroll-behavior: contain; }
.dock-foot { flex: none; display: flex; gap: 8px; padding: 10px; background: var(--surface); border-top: 1px solid var(--border); }
.dock-foot:empty { display: none; }
.dock-foot input { flex: 1; border-radius: 20px; }
.dock-foot button { margin: 0; border-radius: 50%; width: 40px; height: 40px; min-height: 0; padding: 0; flex: none; }
.dock-foot button.secondary { border-radius: 20px; width: auto; padding: 0 12px; }
.dock-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 60px; }
.dock-item:hover { background: var(--primary-50); }
.dock-item.destacado { background: var(--primary-50); }
.dock-item.leida { opacity: .8; }
.dock-ava { flex: none; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); }
.dock-ava svg { width: 19px; height: 19px; }
.dock-item-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.dock-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: var(--fs-sm); }
.dock-time { color: var(--muted); font-size: 11px; flex: none; }
.dock-item-txt { font-size: var(--fs-sm); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-item-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: none; }
.dock-sep { padding: 8px 14px 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--bg); }
.dock-msgs { max-height: none; padding: 12px; }

/* ---------------------------------------------------------------- 13. RESPONSIVE */
/* Pantallas grandes: más aire, mismo ancho de lectura */
@media (min-width: 1600px) {
  :root { --page-x: 40px; --sidebar-w: 268px; }
  .chart-box { height: 290px; }
}

/* Tablet y móvil (≤ 1024): menú lateral como cajón */
@media (max-width: 1024px) {
  :root { --page-x: 24px; }
  .app { flex-direction: column; }
  .mobilebar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: calc(var(--z-topbar) + 2);
    height: calc(var(--mobilebar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 12px 0 max(6px, env(safe-area-inset-left, 0px));
    background: rgba(255, 255, 255, .94);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .menu-btn {
    margin: 0; width: 44px; height: 44px; min-height: 0; padding: 0;
    background: transparent; color: var(--text); border: 0; box-shadow: none; border-radius: var(--radius-sm);
  }
  .menu-btn:hover { background: var(--bg-2); }
  .menu-btn .ico { width: 24px; height: 24px; }
  .mobilebar-logo { height: 28px; width: auto; display: block; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: auto;
    width: min(86vw, 320px);
    transform: translateX(-104%);
    transition: transform .24s var(--ease), visibility 0s linear .24s;
    visibility: hidden;
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .app.menu-abierto .sidebar { transform: none; visibility: visible; transition: transform .24s var(--ease); }
  .sidebar-overlay {
    display: block; position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
    background: rgba(10, 22, 48, .5); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .app.menu-abierto .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .sidebar .logo { padding: 12px 10px 12px 20px; min-height: var(--mobilebar-h); }
  .sidebar-close {
    display: inline-flex; margin: 0; width: 44px; height: 44px; min-height: 0; padding: 0;
    background: transparent; border: 0; box-shadow: none; color: var(--side-text);
  }
  .sidebar-close:hover { background: var(--side-hover); color: #fff; }
  .sidebar-close .ico { width: 22px; height: 22px; }
  /* El selector de empresa sube arriba del cajón: siempre a mano */
  .sidebar .empresa-switch { order: -1; border-top: 0; border-bottom: 1px solid var(--side-line); }
  .sidebar .logo { order: -2; }
  .sidebar nav a { min-height: 44px; font-size: var(--fs-md); }
  .sidebar nav .nav-group { min-height: 40px; }
  .user-info button { min-height: 44px; }

  .topbar { position: static; min-height: 0; padding: 20px var(--page-x) 4px; background: transparent; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .gestoria-bar { top: calc(var(--mobilebar-h) + env(safe-area-inset-top, 0px)); }
  .gestoria-bar:not(.hidden) + .topbar { top: auto; }
  #view-container { padding: 16px var(--page-x) 112px; }
  .table-container.listado { max-height: none; overflow-x: auto; overflow-y: visible; }
  .table-container.listado thead th { position: static; }
  .import-indicator { left: 16px; }
  button, input, select, textarea { min-height: 44px; }
  button.small { min-height: 36px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; }
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { min-height: 40px; align-items: center; }
}

/* Tablet (641–1024) */
@media (min-width: 641px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
  .stat-card .value { font-size: var(--fs-2xl); }
  .lineas-head, .lf-row { grid-template-columns: 20px minmax(160px, 2fr) 64px 92px 58px 78px 60px 96px 34px; gap: 6px; }
}
@media (max-width: 860px) {
  .charts-grid { grid-template-columns: 1fr; }
  /* Editor de líneas: cada línea es una tarjeta con sus etiquetas */
  .lineas-head { display: none; }
  .lf-row {
    grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; align-items: end;
    border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; background: var(--surface-2);
  }
  .lf-row:first-child { border-top: 1px solid var(--border); }
  .lf-drag { display: none; }
  .lf-prod, .rl-grid > input:first-of-type, .rl-grid > .combo { grid-column: 1 / -1; }
  .rl-grid .lf-c { grid-column: span 3; }
  .lf-c { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; margin: 0; min-width: 0; }
  .lf-l { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .lf-importe { grid-column: 1 / span 5; text-align: left; font-size: var(--fs-md); align-self: center; }
  .lf-importe::before { content: 'Importe  '; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
  .lf-del { grid-column: 6; justify-self: end; width: 44px; min-height: 44px; }
  .lf-importe { grid-column: 1 / span 5; }
  .cfg-grid2 { grid-template-columns: 1fr; }
}

/* Móvil (≤ 640) */
@media (max-width: 640px) {
  :root { --page-x: 16px; --fs-input: 16px; }
  body { font-size: var(--fs-base); }
  /* ≥ 16 px en campos: iOS no hace zoom al enfocarlos */
  input, select, textarea { font-size: 16px !important; }
  .topbar { padding-top: 16px; gap: 12px; }
  .topbar h2 { font-size: var(--fs-xl); width: 100%; }
  #view-actions { width: 100%; }
  #view-actions > button:only-child { width: 100%; }
  #view-container { padding-top: 12px; }

  /* Botones largos: que partan línea antes que desbordar */
  button { white-space: normal; max-width: 100%; text-align: center; }
  /* Rejillas en línea de las vistas (style="grid-template-columns:…") → 1–2 columnas */
  [style*="grid-template-columns:1fr 1fr"], [style*="grid-template-columns:1fr 1.4fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="grid-template-columns:repeat(3,1fr)"], [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(5,1fr)"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* Formularios en una columna */
  .form-row { grid-template-columns: 1fr; }
  .form-row > [style*="grid-column"] { grid-column: auto !important; }
  .filters { gap: 8px; }
  .filters > input, .filters > select { width: 100%; min-width: 0 !important; flex: 1 1 100%; }
  .filters > span:empty { display: none; }
  .filters > span[style*="margin-left:auto"] { margin-left: 0 !important; width: 100%; }
  .filters .rango { width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; }
  .filters .rango .rango-preset { grid-column: 1 / -1; width: 100%; }
  .filters .rango input[type="date"] { min-width: 0; width: 100%; }
  .rango input[type="date"], .rango .rango-preset { min-width: 0; }

  /* KPIs en 1–2 columnas */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
  .stat-card { padding: 14px; }
  .stat-card .label { font-size: 11px; letter-spacing: .04em; }
  .stat-card .value { font-size: var(--fs-xl); }
  .sk-grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-box { height: 220px; }
  .card { padding: 16px; }

  /* Listados principales → tarjetas apiladas */
  .table-container.listado { background: transparent; border: 0; box-shadow: none; overflow: visible; border-radius: 0; }
  table.tabla-listado, table.tabla-listado tbody { display: block; }
  table.tabla-listado thead { display: none; }
  table.tabla-listado tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 12px 14px; margin-bottom: 10px;
  }
  table.tabla-listado tbody tr:hover > td { background: transparent; }
  table.tabla-listado td {
    display: block; grid-column: 1 / -1;
    padding: 5px 0; border: 0; font-size: var(--fs-base); text-align: right !important; white-space: normal !important;
    min-width: 0; max-width: none !important; overflow: visible !important; overflow-wrap: anywhere;
  }
  table.tabla-listado td::before {
    content: attr(data-label); float: left; max-width: 45%; margin-right: 12px; padding-top: 2px;
    color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; text-align: left;
  }
  table.tabla-listado td::after { content: ''; display: table; clear: both; }
  table.tabla-listado td > * { vertical-align: middle; }
  table.tabla-listado td:not([data-label])::before, table.tabla-listado td[data-label=""]::before { content: none; }
  /* Primera columna = título de la tarjeta */
  table.tabla-listado td:first-child {
    grid-column: 1; text-align: left !important;
    font-weight: 650; font-size: var(--fs-md); padding: 0 0 8px; margin-bottom: 4px;
  }
  table.tabla-listado td:first-child::before { content: attr(data-label); float: none; display: inline; margin-right: 8px; vertical-align: 1px; }
  table.tabla-listado tr > td:first-child { border-bottom: 0; }
  /* Acciones (columna sin título) → fila de botones al pie */
  table.tabla-listado td[data-label=""], table.tabla-listado td:not([data-label]) {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center; text-align: left !important;
    border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px;
  }
  table.tabla-listado td[data-label=""] button.small, table.tabla-listado td:not([data-label]) button.small { min-height: 44px; padding: 6px 14px; margin: 0; }
  table.tabla-listado td[data-label=""] > button.small + button.small { margin-left: 0; }
  table.tabla-listado td.celda-vacia { border: 0; margin: 0; padding: 0; }
  table.tabla-listado tr:has(td.celda-vacia) { padding: 0; }

  /* Resto de tablas: scroll horizontal dentro de su caja, 1ª columna fija */
  .table-container:not(.listado) th:first-child,
  .table-container:not(.listado) td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--border); }
  .table-container:not(.listado) th:first-child { background: var(--surface-2); }
  .table-container:not(.listado) td { white-space: nowrap; }
  .table-container:not(.listado) td:first-child { white-space: normal; min-width: 96px; max-width: 46vw; }
  .table-container:not(.listado) td[colspan]:first-child { position: static; max-width: none; white-space: normal; box-shadow: none; }
  th, td { padding: 10px 12px; }
  .card { overflow-x: auto; }
  .card:has(.combo), .card:has(.chart-box) { overflow-x: visible; }

  /* Modales a pantalla completa */
  .modal { padding: 0; align-items: stretch; }
  .modal-content, .modal-content.ancho {
    max-width: none; width: 100%; min-height: 100%; max-height: none; height: 100%;
    border-radius: 0; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
    animation: sheet-in .22s var(--ease);
  }
  .modal-close { top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; width: 44px; height: 44px; }
  .modal-content h3 { font-size: var(--fs-lg); }
  .modal-actions { bottom: calc(-16px - env(safe-area-inset-bottom, 0px)); padding: 12px 0 calc(14px + env(safe-area-inset-bottom, 0px)); }
  .modal-actions > button { flex: 1 1 auto; }
  #view-container .modal-actions { padding-right: 72px; bottom: env(safe-area-inset-bottom, 0px); }
  #view-container .modal-actions > button { flex: 0 1 auto; }
  @keyframes sheet-in { from { transform: translateY(16px); } to { transform: none; } }

  .totales { grid-template-columns: repeat(2, 1fr); }
  .linea-row { grid-template-columns: 1fr 1fr; }
  .linea-row > :first-child { grid-column: 1 / -1; }

  /* Chat: el botón no tapa acciones; el panel ocupa la pantalla */
  #chat-launcher { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); width: 52px; height: 52px; }
  .chat-dock {
    inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; border: 0;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: calc(var(--z-modal) - 1);
  }
  .chat-dock .dock-head { min-height: 56px; }
  .chat-bubble { max-width: 88%; }

  #toasts { top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); left: 12px; right: 12px; width: auto; max-width: none; }
  .task-row { flex-wrap: wrap; }
  .task-acts { width: 100%; }
  .choice-grid { grid-template-columns: 1fr; }
  .wizard { padding: 16px; }
  .gestoria-bar { padding: 8px 16px; }
  .seg { display: flex; }
  .seg button { flex: 1 0 auto; }
  .chat-adj-img { max-width: 100%; }

  /* Login: solo la tarjeta, con el logo encima */
  .login-screen { grid-template-columns: 1fr; background: var(--bg); }
  .login-brand { display: none; }
  .login-main { justify-content: flex-start; padding: 48px 16px 24px; }
  .login-card { padding: 28px 20px; box-shadow: var(--shadow-sm); }
  .login-logo { display: block; }
}

/* Login en tablet: panel de marca arriba, compacto */
@media (min-width: 641px) and (max-width: 1024px) {
  .login-screen { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 32px 40px; gap: 20px; }
  .login-brand-logo { height: 34px; }
  .login-claim h2 { font-size: 26px; }
  .login-features, .login-foot { display: none; }
  .login-brand::after { width: 300px; height: 300px; border-width: 40px; right: -100px; bottom: -160px; }
}

/* ---------------------------------------------------------------- 14. IMPRESIÓN Y MOVIMIENTO */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .sk { animation: none; }
}

@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .sidebar, .mobilebar, .sidebar-overlay, .topbar #view-actions, .gestoria-bar, #chat-launcher, .chat-dock, #toasts,
  .filters, .pager, .cfg-tabs, .modal-actions, .modal-close, button, .dzc, .empresa-switch, .import-indicator { display: none !important; }
  .app, .main { display: block; min-height: 0; }
  .main { overflow: visible; }
  .topbar { position: static; padding: 0 0 8px; border: 0; box-shadow: none; background: none; backdrop-filter: none; }
  .topbar h2 { font-size: 16px; }
  #view-container { max-width: none; padding: 0; }
  #view-container, .card, .table-container, .stat-card { box-shadow: none; border: 0; padding: 0; margin: 0 0 10px; break-inside: auto; overflow: visible; max-height: none; }
  table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  th, td { padding: 3px 5px; border-bottom: 1px solid #ccc; position: static !important; background: none !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .badge { border: 1px solid #999; background: none !important; color: #000 !important; }
  .badge::before { display: none; }
  body:has(#modal:not(.hidden)) .app { display: none !important; }
  #modal, .modal-content { position: static; background: #fff; box-shadow: none; max-height: none; width: auto; max-width: none; padding: 0; backdrop-filter: none; }
}
.facfg [hidden] { display: none !important; }

/* Configuración y modales en móvil: objetivos táctiles de 44 px, acciones a todo el ancho */
@media (max-width: 640px) {
  button.small, .seg button { min-height: 44px; }
  .fila-accion > *, .fila-accion > select { flex: 1 1 100%; width: 100%; min-width: 0 !important; }
  .botonera { display: grid; grid-template-columns: minmax(0, 1fr); }
  .botonera > button { width: 100%; margin: 0; }
  .gestor-fila > button { margin-left: 0; width: 100%; }
  table.tabla-listado td.titulo-tarjeta::before { content: none !important; }
  .modal .modal-actions > button { min-height: 44px; }
  .cfg-tab .radio-list label { padding: 12px; }
}
textarea.auto-crece { resize: none; overflow: hidden; min-height: 38px; line-height: 1.45; padding-top: 8px; padding-bottom: 8px; }
/* ------------------------------------------------------------------
   Campos de fecha/hora en iOS Safari: por defecto se dibujan con ancho
   propio (se salen del contenedor) y el valor centrado. Se igualan al
   resto de campos: ancho del contenedor, alto normal y texto a la izquierda.
   ------------------------------------------------------------------ */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  text-align: left;
  min-height: 44px;
  line-height: normal;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value {
  text-align: left;
  margin: 0;
  min-height: 1.4em;
}
/* En filtros de rango (dos fechas en línea) cada campo ocupa su hueco, sin desbordar. */
.filters input[type="date"], .rango input[type="date"] { width: auto; flex: 1 1 0; }

/* ------------------------------------------------------------------
   Listados: orden por columna, totales al pie y menú «Más» de acciones
   ------------------------------------------------------------------ */
.tabla-listado th.ordenable { cursor: pointer; user-select: none; }
.tabla-listado th.ordenable:hover, .tabla-listado th.ordenable:focus-visible { color: var(--primary); outline: none; }
.tabla-listado th.ordenable::after { content: '↕'; margin-left: 4px; opacity: .35; font-size: 11px; display: none; }
.tabla-listado th.ordenable:hover::after, .tabla-listado th.ordenable:focus-visible::after, .tabla-listado th.ordenable[data-dir="asc"]::after, .tabla-listado th.ordenable[data-dir="desc"]::after { display: inline; }
.tabla-listado th.ordenable[data-dir="asc"]::after { content: '↑'; opacity: 1; color: var(--primary); }
.tabla-listado th.ordenable[data-dir="desc"]::after { content: '↓'; opacity: 1; color: var(--primary); }
.tabla-listado tfoot td { position: sticky; bottom: 0; z-index: 1; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.filters .orden-movil { display: none; }
.filters .ico { width: 16px; height: 16px; vertical-align: -3px; }
/* Menú de acciones secundarias de una fila */
.menu-acc { position: relative; display: inline-block; }
.menu-acc > summary { list-style: none; cursor: pointer; }
.menu-acc > summary::-webkit-details-marker { display: none; }
.menu-acc > summary.small { display: inline-flex; align-items: center; justify-content: center; }
.menu-acc[open] > .menu-acc-lista {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px;
  display: flex; flex-direction: column; padding: 6px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg, 0 10px 30px rgba(14, 30, 61, .16));
}
.menu-acc-lista > button { width: 100%; justify-content: flex-start; text-align: left; margin: 0 !important; background: transparent; color: var(--text); border: 0; box-shadow: none; font-weight: 500; }
.menu-acc-lista > button:hover { background: var(--primary-50); color: var(--primary); }
.menu-acc-lista > button.peligro { color: var(--danger, #c62828); }
.menu-acc-lista > button .ico { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; }
.menu-acc > summary .ico { width: 16px; height: 16px; }
.tabla-listado td .menu-acc { vertical-align: middle; margin: 2px 0; }
@media (max-width: 640px) {
  .filters .orden-movil { display: block; width: 100%; min-width: 0 !important; flex: 1 1 100%; }
  table.tabla-listado tfoot { display: block; }
  table.tabla-listado tfoot tr {
    display: grid; grid-template-columns: minmax(0, 1fr); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px;
  }
  table.tabla-listado tfoot td { position: static; display: block; padding: 4px 0; border: 0; text-align: right !important; background: transparent; }
  table.tabla-listado tfoot td.vacia { display: none; }
  table.tabla-listado tfoot td::before { content: attr(data-label); float: left; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
  table.tabla-listado tfoot td:first-child { text-align: left !important; font-weight: 700; }
  .menu-acc > summary.small { min-height: 44px; padding: 6px 14px; }
  .menu-acc[open] > .menu-acc-lista { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; min-width: 0; padding: 8px; }
  .menu-acc-lista > button { min-height: 48px; font-size: var(--fs-md); }
}
@media print { .tabla-listado th.ordenable::after { content: none; } .menu-acc { display: none !important; } }
.menu-acc > summary {
  display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 4px 10px;
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.25; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.menu-acc > summary:hover { background: var(--surface-2); border-color: #B5C0D2; }
.menu-acc > summary:focus-visible { outline: none; box-shadow: var(--ring); }
/* Con menú «Más» las acciones caben en una línea: filas más compactas. */
@media (min-width: 641px) { .tabla-listado td:has(> .menu-acc) { white-space: nowrap !important; min-width: 0; } }
@media (min-width: 641px) and (max-width: 1599px) {
  .tabla-listado th, .tabla-listado td { padding-left: 8px; padding-right: 8px; }
  .tabla-listado td .badge { padding-left: 7px; padding-right: 7px; }
}
.centro-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 12px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }
.centro-chip > button.small { margin: 0; min-height: 30px; padding: 2px 8px; font-weight: 500; }
.centro-chip > button .ico { width: 14px; height: 14px; }
.ico-error { color: var(--danger); vertical-align: -3.5px; }
.ico-aviso { color: var(--warn-fg, #B45309); vertical-align: -3.5px; }
.stat-card.kpi-link { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.stat-card.kpi-link:hover, .stat-card.kpi-link:focus-visible { border-color: var(--primary); box-shadow: var(--ring); outline: none; }
@media (max-width: 640px) {
  .filters .orden-movil { flex: 1 1 150px; width: auto; min-width: 0 !important; }
  .filters > .filtros-info { order: 9; }
  .filters > span.filtros-acciones { order: 10; }
  .filters > .filtros-info { flex: 1 1 auto; align-self: center; }
  .filters > span.filtros-acciones[style*="margin-left:auto"] { width: auto; margin-left: auto !important; }
  .menu-acc[open] > .menu-acc-lista { z-index: 1200; box-shadow: 0 -8px 40px rgba(14, 30, 61, .28); }
}
@media (max-width: 640px) {
  .centro-chip > button.small { min-height: 44px; }
  .card p code, .stat-card p code { overflow-wrap: anywhere; word-break: break-all; }
}

/* ---------------------------------------------------------------- 15. DOCUMENTOS A PANTALLA COMPLETA
   Facturas emitidas y recibidas: editor (documento + panel de totales y vista
   previa), ficha (PDF real + pestañas) y vista dividida de las recibidas
   (documento original del proveedor junto a los datos). js/54-hoja-documento.js */
.hoja {
  position: fixed; inset: 0; z-index: 97; background: var(--bg);
  display: flex; flex-direction: column; animation: fade-in .14s ease-out;
}
.hoja-top {
  display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); flex: none;
}
.hoja-volver { margin: 0; min-height: 38px; padding: 6px 10px; }
.hoja-volver .ico { width: 18px; height: 18px; }
.hoja-tit { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.hoja-tit h2 { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hoja-tit .hoja-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.hoja-acc { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hoja-acc button, .hoja-acc .menu-acc > summary { margin: 0; }
.hoja-acc .menu-acc > summary { min-height: 38px; padding: 6px 12px; font-size: var(--fs-base); }
.hoja-cuerpo { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.hoja-pie {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 24px;
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
  box-shadow: 0 -6px 18px -12px rgba(14, 30, 61, .25);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.hoja-pie button { margin: 0; }
.hoja-pie-info { flex: 1; min-width: 0; color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 14px; }
.hoja-pie-info kbd, .atajo kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--text-2);
}
.hoja-pie-total { display: none; }
.sucio-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--warn-fg); font-weight: 600; }
.sucio-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.guardado-ok { color: var(--ok-fg); font-weight: 600; }

/* Botón dividido «Emitir ▾» */
.btn-split { display: inline-flex; position: relative; }
.btn-split > button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-split > details > summary {
  list-style: none; display: inline-flex; align-items: center; min-height: 38px; padding: 0 10px; cursor: pointer;
  background: var(--primary); color: #fff; border: 1px solid var(--primary); border-left-color: rgba(255,255,255,.35);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.btn-split > details > summary::-webkit-details-marker { display: none; }
.btn-split > details > summary:hover { background: var(--primary-600); }
.btn-split > details[open] > .split-menu {
  position: absolute; right: 0; bottom: calc(100% + 6px); min-width: 230px; z-index: 30; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px;
}
.split-menu > button { margin: 0; justify-content: flex-start; background: transparent; color: var(--text); border: 0; box-shadow: none; font-weight: 500; }
.split-menu > button:hover { background: var(--primary-50); color: var(--primary); }

/* Editor: documento a la izquierda, panel fijo a la derecha */
.ed-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start;
  max-width: 1440px; margin: 0 auto; padding: 24px 24px 40px;
}
.ed-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ed-aside { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ed-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-xs); padding: 20px;
}
.ed-card > h4, .ed-card-tit {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 14px;
}
.ed-card-tit button { margin: 0; text-transform: none; letter-spacing: 0; }
.ed-card label:first-child { margin-top: 0; }
.ed-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.ed-campos > div > label { margin-top: 0; }
.ed-campos > div { margin-bottom: 12px; min-width: 0; }
.ed-campos .span2 { grid-column: span 2; }
.ed-nota { color: var(--muted); font-size: var(--fs-xs); margin: 4px 0 0; }
.ed-plegable > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; color: var(--text-2);
  font-size: var(--fs-sm); padding: 6px 0; user-select: none;
}
.ed-plegable > summary::-webkit-details-marker { display: none; }
.ed-plegable > summary::before { content: '›'; font-size: 18px; line-height: 1; transition: transform var(--dur) var(--ease); color: var(--muted); }
.ed-plegable[open] > summary::before { transform: rotate(90deg); }
.ed-plegable > summary .chips-mini { margin-left: auto; }
.chips-mini { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip-mini { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg-2); color: var(--text-2); }
.chip-mini.azul { background: var(--primary-50); color: var(--primary-700); }
.chip-mini.ambar { background: var(--warn-bg); color: var(--warn-fg); }

/* Validación junto al campo */
.campo-err { color: var(--danger-fg); font-size: var(--fs-xs); font-weight: 500; margin: 4px 0 0; display: flex; gap: 4px; align-items: flex-start; }
.campo-err:empty { display: none; }
.invalido, .invalido .combo-input, input.invalido, select.invalido, textarea.invalido { border-color: var(--danger) !important; }
.invalido:focus, .invalido .combo-input:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .18) !important; }

/* Tercero (cliente / proveedor) */
.tercero-sel { display: flex; gap: 8px; align-items: flex-start; }
.tercero-sel .combo { flex: 1; }
.tercero-sel > button { margin: 0; flex: none; min-height: 38px; }
.tercero-ficha {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px 14px; align-items: start;
  margin-top: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
}
.tercero-ava {
  width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-50); color: var(--primary-700); font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.tercero-nombre { font-weight: 650; font-size: var(--fs-md); line-height: 1.3; }
.tercero-datos { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.5; }
.tercero-datos span + span::before { content: ' · '; color: var(--faint); }
.tercero-ficha .chips-mini { grid-column: 2 / -1; margin-top: 6px; }
.tercero-ficha > button { margin: 0; }

/* Líneas (editor de conceptos) */
.le { min-width: 0; }
.le-head, .le-fila {
  display: grid; gap: 8px; align-items: start;
  grid-template-columns: 24px minmax(220px, 1fr) 64px 100px 58px 108px 60px 108px 62px;
}
.le.sin-dto .le-head, .le.sin-dto .le-fila { grid-template-columns: 24px minmax(220px, 1fr) 68px 104px 112px 62px 108px 62px; }
.le.compra .le-head, .le.compra .le-fila { grid-template-columns: 24px minmax(200px, 1fr) 64px 100px 108px 62px 58px 104px 62px; }
.le-head {
  padding: 0 0 8px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.le-head .r, .le-fila .r { text-align: right; }
.le-fila { padding: 12px 0; border-bottom: 1px solid var(--border); position: relative; }
.le-fila:last-child { border-bottom: 0; }
.le-fila input, .le-fila select, .le-fila textarea { margin: 0; }
.le-fila input.r { text-align: right; }
.le-fila select { padding-left: 8px; padding-right: 26px; background-position: right 6px center; }
.le-c { display: contents; }
.le-l { display: none; }
.le-drag {
  cursor: grab; color: var(--faint); user-select: none; display: flex; flex-direction: column; align-items: center; gap: 0;
  padding-top: 6px; font-size: 15px; line-height: 1;
}
.le-drag:active { cursor: grabbing; }
.le-fila.dragging { opacity: .4; }
.le-fila.dragover { box-shadow: inset 0 2px 0 0 var(--primary); }
.le-desc { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.le-desc textarea { min-height: 38px; resize: none; overflow: hidden; line-height: 1.45; padding-top: 8px; padding-bottom: 8px; }
.le-desc textarea.rica { font-size: var(--fs-sm); }
.le-prod {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; max-width: 100%;
  font-size: 11.5px; font-weight: 600; color: var(--primary-700); background: var(--primary-50);
  border-radius: 999px; padding: 1px 4px 1px 9px;
}
.le-prod span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.le-prod button { margin: 0; min-height: 0; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--primary-700); box-shadow: none; font-size: 13px; line-height: 1; }
.le-prod button:hover { background: var(--primary-100); }
.le-sug {
  position: absolute; left: 0; right: 0; top: calc(100% - 2px); z-index: 60; list-style: none; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 260px; overflow-y: auto;
}
.le-sug li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: var(--fs-sm); }
.le-sug li.activo, .le-sug li:hover { background: var(--primary-50); }
.le-sug .cod { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.le-sug .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.le-sug .pre { color: var(--text-2); font-variant-numeric: tabular-nums; }
.le-sug .tit { grid-column: 1 / -1; padding: 2px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; cursor: default; }
.le-sug .tit:hover { background: none; }
.le-importe { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 9px; }
.le-importe small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.le-acc { display: flex; gap: 2px; justify-content: flex-end; padding-top: 3px; }
.le-acc button, .le-btn {
  margin: 0; min-height: 30px; width: 30px; padding: 0; background: transparent; color: var(--muted); border: 0; box-shadow: none; border-radius: 6px;
}
.le-acc button:hover, .le-btn:hover { background: var(--bg-2); color: var(--text); }
.le-acc button.borrar:hover { background: var(--danger-bg); color: var(--danger-fg); }
.le-acc .ico, .le-btn .ico { width: 16px; height: 16px; }
.le-fila:not(:hover):not(:focus-within) .le-acc .ocultable { opacity: .35; }
.le-resumen { display: none; }
.le-pie { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); margin-top: 2px; }
.le-pie button { margin: 0; }
.le-ayuda { color: var(--muted); font-size: var(--fs-xs); margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.le-ayuda button { min-height: 0; padding: 2px 8px; font-size: var(--fs-xs); }
.formato-ayuda {
  margin-top: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px dashed var(--border-strong);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; font-size: var(--fs-sm);
}
.formato-ayuda pre { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--text-2); margin: 0; }
.desc-rica .t { font-weight: 650; }
.desc-rica .s { color: var(--muted); font-size: .92em; }
.desc-rica ul { margin: 4px 0 0 18px; padding: 0; }
.desc-rica li { margin: 1px 0; }
.desc-rica li b { font-weight: 650; }
.le-marca { align-self: flex-start; font-size: 11px; font-weight: 600; color: var(--primary-700); background: var(--primary-50); border-radius: 4px; padding: 0 6px; }
.hoja [hidden] { display: none !important; }
.le-fila input, .le-fila select { padding-left: 8px; padding-right: 8px; }
.le-fila select { padding-right: 24px; }
.le-fila input[type=number]::-webkit-inner-spin-button, .le-fila input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.le-fila input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* Panel de totales */
.tot-panel { display: flex; flex-direction: column; gap: 0; font-variant-numeric: tabular-nums; }
.tot-fila { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: var(--fs-sm); color: var(--text-2); }
.tot-fila b { color: var(--text); font-weight: 600; }
.tot-fila.sub { padding: 2px 0 2px 12px; font-size: var(--fs-xs); color: var(--muted); }
.tot-fila.neg b { color: var(--danger-fg); }
.tot-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.tot-total span { font-weight: 650; color: var(--text); }
.tot-total b { font-size: 26px; font-weight: 750; letter-spacing: -.025em; color: var(--text); }
.tot-contra { text-align: right; color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; }
.tot-vacio { color: var(--muted); font-size: var(--fs-sm); }

/* Vista previa del PDF real */
.prev-mini {
  position: relative; display: block; width: 100%; padding: 14px; margin: 0; border: 0; border-radius: var(--radius-sm);
  background: var(--bg-2); cursor: zoom-in; box-shadow: none; min-height: 0;
}
.prev-mini:hover { background: var(--bg-2); }
.prev-mini img, .prev-mini .sk {
  width: 100%; aspect-ratio: 210 / 297; display: block; background: #fff; border-radius: 2px;
  box-shadow: 0 8px 24px rgba(14, 30, 61, .14), 0 1px 3px rgba(14, 30, 61, .08); transition: opacity var(--dur) var(--ease);
}
.prev-mini.cargando img { opacity: .5; }
.prev-mini .prev-spin { position: absolute; top: 22px; right: 22px; display: none; }
.prev-mini.cargando .prev-spin { display: block; }
.prev-pie { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: var(--fs-xs); color: var(--muted); flex-wrap: wrap; }
.prev-pie button { margin: 0; }
.prev-error { padding: 24px 12px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }
.lightbox-doc { display: flex; flex-direction: column; gap: 12px; }
.lightbox-doc img { width: 100%; height: auto; display: block; border-radius: 2px; box-shadow: 0 10px 30px rgba(14, 30, 61, .16); background: #fff; }

/* Lista de comprobación antes de emitir */
.check-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.check-lista li { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); }
.check-lista li .ico { width: 16px; height: 16px; margin-top: 2px; }
.check-lista li.ok .ico { color: var(--ok); }
.check-lista li.no .ico { color: var(--warn); }
.emitir-explica { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.emitir-paso { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.emitir-paso .ico { width: 20px; height: 20px; color: var(--primary); margin: 4px auto 0; }
.emitir-paso b { display: block; font-size: var(--fs-sm); }
.emitir-paso span { color: var(--muted); font-size: var(--fs-sm); }

/* Ficha: PDF real a la izquierda, pestañas a la derecha */
.fi-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 520px); gap: 24px; align-items: start;
  max-width: 1440px; margin: 0 auto; padding: 24px 24px 40px;
}
.fi-doc { position: sticky; top: 24px; min-width: 0; }
.fi-doc .prev-mini { padding: 20px; cursor: zoom-in; }
.fi-doc .prev-mini img, .fi-doc .prev-mini .sk { max-width: 640px; margin: 0 auto; }
.fi-lado { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fi-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.fi-kpi { padding: 14px 16px; min-width: 0; }
.fi-kpi + .fi-kpi { border-left: 1px solid var(--border); }
.fi-kpi .k { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.fi-kpi .v { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-kpi .s { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.fi-kpi .v.ok { color: var(--ok-fg); } .fi-kpi .v.warn { color: var(--warn-fg); } .fi-kpi .v.mal { color: var(--danger-fg); }
.prog { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.prog > span { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .3s var(--ease); }
.prog.parcial > span { background: var(--brand-teal); }
.tabs-doc { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs-doc::-webkit-scrollbar { display: none; }
.tabs-doc button {
  margin: 0; background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  box-shadow: none; padding: 10px 12px; min-height: 42px; font-weight: 600; font-size: var(--fs-sm);
}
.tabs-doc button:hover { background: transparent; color: var(--text); }
.tabs-doc button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs-doc .cnt { font-size: 11px; background: var(--bg-2); color: var(--text-2); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.tab-panel { padding-top: 16px; }
.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 14px; font-size: var(--fs-sm); margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.venc-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; margin-left: 6px; }
.venc-chip.ok { background: var(--ok-bg); color: var(--ok-fg); }
.venc-chip.pronto { background: var(--warn-bg); color: var(--warn-fg); }
.venc-chip.vencida { background: var(--danger-bg); color: var(--danger-fg); }
.mini-tabla { width: 100%; font-size: var(--fs-sm); }
.mini-tabla th, .mini-tabla td { padding: 8px 10px; }
.mini-tabla td.r, .mini-tabla th.r { text-align: right; }
.bloque-vacio { padding: 22px 12px; text-align: center; color: var(--muted); font-size: var(--fs-sm); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.asiento-caja { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; background: var(--surface); }
.asiento-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.asiento-cab b { font-weight: 650; }
.asiento-cab button { margin: 0; }

/* Línea de tiempo */
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; padding: 0 0 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted);
}
.tl-dot .ico { width: 12px; height: 12px; }
.tl-item.ok .tl-dot { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.tl-item.error .tl-dot { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.tl-item.warn .tl-dot { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.tl-item.info .tl-dot { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.tl-tit { font-weight: 600; font-size: var(--fs-sm); line-height: 1.35; padding-top: 2px; }
.tl-det { color: var(--text-2); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.tl-meta { color: var(--muted); font-size: var(--fs-xs); margin-top: 1px; }

/* Adjuntos */
.adj-lista { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.adj-lista li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-sm); }
.adj-lista li .ico { color: var(--muted); }
.adj-lista li .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.adj-lista li .m { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.adj-lista li button { margin: 0; }

/* Visor del documento original (recibidas) */
.visor { display: flex; flex-direction: column; min-height: 0; background: #E9EDF3; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.visor-barra {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm); flex-wrap: wrap;
}
.visor-barra .n { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.visor-barra button { margin: 0; }
.visor-barra .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.visor-barra .pag { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.visor-lienzo { flex: 1; overflow: auto; padding: 18px; display: flex; justify-content: center; align-items: flex-start; min-height: 0; }
.visor-lienzo img { display: block; max-width: none; background: #fff; box-shadow: 0 8px 24px rgba(14, 30, 61, .16); border-radius: 2px; transition: opacity var(--dur); }
.visor-lienzo.cargando img { opacity: .45; }
.visor-vacio { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 32px 20px; text-align: center; color: var(--muted); }
.visor-vacio .dzc { width: 100%; max-width: 420px; }
.visor-local { width: 100%; height: 100%; min-height: 480px; border: 0; background: #fff; }

/* Vista dividida (recibidas) */
.split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(460px, 600px); gap: 20px; align-items: start;
  max-width: 1600px; margin: 0 auto; padding: 20px 24px 32px;
}
.split-doc { position: sticky; top: 20px; height: calc(100vh - 64px - 66px - 40px); height: calc(100dvh - 64px - 66px - 40px); min-height: 420px; display: flex; flex-direction: column; }
.split-doc > .visor { flex: 1; }
.split-datos { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.split-doc-plegar { display: none; }

/* Estado de la IA y campos dudosos */
.ia-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; box-shadow: var(--shadow-xs); }
.ia-panel.revisar { border-color: var(--warn-border); background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box, var(--warn-bg); box-shadow: inset 4px 0 0 var(--warn); }
.ia-panel.propuesta { box-shadow: inset 4px 0 0 var(--primary); }
.ia-panel.contabilizada { box-shadow: inset 4px 0 0 var(--ok); }
.ia-cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ia-cab .ico { color: var(--primary); }
.ia-cab b { font-size: var(--fs-md); }
.ia-cab .badge { margin-left: auto; }
.ia-conf { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-top: 12px; font-size: var(--fs-sm); color: var(--text-2); }
.ia-conf .prog > span { background: var(--primary); }
.ia-conf .prog.baja > span { background: var(--warn); }
.ia-conf .prog.alta > span { background: var(--ok); }
.ia-dato { margin-top: 10px; font-size: var(--fs-sm); color: var(--text-2); }
.ia-dato b { color: var(--text); }
.ia-avisos { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ia-avisos li { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); color: var(--warn-fg); background: var(--warn-bg); border-radius: var(--radius-xs); padding: 7px 10px; }
.ia-avisos li .ico { width: 16px; height: 16px; margin-top: 2px; flex: none; }
.ia-acc { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.ia-acc button { margin: 0; }
.dudoso input, .dudoso select, .dudoso .combo-input, input.dudoso { border-color: var(--warn) !important; background-color: #FFFBF3; }
.campo-aviso { color: var(--warn-fg); font-size: var(--fs-xs); font-weight: 500; margin: 4px 0 0; display: flex; gap: 4px; }
.campo-aviso .ico { width: 14px; height: 14px; margin-top: 1px; }

@media (max-width: 1200px) {
  .ed-grid { grid-template-columns: minmax(0, 1fr) 320px; }
  .fi-grid { grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); }
  .split { grid-template-columns: minmax(0, 1fr) minmax(420px, 520px); }
  .le-head, .le-fila { grid-template-columns: 22px minmax(180px, 1fr) 62px 96px 56px 104px 56px 100px 58px; gap: 6px; }
  .le.sin-dto .le-head, .le.sin-dto .le-fila { grid-template-columns: 22px minmax(180px, 1fr) 62px 96px 104px 56px 100px 58px; }
  .le.compra .le-head, .le.compra .le-fila { grid-template-columns: 22px minmax(170px, 1fr) 58px 92px 104px 56px 54px 96px 58px; }
}
@media (max-width: 1024px) {
  .ed-grid, .fi-grid { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 24px; }
  .ed-aside, .fi-doc { position: static; }
  .ed-aside { order: 2; }
  .split { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .split-doc { position: static; height: auto; min-height: 0; }
  .split-doc > .visor { height: 62vh; }
  .split-doc.plegado > .visor { display: none; }
  .split-doc-plegar {
    display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; min-height: 44px;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-xs); font-weight: 650;
  }
  .split-doc-plegar:hover { background: var(--surface-2); }
  .split-doc-plegar .chev { transition: transform var(--dur) var(--ease); }
  .split-doc.plegado .split-doc-plegar .chev { transform: rotate(-90deg); }
  .fi-doc .prev-mini img, .fi-doc .prev-mini .sk { max-width: 420px; }
}
/* Poco ancho (móvil, tableta o la columna de datos de la vista dividida): líneas como
   tarjetas plegables. Consulta de contenedor: depende del ancho del editor, no de la pantalla. */
.le { container-type: inline-size; container-name: lineas; }
@container lineas (max-width: 780px) {
  .le-head { display: none; }
  .le-fila, .le.sin-dto .le-fila, .le.compra .le-fila {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 10px; padding: 0 12px; margin-bottom: 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-xs); overflow: visible;
  }
  .le-fila:last-child { border-bottom: 1px solid var(--border); }
  .le-fila.abierta { border-color: var(--primary-100); box-shadow: 0 0 0 3px var(--primary-50); }
  .le-resumen {
    display: flex; grid-column: 1 / -1; align-items: center; gap: 10px; width: calc(100% + 24px); margin: 0 -12px; padding: 12px 14px; min-height: 52px;
    background: transparent; color: var(--text); border: 0; box-shadow: none; border-radius: var(--radius-sm); text-align: left; font-weight: 500;
  }
  .le-resumen:hover { background: var(--surface-2); }
  .le-resumen .num { width: 22px; height: 22px; border-radius: 50%; background: var(--bg-2); color: var(--text-2); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
  .le-resumen .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .le-resumen .txt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .le-resumen .txt small { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .le-resumen .imp { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .le-resumen .chev { color: var(--muted); transition: transform var(--dur) var(--ease); }
  .le-fila.abierta .le-resumen .chev { transform: rotate(180deg); }
  .le-fila:not(.abierta) > :not(.le-resumen) { display: none !important; }
  .le-fila.abierta .le-resumen { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
  .le-drag { display: none !important; }
  .le-desc { grid-column: 1 / -1; }
  .le-c { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; margin: 0; min-width: 0; padding: 0; }
  .le-l { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .le-fila input, .le-fila select { min-height: 44px; }
  .le-importe { grid-column: 1 / span 3; text-align: left; padding: 0 0 12px; align-self: center; }
  .le-importe::before { content: 'Importe '; display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .le-acc { grid-column: 4 / -1; padding: 0 0 12px; align-self: center; }
  .le-acc button { width: 40px; min-height: 40px; }
  .le-fila:not(:hover):not(:focus-within) .le-acc .ocultable { opacity: 1; }
  .le-ayuda { margin-left: 0; width: 100%; }
  .formato-ayuda { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hoja-top { padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; gap: 8px; min-height: 56px; }
  .hoja-tit h2 { font-size: var(--fs-md); }
  .hoja-volver { min-height: 44px; min-width: 44px; padding: 6px; }
  .hoja-volver .txt { display: none; }
  /* Acciones de la ficha: barra fija abajo */
  .hoja-acc.al-pie {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, .97); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px -12px rgba(14, 30, 61, .25);
    flex-wrap: nowrap; justify-content: stretch;
  }
  .hoja-acc.al-pie > * { flex: 1 1 0; min-width: 0; }
  .hoja-acc.al-pie > button, .hoja-acc.al-pie > .menu-acc > summary { width: 100%; min-height: 44px; padding: 6px 8px; font-size: var(--fs-sm); justify-content: center; }
  .hoja-acc.al-pie > .menu-acc { display: flex; }
  .hoja-acc.al-pie .opc-escritorio { display: none; }
  .hoja:has(.hoja-acc.al-pie) .hoja-cuerpo { padding-bottom: 76px; }
  .hoja-pie { padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); flex-wrap: nowrap; gap: 8px; }
  .hoja-pie-info { flex: 0 1 auto; min-width: 0; }
  .hoja-pie-info #hoja-estado { display: none; }
  .hoja-pie .txt-largo { display: none; }
  .hoja-pie .txt-corto { display: inline; }
  .hoja-pie-info .atajo { display: none; }
  .hoja-pie-total { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
  .hoja-pie-total b { color: var(--text); font-size: var(--fs-lg); font-weight: 750; }
  .hoja-pie > button, .hoja-pie > .btn-split { flex: 1 1 auto; min-height: 46px; padding-left: 10px; padding-right: 10px; }
  .hoja-pie > .btn-split > button:first-child { flex: 1; min-height: 46px; }
  .hoja-pie > .btn-split > details > summary { min-height: 46px; }
  .hoja-pie .solo-escritorio { display: none; }
  .ed-grid, .fi-grid, .split { padding: 12px 10px 20px; gap: 12px; }
  .ed-card { padding: 16px 14px; }
  .ed-campos { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
  .ed-campos .span2, .ed-campos .entero { grid-column: 1 / -1; }
  .tercero-sel { flex-wrap: wrap; }
  .tercero-sel > button { width: 100%; min-height: 44px; }
  .tercero-ficha { grid-template-columns: 40px minmax(0, 1fr); }
  .tercero-ficha > button { grid-column: 1 / -1; width: 100%; }
  .fi-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fi-kpi { padding: 10px 10px; }
  .fi-kpi .v { font-size: var(--fs-md); }
  .dl { grid-template-columns: 112px minmax(0, 1fr); }
  .fi-doc .prev-mini { padding: 10px; }
  .fi-doc .prev-mini img, .fi-doc .prev-mini .sk { max-width: 260px; }
  .split-doc > .visor { height: 56vh; }
  .visor-barra { gap: 4px; }
  .visor-barra button.small { min-height: 40px; min-width: 40px; }
  .btn-split > details[open] > .split-menu { right: 0; left: auto; }
}
@media print { .hoja { display: none !important; } }
.visor-host { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.visor-host > .visor { flex: 1; }
.fis-bloque .fis-fila { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 8px; }
.fis-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: var(--fs-sm); }
.menu-acc-lista > button > span { display: flex; flex-direction: column; align-items: flex-start; white-space: normal; }
.menu-motivo { font-size: 11.5px; color: var(--muted); font-weight: 400; line-height: 1.35; max-width: 240px; }
.menu-acc-lista > button:disabled { opacity: 1; cursor: not-allowed; color: var(--faint); }
.menu-acc-lista > button:disabled:hover { background: transparent; color: var(--faint); }
.hoja-acc .menu-acc-lista { min-width: 230px; }
@media (min-width: 641px) { .menu-acc-lista > .solo-movil-menu { display: none !important; } }
@container lineas (min-width: 781px) { .le-acc .solo-movil { display: none; } }

.hoja-pie .txt-corto { display: none; }
.tercero-ficha > button { grid-column: 3; grid-row: 1; }
@media (max-width: 640px) { .tercero-ficha > button { grid-column: 1 / -1; grid-row: auto; } .tercero-ficha .chips-mini { grid-column: 1 / -1; } }
.mini-tabla td.r, .mini-tabla th.r { white-space: nowrap; }
.mini-tabla td:first-child { width: 100%; }
/* Editor de líneas compartido (presupuestos, pedidos, albaranes, recurrentes, compras) */
.ln-caja { box-shadow: none; }
.ln-tabla th, .ln-tabla td { padding: 8px 6px; vertical-align: top; }
.ln-tabla th:first-child, .ln-tabla td:first-child { padding-left: 8px; }
.ln-tabla th.r, .ln-tabla td.r { text-align: right; }
.ln-tabla input, .ln-tabla select, .ln-tabla textarea { margin: 0; padding-left: 8px; padding-right: 8px; }
.ln-tabla select { padding-right: 24px; background-position: right 6px center; min-width: 76px; }
.ln-tabla input.r { text-align: right; }
.ln-tabla input[type=number] { width: 84px; -moz-appearance: textfield; appearance: textfield; }
.ln-tabla input[type=number]::-webkit-inner-spin-button, .ln-tabla input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ln-tabla td:nth-last-child(4) input { width: 100px; }
.ln-tabla .ln-desc { min-width: 240px; width: 100%; }
.ln-tabla .ln-desc textarea { min-height: 38px; resize: none; overflow: hidden; }
.ln-tabla .ln-orden { width: 28px; padding-top: 10px; }
.ln-tabla .ln-orden .le-btn { display: block; width: 22px; height: 16px; min-height: 16px; }
.ln-tabla .ln-imp { font-weight: 650; white-space: nowrap; padding-top: 17px; min-width: 96px; font-variant-numeric: tabular-nums; }
.ln-tabla tbody tr:hover > td { background: transparent; }
.ln-tot { margin: 12px 0 0 auto; max-width: 380px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.ln-tot .tot-total b { font-size: 22px; }
.le-ayuda kbd { font-family: var(--font); font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 4px; border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); }
.hoja .aviso-cobro > span { flex: 1 1 0; min-width: 0; }
.hoja-pie-total b { white-space: nowrap; }
@media (max-width: 640px) {
  .hoja .hoja-pie .txt-corto { display: inline; }
  .hoja .hoja-pie .txt-largo { display: none; }
  .hoja-pie-total b { font-size: var(--fs-md); }
  .hoja-sub .sub-txt { display: none; }
  .hoja-pie > button#rc-guardar, .hoja-pie > button#rc-validar { white-space: normal; line-height: 1.15; }
  /* Ficha: miniatura del PDF compacta junto a sus botones */
  .fi-doc { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; align-items: center; }
  .fi-doc .prev-mini { padding: 8px; }
  .fi-doc .prev-mini img, .fi-doc .prev-mini .sk { max-width: none; }
  .fi-doc .prev-pie { flex-direction: column; align-items: stretch; margin: 0; }
  .fi-doc .prev-pie > span:last-child { flex-direction: column; }
  .fi-doc .prev-pie button { width: 100%; min-height: 44px; }
  .split-doc > .visor { height: 48vh; }
}

.mini-tabla .det-movil { display: none; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; margin-top: 2px; }
@media (max-width: 640px) {
  .mini-tabla .col-det { display: none; }
  .mini-tabla .det-movil { display: block; }
  .fi-lado .table-container td:first-child { position: static; box-shadow: none; }
}

/* ================================================================ 20. ACCESO, SEGURIDAD Y APP INSTALABLE
   (js/10-auth-perfil.js, js/12-seguridad-pwa.js) — bloque añadido, no reordenar lo anterior */

/* Arranque con sesión guardada: pantalla de marca mientras se renueva la sesión */
.vc-splash { display: none; }
html.vc-arrancando #login-screen { display: none; }
html.vc-arrancando .vc-splash {
  display: flex; position: fixed; inset: 0; z-index: calc(var(--z-toast) + 10);
  flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg);
}
.vc-splash img { height: 40px; width: auto; }
.vc-spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--primary-100); border-top-color: var(--primary); animation: vc-giro .8s linear infinite; }
@keyframes vc-giro { to { transform: rotate(360deg); } }

/* Login: biometría, separador, casillas */
.login-card .btn-biometria { margin-top: 0; min-height: 48px; font-size: var(--fs-md); }
.btn-biometria .ico, #btn-passkey .ico, #btn-2fa-passkey .ico { width: 20px; height: 20px; }
.login-sep { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; color: var(--muted); font-size: var(--fs-sm); }
.login-sep::before, .login-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-check { display: flex !important; align-items: flex-start; gap: 10px; margin: 14px 0 0; font-weight: 500; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; line-height: 1.4; }
.login-check input { width: 18px; height: 18px; min-height: 0; margin: 1px 0 0; flex: none; accent-color: var(--primary); }
.login-alt-izq { text-align: left; margin-top: 8px; }
#login-2fa-passkey .btn-block { margin-top: 10px; }

/* Capas propias (re-autenticación, 2FA obligatoria, hoja de iOS): por encima del modal */
.vc-capa {
  position: fixed; inset: 0; z-index: calc(var(--z-modal) + 20);
  display: flex; align-items: center; justify-content: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 22, 48, .55); animation: fade-in .15s ease-out; overflow-y: auto;
}
.vc-capa-total { background: var(--bg); z-index: calc(var(--z-modal) + 10); align-items: flex-start; }
.vc-capa-abajo { align-items: flex-end; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
.vc-hoja {
  position: relative; width: 100%; max-width: 480px; margin: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 28px; animation: modal-in .2s var(--ease);
}
.vc-capa-total .vc-hoja { margin-top: max(6vh, 24px); }
.vc-hoja-sm { max-width: 420px; }
.vc-hoja h2 { font-size: var(--fs-2xl); letter-spacing: -.02em; margin: 0 0 8px; }
.vc-hoja h3 { margin: 0 0 6px; }
.vc-hoja-ico { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); margin-bottom: 14px; }
.vc-hoja-ico .ico { width: 28px; height: 28px; }
.vc-hoja-txt { color: var(--text-2); margin: 0 0 16px; }
.vc-hoja .btn-block { width: 100%; margin-top: 10px; min-height: 48px; }
.vc-hoja .btn-block .ico { width: 20px; height: 20px; }
.vc-hoja .modal-actions { position: static; padding: 0; margin-top: 16px; }

/* Perfil → Seguridad */
.pf-tabs { margin-bottom: 16px; }
.pf-tabs button .ico { width: 17px; height: 17px; }
.seg-estado { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 18px; }
.seg-estado b { display: block; font-size: var(--fs-md); }
.seg-escudo { flex: none; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.seg-escudo .ico { width: 26px; height: 26px; }
.seg-estado.nivel-alta { background: var(--ok-bg); border-color: var(--ok-border); }
.seg-estado.nivel-alta .seg-escudo { background: #fff; color: var(--ok); }
.seg-estado.nivel-media { background: var(--info-bg); border-color: var(--primary-100); }
.seg-estado.nivel-media .seg-escudo { background: #fff; color: var(--primary); }
.seg-estado.nivel-baja { background: var(--warn-bg); border-color: var(--warn-border); }
.seg-estado.nivel-baja .seg-escudo { background: #fff; color: var(--warn); }
.seg-recos { margin: 8px 0 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-2); display: grid; gap: 4px; }
.seg-ok { margin: 4px 0 0; font-size: var(--fs-sm); color: var(--ok-fg); }
.seg-politica { display: inline-block; margin-top: 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--primary-700); background: #fff; border-radius: var(--radius-pill); padding: 2px 10px; }
.seg-bloque { padding: 18px 0; border-top: 1px solid var(--border); }
.seg-cab { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.seg-cab h4 { margin: 0 0 2px; font-size: var(--fs-md); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg-cab p { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.seg-ico { width: 22px; height: 22px; color: var(--primary); margin-top: 1px; }
.seg-nota { font-size: var(--fs-sm); color: var(--muted); margin: 6px 0; }
.seg-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.seg-acciones button, .seg-bloque > button { margin-top: 0; }
.seg-bloque > button { margin-top: 6px; }
.seg-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.seg-item.ses-actual { border-color: var(--ok-border); background: #FAFDFB; }
.seg-item-ico { width: 24px; height: 24px; color: var(--text-2); flex: none; }
.seg-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.seg-item-txt b { font-size: var(--fs-base); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg-item-txt span { font-size: var(--fs-xs); color: var(--muted); }
.seg-item-acc { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.seg-item-acc button { margin: 0; }
.pk-input { min-height: 32px; padding: 4px 8px; font-size: var(--fs-base); width: 100%; max-width: 320px; }
.ses-lista { margin: 10px 0 14px; }
.codigos-rej { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; padding: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.codigos-rej code { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; text-align: center; padding: 6px; background: var(--surface); border-radius: var(--radius-xs); user-select: all; }

/* Asistente TOTP */
.tw { margin-top: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.tw-pasos { list-style: none; display: flex; gap: 6px; margin: 0 0 14px; padding: 0; flex-wrap: wrap; }
.tw-pasos li { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; padding-right: 10px; }
.tw-pasos li span { width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; background: var(--bg-2); color: var(--muted); }
.tw-pasos li.actual { color: var(--text); }
.tw-pasos li.actual span { background: var(--primary); color: #fff; }
.tw-pasos li.hecho span { background: var(--ok); color: #fff; }
.tw-qr { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.tw-qr img { width: 180px; height: 180px; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 6px; }
.tw-qr > div { flex: 1; min-width: 220px; }
.tw-qr p { margin: 0 0 8px; font-size: var(--fs-sm); }
.tw-clave { font-family: var(--mono); font-size: 14px; letter-spacing: .08em; user-select: all; word-break: break-all; background: var(--surface); padding: 4px 8px; border-radius: var(--radius-xs); border: 1px solid var(--border); margin-right: 6px; }
.tw-cod { max-width: 200px; font-size: 22px !important; letter-spacing: .3em; text-align: center; font-family: var(--mono); }
.tw-guardado { margin: 12px 0 4px; }

/* Instalar la app: aviso discreto y hoja de iOS */
.vc-instalar {
  position: fixed; z-index: var(--z-dock); left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom, 0px)); width: min(560px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: pop-in .25s var(--ease);
}
.vc-instalar img { border-radius: 10px; flex: none; }
.vc-instalar > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vc-instalar b { font-size: var(--fs-base); }
.vc-instalar span { font-size: var(--fs-xs); color: var(--muted); }
.vc-instalar button { margin: 0; flex: none; }
.vc-hoja-ios { max-width: 440px; margin: 0 auto; }
.ios-cab { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.ios-cab img { border-radius: 12px; flex: none; box-shadow: var(--shadow-sm); }
.ios-cab h3 { font-size: var(--fs-lg); }
.ios-cab p { margin: 2px 0 0; }
.ios-pasos { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.ios-pasos li { display: flex; gap: 12px; align-items: center; font-size: var(--fs-base); }
.ios-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-50); color: var(--primary); font-weight: 700; font-size: var(--fs-sm); display: inline-flex; align-items: center; justify-content: center; }
.ios-ico { width: 22px; height: 22px; color: var(--primary); vertical-align: -5px; margin: 0 2px; }
.ios-flecha { position: absolute; left: 50%; bottom: -9px; width: 18px; height: 18px; background: var(--surface); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: translateX(-50%) rotate(45deg); }
@media (min-width: 768px) { .vc-capa-abajo { align-items: center; } .ios-flecha { display: none; } }

/* Zonas seguras (notch, isla, barra de inicio) en la app instalada y en móvil */
@media (display-mode: standalone) {
  /* Barra de estado de iOS translúcida: franja de marca bajo el reloj y la batería */
  body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: env(safe-area-inset-top, 0px); background: var(--brand-navy); z-index: calc(var(--z-toast) + 20); pointer-events: none; }
  .login-main { padding-top: calc(48px + env(safe-area-inset-top, 0px)); padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .login-brand { padding-top: calc(48px + env(safe-area-inset-top, 0px)); }
  .sidebar { padding-left: env(safe-area-inset-left, 0px); }
  #view-container { padding-left: max(var(--page-x), env(safe-area-inset-left, 0px)); padding-right: max(var(--page-x), env(safe-area-inset-right, 0px)); }
}
#toasts { top: calc(20px + env(safe-area-inset-top, 0px)); right: calc(20px + env(safe-area-inset-right, 0px)); }
.import-indicator { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
#chat-launcher { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: calc(24px + env(safe-area-inset-right, 0px)); }
@media (max-width: 640px) {
  #toasts { top: auto; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  #chat-launcher { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .vc-hoja { padding: 22px 18px; }
  .vc-instalar { flex-wrap: wrap; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .vc-instalar > div { flex: 1 1 calc(100% - 60px); }
  .vc-instalar button { flex: 1 1 auto; min-height: 44px; }
  .seg-item { flex-wrap: wrap; }
  .seg-item-acc { width: 100%; justify-content: flex-start; }
  .seg-item-acc button { flex: 1 1 auto; }
  .codigos-rej { grid-template-columns: 1fr 1fr; padding: 10px; }
  .tw-qr img { width: 160px; height: 160px; }
  .pf-tabs button { padding: 10px 10px; font-size: var(--fs-sm); }
}
