/* ═══════════════════════════════════════════════════════════════
   ContaRD — Estilos principales
   Tema "Clutch Clean Trust": Azul #1B7499 · Tinta #17313B · Superficie #F8FAFC
   Sobrio y editorial: bordes finos, sin glows, radios 8px
   ═══════════════════════════════════════════════════════════════ */

/* ─── Variables ─────────────────────────────────────────────── */
/* ─── Tema "Clutch Clean Trust" · azul profesional, plano ────── */
:root {
  --primary:        #1B7499;   /* azul principal — acciones y acentos clave */
  --primary-light:  #4FA3C7;   /* azul claro — acentos sobre fondos oscuros */
  --primary-dark:   #155D7B;   /* azul profundo — texto sobre fondo claro */
  --primary-hover:  #16638A;
  --primary-lt:     #EAF4F8;   /* tinte azul suave — banners, chips */
  --primary-lt2:    #F4F9FB;
  --accent:         #1B7499;   /* alias del primario — sin acentos saturados */
  --accent-lt:      #D5E9F1;
  --accent-dark:    #155D7B;
  --accent-bg:      #EAF4F8;
  --accent-text:    #155D7B;
  --success:        #1E8449;
  --success-lt:     #EAF5EF;
  --warning:        #B54708;
  --warning-lt:     #FEF4E6;
  --danger:         #D92D20;
  --danger-lt:      #FDECEA;
  --info:           #4E88AE;
  --info-lt:        #EAF2F7;
  --neutral:        #F8FAFC;   /* superficie base de página */
  --neutral-dark:   #EDF1F5;
  --border:         #E5E7EB;
  --border-dark:    #D3D8DE;
  --white:          #FFFFFF;
  --text:           #17313B;   /* tinta azul-verdosa profunda */
  --text-muted:     #68737A;
  --text-light:     #9AA5AC;
  --sidebar-w:      240px;
  --sidebar-w-collapsed: 64px;
  --sidebar-bg:     #17313B;
  --card-bg:        var(--white);
  --card-surface:   var(--neutral);
  --header-h:       60px;
  /* Los tres únicos tamaños que estrena el modo tarea. Todo lo demás
     —colores, radios, sombras, cuerpos de letra— sale de arriba. */
  --tarea-barra-h:    60px;   /* la barra de tarea, a la altura de la cabecera */
  --tarea-rail-w:     252px;  /* el rail de pasos */
  --tarea-contexto-w: 320px;  /* la columna donde se ve el asiento */
  --radius:         8px;
  --radius-sm:      4px;
  --radius-lg:      12px;
  --radius-round:   9999px;
  --shadow-sm:      0 1px 2px rgba(23,49,59,0.05);
  --shadow:         0 2px 8px rgba(23,49,59,0.08);
  --shadow-lg:      0 8px 24px rgba(23,49,59,0.12);
  --shadow-card:    none;
  --shadow-focus:   0 0 0 3px rgba(27,116,153,0.15);
  --transition:     0.2s ease;
}

/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Roboto', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--neutral);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── Iconos ─────────────────────────────────────────────────── */
/* El marcado lo produce modules/iconos.js; aquí solo el tamaño.
   1em: el icono crece y mengua con la letra que lo rodea, y el
   viewBox conserva la proporción, así que nunca se deforma. El
   color lo hereda del texto por currentColor. */
.ico {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.14em;
  flex-shrink: 0;
}

/* ─── App Shell ──────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  flex-shrink: 0;
  transition: width var(--transition);
}

/* Logo */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.logo-name {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.02em;
}
.logo-sub {
  font-size: 0.68rem;
  opacity: 0.65;
  white-space: nowrap;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 8px 0;
  /* Columna: es lo que deja anclar reportes y configuración al pie
     del menú sin sacarlos del flujo cuando la lista crece. */
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.45);
}

/* Las anclas: la pantalla de entrada arriba, reportes y
   configuración abajo del todo, fuera de los grupos plegables. */
/* Sin esto los tres bloques se encogerían entre ellos al no caber,
   en vez de dejar que el menú se desplace. */
.nav-anclas, .nav-grupos { flex-shrink: 0; }
.nav-anclas-arriba { padding-bottom: 4px; }
.nav-anclas-abajo {
  margin-top: auto;               /* siempre al pie, aunque sobre sitio */
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.nav-section-label {
  display: flex;
  align-items: center;
  position: relative;             /* ancla del contador plegado a punto */
  gap: 12px;
  width: 100%;
  padding: 11px 16px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  transition: color var(--transition);
}
.nav-section-label:hover { color: rgba(255,255,255,0.85); }
.nav-section-label:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: -2px;
}
/* Con el menú plegado a solo iconos, el icono del grupo es lo único
   que queda de su cabecera: por eso lo llevan también los grupos. */
.nav-section-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.nav-section-nombre {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* La suma de lo pendiente que hay dentro del grupo. Solo se ve con el
   grupo plegado: al abrirlo el número baja a la entrada que lo genera.
   Misma píldora que la de las entradas, algo más pequeña porque
   convive con una etiqueta de 0.68rem. */
.nav-section-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 1px 6px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0;
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}
.nav-section-badge.hidden { display: none; }

.nav-section-caret {
  display: inline-flex;
  font-size: 0.7rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}
.nav-section-label.collapsed .nav-section-caret { transform: rotate(-90deg); }

.nav-section-items { overflow: hidden; }
.nav-section-items.collapsed { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
  color: rgba(255,255,255,0.75);
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  user-select: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}
.nav-item.active {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border-left-color: var(--primary-light);
}
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: 1.05rem;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-label {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.nav-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 20px;
  text-align: center;
  line-height: 1.4;
}
.nav-badge.beta { background: var(--warning); }
.nav-badge.hidden { display: none; }

