:root {
  --primary: #0047FF;
  --primary-dark: #0033CC;
  --primary-light: #3B82F6;
  --primary-gradient: linear-gradient(135deg, #3B82F6, #0033CC);
  --sidebar-bg: #07102B;
  --sidebar-hover: #0D1F4A;
  --sidebar-active: #0047FF;
  --surface: #FFFFFF;
  --surface-2: #F5F7FF;
  --surface-3: #EEF2FF;
  --border: #E2E8F0;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 10px 40px rgba(0,0,0,.1);
  --shadow-lg: 0 20px 60px rgba(0,71,255,.15);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Typography ── */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 4px;
  font-size: .875rem; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary); color: #fff;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface-3); color: var(--primary); }
.btn-secondary:hover { filter: brightness(.96); }
.btn-ghost { background: var(--surface-3); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.btn-icon { background: transparent; border: none; }
.btn-ghost.btn-icon:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-icon { padding: 8px; border-radius: 4px; }

/* ── Inputs ── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); letter-spacing: .4px; }
.input-hint { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }
.input {
  padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: .9rem; color: var(--text);
  background: var(--surface); transition: var(--transition); outline: none; width: 100%;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.1); }
/* Selector de color: con el padding de .input el navegador aplasta la muestra
   hasta dejarla en una raya, y el campo se leía como vacío aunque tuviera valor. */
.input[type="color"] { height: 44px; padding: 4px 6px; cursor: pointer; }
.input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.input[type="color"]::-webkit-color-swatch { border: none; border-radius: calc(var(--radius-sm) - 2px); }
.input[type="color"]::-moz-color-swatch { border: none; border-radius: calc(var(--radius-sm) - 2px); }
.input-icon-wrap { position: relative; }
.input-icon-wrap:has(.icon:not(.icon-right)) .input { padding-left: 40px; }
.input-icon-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon-wrap .icon-right { position: absolute; right: 12px; left: auto; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }
.input-icon-wrap:has(.icon-right) .input { padding-right: 40px; }
/* Input con checkbox prefijo */
.input-prefix-wrap { display: flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.input-prefix-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.1); }
.input-prefix-wrap.prefix-disabled { opacity: .5; }
.input-prefix { display: flex; align-items: center; justify-content: center; padding: 0 12px; border-right: 1px solid var(--border); background: var(--surface-2); height: 100%; cursor: pointer; }
.input-prefix input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.input-prefix-wrap .input-icon-wrap .input { border: none; border-radius: 0; box-shadow: none; }
.input-prefix-wrap .input-icon-wrap .input:focus { border: none; box-shadow: none; }

/* ── Cards ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 600;
}
.badge-blue { background: #EEF2FF; color: var(--primary); }
.badge-green { background: #ECFDF5; color: var(--success); }
.badge-yellow { background: #FFFBEB; color: var(--warning); }
.badge-red { background: #FEF2F2; color: var(--danger); }
.badge-gray { background: var(--surface-3); color: var(--text-secondary); }
/* Reserva en línea que espera el pago (citas y alquiler). */
.badge-purple { background: #F5F3FF; color: #7C3AED; }
.badge-dot::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; display: inline-block;
}

/* ── Avatar ── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem; flex-shrink: 0;
  background: var(--primary-gradient); color: #fff;
}
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }

/* ── App Shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar-bg);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width var(--transition);
}
.sidebar.collapsed { width: 64px; }

.sidebar-logo {
  padding: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.07); flex-shrink: 0;
}
.sidebar-logo img { flex-shrink: 0; }
.sidebar-logo-text {
  font-size: 1.1rem; font-weight: 800; color: #fff;
  white-space: nowrap; overflow: hidden;
}
.sidebar-logo-text span { color: var(--primary-light); }
.sidebar.collapsed .sidebar-logo-text { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }

.nav-section { margin-bottom: 4px; }
.nav-section-label {
  padding: 8px 10px 4px;
  font-size: .65rem; font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6); text-decoration: none;
  font-size: .8125rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(0,71,255,.4); }

/* Variante para usar dentro de cards claros (ej: Settings) */
.nav-item-light {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: var(--transition); white-space: nowrap;
}
.nav-item-light:hover { background: var(--surface-3); color: var(--text); }
.nav-item-light.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(0,71,255,.25); }
.nav-item svg { flex-shrink: 0; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.nav-item .nav-chevron { margin-left: auto; opacity: .6; flex-shrink: 0; transition: transform .2s; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-chevron { display: none; }
.nav-children { background: rgba(0,0,0,.15); }
.nav-child { padding-left: 36px !important; font-size: .82rem; opacity: .9; }
.nav-grandchild { padding-left: 52px !important; font-size: .8rem; opacity: .85; }

.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 99px; display: flex; align-items: center; justify-content: center;
  padding: 0 5px; line-height: 1; box-sizing: border-box; flex-shrink: 0;
}
.sidebar.collapsed .nav-badge { position: absolute; top: 4px; right: 4px; }

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid rgba(255,255,255,.07);
}
.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: default; transition: var(--transition);
}
.user-info { overflow: hidden; flex: 1; }
.user-info .name { font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; color: rgba(255,255,255,.4); white-space: nowrap; }
.sidebar.collapsed .user-info { display: none; }
.user-menu-btn { color: rgba(255,255,255,.5) !important; }
.user-menu-btn:hover { color: #fff !important; background: rgba(255,255,255,.1) !important; }
.user-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 -4px 16px rgba(0,0,0,.15);
  z-index: 200; overflow: hidden;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: .875rem; color: var(--text);
  cursor: pointer; transition: background .15s;
}
.user-menu-item:hover { background: var(--surface-3); }
.user-menu-danger { color: #ef4444 !important; }
.user-menu-danger:hover { background: rgba(239,68,68,.08) !important; }

/* ── Main content ── */
/* `min-width:0` es obligatorio: un hijo flex nace con `min-width:auto`, así que
   sin esto se niega a encogerse por debajo del ancho intrínseco de su contenido
   (una tabla ancha, un grid con columna fija) y, como `.app-shell` recorta con
   `overflow:hidden`, lo que sobra queda **cortado y fuera de alcance**. */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; flex-shrink: 0;
}
.topbar-spacer { flex: 1; }
.topbar-btn { width: 36px !important; height: 36px !important; padding: 0 !important; justify-content: center; }

