/* ==========================================================================
   Sistema visual base
   Índice: 1. Tokens  2. Base  3. Layout/Sidebar  4. Header  5. Botones
   6. Formularios/Toolbar  7. Tablas  8. Badges/Estados  9. Cards
   10. Modales  11. Ficha  12. Dashboard  13. Pipeline (heredado, sin uso)
   14. Calendario  15. Responsive  16. Toasts/Utilidades
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* --color-primary, --color-primary-dark, --color-primary-light, --color-sidebar y --color-sidebar-dark
     vienen de /css/theme.css, generado desde config/app.config.js */
  --gray-industrial: var(--color-gray, #545f66);
  --gray-light: #eef2f4;
  --gray-border: #dfe5e9;
  --white: #ffffff;
  --text-main: #333c47;
  --text-muted: #7b8591;
  /* Paleta semántica — el color siempre representa el mismo significado en
     todo el sistema (sección 2.2): azul = información /
     activo / proceso; verde = completado / vigente / pagado; ámbar =
     pendiente / atención / próximo a vencer; rojo = vencido / cancelado /
     error / riesgo. */
  --danger: #e0403b;
  --danger-bg: #ffe6e5;
  --warning: #c97d00;
  --warning-bg: #fff1d0;
  --success: #5f8f00;
  --success-bg: #eef8d3;
  --info: var(--color-primary);
  --info-bg: var(--color-primary-light);
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --sidebar-width: 240px;
  /* Tokens tipográficos (v2.2.2) — documentan valores ya existentes en el
     sistema; no cambian ningún tamaño visual. Se aplican solo a las reglas
     "canónicas" de cada nivel (título de página, título de sección, etc.);
     el resto de declaraciones de font-size del archivo quedan como estaban. */
  --fs-page-title: 22px;
  --fs-section-title: 15px;
  --fs-body: 13px;
  --fs-small: 12px;
  --fs-label: 12.5px;
  --fs-meta: 11.5px;
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--gray-light);
  color: var(--text-main);
}

/* ---------- 3. Layout / Sidebar ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  --color-primary: var(--color-sidebar);
  --color-primary-dark: var(--color-sidebar-dark);
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-primary-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
  z-index: 90;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-logo {
  background: var(--white);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
}

.brand-logo img { width: 100%; height: auto; display: block; }
.brand-logo .logo-dark { display: none !important; }
.brand-logo .logo-light { display: block !important; }

.sidebar-brand small { color: rgba(255, 255, 255, 0.65); font-size: 11px; letter-spacing: 0.02em; }

.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-account-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.sidebar-nav { padding: 12px 10px; flex: 1; }

/* Agrupación visual del sidebar elegante */
.nav-group-label {
  padding: 14px 12px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}
.nav-group-label:first-child { padding-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 3px;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
  transform: translateX(3px);
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(43, 122, 158, 0.95) 0%, rgba(31, 74, 98, 0.85) 100%);
  color: #ffffff;
  font-weight: 600;
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 4px 14px rgba(7, 43, 74, 0.4);
}
.nav-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: rgba(255, 255, 255, 0.7);
  transition: transform 0.15s ease, color 0.15s ease;
}
.nav-item:hover .nav-icon { color: #38bdf8; transform: scale(1.08); }
.nav-item.active .nav-icon { color: #ffffff; }

/* Toggle "Más módulos" (2026-09-23) — reutiliza el look de .nav-item sobre un
   <button>, así que se le quita el estilo nativo de botón. El ícono (chevron)
   gira 180° al expandir, marcado desde JS con .nav-mas-toggle.expanded. */
.nav-mas-toggle { width: 100%; background: none; border: none; font: inherit; cursor: pointer; color: rgba(255, 255, 255, 0.6); }
.nav-mas-toggle:hover { color: rgba(255, 255, 255, 0.85); }
.nav-icon svg { transition: transform 0.15s ease; }
.nav-mas-toggle.expanded .nav-icon svg { transform: rotate(180deg); }
.nav-icon svg { width: 18px; height: 18px; display: block; }

.sidebar-footer {
  padding: 12px 20px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
}
.sidebar-logout { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; background: rgba(255,255,255,.06); color: rgba(255,255,255,.78); cursor: pointer; font: inherit; font-size: 12px; transition: background .18s ease, color .18s ease, border-color .18s ease; }
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover, .sidebar-logout:focus-visible { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.34); color: #fff; outline: none; }

/* Botón hamburguesa: solo visible en tablet/móvil (ver sección 15 Responsive) */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--color-primary-dark);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle svg { width: 20px; height: 20px; display: block; }
.sidebar-backdrop { display: none; }
.mobile-topbar { display: none; }

/* ---------- 4. Header / Content ---------- */
.content { flex: 1; padding: 28px 32px; overflow-x: auto; min-width: 0; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header-titulo { display: flex; align-items: center; gap: 12px; }
.page-header h1 { font-size: var(--fs-page-title); margin: 0; color: var(--color-primary-dark); }
.page-header p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-body); }