/* Submenú desplegable del sidebar (acordeón de Configuración) */
.nav-caret {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.nav-subitem {
  padding-left: 46px;             /* alineado con la etiqueta, no con el icono */
}
.nav-subitem .nav-label {
  font-size: 0.78rem;
  font-weight: 400;
  opacity: 0.9;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.sidebar-footer-user {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.sidebar-footer-user:hover,
.sb-desplegable.abierto > .sidebar-footer-user {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
}
.sb-desplegable { position: relative; }
.footer-avatar {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.footer-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.footer-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.footer-role {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}

/* ─── Main Wrapper ───────────────────────────────────────────── */
#main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Header ─────────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--neutral); color: var(--text); }

/* ─── Controles de la cabecera ───────────────────────────────
   Empresa, período, «Nuevo», avisos y avatar. El alto de la barra
   no cambia: --header-h sigue siendo 60px y todo lo de dentro se
   dimensiona para caber en ella, incluido el bloque de dos líneas
   de la empresa. */
.header-controles {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* El control pulsable: lo que antes era un rótulo fijo. */
.hdr-control {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 4px 8px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.hdr-control:hover { background: var(--neutral); border-color: var(--border); }
.hdr-desplegable.abierto > .hdr-control {
  background: var(--neutral);
  border-color: var(--border-dark);
}
.hdr-caret { color: var(--text-light); display: flex; font-size: 0.8rem; }
.hdr-ico   { color: var(--text-muted); display: flex; }

.hdr-desplegable { position: relative; min-width: 0; }

/* Identidad de la empresa. Aquí hubo un punto de color que
   distinguía una empresa de otra en el selector; con una sola
   empresa por instalación no distingue nada, y se fue con él. */
.hdr-empresa-txt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  line-height: 1.25;
}
.hdr-empresa-nombre {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  max-width: 22ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr-empresa-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26ch;
}

/* Disparador de la búsqueda. Ocupa el espacio que separa la
   identidad de los controles de la derecha, y enseña su atajo: un
   atajo que no se ve no lo usa nadie. */
.hdr-busqueda-hueco { flex: 1; min-width: 12px; }
.hdr-busqueda {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--neutral);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 10px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.hdr-busqueda:hover { background: var(--white); border-color: var(--border-dark); }
.hdr-busqueda-ico   { display: flex; color: var(--text-light); }
.hdr-busqueda-txt   { flex: 1; text-align: left; white-space: nowrap;
                      overflow: hidden; text-overflow: ellipsis; }
.hdr-busqueda-atajo {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  background: var(--white);
  white-space: nowrap;
}

/* Período contable */
.hdr-periodo-txt {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
}
.hdr-periodo { background: var(--primary-lt); border-color: var(--primary-lt); }
.hdr-periodo:hover { background: var(--accent-lt); border-color: var(--accent-lt); }
.hdr-periodo .hdr-ico, .hdr-periodo .hdr-caret { color: var(--primary-dark); }

/* Botón «Nuevo» */
.hdr-nuevo { padding: 6px 10px; }
.hdr-nuevo .hdr-caret { color: rgba(255,255,255,0.75); }

/* Botones que son solo icono (avisos) */
.hdr-icono {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.hdr-icono:hover { background: var(--neutral); color: var(--text); }
.hdr-avisos.con-avisos { color: var(--warning); }
.hdr-aviso-punto {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--white);
}

/* El panel que abre cada control */
.hdr-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-width: 320px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
}
.hdr-menu[hidden] { display: none; }
.hdr-menu-der  { left: auto; right: 0; }
.hdr-menu-alto { max-height: 320px; overflow-y: auto; }
.hdr-menu-titulo {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 6px 10px 4px;
}
.hdr-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.hdr-menu-item:hover { background: var(--neutral); }
.hdr-menu-item.activa { color: var(--primary-dark); font-weight: 700; }
.hdr-menu-ico  { display: flex; width: 16px; color: var(--text-muted); flex-shrink: 0; }
.hdr-menu-item.activa .hdr-menu-ico { color: var(--primary); }
.hdr-menu-txt  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hdr-menu-cant {
  background: var(--warning-lt);
  color: var(--warning);
  border-radius: var(--radius-round);
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.hdr-menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.hdr-menu-vacio {
  padding: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* El menú del avatar abre hacia arriba: vive al pie del sidebar y no
   hay espacio debajo. */
.sb-menu {
  top: auto;
  bottom: calc(100% + 6px);
  left: 4px;
  right: 4px;
  min-width: 0;
}
.sb-menu-rol {
  padding: 0 10px 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}
.header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Content Area ───────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  color: var(--text-muted);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ─── Page Header ────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ─── Cards & Metrics ────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow); }
.metric-card .mc-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 8px;
}
.metric-card .mc-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.metric-card .mc-value.danger  { color: var(--danger); }
.metric-card .mc-value.success { color: var(--success); }
.metric-card .mc-value.warning { color: var(--warning); }
.metric-card .mc-trend {
  font-size: 0.74rem;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.mc-trend.up   { color: var(--success); }
.mc-trend.down { color: var(--danger); }
.mc-trend.neutral { color: var(--text-muted); }
.mc-icon {
  float: right;
  font-size: 1.6rem;
  margin-top: -4px;
  opacity: 0.15;
}

/* ─── Panel / Card ───────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  overflow: visible;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ─── Alerts / Vencimientos ──────────────────────────────────── */
.alert-list { list-style: none; }
.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.alert-item:last-child { border-bottom: none; }
.alert-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red    { background: var(--danger); }
.dot-yellow { background: var(--warning); }
.dot-green  { background: var(--success); }
.dot-gray   { background: var(--text-light); }
.alert-body { flex: 1; }
.alert-title { font-size: 0.82rem; font-weight: 600; }
.alert-desc  { font-size: 0.74rem; color: var(--text-muted); }
.alert-date  { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; }

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-wrap { margin: 8px 0 4px; }
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--success);
  transition: width 0.6s ease;
}
.progress-fill.warning { background: var(--warning); }
.progress-fill.danger  { background: var(--danger); }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Chart Container ────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  height: 240px;
}

/* ─── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}
.tab-btn {
  background: none;
  border: none;
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn:hover { color: var(--text); background: var(--neutral); }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ─── Cabecera de módulo ─────────────────────────────────────── */
/* Las tres piezas que sitúan una pantalla: la miga de pan, la cinta
   del ciclo y las pestañas que filtran. El marcado sale de
   modules/cabecera-modulo.js. Ni un color, radio ni tamaño nuevo:
   todo son las variables que ya estaban. */

.mod-cabecera { margin-bottom: 20px; }

/* La miga: pasos pulsables y, al final, dónde se está. */
.mod-miga {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 0.72rem;
}
.mod-miga-paso {
  background: none;
  border: none;
  padding: 1px 3px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.mod-miga-paso:hover { color: var(--primary-dark); background: var(--primary-lt); }
.mod-miga-aqui {
  font-weight: 700;
  color: var(--text);
  padding: 1px 3px;
}
.mod-miga-sep { display: flex; color: var(--text-light); font-size: 0.68rem; }

/* Los botones de la derecha del título. */
.mod-acciones {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* El botón primario partido: una sola pieza con dos zonas
   pulsables, separadas por una línea y no por un hueco. */
.btn-partido { display: flex; position: relative; }
.btn-partido .btn-partido-cara {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.btn-partido .btn-partido-caret {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding-left: 8px;
  padding-right: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}
.mod-desplegable { position: relative; }
.mod-menu { min-width: 280px; }
.mod-menu-item { align-items: flex-start; }
.mod-menu-item .hdr-menu-ico { margin-top: 2px; }
.mod-menu-item .hdr-menu-txt { white-space: normal; overflow: visible; }
.mod-menu-nombre { display: block; font-weight: 600; }
.mod-menu-desc {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* La cinta del ciclo. El número de cada etapa es el trabajo detenido
   en ella; la etapa donde se está no se pulsa, las vecinas sí. */
.mod-cinta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--primary-lt2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mod-cinta-nombre {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
}
.mod-cinta-etapas {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.mod-cinta-sep { display: flex; color: var(--text-light); font-size: 0.68rem; }
.mod-cinta-nota {
  font-size: 0.68rem;
  color: var(--text-light);
  white-space: nowrap;
}
.mod-etapa {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-round);
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.mod-etapa:hover { background: var(--white); border-color: var(--border-dark); color: var(--text); }
.mod-etapa.actual {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  cursor: default;
}
.mod-etapa-cont {
  min-width: 18px;
  text-align: center;
  border-radius: var(--radius-round);
  padding: 0 6px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--neutral-dark);
  color: var(--text-muted);
}
.mod-etapa.con-cola .mod-etapa-cont { background: var(--warning-lt); color: var(--warning); }
.mod-etapa.actual .mod-etapa-cont { background: rgba(255, 255, 255, 0.22); color: #fff; }

/* Las pestañas que filtran la lista. El filtro destacado es el que
   abre un trabajo urgente; su nota dice qué pasa si se deja. */
.mod-filtros { margin-bottom: 12px; }
.mod-filtro { display: inline-flex; align-items: center; gap: 6px; }
.mod-filtro-cant {
  border-radius: var(--radius-round);
  padding: 0 7px;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--neutral-dark);
  color: var(--text-muted);
}
.mod-filtro.active .mod-filtro-cant { background: var(--primary-lt); color: var(--primary-dark); }
.mod-filtro-alerta { color: var(--danger); }
.mod-filtro-alerta:hover { color: var(--danger); background: var(--danger-lt); }
.mod-filtro-alerta.active { color: var(--danger); border-bottom-color: var(--danger); }
.mod-filtro-alerta .mod-filtro-cant,
.mod-filtro-alerta.active .mod-filtro-cant { background: var(--danger-lt); color: var(--danger); }
.mod-filtro-nota {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: -4px 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  background: var(--primary-lt);
  color: var(--primary-dark);
  border-left: 3px solid var(--primary);
}
.mod-filtro-nota.alerta {
  background: var(--danger-lt);
  color: var(--danger);
  border-left-color: var(--danger);
}

/* Vuelta a la lista desde un trabajo largo. Hasta el ticket 11 el
   alta y el lote siguen viviendo dentro de la pantalla. */
.mod-volver {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 11px;
  margin-bottom: 14px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.mod-volver:hover { background: var(--neutral); color: var(--text); }

@media (max-width: 900px) {
  .mod-cinta-nota { display: none; }
}

/* ─── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
thead th {
  background: var(--primary-lt2);
  color: var(--primary-dark);
  font-weight: 700;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--primary-lt);
  position: sticky;
  top: 0;
  z-index: 1;
}
thead th.text-right { text-align: right; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:nth-child(even) { background: #FAFBFC; }
tbody tr:hover { background: var(--primary-lt2); }
td { padding: 9px 12px; }
td.text-right { text-align: right; }
td.text-center { text-align: center; }
tfoot td {
  font-weight: 700;
  background: var(--primary-lt);
  color: var(--primary-dark);
  padding: 10px 12px;
  border-top: 2px solid var(--primary-lt);
}

/* ─── Guía de puesta en marcha ───────────────────────────────── */
.onb-card { margin-bottom: 20px; border-left: 3px solid var(--primary); }
.onb-sub { margin: 2px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.onb-barra { height: 3px; background: var(--neutral-dark); }
.onb-barra-fill {
  height: 100%;
  background: var(--primary);
  transition: width var(--transition);
}
.onb-lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.onb-paso {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.onb-paso:last-child { border-bottom: 0; }
.onb-check {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.74rem; font-weight: 700;
  background: var(--neutral-dark);
  color: var(--text-muted);
  border: 1px solid var(--border-dark);
}
.onb-paso.done .onb-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.onb-texto { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.onb-titulo { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.onb-paso.done .onb-titulo { color: var(--text-muted); text-decoration: line-through; }
.onb-detalle { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }
.onb-listo { font-size: 0.75rem; font-weight: 700; color: var(--success); white-space: nowrap; }

@media (max-width: 640px) {
  .onb-paso { flex-wrap: wrap; }
  .onb-texto { flex-basis: calc(100% - 36px); }
}

/* ─── Hub de reportes ────────────────────────────────────────── */
.rh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.rh-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-family: inherit;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.rh-card:hover {
  border-color: var(--primary);
  background: var(--primary-lt2);
}
.rh-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.rh-card-title { font-weight: 700; font-size: 0.84rem; color: var(--text); }
.rh-card-desc  { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }

/* ─── Paginación de listados ─────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--neutral);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.pag-group { display: flex; align-items: center; gap: 8px; }
.pag-label { color: var(--text-muted); }
.pag-select {
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  padding: 3px 6px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
}
.pag-range,
.pag-actual { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pag-actual { color: var(--text); font-weight: 600; padding: 0 4px; }
.pag-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--primary-dark);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition);
}
.pag-btn:hover:not(:disabled) { background: var(--primary-lt); }
.pag-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pag-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ─── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: var(--success-lt); color: var(--success); }
.badge-warning { background: var(--warning-lt); color: var(--warning); }
.badge-danger  { background: var(--danger-lt);  color: var(--danger); }
.badge-info    { background: var(--primary-lt);  color: var(--primary-dark); }
.badge-gray    { background: var(--neutral-dark); color: var(--text-muted); }
.badge-gold    { background: var(--primary-lt); color: var(--primary-dark); }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #17693A; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B3251A; }

.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #93390A; }

.btn-gold      { background: var(--primary-lt); color: var(--primary-dark); border: 1px solid var(--accent-lt); }
.btn-gold:hover:not(:disabled) { background: var(--accent-lt); }

.btn-outline   {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover:not(:disabled) { background: var(--primary-lt); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--neutral); color: var(--text); }

.btn-sm { padding: 5px 11px; font-size: 0.75rem; }
.btn-lg { padding: 11px 22px; font-size: 0.9rem; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.form-label .required { color: var(--danger); margin-left: 3px; }
.form-control {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}
.form-control::placeholder { color: var(--text-light); }
.form-control:disabled,
input.form-control:read-only,
textarea.form-control:read-only { background: var(--neutral); color: var(--text-muted); cursor: not-allowed; }
.form-control.error { border-color: var(--danger); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-row-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }

.input-group { display: flex; gap: 8px; align-items: flex-end; }
.input-group .form-control { flex: 1; }

.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.72rem; color: var(--danger); margin-top: 4px; }

/* NCF display */
.ncf-display {
  background: var(--primary-lt);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.03em;
}

/* ─── Invoice Line Items ─────────────────────────────────────── */
.line-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 8px;
}
.line-items-table th {
  background: var(--neutral);
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid var(--border);
  font-size: 0.75rem;
}
.line-items-table td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  vertical-align: middle;
}
.line-items-table td input,
.line-items-table td select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 0.8rem;
  color: var(--text);
  padding: 2px 4px;
}
.line-items-table td input:focus,
.line-items-table td select:focus { outline: 1px solid var(--primary); background: var(--primary-lt2); }
.line-items-table .td-action { text-align: center; width: 36px; }
.line-items-table .td-num { text-align: right; color: var(--text-muted); }
.line-items-table .td-total { text-align: right; font-weight: 600; color: var(--text); }

/* ─── Totals Box ─────────────────────────────────────────────── */
.totals-box {
  background: var(--primary-lt);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.82rem;
}
.totals-row .tr-label { color: var(--text-muted); }
.totals-row .tr-val { font-weight: 600; color: var(--text); }
.totals-divider { border: none; border-top: 1px solid var(--primary-lt); margin: 8px 0; }
.totals-row.total-final .tr-label { font-weight: 700; color: var(--text); font-size: 0.88rem; }
.totals-row.total-final .tr-val   { font-weight: 700; color: var(--primary-dark); font-size: 1rem; }
.totals-row.total-pagar .tr-val   { color: var(--danger); font-weight: 800; font-size: 1rem; }
.totals-row.total-favor .tr-val   { color: var(--success); font-weight: 800; font-size: 1rem; }

/* ─── ITBIS Liquidation ──────────────────────────────────────── */
.liq-section { margin-bottom: 16px; }
.liq-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 8px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.liq-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 6px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border);
}
.liq-row:last-child { border-bottom: none; }
.liq-row .liq-label { color: var(--text); }
.liq-row .liq-base  { text-align: right; color: var(--text-muted); font-size: 0.78rem; min-width: 120px; }
.liq-row .liq-tax   { text-align: right; font-weight: 600; min-width: 110px; }
.liq-row.subtraction .liq-tax { color: var(--danger); }
.liq-row.addition   .liq-tax { color: var(--success); }
.liq-subtotal {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  font-weight: 700;
  font-size: 0.85rem;
  border-top: 2px solid var(--border);
  color: var(--primary);
  margin-top: 4px;
}
.liq-total-final {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--danger-lt);
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 800;
  color: var(--danger);
  margin-top: 16px;
}

/* ─── ISR Calculator ─────────────────────────────────────────── */
.calc-table { width: 100%; }
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  gap: 12px;
}
.calc-row:last-child { border-bottom: none; }
.calc-label { color: var(--text); flex: 1; }
.calc-input-wrap { flex-shrink: 0; width: 160px; }
.calc-input-wrap .form-control { text-align: right; }
.calc-result {
  font-weight: 700;
  color: var(--text);
  text-align: right;
  min-width: 140px;
}
.calc-result.success { color: var(--success); }
.calc-result.danger  { color: var(--danger); }
.calc-highlight {
  background: var(--primary-lt);
  margin: 0 -20px;
  padding: 10px 20px;
  border-radius: 0;
}
.calc-highlight .calc-label { font-weight: 700; color: var(--primary); }
.calc-highlight .calc-result { font-size: 1rem; }

/* ─── Salary / TSS Table ─────────────────────────────────────── */
.tss-scale {
  background: var(--neutral);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 0.8rem;
}
.tss-scale-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.tss-scale-row:last-child { border-bottom: none; }

/* ─── Calendar ───────────────────────────────────────────────── */
.cal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-month-label { font-size: 1rem; font-weight: 700; }
.cal-nav-btn {
  background: var(--neutral);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-nav-btn:hover { background: var(--border); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-day-header {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-day {
  min-height: 82px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-day:hover { background: var(--primary-lt2); }
.cal-day.other-month { background: #F5F7F9; opacity: 0.6; }
.cal-day.today { border-color: var(--primary); background: var(--primary-lt2); }
.cal-day-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: 4px;
}
.cal-day.today .cal-day-num {
  background: var(--primary);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  margin-bottom: 4px;
}
.cal-event {
  font-size: 0.67rem;
  border-radius: 3px;
  padding: 2px 5px;
  margin-top: 2px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.cal-event.ev-red    { background: var(--danger-lt);  color: var(--danger); }
.cal-event.ev-yellow { background: var(--warning-lt); color: var(--warning); }
.cal-event.ev-green  { background: var(--success-lt); color: var(--success); }
.cal-event.ev-gray   { background: var(--neutral-dark); color: var(--text-muted); text-decoration: line-through; }

.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.cal-legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ─── Reports / File Download ────────────────────────────────── */
.report-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--white);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--transition);
}
.report-card:hover { box-shadow: var(--shadow); }
.report-icon {
  font-size: 2rem;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  background: var(--primary-lt);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}
.report-info { flex: 1 }
.report-name { font-weight: 700; font-size: 0.88rem; color: var(--text); }
.report-desc { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }
.report-meta { font-size: 0.73rem; color: var(--text-light); margin-top: 3px; }

/* RNC Validator */
.rnc-result {
  background: var(--success-lt);
  border: 1px solid var(--success);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 12px;
}
.rnc-result.not-found {
  background: var(--danger-lt);
  border-color: var(--danger);
}

/* ─── IA Module ──────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--white);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-lt2);
}
.upload-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 5px; }
.upload-sub { font-size: 0.78rem; color: var(--text-muted); }
.upload-types {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}
.upload-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--neutral);
  cursor: pointer;
  transition: all var(--transition);
}
.upload-type-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-lt); }
.upload-type-btn span:first-child { font-size: 1.3rem; }

/* Review Items */
.review-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.review-item:hover { box-shadow: var(--shadow); }
.review-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.ri-conf-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ri-title { flex: 1; font-weight: 600; font-size: 0.84rem; }
.ri-meta { font-size: 0.74rem; color: var(--text-muted); }
.ri-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--neutral);
}
.ri-warning {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--warning);
  padding: 6px 16px;
  background: var(--warning-lt);
  border-top: 1px solid rgba(212,118,10,0.2);
}

/* Confidence bars */
.conf-bar-wrap { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.75rem; }
.conf-bar-label { width: 90px; color: var(--text-muted); }
.conf-bar-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.conf-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.conf-high   { background: var(--success); }
.conf-medium { background: var(--warning); }
.conf-low    { background: var(--danger); }
.conf-pct { width: 34px; text-align: right; font-weight: 600; }

/* Mode selector (IA) */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.mode-card:hover { border-color: var(--primary); background: var(--primary-lt2); }
.mode-card.selected { border-color: var(--primary); background: var(--primary-lt); }
.mode-card .mc-emoji { font-size: 1.8rem; margin-bottom: 8px; }
.mode-card .mc-name  { font-weight: 700; font-size: 0.88rem; margin-bottom: 4px; }
.mode-card .mc-desc  { font-size: 0.76rem; color: var(--text-muted); }

/* IA Stats */
.ia-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.ia-stat {
  background: var(--neutral);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.ia-stat .ist-value { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.ia-stat .ist-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }

/* ─── IA Settings ────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { flex: 1; }
.settings-row-label strong { display: block; font-size: 0.84rem; margin-bottom: 2px; }
.settings-row-label span { font-size: 0.76rem; color: var(--text-muted); }
.toggle-switch {
  width: 42px;
  height: 24px;
  background: var(--border-dark);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
  border: none;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on::after { left: 21px; }

/* ─── Banner (preview modules) ───────────────────────────────── */
.preview-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.preview-banner-icon { font-size: 2rem; flex-shrink: 0; }
.preview-banner-text h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 4px; }
.preview-banner-text p  { font-size: 0.8rem; opacity: 0.8; }

/* ─── Quarterly Advances ─────────────────────────────────────── */
.quarter-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.quarter-item:last-child { border-bottom: none; }
.quarter-status { font-size: 1.1rem; flex-shrink: 0; }
.quarter-label { flex: 1; }
.quarter-label strong { display: block; font-size: 0.84rem; }
.quarter-label span { font-size: 0.74rem; color: var(--text-muted); }
.quarter-amount { font-weight: 700; font-size: 0.88rem; color: var(--text); }

/* ─── Toasts ─────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #17313B;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 340px;
  pointer-events: all;
  animation: toastIn 0.28s ease;
}
.toast.out { animation: toastOut 0.25s ease forwards; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--primary); }
.toast-icon    { font-size: 1rem; flex-shrink: 0; }
.toast-text    { flex: 1; line-height: 1.3; }

/* ─── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.46);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
  animation: modalIn 0.22s ease;
}
.modal-lg  { max-width: 820px; }
.modal-xl  { max-width: 1050px; }
.modal-sm  { max-width: 420px; }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}
.modal-title { font-size: 0.96rem; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--neutral); color: var(--text); }

.modal-body   { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--neutral);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  position: sticky;
  bottom: 0;
  z-index: 1;
}

/* ─── Spinner (inline) ───────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-dark {
  border-color: rgba(27,116,153,0.25);
  border-top-color: var(--primary);
}

/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state .es-icon { font-size: 2.8rem; margin-bottom: 12px; }
.empty-state .es-title { font-size: 0.92rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.empty-state .es-desc  { font-size: 0.8rem; }

/* ─── PDF Preview ────────────────────────────────────────────── */
.invoice-preview {
  font-size: 0.82rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.inv-header {
  background: var(--primary);
  color: #fff;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.inv-header h2 { font-size: 1.2rem; font-weight: 800; }
.inv-header p  { font-size: 0.76rem; opacity: 0.8; margin-top: 2px; }
.inv-ncf-block { text-align: right; }
.inv-ncf-label { font-size: 0.68rem; opacity: 0.7; text-transform: uppercase; }
.inv-ncf-num   { font-size: 1rem; font-weight: 700; }
.inv-body { padding: 20px 24px; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 16px; }
.inv-party-label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.inv-party-name  { font-weight: 700; font-size: 0.88rem; }
.inv-party-meta  { font-size: 0.76rem; color: var(--text-muted); }

/* ─── Slider ─────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}
.slider-row label { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--primary); }
.slider-value { font-weight: 700; font-size: 0.9rem; color: var(--primary); min-width: 80px; text-align: right; }

/* ─── Utility ────────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 10px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 20px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 28px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 28px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.font-bold    { font-weight: 700; }
.font-mono    { font-family: 'Consolas', 'Courier New', monospace; }
.hidden       { display: none !important; }
.full-width   { width: 100%; }
.separator    { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalIn {
  from { transform: scale(0.95) translateY(-8px); opacity: 0; }
  to   { transform: scale(1) translateY(0);        opacity: 1; }
}

/* ─── Sidebar Collapsed (JS adds .collapsed to #sidebar) ─────── */
/* Plegado a solo iconos. Antes se mostraba la inicial de la etiqueta
   —«F» para Facturación y «F» para Facturas, indistinguibles—; ahora
   queda el icono, que es lo que el menú tiene para reconocerse de un
   vistazo. Las cabeceras de grupo se quedan: sin ellas no habría
   forma de abrir otro grupo sin desplegar el menú entero. */
#sidebar.collapsed { width: var(--sidebar-w-collapsed); }
#sidebar.collapsed .logo-text,
#sidebar.collapsed .logo-sub,
#sidebar.collapsed .nav-label,
#sidebar.collapsed .nav-caret,
#sidebar.collapsed .nav-section-nombre,
#sidebar.collapsed .nav-section-caret,
#sidebar.collapsed .nav-subitem,
#sidebar.collapsed .nav-badge,
#sidebar.collapsed .footer-info { display: none; }
/* El contador del grupo no cabe como número junto a un icono de 18px,
   y es justo aquí donde más falta hace saber que hay trabajo dentro:
   se queda, reducido a un punto. */
#sidebar.collapsed .nav-section-badge {
  position: absolute;
  top: 6px;
  right: 12px;
  width: 8px;
  height: 8px;
  min-width: 0;
  padding: 0;
  font-size: 0;
  border-radius: 50%;
}
#sidebar.collapsed .sidebar-logo { justify-content: center; padding: 18px 0; }
#sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
#sidebar.collapsed .nav-section-label {
  justify-content: center;
  padding: 10px 0 4px;
  gap: 0;
}
#sidebar.collapsed .nav-anclas-abajo { padding-top: 4px; }
#sidebar.collapsed .sidebar-footer-user { justify-content: center; }

/* ─── Modo tarea ─────────────────────────────────────────────── */
/* Las tareas largas salen del menú: barra de tarea arriba, rail de
   pasos, contenido y barra de avance abajo. El marcado sale de
   modules/modo-tarea.js. Es una capa encima de la aplicación, no una
   pantalla más: al vaciarla, el menú y la cabecera vuelven a estar
   donde estaban. Ni un color, radio ni cuerpo de letra nuevo: solo
   los tres tamaños que el spec autoriza. */

#modo-tarea {
  position: fixed;
  inset: 0;
  z-index: 700;          /* encima de la aplicación, debajo de los modales */
  background: var(--neutral);
  display: none;
  flex-direction: column;
}
/* La hoja de estilos es la dueña de mostrar y ocultar la capa: las
   tareas solo ponen y quitan esta clase en el body, nunca escriben
   el modo de presentación de #modo-tarea desde JavaScript. */
body.en-modo-tarea #modo-tarea { display: flex; }

/* Mientras dura la tarea, el asistente flotante se retira: es lo
   único de la aplicación que quedaba por encima de esta capa, y
   distrae de lo que toca ahora. */
body.en-modo-tarea #ast-fab,
body.en-modo-tarea #ast-panel { display: none !important; }

/* La barra de tarea: qué se hace, por dónde va y cómo se sale. */
.tarea-barra {
  flex-shrink: 0;
  height: var(--tarea-barra-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--sidebar-bg);
  color: var(--white);
}
.tarea-barra-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tarea-barra-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  font-size: 1rem;
}
.tarea-titulo {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.tarea-subtitulo {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.2;
}
.tarea-barra-centro { flex: 1; display: flex; align-items: center; gap: 12px; }
.tarea-paso-de {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.03em;
}
.tarea-aviso { font-size: 0.74rem; color: var(--primary-light); }
.tarea-barra-acciones { display: flex; align-items: center; gap: 8px; }
.tarea-salir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--white);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.78rem;
  transition: background var(--transition);
}
.tarea-salir:hover { background: rgba(255, 255, 255, 0.2); }