.bell-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 290px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,.15);
  z-index: 300; padding: 4px 0 8px;
}
.bell-menu-title {
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 16px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.bell-menu-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 12px; font-size: .875rem; cursor: default;
}
.bell-menu-row span:first-child { display: flex; align-items: center; gap: 8px; }
.bell-menu-note { font-size: .73rem; color: var(--text-muted); margin: 4px 16px 0; line-height: 1.4; }
.toggle-track {
  flex-shrink: 0; width: 40px; height: 22px; border-radius: 11px;
  background: var(--surface-3); display: inline-block; position: relative;
  cursor: pointer; transition: background .2s;
}
.toggle-thumb {
  position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: left .2s;
}

.page { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; }

/* ── Encajar el contenido: nada de scroll horizontal en la página ──
   Un grid con una columna en `1fr` **no** se encoge por debajo del contenido:
   `1fr` es `minmax(auto,1fr)` y ese `auto` es un mínimo basado en el contenido.
   Con una tabla o un grid anidado dentro, la columna se queda a su ancho
   intrínseco y empuja al resto fuera de la pantalla. La forma correcta es
   `minmax(0,1fr)`, y estas reglas la imponen a los layouts de dos columnas de
   la app, que se declaran con `grid-template-columns` en línea. */
.dash-two-col  { grid-template-columns: minmax(0, 1fr) 320px; }
.dash-even-col { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.cfg-two-col   { grid-template-columns: 220px minmax(0, 1fr) !important; }

/* Cabecera de página (título + botón de acción): al estrecharse envuelve en
   vez de desbordar. Sin esto el botón se sale por la derecha.
   El segundo hijo lleva `margin-left:auto` en vez de fiarse de
   `justify-content:space-between`: con wrap, un único hijo en su propia
   fila cae a flex-start (así resuelve el spec space-between con 1 ítem), y
   el bloque de acciones quedaba pegado a la izquierda cuando el título +
   subtítulo empujaban todo a la fila de abajo. El margen automático lo
   ancla a la derecha tanto si comparte fila con el título como si no.
   Solo lo lleva el **segundo** hijo: con `:last-child` una cabecera sin
   acciones (Inicio) empujaba el propio título a la derecha. */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head > * { min-width: 0; }
.page-head > * + * { margin-left: auto; }

/* Grupo de acciones de una cabecera (botones, buscador). Envuelve, y sus
   campos pueden encogerse: un `<input>` trae un mínimo intrínseco propio que
   sin `min-width:0` impide que la fila quepa. */
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.head-actions .input, .head-actions select { min-width: 0; max-width: 100%; }
/* `.input` trae `width: 100%`, así que un campo de fecha sin ancho propio se
   come la fila entera y empuja al resto a una línea nueva: la barra de filtros
   de Compras salía con «Desde» y «Hasta» cada uno en su renglón y el campo
   ocupando todo el ancho de la tarjeta. Un `input[type=date]` tiene ancho
   intrínseco, así que `auto` es lo correcto; donde ya se declara uno en línea,
   ese gana. */
.head-actions .input[type="date"] { width: auto; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card .stat-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* ── Tarjetas KPI con degradado (dashboard) ──
   Modificador de .stat-card: mismo grid, otra piel. No se toca .stat-card a secas
   porque la usan los KPIs de Informes y de Ventas, que van sobre fondo blanco. */
.stat-card-grad {
  position: relative; overflow: hidden;
  border: 0; padding: 16px 18px; border-radius: 10px; min-height: 104px;
  flex-direction: row; align-items: stretch; justify-content: space-between; gap: 12px;
  color: #fff; box-shadow: 0 2px 6px rgba(15,23,42,.12);
}
/* El "swoosh" del fondo: una elipse más ancha que la tarjeta asomando por abajo.
   Va en ::after y el contenido en position:relative, o el texto queda debajo. */
.stat-card-grad::after {
  content: ''; position: absolute; left: -12%; right: -12%; bottom: -78%;
  height: 130%; border-radius: 50%; background: rgba(255,255,255,.12); pointer-events: none;
}
.stat-card-grad > * { position: relative; z-index: 1; }
/* El texto ocupa el alto de la tarjeta con la etiqueta arriba y el número abajo:
   así los números quedan alineados entre tarjetas aunque una etiqueta ocupe dos
   líneas. El ícono se centra aparte. */
.stat-card-grad .stat-grad-txt {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
}
.stat-card-grad .stat-label {
  color: rgba(255,255,255,.88); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; line-height: 1.25;
}
.stat-card-grad .stat-value { color: #fff; font-size: 2.1rem; }
.stat-card-grad .stat-icon {
  width: 44px; height: 44px; flex-shrink: 0; align-self: center; border-radius: 50%;
  background: rgba(255,255,255,.22); color: #fff;
}

.sc-blue   { background: linear-gradient(135deg, #3B82F6, #1D4ED8); }
.sc-purple { background: linear-gradient(135deg, #8B5CF6, #6D28D9); }
.sc-teal   { background: linear-gradient(135deg, #14B8A6, #0E7490); }
.sc-gray   { background: linear-gradient(135deg, #94A3B8, #475569); }
.sc-orange { background: linear-gradient(135deg, #FBBF24, #D97706); }
.sc-green  { background: linear-gradient(135deg, #34D399, #059669); }
.sc-red    { background: linear-gradient(135deg, #F87171, #DC2626); }


/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.table-wrap thead th:last-child { position: sticky; right: 0; z-index: 2; background: var(--surface-2); box-shadow: -2px 0 6px rgba(0,0,0,.06); }
.table-wrap tbody td:last-child { position: sticky; right: 0; z-index: 2; background: var(--surface); box-shadow: -2px 0 6px rgba(0,0,0,.06); }
.table-wrap tbody tr:hover td:last-child { background: var(--surface-2); }
/* La columna de acciones queda fija a la derecha y con los botones centrados
   aunque la tabla no esté dentro de `.table-wrap` (varias traen el overflow en
   línea). Se reconoce por los botones, no por la posición: una última columna
   de importes no debe quedar fija ni centrada. El `!important` es por el
   `text-align:right` que muchas celdas traen en línea, que de otro modo gana a
   la regla de centrado de abajo. */
thead:has(~ tbody td:last-child :is(button, .btn)) th:last-child,
tbody td:last-child:has(:is(button, .btn)) { position: sticky; right: 0; z-index: 2; box-shadow: -2px 0 6px rgba(0,0,0,.06); text-align: center !important; }
thead:has(~ tbody td:last-child :is(button, .btn)) th:last-child { background: var(--surface-2); }
tbody td:last-child:has(:is(button, .btn)) { background: var(--surface); }
tbody tr:hover td:last-child:has(:is(button, .btn)) { background: var(--surface-2); }
table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { padding: 10px 16px; text-align: center; font-size: .75rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0; text-transform: capitalize; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); white-space: nowrap; }
tbody td:last-child { text-align: center; }
tbody td:last-child > div { justify-content: center; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.pg-bar { display:flex; align-items:center; gap:16px; padding:10px 16px; border-top:1px solid var(--border); font-size:.8rem; color:var(--text-muted); flex-wrap:wrap; }
.pg-info { margin-right:auto; }
.pg-size { display:flex; align-items:center; gap:6px; }
.pg-size select { padding:3px 6px; border:1px solid var(--border); border-radius:var(--radius-sm); font-size:.8rem; background:var(--surface); color:var(--text); cursor:pointer; }
.pg-nav { display:flex; align-items:center; gap:2px; }
.pg-nav span { padding:0 8px; font-size:.82rem; }
.pg-nav button { width:28px; height:28px; border:1px solid var(--border); border-radius:var(--radius-sm); background:var(--surface); color:var(--text); cursor:pointer; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.pg-nav button:hover:not(:disabled) { background:var(--surface-2); }
.pg-nav button:disabled { opacity:.35; cursor:not-allowed; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
/* Un modal más alto que la ventana tiene que poder recorrerse: el overlay es
   `position:fixed`, así que sin esto el contenido que sobra queda inalcanzable
   (la página de detrás no lo scrollea). */
/* El aire alrededor lo da el `max-height`, no un padding del overlay: los
   modales traen `max-width` en `vw` y con padding se desbordarían de lado. */
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; width: 90%; max-width: 480px; max-height: calc(100vh - 48px); overflow-y: auto; transform: translateY(12px); transition: var(--transition); }
/* Con cabecera y pie propios se scrollea solo el cuerpo, para no perder de
   vista la X ni el botón de guardar. Los modales sin `.modal-body` se siguen
   recorriendo enteros con la regla de arriba. */
.modal:has(> .modal-body) { display: flex; flex-direction: column; overflow: hidden; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; }
.modal-overlay.open .modal { transform: translateY(0); }
/* Los modales van sin título, así que la cabecera solo contiene la X — y esa
   es absoluta sobre la caja, o sea que no ocupa sitio. Lo único que aporta
   entonces es el `margin-bottom`: el aire que deja libre la esquina. */
.modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-shrink: 0; }
.modal-footer { display: flex; gap: 10px; margin-top: 24px; flex-shrink: 0; }
.modal-footer .btn { flex: 1; justify-content: center; }

/* ── Login ── */
.login-screen {
  min-height: 100vh; display: flex; align-items: stretch;
  background: var(--surface);
}
.login-left {
  flex: 1; background: var(--sidebar-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px; position: relative; overflow: hidden;
}
.login-left::before {
  content: ''; position: absolute; width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,71,255,.25) 0%, transparent 70%);
  top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; position: relative; z-index: 1; }
.login-brand-identity { display: flex; flex-direction: column; align-items: center; gap: 0; }
.login-brand h1 { color: #fff; font-size: 2rem; font-weight: 800; }
.login-brand h1 span { color: var(--primary-light); }
.login-tagline { color: rgba(255,255,255,.5); font-size: .95rem; max-width: 340px; line-height: 1.6; }
.login-channels { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.login-channel-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 99px;
  background: rgba(255,255,255,.07); color: rgba(255,255,255,.7);
  font-size: .78rem; font-weight: 500; border: 1px solid rgba(255,255,255,.1);
}

.login-right {
  width: 480px; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 56px;
}
.login-form-wrap { width: 100%; }
.login-form-wrap h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 6px; }
.login-form-wrap p { color: var(--text-muted); font-size: .875rem; margin-bottom: 32px; }
.login-form-wrap .form-fields { display: flex; flex-direction: column; gap: 18px; }
.login-form-wrap .btn-primary { width: 100%; justify-content: center; padding: 13px; font-size: .95rem; margin-top: 8px; }
.login-error { background: #FEF2F2; border: 1px solid #FECACA; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; display: none; margin-bottom: 16px; }
.login-error.show { display: block; }
/* Recuperación de contraseña y cambio obligatorio (vistas dentro de .login-form-wrap) */
.login-forgot { display: flex; justify-content: flex-end; margin-top: 8px; font-size: .82rem; }
.login-link { color: var(--primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.login-link:hover { text-decoration: underline; }
.login-info { color: var(--text-muted); font-size: .8rem; text-align: right; }
.login-back { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: .85rem; }
.login-notice { display: flex; align-items: center; gap: 8px; background: #F0FDF4; border: 1px solid #BBF7D0; color: #15803D; padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; margin-bottom: 16px; }
.login-big-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--primary); margin-bottom: 18px; }
.login-big-icon.bad { background: #FEF2F2; color: var(--danger); }
.login-blocked { display: flex; gap: 12px; align-items: flex-start; background: #FFF7ED; border: 1px solid #FED7AA; border-left: 4px solid #EA580C; color: #7C2D12; padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.login-blocked-ico { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #FFEDD5; color: #C2410C; }
.login-blocked b { display: block; font-size: .9rem; margin-bottom: 2px; }
.login-blocked span:not(.login-blocked-ico) { display: block; font-size: .82rem; line-height: 1.45; }
.pw-account { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; padding: 6px 12px; border-radius: 99px; background: var(--surface-3); margin: -18px 0 20px; }
.pw-meter { height: 4px; border-radius: 2px; background: var(--border); margin-top: 8px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.pw-meter[data-s="1"] span { width: 25%; background: var(--danger); }
.pw-meter[data-s="2"] span { width: 50%; background: var(--warning); }
.pw-meter[data-s="3"] span { width: 75%; background: #84CC16; }
.pw-meter[data-s="4"] span { width: 100%; background: var(--success); }
.pw-hint { font-size: .78rem; color: var(--text-muted); margin-top: 6px; line-height: 1.45; }
.pw-hint.bad { color: var(--danger); }
.pw-hint.ok { color: var(--success); }
.pw-caps { align-items: center; gap: 4px; font-size: .78rem; color: #B45309; margin-top: 6px; }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
/* max-width: sin él, un mensaje de error largo estira el toast por toda la
   pantalla (no tenía tope y `min-width` solo marca el suelo). Los mensajes que
   además hay que LEER van en modal, no aquí: el toast se va en 3,5 s. */
.toast { background: var(--text); color: #fff; padding: 12px 18px; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 500; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; animation: slideIn .3s ease; min-width: 260px; max-width: min(420px, calc(100vw - 48px)); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rec-pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.7); } }
/* ── Sidebar toggle button ── */
.toggle-sidebar { background: none; border: none; cursor: pointer; color: var(--text-secondary); padding: 4px; border-radius: 6px; transition: var(--transition); display: flex; }
.toggle-sidebar:hover { color: var(--text); background: var(--surface-3); }

/* ── Select ── */
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; cursor: pointer; }

/* ── Toggle switch ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }

/* ── Permission checkboxes ── */
.perm-sections { display: flex; flex-direction: column; gap: 16px; }
.perm-cat-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 6px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-subgrid { margin-left: 24px; background: var(--surface-2); border-radius: 2px; padding: 10px 12px; border: 1px solid var(--border); }
.perm-group-header { padding-bottom: 6px; }
.perm-check { display: flex; align-items: center; gap: 8px; font-size: .85rem; cursor: pointer; }
.perm-check input[type="checkbox"],
.perm-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* ── User form tabs ── */
.user-form-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border);
  margin-bottom: 20px; padding-bottom: 0;
}
.user-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: none; background: none; cursor: pointer;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 6px 6px 0 0; transition: var(--transition);
}
.user-tab:hover { color: var(--text); background: var(--surface-2); }
.user-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.uf-hint { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.uf-check { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-secondary); margin-top: 6px; cursor: pointer; }


/* ── Multiselect de grupos ── */
.ms-wrap { position: relative; }
.ms-trigger {
  display: flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--surface-2); transition: border-color .15s;
}
.ms-trigger:hover, .ms-wrap.open .ms-trigger { border-color: var(--primary); }
.ms-tags  { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; align-items: center; }
.ms-tag   {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 4px; font-size: .78rem; font-weight: 600;
  border: 1px solid; white-space: nowrap;
}
.ms-tag-remove { cursor: pointer; opacity: .6; font-size: 1rem; line-height: 1; margin-left: 2px; }
.ms-tag-remove:hover { opacity: 1; }
.ms-placeholder { color: var(--text-muted); font-size: .875rem; padding: 2px 0; }
.ms-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform .2s; }
.ms-wrap.open .ms-chevron { transform: rotate(180deg); }
.ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 2px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 300; overflow: hidden;
  animation: fadeIn .12s ease;
}
.ms-option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; cursor: pointer; user-select: none; transition: background .1s;
}
.ms-option:hover { background: var(--surface-2); }
.ms-option input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; flex-shrink: 0; cursor: pointer; }
.ms-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: .85rem; }

/* ── Responsive (tablet) ── */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar .nav-label, .sidebar .nav-section-label, .sidebar .sidebar-logo-text, .sidebar .user-info { display: none; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 40px 32px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span2 { grid-column: span 1; }
  /* Configuración: el menú de pestañas pasa arriba, a lo ancho */
  .cfg-two-col { grid-template-columns: minmax(0, 1fr) !important; }
}
/* Bloque móvil completo al final del archivo (── Responsive móvil ──) */

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal-box {
  background: var(--surface); border-radius: 4px;
  padding: 32px 28px 24px; width: 360px; max-width: calc(100vw - 32px);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: scaleIn .18s cubic-bezier(.34,1.56,.64,1);
}
.modal-icon {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.modal-icon.danger { background: rgba(239,68,68,.12); color: var(--danger); }
.modal-icon.info   { background: rgba(0,71,255,.1);   color: var(--primary); }
.modal-msg   { font-size: .9rem; color: var(--text-muted); text-align: center; line-height: 1.5; }
/* ── X de cierre en la esquina superior derecha ──
   Va anclada a la caja del modal, no al título, para que caiga siempre en la
   esquina aunque el título esté centrado o ocupe dos líneas. Por eso la caja
   necesita `position: relative`. */
.modal-box, .modal { position: relative; }
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
/* Elegir entre opciones equivalentes (`modal.choose`).
   El ancho sube con DOS clases porque `.modal-box` se declara aquí mismo y a
   igual especificidad ganaría ella, dejando el modal en sus 360px sin que nada
   pareciera mal escrito. `align-items: stretch` es lo que hace que las tarjetas
   ocupen el ancho en vez de encogerse a su texto. */
.modal-box.modal-choose { width: 480px; max-width: calc(100vw - 32px); align-items: stretch; gap: 0; padding-top: 42px; }
.choose-intro { font-size: .9rem; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.modal-choose .choose-list { display: flex; flex-direction: column; gap: 10px; }
.choose-opt {
  display: flex; flex-direction: column; gap: 3px;
  text-align: left; width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.choose-opt:hover { border-color: var(--primary); background: var(--bg); }
.choose-opt:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.choose-opt-label { font-size: .88rem; font-weight: 600; color: var(--text); }
.choose-opt-desc  { font-size: .78rem; color: var(--text-muted); line-height: 1.45; }
/* La opción recomendada se distingue por el borde, no por ser el único botón
   «de verdad»: las dos son elecciones válidas. */
.choose-opt-primary { border-color: var(--primary); }


.modal-actions { display: flex; gap: 10px; margin-top: 20px; width: 100%; }
.modal-actions .btn { flex: 1; justify-content: center; }
.btn-danger { background: var(--danger); color: #fff; border: none; }
/* Multiselect de etiquetas */
.cf-ms { position:relative; display:flex; align-items:center; gap:6px; min-height:38px; padding:4px 10px 4px 8px; border:1.5px solid var(--border); background:var(--surface); cursor:pointer; transition:border-color .15s; }
.cf-ms:focus-within, .cf-ms:hover { border-color: var(--primary); }
.cf-ms-values { display:flex; flex-wrap:wrap; gap:5px; flex:1; min-width:0; }
.cf-ms-chip { display:inline-flex; align-items:center; font-size:.75rem; font-weight:600; padding:2px 7px; border-radius:2px; }
.cf-ms-placeholder { font-size:.85rem; color:var(--text-muted); padding:2px 0; }
.cf-ms-drop { position:absolute; top:calc(100% + 2px); left:-1px; right:-1px; background:var(--surface); border:1.5px solid var(--primary); border-top:none; z-index:500; max-height:200px; overflow-y:auto; }
.cf-ms-opt { display:flex; align-items:center; gap:8px; padding:8px 12px; font-size:.85rem; cursor:pointer; transition:background .1s; }
.cf-ms-opt:hover { background:var(--surface-2); }
.cf-ms-chk { margin-left:auto; color:var(--primary); display:none; }
.cf-ms-opt.sel .cf-ms-chk { display:block; }
/* Form elements used in modals and panels */
.form-label { display: block; font-size: .82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-input { display: block; width: 100%; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); color: var(--text); font-family: inherit; outline: none; transition: border-color .15s; resize: vertical; box-sizing: border-box; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,71,255,.08); }
.form-hint { display: block; font-size: .75rem; color: var(--text-muted); margin-top: 4px; }
.modal-form { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.modal-form-row { display: flex; flex-direction: column; }
.btn-danger:hover { background: #c0392b; }
/* Un botón deshabilitado tiene que VERSE deshabilitado: sin esto se pintaba igual
   que uno activo y el clic simplemente no hacía nada. Va después de todos los
   :hover para ganarles; el cursor y el title siguen funcionando (sin
   pointer-events:none, que mataría el tooltip que explica por qué). */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }
.btn-danger:disabled:hover, .btn-danger[disabled]:hover { background: var(--danger); }
.btn-primary:disabled:hover, .btn-primary[disabled]:hover { filter: none; }
@keyframes scaleIn {
  from { transform: scale(.85); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.em-folder-custom:hover .em-folder-del { display: block !important; }
.em-folder-custom:hover { background: var(--surface-2, rgba(0,0,0,.04)); }

/* Altura dinámica en navegadores móviles (barra de URL) */
.app-shell { height: 100dvh; }

/* Elementos solo-móvil: ocultos por defecto en escritorio */
.chat-back-btn { display: none; }
.rp-close-btn {
  display: none; position: absolute; top: 10px; left: 10px; z-index: 5;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-secondary); cursor: pointer;
  align-items: center; justify-content: center;
}
.sidebar-backdrop { display: none; }

@media (max-width: 768px) {
  /* ── Sidebar → drawer deslizante ── */
  .sidebar, .sidebar.collapsed {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 1100;
    width: 264px; height: 100dvh;
    transform: translateX(-105%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 12px 0 40px rgba(0,0,0,.35); }
  .sidebar .nav-label, .sidebar .sidebar-logo-text { display: inline; }
  .sidebar .user-info { display: block; }
  .sidebar .nav-section-label { display: block; opacity: 1; }
  .sidebar .nav-chevron { display: inline-flex; }
  .sidebar.collapsed .nav-badge { position: static; }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1090;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity .25s;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: all; }

  /* ── Topbar y página ── */
  .topbar { padding: 0 10px; gap: 6px; }
  #clock-date { display: none; }
  #topbar-clock { min-width: 0 !important; }
  .page { padding: 12px; }
  .card { padding: 16px; }

  /* Evitar zoom automático de iOS al enfocar campos */
  .input, .form-input, select, textarea { font-size: 16px !important; }

  /* ── Grids y formularios ── */
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .stat-card-grad { padding: 14px; }
  .stat-card-grad .stat-value { font-size: 1.6rem; }
  .stat-card-grad .stat-icon { width: 36px; height: 36px; }
  .dash-two-col { grid-template-columns: minmax(0, 1fr) !important; }
  .perm-grid { grid-template-columns: minmax(0, 1fr); }
  .perm-subgrid { margin-left: 10px; }
  .user-form-tabs { overflow-x: auto; }

  /* ── Modales ── */
  .modal { width: calc(100vw - 24px); padding: 20px 16px; max-height: 92dvh; overflow-y: auto; }
  .modal-box { max-height: 92dvh; overflow-y: auto; }

  /* ── Toasts ── */
  .toast-wrap { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; }

}

@media (max-width: 480px) {
  #topbar-clock { display: none !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .channels-grid { grid-template-columns: minmax(0, 1fr); }
  .login-right { padding: 32px 20px; }
  .page { padding: 10px; }
}

/* ── Aviso en línea con acción ────────────────────────────────────────────────
   Bloque de aviso reutilizable: texto a la izquierda, botones a la derecha, y
   los botones son `.btn` de verdad — un enlace suelto metido dentro de la frase
   no se ve como algo pulsable y rompe la uniformidad con el resto de módulos.
   Bajo 620px la acción pasa debajo y ocupa el ancho, como en las cabeceras.   */
.alert {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 14px;
}
.alert-body { flex: 1; min-width: min(100%, 240px); font-size: .85rem; }
.alert-body b { display: block; margin-bottom: 3px; }
.alert-body > div { color: var(--text-secondary); }
.alert-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.alert-warning { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 7%, var(--surface)); }
.alert-warning .alert-body b { color: var(--warning); }
.alert-danger  { border-left-color: var(--danger);  background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.alert-danger .alert-body b { color: var(--danger); }
.alert-info    { border-left-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.alert-info .alert-body b { color: var(--primary); }

@media (max-width: 620px) {
  .alert-actions { width: 100%; }
  .alert-actions .btn { flex: 1; }
}

/* ══════════════════════════════════════════════════════════
   contaprit — Inicio (lista de verificación) y Ayuda
   ══════════════════════════════════════════════════════════ */

/* ── Inicio ── */
.dash-checklist { display: flex; flex-direction: column; gap: 8px; }
.dash-check {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.dash-check-num {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #fff; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.dash-check-ico { color: var(--primary); flex-shrink: 0; display: flex; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.dash-soon { display: flex; flex-direction: column; }
.dash-soon-ico {
  width: 42px; height: 42px; border-radius: 10px; margin-bottom: 10px;
  background: var(--surface-3); color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.dash-soon-off { opacity: .6; }

/* ── Formularios de ficha (Empresa y los que vengan) ── */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span2 { grid-column: span 2; }
.empresa-sec { display: flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 700; margin: 0 0 16px; }
.empresa-resps { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 16px; }
.dash-check.done .dash-check-num { background: var(--success); }
.dash-check.done .dash-check-ico { color: var(--success); }

/* ── Botón «?» de la cabecera de cada pantalla ── */
.help-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer; flex-shrink: 0;
  transition: var(--transition); vertical-align: middle;
}
.help-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--surface-3); }

/* ── Ayuda: índice ── */
.help-search { position: relative; margin-bottom: 20px; max-width: 560px; }
.help-search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); display: flex; pointer-events: none; }
.help-search .input { padding-left: 38px; }
.help-mod { margin-bottom: 24px; }
.help-mod-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text-secondary); margin-bottom: 10px; font-size: .9rem; text-transform: uppercase; letter-spacing: .3px; }
.help-mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.help-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: inherit; text-decoration: none; transition: var(--transition);
}
.help-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.help-card-ico { width: 36px; height: 36px; border-radius: 8px; background: var(--surface-3); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.help-card-title { font-weight: 600; font-size: .92rem; }
.help-card-sum { color: var(--text-muted); font-size: .8rem; margin-top: 3px; line-height: 1.4; }

/* ── Ayuda: artículo ── */
.help-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.help-side { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; max-height: calc(100dvh - 100px); overflow-y: auto; }
.help-side-mod { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); padding: 10px 10px 4px; }
.help-side-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; font-size: .84rem; color: var(--text-secondary); text-decoration: none; }
.help-side-item:hover { background: var(--surface-3); color: var(--text); }
.help-side-item.active { background: var(--primary); color: #fff; }
.help-article { padding: 28px 32px; }
.help-crumbs { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-muted); margin-bottom: 14px; }
.help-crumbs a { color: var(--primary); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.help-body { max-width: 820px; line-height: 1.65; font-size: .95rem; }
.help-body h1 { font-size: 1.6rem; margin-bottom: 14px; }
.help-body h2 { font-size: 1.2rem; margin: 28px 0 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.help-body h3 { font-size: 1rem; margin: 20px 0 8px; }
.help-body p { margin: 0 0 12px; }
.help-body ul, .help-body ol { margin: 0 0 12px 22px; }
.help-body li { margin-bottom: 4px; }
.help-body li > ul, .help-body li > ol { margin-top: 4px; margin-bottom: 0; }
.help-body code { background: var(--surface-3); padding: 1px 6px; border-radius: 4px; font-size: .86em; }
.help-body pre { background: var(--sidebar-bg); color: #E2E8F0; padding: 14px 16px; border-radius: 8px; overflow-x: auto; margin: 0 0 14px; font-size: .84rem; line-height: 1.5; }
.help-body pre code { background: none; padding: 0; color: inherit; }
.help-body a { color: var(--primary); }
.help-body hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.help-body blockquote { margin: 0 0 14px; padding: 10px 14px; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--text-secondary); }
.help-body blockquote p:last-child { margin-bottom: 0; }
.help-callout { border-left-width: 3px; color: var(--text); }
.help-nota, .help-note { border-left-color: var(--info); background: color-mix(in srgb, var(--info) 8%, var(--surface)); }
.help-consejo, .help-tip { border-left-color: var(--success); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.help-importante, .help-aviso, .help-warning { border-left-color: var(--warning); background: color-mix(in srgb, var(--warning) 9%, var(--surface)); }
/* Tabla de un tema de ayuda: es texto, no un listado de datos. Las reglas
   genéricas (`nowrap`, ancho `max-content`, cabeceras centradas y última
   columna fija a la derecha) la desbordaban, cortaban celdas y la columna
   pegajosa tapaba la del medio. Aquí envuelve, va a la izquierda y ocupa
   justo el ancho del cuerpo; la alineación `:---:` del Markdown va en línea
   y sigue ganando. */
.help-table { font-size: .88rem; width: 100%; min-width: 0; }
.help-table thead th, .help-table tbody td { white-space: normal; text-align: left; vertical-align: top; }
.help-table thead th { text-transform: none; }
.table-wrap .help-table thead th:last-child, .table-wrap .help-table tbody td:last-child {
  position: static; box-shadow: none; text-align: left;
}
.help-body .table-wrap { margin: 0 0 14px; }
.help-fig { margin: 0 0 16px; text-align: center; }
.help-fig img { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.help-fig figcaption { color: var(--text-muted); font-size: .8rem; margin-top: 6px; }
.help-body img { max-width: 100%; }
.help-check { display: inline-flex; vertical-align: middle; color: var(--text-muted); margin-right: 2px; }
.help-check.done { color: var(--success); }
.help-toc { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 3px; }
.help-toc-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 4px; }
.help-toc a { color: var(--text-secondary); text-decoration: none; font-size: .86rem; }
.help-toc a:hover { color: var(--primary); }
.help-toc-h3 { padding-left: 14px; font-size: .82rem !important; }
.help-related { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.help-related a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: .88rem; }

@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-side { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  .help-side-mod { width: 100%; padding-top: 6px; }
  .help-article { padding: 18px 16px; }
}

/* ── Genéricos recuperados de la poda: spinner y estado vacío ── */
.spinner-sm { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; opacity: .7; }
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-muted);
  font-size: .88rem;
}