/* ---------- 5. Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.btn-primary { background: var(--color-primary); color: var(--white); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--white); color: var(--color-primary); border-color: var(--gray-border); }
.btn-secondary:hover { background: var(--color-primary-light); }
.btn-outline { background: transparent; color: var(--gray-industrial); border-color: var(--gray-border); }
.btn-outline:hover { background: var(--gray-light); }
.btn-danger { background: var(--white); color: var(--danger); border-color: var(--danger-bg); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-small); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .nav-item:focus-visible, .tab-btn:focus-visible, .cal-filtro-btn:focus-visible,
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.btn-link { background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: 13px; padding: 4px 0; text-decoration: underline; }

/* Ícono SVG dentro de un botón/enlace (v2.2.2) — mismo tratamiento que .nav-icon. */
.btn-icon { display: inline-flex; flex-shrink: 0; }
.btn-icon svg { width: 15px; height: 15px; display: block; }

/* ---------- 9. Cards ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: var(--fs-section-title);
  color: var(--color-primary-dark);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Secciones colapsables tipo <details> (2026-09-24) — misma apariencia que
   .card h2, para que abrir/cerrar no se sienta como un componente distinto. */
.card summary {
  font-size: var(--fs-section-title);
  color: var(--color-primary-dark);
  cursor: pointer;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-border);
}
.card details[open] summary { margin-bottom: 16px; }
.card summary::marker { color: var(--text-muted); }

/* ---------- 6. Formularios / Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
}

.search-box { flex: 1; min-width: 220px; position: relative; }
.search-box input { width: 100%; padding: 9px 12px 9px 30px; }
/* Ícono de búsqueda (v2.2.2): antes era el emoji 🔍 vía `content`, ahora un SVG
   lineal aplicado como máscara — hereda color del contexto (currentColor) igual
   que los SVG del sidebar, sin imagen externa ni librería de íconos. */
.search-box::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  background: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

select, input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="file"]), textarea {
  border: 1px solid var(--gray-border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--white);
}

select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.filter-select { min-width: 140px; }

/* ---------- 7. Tablas ---------- */
.table-wrap { overflow-x: auto; background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius); }

table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); min-width: 900px; }

thead th {
  text-align: left;
  background: var(--gray-light);
  color: var(--gray-industrial);
  font-size: var(--fs-meta);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-border);
  white-space: nowrap;
}

tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-light); }
.row-inactive { opacity: 0.55; }

.link-cliente { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.link-cliente:hover { text-decoration: underline; }
.text-muted { color: var(--text-muted); }
.code-badge { font-family: Consolas, monospace; font-size: 12px; color: var(--gray-industrial); }

/* ---------- 8. Badges / Estados ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.badge-nuevo { background: var(--color-primary-light); color: var(--color-primary); }
.badge-activo { background: var(--success-bg); color: var(--success); }
.badge-riesgo { background: var(--warning-bg); color: var(--warning); }
.badge-inactivo { background: #ececec; color: #6b7280; }
.badge-vencida { background: var(--danger-bg); color: var(--danger); }
.badge-pendiente-facturar { background: #fff0e0; color: #c2540a; }

.saldo-pendiente { color: var(--danger); font-weight: 700; }
.saldo-liquidado { color: var(--success); font-weight: 700; }

.prioridad { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 800; }
.prioridad-a { background: #fdecea; color: var(--danger); }
.prioridad-b { background: var(--warning-bg); color: var(--warning); }
.prioridad-c { background: var(--gray-light); color: var(--gray-industrial); }

.estatus-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.estatus-pill.activa, .estatus-pill.activo { background: var(--success-bg); color: var(--success); }
.estatus-pill.inactiva, .estatus-pill.inactivo { background: #ececec; color: #6b7280; }

td.actions-cell, .actions-cell {
  vertical-align: middle;
  white-space: nowrap;
}
.actions-cell > div {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
}

/* Empty state */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { display: flex; justify-content: center; margin-bottom: 10px; color: var(--gray-border); }
.empty-state .icon svg { width: 34px; height: 34px; display: block; }

/* Indicador de carga (v2.2.2) — reutiliza .empty-state, agrega un spinner
   discreto antes del mismo texto "Cargando..." que ya existía; sin librerías,
   solo CSS. */
.loading-state { display: flex; align-items: center; justify-content: center; gap: 10px; }
.spinner {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2.5px solid var(--gray-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: app-spin 0.7s linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.8s; }
}

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field label { font-size: var(--fs-label); font-weight: 600; color: var(--gray-industrial); }
.field .hint { font-size: 11px; color: var(--text-muted); }
.field .error-msg { font-size: 11.5px; color: var(--danger); }
textarea { resize: vertical; min-height: 60px; }

.form-section-title { font-size: 13px; font-weight: 700; color: var(--color-primary-dark); margin: 22px 0 12px; text-transform: uppercase; letter-spacing: 0.03em; }

.filtros-activos { font-size: 12.5px; color: var(--text-muted); background: var(--gray-light); border: 1px solid var(--gray-border); border-radius: 8px; padding: 8px 12px; margin: -6px 0 14px; }
.filtros-activos strong { color: var(--color-primary-dark); }
.form-section-title:first-child { margin-top: 0; }

.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-success { background: var(--success-bg); color: var(--success); }

.subitem-card {
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--gray-light);
}
.subitem-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.subitem-card-header strong { font-size: 13.5px; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--gray-border); }