/* El cuerpo: rail, contenido y —si la tarea la usa— la columna de
   contexto. Cada zona se desplaza por su cuenta. */
.tarea-cuerpo {
  flex: 1;
  display: grid;
  grid-template-columns: var(--tarea-rail-w) minmax(0, 1fr);
  min-height: 0;
}
.tarea-cuerpo:has(.tarea-contexto) {
  grid-template-columns: var(--tarea-rail-w) minmax(0, 1fr) var(--tarea-contexto-w);
}

/* El rail: en qué paso se está, cuáles quedan y a cuáles se vuelve. */
.tarea-rail {
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--white);
  overflow-y: auto;
  padding: 18px 0;
}
.tarea-rail ol { list-style: none; }
.tarea-paso-cara {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  padding: 10px 16px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
}
button.tarea-paso-cara:hover { background: var(--primary-lt2); color: var(--text); }
.tarea-paso-marca {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-round);
  border: 1px solid var(--border-dark);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.tarea-paso-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tarea-paso-nombre { font-weight: 600; }
.tarea-paso-desc { font-size: 0.72rem; color: var(--text-light); line-height: 1.3; }
.tarea-paso.es-hecho .tarea-paso-cara { color: var(--text); }
.tarea-paso.es-hecho .tarea-paso-marca {
  border-color: var(--success);
  color: var(--success);
}
.tarea-paso.es-actual .tarea-paso-cara {
  border-left-color: var(--primary);
  background: var(--primary-lt);
  color: var(--primary-dark);
}
.tarea-paso.es-actual .tarea-paso-marca {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}
/* Un paso al que todavía no se ha llegado se ve, pero no se pulsa:
   el rail dice por dónde va la tarea, no es un índice para saltarse
   el trabajo. */
.tarea-paso.es-pendiente .tarea-paso-cara { opacity: 0.5; }

/* El contenido, en el centro y con medida de columna de lectura: un
   formulario a todo lo ancho de la pantalla no se lee. */
.tarea-contenido { min-height: 0; overflow-y: auto; padding: 26px 32px 32px; }
.tarea-panel { max-width: 780px; }
.tarea-h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.tarea-h3 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.tarea-intro {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  max-width: 62ch;
}

/* La columna de contexto: lo que va saliendo del gasto mientras se
   escribe —la liquidación y el asiento—. */
.tarea-contexto {
  min-height: 0;
  border-left: 1px solid var(--border);
  background: var(--white);
  overflow-y: auto;
  padding: 20px;
}
.tarea-contexto-titulo {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.tarea-contexto-titulo + * { margin-bottom: 18px; }
.tarea-contexto-vacio {
  font-size: 0.8rem;
  color: var(--text-light);
  line-height: 1.5;
}
.tarea-contexto-vacio .ico { font-size: 1.4rem; display: block; margin-bottom: 8px; }

/* La barra de avance. */
.tarea-avance {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
}
.tarea-avance-medida { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tarea-avance-barra {
  width: 160px;
  height: 5px;
  border-radius: var(--radius-round);
  background: var(--neutral-dark);
  overflow: hidden;
}
.tarea-avance-barra span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width var(--transition);
}
.tarea-avance-texto { font-size: 0.78rem; color: var(--text-muted); }
.tarea-guardado { font-size: 0.72rem; color: var(--success); }
.tarea-avance-botones { display: flex; align-items: center; gap: 8px; }

/* ─── El alta de un gasto en modo tarea ──────────────────────── */
/* Lo propio de esta tarea: la zona de lectura por IA, los campos que
   la IA leyó con dudas, la nota de la precarga por suplidor y la
   lista de lo que va a cambiar al registrar. */

.gt-lectura {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  background: var(--primary-lt2);
  padding: 14px 16px;
  margin-bottom: 20px;
}
.gt-lectura-nota { flex: 1; min-width: 220px; font-size: 0.76rem; color: var(--text-muted); }

.gt-adjunto {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  background: var(--neutral);
  transition: border-color var(--transition);
}
.gt-adjunto:hover { border-color: var(--primary); }
.gt-adjunto-titulo { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.gt-adjunto-nota { font-size: 0.72rem; color: var(--text-muted); }

/* Lo que la IA leyó con poca confianza. La confianza la devuelve el
   backend por bloque desde siempre; lo que faltaba era enseñarla. */
.form-group.es-dudoso {
  border-left: 3px solid var(--warning);
  padding-left: 10px;
  margin-left: -13px;
}
.form-group.es-dudoso .form-control { border-color: var(--warning); background: var(--warning-lt); }
.gt-dudoso-nota { font-size: 0.72rem; color: var(--warning); margin-top: 4px; }

/* La precarga por suplidor, dicha en voz alta. */
.gt-precarga {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-lt);
  padding: 12px 14px;
  margin-bottom: 18px;
}
.gt-precarga.es-limpia {
  border-left-color: var(--border-dark);
  background: var(--neutral);
}
.gt-precarga-ico { color: var(--primary-dark); font-size: 1.1rem; }
.gt-precarga-texto { font-size: 0.8rem; color: var(--text); line-height: 1.45; }

/* La liquidación y el asiento, en la columna de contexto y otra vez
   en el paso de revisar. */
.gt-datos { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 0.8rem; }
.gt-datos dt { color: var(--text-muted); }
.gt-datos dd { text-align: right; font-variant-numeric: tabular-nums; }

.gt-asiento { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.gt-asiento th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
}
.gt-asiento td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.gt-asiento .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gt-asiento tfoot td { font-weight: 700; border-bottom: none; }
.gt-descuadre {
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--danger);
  background: var(--danger-lt);
  border-radius: var(--radius);
  padding: 8px 10px;
  line-height: 1.45;
}