/* ---------- 10. Modales ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(7, 43, 74, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto; z-index: 100;
  animation: fadeIn 0.15s ease-out;
}
.modal {
  background: var(--white); border-radius: 14px; width: 100%; max-width: 640px;
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.06);
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.modal-lg { max-width: 900px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-border);
  background: #f8fafc;
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--color-primary-dark); letter-spacing: -0.01em; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.06);
  background: #f1f5f9; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer; color: #64748b; line-height: 1; transition: all 0.15s ease;
}
.modal-close:hover { background: #e2e8f0; color: #0f172a; transform: scale(1.05); }
.modal-body { padding: 22px 24px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--gray-border); flex: 0 0 auto; background: var(--white); }

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- 11. Ficha ---------- */
.ficha-header {
  background: var(--white); border: 1px solid var(--gray-border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 20px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.ficha-header h1 { margin: 0 0 4px; font-size: 20px; color: var(--color-primary-dark); }
.ficha-header .nombre-comercial { color: var(--text-muted); font-size: 13.5px; margin-bottom: 10px; }
.ficha-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.ficha-badges { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ficha-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.info-item .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 3px; }
.info-item .value { font-size: 14px; color: var(--text-main); }
.info-item .value.empty { color: #b3b9c2; font-style: italic; }

.history-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--gray-border); }
.history-item:last-child { border-bottom: none; }
.history-time { width: 150px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); }
.history-detail strong { font-size: 13.5px; }
.history-diff { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- 12. Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.dash-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
}
.dash-card:hover { border-left-color: var(--color-primary-dark); }
.dash-card.dash-alerta { border-left-color: var(--danger); }
/* "Por vencer" / atención próxima — mismo significado ámbar que el resto del
   sistema (badge-riesgo, .dash-dot.ambar), distinto de "vencido" (rojo). */
.dash-card.dash-atencion { border-left-color: var(--warning); }
.dash-card.dash-alerta .dash-card-valor { color: var(--danger); }
.dash-card.dash-atencion .dash-card-valor { color: var(--warning); }
.dash-card-titulo { font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 6px; }
.dash-card-valor { font-size: 24px; font-weight: 700; color: var(--color-primary-dark); }
.dash-card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.dash-seccion { margin-bottom: 22px; }
.dash-seccion-titulo {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text-muted); margin: 0 0 10px;
  text-transform: uppercase; letter-spacing: 0.02em;
}
.dash-seccion .dash-grid { margin-bottom: 0; }
.dash-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; vertical-align: middle; margin-bottom: 2px; }
.dash-dot.rojo { background: var(--danger); }
.dash-dot.ambar { background: var(--warning); }
.dash-dot.verde { background: var(--success); }

/* Tarjetas de estadística compactas (reemplaza los "chip" inline duplicados
   del dashboard — mismo patrón visual, ahora como clase reutilizable) */
.stat-tiles { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.stat-tile {
  flex: 1; min-width: 140px; background: var(--gray-light); border: 1px solid var(--gray-border);
  border-radius: var(--radius); padding: 10px 12px;
}
.stat-tile-value { display: block; font-size: 20px; font-weight: 700; color: var(--color-primary-dark); }
.stat-tile-value.sm { font-size: 14px; }
.stat-tile-label { font-size: 11.5px; color: var(--text-muted); }

/* ---------- 15. Responsive ---------- */
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .form-grid, .form-grid.cols-2, .info-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
  .dash-grid { grid-template-columns: 1fr; }

  /* Sidebar pasa a panel off-canvas (tablet y móvil) — se abre con el botón
     hamburguesa del header (.sidebar-toggle), nunca cambia rutas ni lógica. */
  .mobile-topbar { display: flex; align-items: center; padding: 14px 20px 0; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 140;
  }
  .content { padding: 20px; }
}