/* Lo que va a cambiar al registrar. */
.gt-resumen-doc {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 12px 14px;
}
.gt-resumen-prov { font-weight: 700; }
.gt-resumen-detalle { flex: 1; font-size: 0.78rem; color: var(--text-muted); }
.gt-resumen-total { font-size: 1.05rem; font-weight: 700; color: var(--primary-dark); }

.gt-efectos { list-style: none; display: flex; flex-direction: column; }
.gt-efecto {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.gt-efecto:last-child { border-bottom: none; }
.gt-efecto-ico { color: var(--primary); font-size: 1rem; margin-top: 2px; }
.gt-efecto-titulo { display: block; font-size: 0.82rem; font-weight: 600; }
.gt-efecto-texto { display: block; font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; }

.gt-faltan,
.gt-aviso-ajuste {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 16px;
}
.gt-faltan { background: var(--danger-lt); color: var(--danger); }
.gt-faltan ul { margin: 4px 0 0 16px; }
.gt-aviso-ajuste {
  background: var(--warning-lt);
  color: var(--warning);
  margin: 20px 0 0;
}

/* ─── El lote de comprobantes en modo tarea ──────────────────── */
/* La zona de arrastre reutiliza .upload-zone, que ya existía. Lo de
   aquí es la tanda: una fila por archivo con lo que la IA le sacó,
   los recuentos de al lado y el aviso de que leer no es registrar.
   Ni un color, radio ni cuerpo de letra nuevo. */

.lote-panel { max-width: 860px; }
.lote-zona-ico { display: block; color: var(--primary); font-size: 1.6rem; margin-bottom: 8px; }
.lote-zona-nota {
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lote-rechazados {
  border: 1px solid var(--warning);
  background: var(--warning-lt);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.78rem;
  line-height: 1.5;
}
.lote-rechazados-titulo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--warning);
  margin-bottom: 6px;
}
.lote-rechazados ul { margin: 0 0 0 16px; }

.lote-chips { margin-top: 20px; }
.lote-lista { list-style: none; margin-top: 14px; }
.lote-fila {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--white);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.lote-fila.es-leido    { border-left-color: var(--success); }
.lote-fila.es-leyendo  { border-left-color: var(--primary); }
.lote-fila.es-problema { border-left-color: var(--danger); background: var(--danger-lt); }
.lote-fila-id { display: flex; flex-direction: column; gap: 2px; min-width: 190px; flex: 1; }
.lote-fila-nombre {
  font-size: 0.84rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lote-fila-estado { font-size: 0.72rem; color: var(--text-muted); }
.lote-confianza { margin-left: 8px; }
.lote-fila-datos { display: flex; gap: 18px; flex-wrap: wrap; flex: 2; min-width: 240px; }
.lote-fila-acciones { display: flex; gap: 6px; align-items: center; }
.lote-campo { display: flex; flex-direction: column; gap: 2px; font-size: 0.82rem; }
.lote-campo-rot {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}
.lote-campo-monto { font-weight: 700; }
.lote-motivo { font-size: 0.8rem; color: var(--danger); display: flex; flex-direction: column; gap: 2px; }
.lote-remedio { font-size: 0.76rem; color: var(--text-muted); }
.lote-espera { font-size: 0.8rem; color: var(--text-muted); }

.lote-vacio {
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  padding: 26px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 14px;
}
.lote-vacio .ico { font-size: 1.4rem; display: block; margin: 0 auto 8px; }

/* La columna de al lado: el recuento y el total detectado, que es lo
   que se coteja contra el fajo de papeles. */
.lote-cifras,
.lote-entrega-cifras { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.lote-cifra {
  flex: 1;
  min-width: 110px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  padding: 10px 12px;
}
.lote-cifra-valor { display: block; font-size: 1.15rem; font-weight: 700; }
.lote-cifra-rot { display: block; font-size: 0.72rem; color: var(--text-muted); line-height: 1.35; }
.lote-cifra.es-ok .lote-cifra-valor     { color: var(--success); }
.lote-cifra.es-espera .lote-cifra-valor { color: var(--primary); }
.lote-cifra.es-malo .lote-cifra-valor   { color: var(--danger); }

.lote-total {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--primary-lt2);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.lote-total-rot {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.lote-total-valor { display: block; font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); }
.lote-total-nota { display: block; font-size: 0.72rem; color: var(--text-muted); line-height: 1.4; margin-top: 4px; }

/* El aviso que esta pantalla no puede dejar de dar. */
.lote-aviso {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--info);
  background: var(--info-lt);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text);
}
.lote-entrega-pendiente,
.lote-entrega-malos {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  margin-bottom: 14px;
}
.lote-entrega-pendiente { background: var(--primary-lt); color: var(--primary-dark); }
.lote-entrega-malos { background: var(--danger-lt); color: var(--danger); }

/* ─── La pantalla de entrada: qué me toca hoy ─────────────────── */
/* Cinco bloques y ni un color, radio o tamaño de letra nuevo: las
   tarjetas, las píldoras, la barra de progreso y los botones son los
   de siempre. Lo único propio de aquí es cómo se colocan. */

/* La cinta de período: el mes de trabajo a la izquierda, el progreso
   del cierre en medio y la cuenta atrás del próximo vencimiento a la
   derecha. En pantalla estrecha se apilan, que es lo que hace el
   flex-wrap sin regla aparte. */