/* ---------- 16. Toasts / Utilidades ---------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--color-primary-dark); color: var(--white); padding: 12px 18px; border-radius: 8px;
  font-size: 13.5px; box-shadow: var(--shadow); min-width: 240px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Ajuste móvil Android — mantiene el escritorio intacto y evita desbordes. */
@media (max-width: 700px) {
  body { font-size: 14px; overflow-x: hidden; }
  .app-main, main, .page-container { padding-left: 12px !important; padding-right: 12px !important; }
  .page-header { gap: 10px !important; align-items: flex-start !important; }
  .page-header h1 { font-size: 22px !important; line-height: 1.2; }
  .page-header .btn, .ficha-actions .btn { min-height: 42px; width: 100%; }
  .ficha-header { display: block !important; padding: 14px !important; }
  .ficha-header h1 { font-size: 22px !important; }
  .ficha-actions { display: grid !important; grid-template-columns: 1fr !important; gap: 8px !important; margin-top: 14px; }
  .tabs { display: flex !important; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 6px !important; }
  .tab-btn { flex: 0 0 auto; min-height: 42px; white-space: nowrap; }
  .card { padding: 14px !important; }
  .info-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .form-grid, .form-grid.cols-2 { grid-template-columns: 1fr !important; }
  .field.span-2 { grid-column: auto !important; }
  .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table { min-width: 760px; }
  .table-wrap th, .table-wrap td { padding: 10px 8px !important; }
  .toolbar { align-items: stretch !important; }
  .toolbar > *, .search-box, .search-box input, .filter-select { width: 100% !important; max-width: none !important; min-height: 42px; }
  .modal { width: calc(100vw - 24px) !important; max-height: 92vh; overflow-y: auto; }
  .modal-footer { position: sticky; bottom: 0; background: #fff; padding-top: 10px; }
  input, select, textarea, button, .btn { font-size: 16px !important; }
}

/* Dashboard SLA, KPIs & Activity Feed Base Styles (Modo Claro) */
.dash-sla-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  background: #fff5f5;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.dash-sla-title {
  font-weight: 700;
  color: var(--color-primario);
  text-decoration: none;
}
.dash-sla-hint {
  font-size: 12px;
  margin-top: 4px;
}
.dash-activity-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e0f2fe;
  color: var(--color-primario);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.dash-activity-meta {
  font-size: 11.5px;
  color: #475569;
}
.kpi-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.kpi-icon-blue { background: var(--color-primario-claro); color: var(--color-primario); }
.kpi-icon-yellow { background: #fef3c7; color: #d97706; }
.kpi-icon-green { background: #ecfccb; color: #5f8f00; }
.kpi-icon-red { background: #fee2e2; color: #e0403b; }

/* Botones en Sidebar Account (Tema y Sesión) */
.sidebar-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-account .theme-toggle,
.sidebar-account .sidebar-logout {
  flex: 1;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.sidebar-account .theme-toggle:hover,
.sidebar-account .sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

/* ==========================================================================
   TEMA OSCURO EMPRESARIAL (Enterprise High-Contrast Dark Mode)
   Paleta: Canvas (#0b111e), Surfaces (#111a2e), Borders (#1e2c44)
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --color-primario: #38bdf8;
  --color-primario-oscuro: #0284c7;
  --color-primary-light: #162a45;
  --gray-light: #0b111e;
  --gray-border: #1e2c44;
  --white: #111a2e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --danger-bg: rgba(239, 68, 68, 0.16);
  --warning-bg: rgba(245, 158, 11, 0.16);
  --success-bg: rgba(34, 197, 94, 0.16);
  --info-bg: rgba(56, 189, 248, 0.16);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}

/* 1. Fondo General, Sidebar y Navegación */
html[data-theme="dark"] body {
  background-color: #0b111e !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .content {
  background-color: #0b111e !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .sidebar {
  background: #070c16 !important;
  border-right: 1px solid #1a2536 !important;
}
html[data-theme="dark"] .mobile-topbar {
  background: #070c16 !important;
  border-bottom: 1px solid #1a2536 !important;
}
html[data-theme="dark"] .brand-logo {
  background: transparent !important;
  border-radius: 0 !important;
  padding: 4px 0 !important;
  box-shadow: none !important;
  border: none !important;
}
html[data-theme="dark"] .brand-logo .logo-light {
  display: none !important;
}
html[data-theme="dark"] .brand-logo .logo-dark {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-height: 80px !important;
  object-fit: contain !important;
}
html[data-theme="dark"] .sidebar-nav a {
  color: #94a3b8;
}
html[data-theme="dark"] .sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}
html[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(56, 189, 248, 0.12) !important;
  color: #38bdf8 !important;
  border-left: 3px solid #38bdf8;
}
html[data-theme="dark"] .nav-group-label {
  color: #64748b;
}

/* 2. Tarjetas, Paneles y Cabeceras */
html[data-theme="dark"] .card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .kpi-card {
  background-color: #111a2e !important;
  border: 1px solid #1e2c44 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35) !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .page-header {
  color: #f8fafc !important;
}
html[data-theme="dark"] .page-header h1,
html[data-theme="dark"] .page-header h2,
html[data-theme="dark"] .card-header h2,
html[data-theme="dark"] .card-header h3 {
  color: #f8fafc !important;
}
html[data-theme="dark"] .page-header p {
  color: #94a3b8 !important;
}

/* 3. Indicadores Clave (KPIs) */
html[data-theme="dark"] .kpi-label {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .kpi-value {
  color: #ffffff !important;
}
html[data-theme="dark"] .kpi-meta,
html[data-theme="dark"] .kpi-hint {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .kpi-click-hint {
  border-top-color: #1e2c44 !important;
  color: #38bdf8 !important;
}
html[data-theme="dark"] .kpi-icon-blue {
  background: rgba(56, 189, 248, 0.14) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.28) !important;
}
html[data-theme="dark"] .kpi-icon-yellow {
  background: rgba(245, 158, 11, 0.14) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.28) !important;
}
html[data-theme="dark"] .kpi-icon-green {
  background: rgba(34, 197, 94, 0.14) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.28) !important;
}
html[data-theme="dark"] .kpi-icon-red {
  background: rgba(239, 68, 68, 0.14) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.28) !important;
}

/* 4. Solicitudes que Requieren Atención (SLA) */
html[data-theme="dark"] .dash-sla-item {
  background: rgba(239, 68, 68, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  border-radius: 8px !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .dash-sla-title {
  color: #38bdf8 !important;
}
html[data-theme="dark"] .dash-sla-hint {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .dash-sla-hint strong {
  color: #f8fafc !important;
}
html[data-theme="dark"] .dash-sla-item .btn,
html[data-theme="dark"] .dash-sla-item button {
  background: #0284c7 !important;
  border-color: #0284c7 !important;
  color: #ffffff !important;
}

/* 5. Actividad y Movimientos Recientes */
html[data-theme="dark"] .dash-activity-avatar {
  background: #1e293b !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
}
html[data-theme="dark"] .dash-activity-item {
  border-bottom: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .dash-activity-item strong {
  color: #f8fafc !important;
}
html[data-theme="dark"] .dash-activity-meta {
  color: #94a3b8 !important;
}

/* 6. Tablas Empresariales de Alto Contraste */
html[data-theme="dark"] .table-wrap {
  background: #111a2e !important;
  border: 1px solid #1e2c44 !important;
  border-radius: 8px !important;
}
html[data-theme="dark"] table {
  background: transparent !important;
  color: #f1f5f9 !important;
}
html[data-theme="dark"] th {
  background-color: #0d1525 !important;
  color: #94a3b8 !important;
  border-bottom: 1px solid #1e2c44 !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
}
html[data-theme="dark"] td {
  background-color: transparent !important;
  border-bottom: 1px solid #182338 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] tbody tr:hover td {
  background-color: rgba(56, 189, 248, 0.04) !important;
}
html[data-theme="dark"] td strong {
  color: #f8fafc !important;
}
html[data-theme="dark"] .hint,
html[data-theme="dark"] td .hint {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .cabecera-fija {
  background: #0b111e !important;
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.6) !important;
}
html[data-theme="dark"] .tabla-fija thead th {
  background: #0d1525 !important;
}

/* 7. Enlaces y Folios en Tablas */
html[data-theme="dark"] .js-quickview-btn,
html[data-theme="dark"] a.js-quickview-btn {
  background: rgba(56, 189, 248, 0.12) !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
  color: #38bdf8 !important;
}

/* 8. Badges y Estatus con Alto Contraste */
html[data-theme="dark"] .badge,
html[data-theme="dark"] .status-pill {
  font-weight: 600 !important;
}
html[data-theme="dark"] .badge-activo,
html[data-theme="dark"] .badge-autorizada,
html[data-theme="dark"] .badge-pagada,
html[data-theme="dark"] .badge-exito {
  background: rgba(34, 197, 94, 0.16) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
}
html[data-theme="dark"] .badge-peligro,
html[data-theme="dark"] .badge-rechazada,
html[data-theme="dark"] .badge-vencida,
html[data-theme="dark"] .badge-devuelta {
  background: rgba(239, 68, 68, 0.16) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
}
html[data-theme="dark"] .badge-riesgo,
html[data-theme="dark"] .badge-pendiente,
html[data-theme="dark"] .badge-alerta,
html[data-theme="dark"] .badge-por-revisar {
  background: rgba(245, 158, 11, 0.16) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.35) !important;
}
html[data-theme="dark"] .badge-info,
html[data-theme="dark"] .badge-en-proceso,
html[data-theme="dark"] .badge-en-revision {
  background: rgba(56, 189, 248, 0.16) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
}
html[data-theme="dark"] .badge-inactivo,
html[data-theme="dark"] .badge-borrador {
  background: rgba(148, 163, 184, 0.14) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
}

/* 9. Formularios, Controles y Búsqueda (en el CRM y Modales) */
html[data-theme="dark"] .app-shell input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] .modal input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="dark"] .app-shell select,
html[data-theme="dark"] .modal select,
html[data-theme="dark"] .app-shell textarea,
html[data-theme="dark"] .modal textarea,
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .filter-select {
  background-color: #0d1525 !important;
  color: #f1f5f9 !important;
  border: 1px solid #222f44 !important;
}
html[data-theme="dark"] .app-shell input:focus,
html[data-theme="dark"] .modal input:focus,
html[data-theme="dark"] .app-shell select:focus,
html[data-theme="dark"] .modal select:focus,
html[data-theme="dark"] .app-shell textarea:focus,
html[data-theme="dark"] .modal textarea:focus {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25) !important;
  outline: none !important;
}
html[data-theme="dark"] .app-shell input::placeholder,
html[data-theme="dark"] .modal input::placeholder,
html[data-theme="dark"] .app-shell textarea::placeholder,
html[data-theme="dark"] .modal textarea::placeholder {
  color: #64748b !important;
}
html[data-theme="dark"] .search-box {
  background-color: #0d1525 !important;
  border: 1px solid #222f44 !important;
}

/* 10. Modales */
html[data-theme="dark"] .modal-backdrop {
  background: rgba(3, 7, 18, 0.78) !important;
  backdrop-filter: blur(4px);
}
html[data-theme="dark"] .modal {
  background-color: #111a2e !important;
  color: #f1f5f9 !important;
  border: 1px solid #1e2c44 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important;
}
html[data-theme="dark"] .modal-header {
  border-bottom: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .modal-header h2,
html[data-theme="dark"] .modal-header h3 {
  color: #f8fafc !important;
}
html[data-theme="dark"] .modal-footer {
  background-color: #0d1525 !important;
  border-top: 1px solid #1e2c44 !important;
}

/* 11. Botones */
html[data-theme="dark"] .btn-primary {
  background: #0284c7 !important;
  border-color: #0284c7 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35) !important;
}
html[data-theme="dark"] .btn-primary:hover {
  background: #0369a1 !important;
  border-color: #0369a1 !important;
}
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-outline {
  background: #162238 !important;
  border-color: #263852 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-outline:hover {
  background: #1e2f4d !important;
  color: #ffffff !important;
}

/* 12. Anulación Universal de Textos Oscuros Inline (exclusivo para el CRM y Modales) */
html[data-theme="dark"] .app-shell [style*="color:#0f172a"],
html[data-theme="dark"] .app-shell [style*="color: #0f172a"],
html[data-theme="dark"] .app-shell [style*="color:#111827"],
html[data-theme="dark"] .app-shell [style*="color: #111827"],
html[data-theme="dark"] .app-shell [style*="color:#1e293b"],
html[data-theme="dark"] .app-shell [style*="color: #1e293b"],
html[data-theme="dark"] .app-shell [style*="color:#1f2937"],
html[data-theme="dark"] .app-shell [style*="color: #1f2937"],
html[data-theme="dark"] .app-shell [style*="color:#0f2744"],
html[data-theme="dark"] .app-shell [style*="color: #0f2744"],
html[data-theme="dark"] .modal [style*="color:#0f172a"],
html[data-theme="dark"] .modal [style*="color: #0f172a"],
html[data-theme="dark"] .modal [style*="color:#111827"],
html[data-theme="dark"] .modal [style*="color: #111827"],
html[data-theme="dark"] .modal [style*="color:#1e293b"],
html[data-theme="dark"] .modal [style*="color: #1e293b"],
html[data-theme="dark"] .modal [style*="color:#1f2937"],
html[data-theme="dark"] .modal [style*="color: #1f2937"],
html[data-theme="dark"] .modal [style*="color:#0f2744"],
html[data-theme="dark"] .modal [style*="color: #0f2744"] {
  color: #f8fafc !important;
}

html[data-theme="dark"] .app-shell [style*="color:#334155"],
html[data-theme="dark"] .app-shell [style*="color: #334155"],
html[data-theme="dark"] .app-shell [style*="color:#475569"],
html[data-theme="dark"] .app-shell [style*="color: #475569"],
html[data-theme="dark"] .app-shell [style*="color:#64748b"],
html[data-theme="dark"] .app-shell [style*="color: #64748b"],
html[data-theme="dark"] .modal [style*="color:#334155"],
html[data-theme="dark"] .modal [style*="color: #334155"],
html[data-theme="dark"] .modal [style*="color:#475569"],
html[data-theme="dark"] .modal [style*="color: #475569"],
html[data-theme="dark"] .modal [style*="color:#64748b"],
html[data-theme="dark"] .modal [style*="color: #64748b"] {
  color: #94a3b8 !important;
}

/* 13. Anulación Universal de Fondos Claros Inline en Modo Oscuro */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background-color:#fff"],
html[data-theme="dark"] [style*="background-color: #fff"],
html[data-theme="dark"] [style*="background-color:#ffffff"],
html[data-theme="dark"] [style*="background-color: #ffffff"] {
  background-color: #111a2e !important;
  color: #f1f5f9 !important;
}

html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f1f5f9"],
html[data-theme="dark"] [style*="background: #f1f5f9"] {
  background-color: #0d1525 !important;
}

html[data-theme="dark"] [style*="background:#e2e8f0"],
html[data-theme="dark"] [style*="background: #e2e8f0"] {
  background-color: #1e2c44 !important;
}

html[data-theme="dark"] [style*="border-top:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border-bottom:1px solid #e2e8f0"],
html[data-theme="dark"] [style*="border:1px solid #e2e8f0"] {
  border-color: #1e2c44 !important;
}

/* 14. Módulo de Administración de Usuarios y Rangos (Modo Oscuro) */
html[data-theme="dark"] .users-kpi-card {
  background-color: #111a2e !important;
  border: 1px solid #1e2c44 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35) !important;
}
html[data-theme="dark"] .users-kpi-val {
  color: #ffffff !important;
}
html[data-theme="dark"] .users-kpi-label {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .users-toolbar-card {
  background-color: #111a2e !important;
  border: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .users-search-input {
  background-color: #0d1525 !important;
  border: 1px solid #222f44 !important;
  color: #f8fafc !important;
}
html[data-theme="dark"] .users-search-input:focus {
  background-color: #0d1525 !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
}
html[data-theme="dark"] .users-select {
  background-color: #0d1525 !important;
  border: 1px solid #222f44 !important;
  color: #f8fafc !important;
}
html[data-theme="dark"] #users-count-badge {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .users-table-container {
  background-color: #111a2e !important;
  border: 1px solid #1e2c44 !important;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35) !important;
}
html[data-theme="dark"] .users-table {
  background-color: transparent !important;
}
html[data-theme="dark"] .users-table th {
  background-color: #0d1525 !important;
  color: #94a3b8 !important;
  border-bottom: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .users-table td {
  background-color: transparent !important;
  border-bottom: 1px solid #182338 !important;
  color: #e2e8f0 !important;
}
html[data-theme="dark"] .users-table tbody tr {
  background-color: transparent !important;
}
html[data-theme="dark"] .users-table tbody tr:hover,
html[data-theme="dark"] .users-table tbody tr:hover td {
  background-color: rgba(56, 189, 248, 0.08) !important;
}
html[data-theme="dark"] .user-name-title {
  color: #f8fafc !important;
  font-weight: 600 !important;
}
html[data-theme="dark"] .user-identifier-tag {
  color: #38bdf8 !important;
  background: rgba(56, 189, 248, 0.12) !important;
  border: 1px solid rgba(56, 189, 248, 0.28) !important;
  border-radius: 4px;
  padding: 1px 6px;
}
html[data-theme="dark"] .user-puesto-tag {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .user-rango-desc {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .user-contact-item {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .user-contact-item:hover {
  color: #38bdf8 !important;
}
html[data-theme="dark"] .user-contact-item svg {
  color: #94a3b8 !important;
}
html[data-theme="dark"] .user-corp-badge {
  background: #1e293b !important;
  color: #cbd5e1 !important;
  border: 1px solid #334155 !important;
}
html[data-theme="dark"] .badge-propietario {
  background: rgba(245, 158, 11, 0.2) !important;
  color: #fbbf24 !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
}
html[data-theme="dark"] .badge-programador {
  background: rgba(56, 189, 248, 0.2) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.45) !important;
}
html[data-theme="dark"] .rango-option-card {
  background-color: #0d1525 !important;
  border-color: #1e2c44 !important;
}
html[data-theme="dark"] .rango-option-card.is-selected {
  background-color: rgba(56, 189, 248, 0.12) !important;
  border-color: #38bdf8 !important;
}
html[data-theme="dark"] .role-pill-card {
  background-color: #0d1525 !important;
  border-color: #1e2c44 !important;
}
html[data-theme="dark"] .role-pill-card.is-active {
  background-color: rgba(56, 189, 248, 0.14) !important;
  border-color: #38bdf8 !important;
}
html[data-theme="dark"] .badge-nuevo {
  background: rgba(56, 189, 248, 0.14) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
}
html[data-theme="dark"] .action-icon-btn {
  background: #162238 !important;
  border: 1px solid #263852 !important;
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .action-icon-btn:hover {
  background: #1e2f4d !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
}
html[data-theme="dark"] .action-icon-btn.btn-delete {
  color: #f87171 !important;
}
html[data-theme="dark"] .action-icon-btn.btn-delete:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #ff8585 !important;
}

/* Rangos Jerárquicos en Modo Oscuro */
html[data-theme="dark"] .badge-rango-1 {
  background: rgba(239, 68, 68, 0.18) !important;
  color: #f87171 !important;
  border: 1px solid rgba(239, 68, 68, 0.38) !important;
}
html[data-theme="dark"] .badge-rango-2 {
  background: rgba(168, 85, 247, 0.18) !important;
  color: #c084fc !important;
  border: 1px solid rgba(168, 85, 247, 0.38) !important;
}
html[data-theme="dark"] .badge-rango-3 {
  background: rgba(56, 189, 248, 0.18) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.38) !important;
}
html[data-theme="dark"] .badge-rango-4 {
  background: rgba(34, 197, 94, 0.18) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.38) !important;
}
html[data-theme="dark"] .badge-rango-5 {
  background: rgba(148, 163, 184, 0.18) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(148, 163, 184, 0.38) !important;
}

/* Roles y Permisos (RBAC Moderno en Modo Oscuro) */
html[data-theme="dark"] .role-identity-panel {
  background: #111a2e !important;
  border: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .role-field-label {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .role-field-input {
  background: #0d1525 !important;
  color: #f1f5f9 !important;
  border: 1px solid #222f44 !important;
}
html[data-theme="dark"] .role-perm-section-title {
  border-bottom: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .role-perm-section-title h3 {
  color: #f8fafc !important;
}
html[data-theme="dark"] .perm-module-card {
  background: #111a2e !important;
  border: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .perm-module-header {
  background: #0d1525 !important;
  border-bottom: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .perm-module-name {
  color: #f8fafc !important;
}
html[data-theme="dark"] .perm-toggle-item {
  background: #0d1525 !important;
  border: 1px solid #1e2c44 !important;
}
html[data-theme="dark"] .perm-toggle-item:hover {
  background: #162238 !important;
  border-color: #263852 !important;
}
html[data-theme="dark"] .perm-toggle-item.is-selected {
  background: rgba(56, 189, 248, 0.12) !important;
  border-color: rgba(56, 189, 248, 0.45) !important;
}
html[data-theme="dark"] .perm-text-title {
  color: #f8fafc !important;
}
html[data-theme="dark"] .perm-text-desc {
  color: #94a3b8 !important;
}

/* Listados con cabecera fija: el título y los filtros se quedan arriba al desplazarse y los
   títulos de la tabla quedan justo debajo. Lo aplica ui.js a cualquier vista con .page-header + .table-wrap. */
.content:has(.cabecera-fija) { overflow: visible; }
.cabecera-fija { position: sticky; top: 0; z-index: 30; margin: -28px -32px 10px; padding: 18px 32px 2px; background: var(--gray-light); box-shadow: 0 6px 10px -8px rgba(15, 30, 50, .25); }
.cabecera-fija .page-header { margin-bottom: 10px; }
.cabecera-fija .toolbar { margin-bottom: 8px; }
.cabecera-fija.compacta { padding-top: 8px; }
.cabecera-fija.compacta .page-header { margin-bottom: 6px; align-items: center; }
.cabecera-fija.compacta .page-header h1 { font-size: 17px; }
.cabecera-fija.compacta .page-header p { display: none; }
.table-wrap.tabla-fija { overflow: visible; }
.tabla-fija thead th { position: sticky; top: var(--cabecera-fija-h, 0px); z-index: 25; background: var(--gray-light); }
@media (max-width: 900px) {
  .cabecera-fija { position: static; margin: 0 0 10px; padding: 0; box-shadow: none; }
  .tabla-fija thead th { position: static; }
}