.hoy-periodo .card-body { padding: 16px 20px; }
.hoy-periodo-cuerpo {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.hoy-periodo-mes { display: flex; flex-direction: column; min-width: 140px; }
.hoy-periodo-rot {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
}
.hoy-periodo-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.hoy-periodo-cierre { flex: 1 1 220px; min-width: 200px; }
.hoy-periodo-cierre .progress-wrap { margin: 0; }

/* La cuenta atrás es pulsable: lleva al calendario fiscal, que es
   donde se marca lo que ya se envió. Cambia de color con los mismos
   cortes que el resto de la aplicación. */
.hoy-venc {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--neutral);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.hoy-venc:hover { border-color: var(--border-dark); background: var(--neutral-dark); }
.hoy-venc-num { font-size: 1.6rem; font-weight: 800; line-height: 1; color: var(--text); }
.hoy-venc-txt { display: flex; flex-direction: column; }
.hoy-venc-rot { font-size: 0.78rem; font-weight: 600; color: var(--text); }
.hoy-venc-det { font-size: 0.72rem; color: var(--text-muted); }
.hoy-venc.avisa { background: var(--warning-lt); border-color: var(--warning-lt); }
.hoy-venc.avisa .hoy-venc-num { color: var(--warning); }
.hoy-venc.apura { background: var(--danger-lt); border-color: var(--danger-lt); }
.hoy-venc.apura .hoy-venc-num { color: var(--danger); }

/* Las cuatro cifras son la tarjeta de métrica de siempre, convertida
   en botón porque cada una lleva a la pantalla donde se trabaja. */
.hoy-cifra {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.hoy-cifra:hover { border-color: var(--border-dark); }

/* La bandeja y el checklist, uno al lado del otro. La columna se
   parte sola en pantalla estrecha con la regla de .grid-2. */
.hoy-columnas { align-items: start; margin-bottom: 20px; }
.hoy-columnas > .card { margin-bottom: 0; }
.hoy-pendientes,
.hoy-pasos { list-style: none; }
.hoy-pendiente,
.hoy-paso {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.hoy-pendiente:last-child,
.hoy-paso:last-child { border-bottom: none; }

/* Cada pendiente lleva al lado el botón que lo resuelve, y el icono
   dice de qué gravedad es sin que haya que leer la fila entera. */
.hoy-pendiente-ico { display: inline-flex; font-size: 1.05rem; flex-shrink: 0; }
.hoy-pendiente.sev-error .hoy-pendiente-ico { color: var(--danger); }
.hoy-pendiente.sev-aviso .hoy-pendiente-ico { color: var(--warning); }
.hoy-pendiente.sev-info  .hoy-pendiente-ico { color: var(--text-muted); }
.hoy-pendiente-texto { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hoy-pendiente-titulo { font-size: 0.86rem; font-weight: 600; }
.hoy-pendiente-detalle { font-size: 0.76rem; color: var(--text-muted); }
.hoy-pendiente-btn { flex-shrink: 0; }

/* El checklist del cierre. Un paso hecho se apaga, uno bloqueado
   lleva su razón escrita al pie: el booleano solo no explica nada a
   quien se lo encuentra. */
.hoy-paso-marca { display: inline-flex; font-size: 1rem; flex-shrink: 0; color: var(--text-light); }
.hoy-paso.hecho .hoy-paso-marca { color: var(--success); }
.hoy-paso.bloqueado .hoy-paso-marca { color: var(--warning); }
.hoy-paso-texto { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hoy-paso-etiqueta { font-size: 0.86rem; font-weight: 600; }
.hoy-paso.hecho .hoy-paso-etiqueta { color: var(--text-muted); }
.hoy-paso-detalle { font-size: 0.76rem; color: var(--text-muted); }
.hoy-paso-razon {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--warning-lt);
  color: var(--warning);
  font-size: 0.74rem;
}
.hoy-paso-nota { font-size: 0.72rem; color: var(--text-light); }
.hoy-paso-estado { flex-shrink: 0; }

/* Los cuatro accesos: lo que más se empieza desde cero, en un clic. */
.hoy-accesos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.hoy-acceso {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.hoy-acceso:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.hoy-acceso-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--primary-lt);
  color: var(--primary);
  font-size: 1.1rem;
}
.hoy-acceso-txt { display: flex; flex-direction: column; min-width: 0; }
.hoy-acceso-nombre { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.hoy-acceso-desc { font-size: 0.74rem; color: var(--text-muted); }

/* ─── Trabajo sin terminar, en la pantalla de entrada ────────── */
/* Un borrador a medias se ve donde se empieza el día: si no, salir de
   una tarea para atender una llamada es perderla de vista. */
.tarea-borradores .card-body { display: flex; flex-direction: column; }
.tarea-borrador {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  list-style: none;
}
.tarea-borrador:last-child { border-bottom: none; }
.tarea-borrador-ico { color: var(--primary); font-size: 1.05rem; }
.tarea-borrador-texto { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.tarea-borrador-titulo { font-size: 0.86rem; font-weight: 600; }
.tarea-borrador-detalle { font-size: 0.76rem; color: var(--text-muted); }
.tarea-borrador-acciones { display: flex; gap: 6px; flex-shrink: 0; }

/* El aviso de «recuperamos lo que estabas escribiendo», encima del
   asiento manual y de la factura de venta. Discreto a propósito: lo
   que importa está ya en los campos; esto solo explica por qué no
   están vacíos y deja tirarlo. Sin tokens nuevos. */
.aviso-borrador {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--primary-lt);
  font-size: 0.8rem;
  color: var(--text);
}

/* ─── Revisar en cadena lo que leyó la IA ────────────────────── */
/* El rail es la cola, el centro es el comprobante y la columna de al
   lado el destino contable. Todo sale de las variables que ya
   estaban: ni un color, radio ni cuerpo de letra nuevo, y **sin un
   token nuevo** —los tres del modo tarea siguen siendo tres—. */

.rv-panel { max-width: 820px; }

.rv-doc-wrap { margin-bottom: 16px; }
.rv-doc {
  display: block;
  width: 100%;
  height: 300px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--neutral);
}
.rv-doc-vacio {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 120px;
  padding: 0 16px;
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius);
  background: var(--neutral);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.rv-doc-vacio .ico { font-size: 1.6rem; color: var(--text-light); }
.rv-doc-vacio span { font-size: 0.74rem; color: var(--text-light); }

.rv-conf-general {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.rv-conf-general .conf-bar-track { flex: 1; }
.rv-conf-rot { font-size: 0.74rem; color: var(--text-muted); white-space: nowrap; }

/* La confianza de cada campo: el número que el backend devolvía y
   nadie enseñaba. Verde arriba, ámbar en medio, rojo abajo del
   umbral; y los que vienen del comprobante firmado no llevan
   porcentaje sino de dónde salen. */
.rv-conf {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rv-conf.es-alta        { color: var(--success); }
.rv-conf.es-media       { color: var(--warning); }
.rv-conf.es-baja        { color: var(--danger); }
.rv-conf.es-verificado  { color: var(--success); }

.rv-campos-cab {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.rv-campos-cab .tarea-h3 { flex: 1; }
.rv-campos-aviso {
  font-size: 0.78rem;
  color: var(--warning);
  background: var(--warning-lt);
  border-radius: var(--radius);
  padding: 8px 10px;
  line-height: 1.45;
  margin-bottom: 10px;
}

.rv-campos { border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); }
.rv-campo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
}
.rv-campo:last-child { border-bottom: none; }
.rv-campo-rot { min-width: 140px; font-size: 0.78rem; color: var(--text-muted); }
.rv-campo-valor { flex: 1; min-width: 0; }
.rv-campo-valor .form-control { font-size: 0.82rem; font-weight: 600; height: auto; padding: 3px 6px; }
.rv-campo-fijo { font-size: 0.82rem; font-weight: 600; }
.rv-campo-nota { font-size: 0.72rem; color: var(--text-muted); margin-top: 3px; }
.rv-campo-conf { min-width: 44px; text-align: right; }
.rv-campo.es-moneda { background: var(--warning-lt); }
.rv-campo.es-moneda .form-control { max-width: 90px; }
/* Lo que la IA leyó con poca confianza, resaltado para no revisarlo
   todo con la misma lupa. */
.rv-campo.es-dudoso { background: var(--warning-lt); }
.rv-campo.es-dudoso .form-control { border-color: var(--warning); }
.rv-campo [data-qr="1"] { border-color: var(--success); }

/* Las comprobaciones automáticas, con su resultado y su porqué. */
.rv-checks { list-style: none; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); }
.rv-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.rv-check:last-child { border-bottom: none; }
.rv-check-ico { flex-shrink: 0; font-size: 1rem; margin-top: 1px; color: var(--text-light); }
.rv-check-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rv-check-rot {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.rv-check-titulo { font-size: 0.82rem; font-weight: 600; }
.rv-check-porque { font-size: 0.76rem; color: var(--text-muted); line-height: 1.45; }
.rv-check.es-ok .rv-check-ico      { color: var(--success); }
.rv-check.es-aviso .rv-check-ico   { color: var(--warning); }
.rv-check.es-aviso .rv-check-titulo{ color: var(--warning); }
.rv-check.es-bloqueo              { background: var(--danger-lt); }
.rv-check.es-bloqueo .rv-check-ico,
.rv-check.es-bloqueo .rv-check-titulo { color: var(--danger); }

/* El bloqueo, encima del botón que no se puede pulsar. */
.rv-bloqueo {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--danger-lt);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.79rem;
  line-height: 1.45;
  margin-bottom: 16px;
}
.rv-bloqueo ul { margin: 6px 0 8px 16px; }

/* La orden de compra propuesta, con su grado de coincidencia. */
.rv-oc { border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 10px 12px; }
.rv-oc.es-alta  { border-left-color: var(--success); }
.rv-oc.es-media { border-left-color: var(--warning); }
.rv-oc.es-baja  { border-left-color: var(--danger); }
.rv-oc-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rv-oc-doc { font-size: 0.84rem; font-weight: 700; }
.rv-oc-grado { font-size: 0.74rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.rv-oc.es-alta .rv-oc-grado  { color: var(--success); }
.rv-oc.es-media .rv-oc-grado { color: var(--warning); }
.rv-oc.es-baja .rv-oc-grado  { color: var(--danger); }
.rv-oc-nota { font-size: 0.76rem; color: var(--text-muted); line-height: 1.45; margin-top: 4px; }

/* Las retenciones que ya vienen calculadas, con la tasa dicha. */
.rv-ret {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--primary-lt);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.77rem;
  line-height: 1.45;
  margin-bottom: 10px;
}
.rv-ret .ico { color: var(--primary-dark); flex-shrink: 0; margin-top: 2px; }
.rv-ret-fuente { color: var(--text-muted); }
.rv-ret-nota { font-size: 0.77rem; color: var(--text-muted); line-height: 1.45; margin-bottom: 10px; }

.rv-destino-intro { font-size: 0.78rem; color: var(--text-muted); line-height: 1.45; margin-bottom: 14px; }
.rv-destino .form-label { display: block; }
.rv-destino .input-group { display: flex; gap: 6px; }

/* La cola se acabó: el final normal de una tanda, no una pantalla
   rota. */
.rv-cuerpo-vacio { display: block; overflow-y: auto; }
.rv-vacia {
  max-width: 460px;
  margin: 80px auto;
  text-align: center;
  color: var(--text-muted);
}
.rv-vacia .ico { font-size: 2.4rem; color: var(--success); }
.rv-vacia h2 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin: 10px 0 6px; }
.rv-vacia p { font-size: 0.84rem; line-height: 1.5; margin-bottom: 18px; }

/* ─── La paleta de comandos ──────────────────────────────────── */
/* El buscador que se abre con Ctrl+K desde cualquier pantalla. Es
   una capa encima de la aplicación, como el modo tarea, y por encima
   de él: se abre estando en cualquier sitio. Ni un color, radio ni
   cuerpo de letra nuevo. */

#paleta { position: fixed; inset: 0; z-index: 1100; }
.pa-velo {
  position: absolute;
  inset: 0;
  background: rgba(23,49,59,0.38);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 24px 24px;
  animation: fadeIn 0.14s ease;
}
.pa-caja {
  width: 100%;
  max-width: 620px;
  max-height: 68vh;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* El campo */
.pa-campo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pa-campo-ico { display: flex; color: var(--text-light); }
.pa-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
}
.pa-input::placeholder { color: var(--text-light); }

/* Los resultados */
.pa-resultados { overflow-y: auto; padding: 6px; flex: 1; }
.pa-grupo + .pa-grupo { margin-top: 4px; }
.pa-grupo-titulo {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 8px 10px 4px;
}
.pa-nota {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0 10px 8px;
  line-height: 1.4;
}
.pa-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius);
  background: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.pa-item:hover { background: var(--neutral); }
/* El resultado seleccionado: el primero, mientras nadie mueva las
   flechas. Se marca con el tinte azul de siempre. */
.pa-item.sel { background: var(--primary-lt); }
.pa-item-ico { display: flex; color: var(--text-muted); flex-shrink: 0; }
.pa-item.sel .pa-item-ico { color: var(--primary-dark); }
.pa-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pa-item-nombre {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pa-item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pa-item-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* El pie: qué teclas mueven esto */
.pa-pie {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--neutral);
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.pa-pie-item { display: flex; align-items: center; gap: 6px; }
.pa-tecla {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: var(--white);
  padding: 1px 5px;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .form-row-4 { grid-template-columns: 1fr 1fr; }
  .ia-stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  /* Aquí vivía el menú lateral plegado a solo iconos, que era lo que
     se hacía en pantalla estrecha antes de que hubiera barra
     inferior. Ya no: a 900 píxeles y por debajo el menú lateral
     desaparece del todo y manda la barra del teléfono, al final de
     esta hoja. Plegar a solo iconos sigue existiendo donde tiene
     sentido —#sidebar.collapsed, en el escritorio—. */

  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .mode-cards { grid-template-columns: 1fr; }
  #content { padding: 16px; }
  /* La cabecera conserva su alto: lo que se recorta en pantalla
     estrecha es el texto, nunca el número de filas. */
  .hdr-empresa-meta   { display: none; }
  .hdr-empresa-nombre { max-width: 12ch; }
  .hdr-periodo-txt    { display: none; }
  .hdr-nuevo-txt      { display: none; }
  /* El disparador de la búsqueda se queda en la lupa: el atajo no
     sirve de nada en una pantalla sin teclado. */
  .hdr-busqueda       { flex: 0 0 auto; padding: 5px 8px; }
  .hdr-busqueda-txt,
  .hdr-busqueda-atajo { display: none; }
  .hdr-menu           { min-width: 200px; }
  .pa-velo            { padding: 8vh 12px 12px; }
  .inv-parties { grid-template-columns: 1fr; }

  /* En pantalla estrecha el rail pasa a ser una fila de arriba y la
     columna de contexto baja debajo del contenido: las tres zonas
     siguen estando, que es lo que importa, pero en vertical. */
  .tarea-cuerpo,
  .tarea-cuerpo:has(.tarea-contexto) {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow-y: auto;
  }
  .tarea-rail {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .tarea-rail ol { display: flex; overflow-x: auto; }
  .tarea-paso-desc { display: none; }
  .tarea-paso-cara {
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }
  .tarea-paso.es-actual .tarea-paso-cara {
    border-left-color: transparent;
    border-bottom-color: var(--primary);
  }
  .tarea-contexto { border-left: none; border-top: 1px solid var(--border); }
  .tarea-contenido { padding: 18px 16px 24px; }
  .tarea-subtitulo { display: none; }
  .tarea-avance-barra { display: none; }
}


/* ─── La barra inferior del teléfono ─────────────────────────── */
/* Por debajo del ancho de escritorio —900 px, el corte que declara
   modules/movil.js— el menú lateral desaparece y lo sustituye una
   barra con los pocos destinos que se usan en la calle, más la foto
   de un comprobante. El marcado sale del manifiesto a través de
   modules/movil.js; aquí solo el aspecto, y ni un color, radio ni
   sombra nuevos: todo sale de las variables de arriba.

   Dos medidas no son gusto sino regla del ticket, y hay pruebas que
   las vigilan: ninguna zona pulsable baja de 44 píxeles, porque se
   usa de pie y con prisa, y el texto va un punto por encima del del
   menú de escritorio (.nav-label, 0.82rem), porque se lee al sol.

   Lo que NO hay aquí, también a propósito: ni barra de estado, ni
   reloj, ni batería, ni teclado dibujados. El teléfono ya trae los
   suyos y encima se superponen los de verdad. */

.mvl-barra { display: none; }

.mvl-item {
  flex: 1 1 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: none;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mvl-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
}
.mvl-txt {
  /* 0.92rem sobre los 0.82rem del menú de escritorio: un punto justo
     por encima, que es lo que pide leerlo al sol. */
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mvl-item.activa { color: var(--primary-dark); }
.mvl-item.activa .mvl-ico { color: var(--primary); }
.mvl-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* La foto, que es la acción destacada: el círculo asoma por encima
   del borde de la barra para que se distinga de los destinos. */
.mvl-foto {
  min-width: 44px;
  min-height: 44px;
  color: var(--primary-dark);
}
.mvl-foto .mvl-ico {
  width: 44px;
  height: 44px;
  margin-top: -16px;
  border-radius: var(--radius-round);
  background: var(--primary);
  color: var(--white);
  box-shadow: var(--shadow);
}
.mvl-foto:active .mvl-ico { background: var(--primary-hover); }

/* La hoja de «Más»: el menú entero, como capa encima. */
.mvl-velo {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(23,49,59,0.45);
  display: flex;
  align-items: flex-end;
}
.mvl-hoja {
  width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
}
.mvl-hoja-cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mvl-hoja-tit { font-size: 0.98rem; font-weight: 700; color: var(--text); }
.mvl-cerrar {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
}
.mvl-hoja-cuerpo {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.mvl-bloque-tit {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 14px 16px 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-light);
}
.mvl-bloque-ico { display: inline-flex; font-size: 0.9rem; }
.mvl-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 16px;
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mvl-fila-ico {
  display: inline-flex;
  justify-content: center;
  width: 18px;
  font-size: 1.05rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.mvl-fila.activa {
  background: var(--primary-lt2);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--primary);
}
.mvl-fila.activa .mvl-fila-ico { color: var(--primary); }
.mvl-sub { padding-left: 46px; color: var(--text-muted); }
.mvl-sub .mvl-fila-ico { opacity: 0.7; }

/* El corte. A 900 píxeles y por debajo se va el menú lateral y
   aparece la barra; por encima, el escritorio de siempre. Va al
   final de la hoja a propósito: el bloque de 680 px fija el relleno
   de #content con la forma corta, y el hueco que deja la barra se
   reserva después. */
@media (max-width: 900px) {
  #sidebar { display: none; }
  /* Sin menú lateral no hay nada que plegar. */
  .sidebar-toggle { display: none; }

  .mvl-barra {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 56px;
    align-items: stretch;
    background: var(--white);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(23,49,59,0.08);
    z-index: 690;
  }

  /* El hueco de la barra, para que no tape la última fila. */
  #content { padding-bottom: 76px; }

  /* En modo tarea no hay barra. La tarea ocupa la pantalla entera y
     tiene su propia salida, que es la que guarda el borrador; una
     barra encima solo serviría para irse a otro sitio a media tarea
     sin pasar por ella, y además su propia barra de avance vive
     justo donde iría esta. Es la misma decisión que se tomó con la
     paleta de comandos y con el asistente flotante. */
  body.en-modo-tarea .mvl-barra { display: none; }

  /* El asistente flotante se sube por encima de la barra: si no, el
     botón cae justo sobre los destinos. */
  #ast-fab   { bottom: 68px; }
  #ast-panel { bottom: 128px; }
}

/* ─── Solo lectura (ticket 16) ─────────────────────────────────
   Lo que ve un rol de solo lectura en lugar de un formulario que no
   podría terminar: el gasto, el lote, la factura, el asiento y los
   registros de nómina. */
.aviso-solo-lectura {
  background: var(--info-lt);
  color: var(--text);
  border: 1px solid var(--info);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: .9rem;
  line-height: 1.45;
}
.aviso-solo-lectura strong { color: var(--info); }
