/* ==========================================================================
   Comisionamiento · Tema basado en Centris (claro + oscuro)
   Construido sobre Bootstrap 5.3 (data-bs-theme). Todo el color se controla
   con variables para que el modo oscuro sea solo un override.
   ========================================================================== */

:root {
  --c-brand: #2563eb;
  --c-brand-dark: #1d4ed8;
  --c-brand-soft: #e8f0ff;

  /* Sidebar — azul marino en los dos temas */
  --c-sidebar: #0f1b33;
  --c-sidebar-hover: rgba(255, 255, 255, .08);
  --c-sidebar-text: #c9d3e6;
  --c-sidebar-muted: #7f8eab;
  --c-sidebar-title: #ffffff;
  --c-sidebar-hover-text: #ffffff;
  --c-sidebar-border: rgba(255, 255, 255, .08);

  /* Superficies y texto (modo claro) */
  --c-bg: #f3f5fa;
  --c-surface: #ffffff;
  --c-surface-2: #f4f6fb;
  --c-ink: #16203a;
  --c-muted: #51607a;
  --c-line: #dde2ec;
  --c-hover: #eef3ff;

  --radius: .65rem;
  --radius-lg: 18px;          /* tarjetas (estilo 1.48) */
  --radius-ctl: 10px;         /* botones y campos */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 6px 22px rgba(15, 23, 42, .10);
}

[data-bs-theme="dark"] {
  --c-brand: #5b8cff;
  --c-brand-dark: #7aa2ff;
  --c-brand-soft: rgba(91, 140, 255, .16);

  --c-sidebar: #0b1322;
  --c-sidebar-hover: #1b2942;
  --c-sidebar-text: #cdd6e4;
  --c-sidebar-muted: #8595af;
  --c-sidebar-title: #ffffff;
  --c-sidebar-hover-text: #ffffff;
  --c-sidebar-border: rgba(255, 255, 255, .08);

  --c-bg: #0a1120;
  --c-surface: #141d30;
  --c-surface-2: #1a2540;
  --c-ink: #e8edf6;
  --c-muted: #a9b5cb;
  --c-line: #283349;
  --c-hover: rgba(91, 140, 255, .12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 8px 26px rgba(0, 0, 0, .45);
}

/* Bootstrap overrides */
.btn-primary {
  --bs-btn-bg: var(--c-brand);
  --bs-btn-border-color: var(--c-brand);
  --bs-btn-hover-bg: var(--c-brand-dark);
  --bs-btn-hover-border-color: var(--c-brand-dark);
  --bs-btn-active-bg: var(--c-brand-dark);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
}
.btn-outline-primary {
  --bs-btn-color: var(--c-brand);
  --bs-btn-border-color: var(--c-brand);
  --bs-btn-hover-bg: var(--c-brand);
  --bs-btn-hover-border-color: var(--c-brand);
  --bs-btn-active-bg: var(--c-brand);
  --bs-btn-hover-color: #fff;
}
a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-dark); text-decoration: underline; }
.text-primary { color: var(--c-brand) !important; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
}

/* ----------------------------------------------------------- App shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.main-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------- Sidebar ---- */
.sidebar {
  background: linear-gradient(180deg, #13213f 0%, var(--c-sidebar) 100%);
  color: var(--c-sidebar-text);
  border-right: 1px solid var(--c-sidebar-border);
  --bs-offcanvas-width: 270px;
  --bs-offcanvas-bg: var(--c-sidebar);
  --bs-offcanvas-color: var(--c-sidebar-text);
}
.sidebar .sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.15rem 1.25rem;
  color: var(--c-sidebar-title); font-weight: 700; font-size: 1.25rem; letter-spacing: .2px;
  border-bottom: 1px solid var(--c-sidebar-border);
}
.sidebar .sidebar-brand:hover { text-decoration: none; color: var(--c-sidebar-title); }
.sidebar .sidebar-brand .logo {
  width: 34px; height: 34px; border-radius: 8px;
  object-fit: contain; display: block; flex: 0 0 auto;
}
.sidebar .nav-section {
  padding: 1.1rem 1.25rem .35rem;
  font-size: .7rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--c-sidebar-muted);
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: .6rem;
  margin: .12rem .5rem; padding: .58rem .65rem;
  border-radius: .55rem;
  color: var(--c-sidebar-text); font-weight: 500; font-size: .92rem;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.sidebar .nav-link:hover { background: var(--c-sidebar-hover); color: var(--c-sidebar-hover-text); text-decoration: none; }
.sidebar .nav-link.active {
  background: linear-gradient(135deg, #2563eb, #3b82f6); color: #fff;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .45); border-radius: .8rem;
}
.sidebar .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.sidebar .nav-link.active i { color: #fff; }
.sidebar .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar .sidebar-footer {
  margin-top: auto; padding: 1rem 1.1rem;
  border-top: 1px solid var(--c-sidebar-border);
}
.sidebar .app-version { margin-top: .5rem; font-size: .72rem; color: var(--c-sidebar-text); opacity: .55; }
.sidebar .user-chip { display: flex; align-items: center; gap: .6rem; color: var(--c-sidebar-text); font-size: .88rem; text-decoration: none; border-radius: .5rem; padding: .2rem; }
.sidebar a.user-chip:hover { background: var(--c-sidebar-hover); color: var(--c-sidebar-hover-text); text-decoration: none; }
.sidebar .user-chip .user-position { font-size: .72rem; color: var(--c-sidebar-muted); line-height: 1.1; }
.profile-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 700;
  background: var(--c-brand); color: #fff;
}
.sidebar .user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-brand); color: #fff; font-weight: 600;
}
/* Botón "Salir" adaptado al tema del sidebar. */
.sidebar .btn-outline-light {
  --bs-btn-color: var(--c-sidebar-text);
  --bs-btn-border-color: var(--c-sidebar-border);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--c-brand);
  --bs-btn-hover-border-color: var(--c-brand);
}

/* En celular el menú es un panel lateral (offcanvas) a toda la altura: sin
   esto, las opciones que no caben en la pantalla no se pueden alcanzar. */
@media (max-width: 991.98px) {
  .sidebar.offcanvas-lg {
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    height: 100dvh;
  }
  .sidebar.offcanvas-lg > .nav,
  .sidebar.offcanvas-lg > .sidebar-brand,
  .sidebar.offcanvas-lg > .sidebar-footer { flex-shrink: 0; }
}
/* Oculta la barra de scroll del menú (el scroll sigue funcionando). */
.sidebar { scrollbar-width: none; -ms-overflow-style: none; }
.sidebar::-webkit-scrollbar { width: 0; height: 0; }

/* Botón de flecha en la orilla del sidebar para colapsar/expandir. */
.nav-edge-toggle {
  position: fixed; top: 50%; left: 230px; margin-left: -13px;
  transform: translateY(-50%); z-index: 1030;
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  align-items: center; justify-content: center;
  background: var(--c-surface); color: var(--c-ink);
  border: 1px solid var(--c-line); box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  transition: left .18s ease, background .12s ease, color .12s ease;
}
.nav-edge-toggle:hover { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.nav-edge-toggle i { font-size: .9rem; line-height: 1; transition: transform .18s ease; }
html.nav-collapsed .nav-edge-toggle { left: 74px; }
html.nav-collapsed .nav-edge-toggle i { transform: rotate(180deg); }

@media (min-width: 992px) {
  .sidebar {
    width: 230px; flex: 0 0 230px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    transition: width .18s ease, flex-basis .18s ease;
  }

  /* ---- Menú colapsado: solo iconos (escritorio) ---- */
  html.nav-collapsed .sidebar { width: 74px; flex: 0 0 74px; overflow-x: hidden; }
  html.nav-collapsed .sidebar .nav { width: 100%; align-items: center; }
  html.nav-collapsed .sidebar .nav-label,
  html.nav-collapsed .sidebar .brand-text,
  html.nav-collapsed .sidebar .user-chip > span { display: none; }
  html.nav-collapsed .sidebar .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  /* Cada opción es una caja fija centrada para que el icono no se recorte. */
  html.nav-collapsed .sidebar .nav-link {
    width: 52px; min-width: 52px; height: 48px; margin-left: auto; margin-right: auto;
    justify-content: center; gap: 0; padding-left: 0; padding-right: 0;
  }
  html.nav-collapsed .sidebar .nav-link i { width: auto; }
  /* Los encabezados de sección pasan a ser una línea divisoria. */
  html.nav-collapsed .sidebar .nav-section {
    width: 48px; height: 0; padding: 0; margin: .5rem auto; overflow: hidden;
    border-top: 1px solid var(--c-sidebar-border);
  }
  html.nav-collapsed .sidebar .sidebar-footer { padding: 1rem .5rem; }
  html.nav-collapsed .sidebar .sidebar-footer .d-flex { flex-direction: column; gap: .6rem; }
  html.nav-collapsed .sidebar .app-version { text-align: center; }
  html.nav-collapsed .sidebar .user-chip { justify-content: center; padding: .2rem 0; }
}

/* -------------------------------------------------------------- Topbar ---- */
/* Buscador del topbar (lleva al listado de solicitudes con ?q=). */
.topbar-search {
  position: relative; align-items: center; flex: 0 1 460px; margin-left: .25rem;
}
.topbar-search .bi { position: absolute; left: 1rem; color: var(--c-muted); pointer-events: none; }
.topbar-search input {
  width: 100%; height: 42px; padding: 0 1rem 0 2.6rem; border-radius: 999px;
  border: 1px solid var(--c-line); background: var(--c-surface-2); color: var(--c-ink);
  font-size: .9rem; transition: border-color .15s, box-shadow .15s, background .15s;
}
.topbar-search input::placeholder { color: var(--c-muted); }
.topbar-search input:focus { outline: 0; background: var(--c-surface); border-color: var(--c-brand);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .15); }
/* Usuario en el topbar: avatar, nombre y puesto con menú (perfil y salir). */
.topbar-user { padding-left: .75rem; margin-left: .25rem; border-left: 1px solid var(--c-line); }
.topbar-user-btn {
  display: flex; align-items: center; gap: .6rem; border: 0; background: none; padding: .2rem .3rem;
  border-radius: 999px; color: var(--c-ink); text-align: left;
}
.topbar-user-btn:hover { background: var(--c-hover); }
.topbar-user-btn .avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff; font-weight: 700; font-size: .85rem;
  box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 3px var(--c-line);
}
.topbar-user-text { display: flex; flex-direction: column; line-height: 1.15; max-width: 170px; }
.topbar-user-text .name { font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user-text .pos { font-size: .72rem; color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user-btn .bi-chevron-down { font-size: .75rem; color: var(--c-muted); }
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .75rem;
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--c-line);
  padding: .7rem 1.4rem; min-height: 66px;
}
.topbar .topbar-title { font-weight: 600; color: var(--c-ink); margin: 0; }
.topbar .btn-menu { border: 0; background: transparent; font-size: 1.4rem; color: var(--c-ink); }
/* Botones redondos del topbar (campana, cambio de tema y vista previa): mismo tamaño y
   color; el icono se anima al pasar el cursor y el botón se encoge al presionarlo. */
.notif-btn, .theme-toggle, .preview-btn {
  position: relative; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--c-surface); color: var(--c-ink); cursor: pointer;
  font-size: 1.05rem; line-height: 1;
  box-shadow: 0 0 0 1px var(--c-line), 0 4px 12px rgba(15, 23, 42, .08);
  transition: background-color .3s, color .3s, transform .3s;
}
.notif-btn:hover, .notif-btn[aria-expanded="true"], .theme-toggle:hover, .preview-btn:hover { background: var(--c-brand-soft); color: var(--c-brand); }
.notif-btn:active, .theme-toggle:active, .preview-btn:active { transform: scale(.8); }
.notif-btn:focus-visible, .theme-toggle:focus-visible, .preview-btn:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
.theme-toggle .bi { display: block; transition: transform .5s ease; }
.theme-toggle:hover .bi { transform: rotate(40deg); }
.preview-btn { text-decoration: none; }
.preview-btn .bi { display: block; transition: transform .3s ease; }
.preview-btn:hover .bi { transform: scale(1.15); }
.notif-bell { font-size: 1rem; line-height: 1; display: block; transform-origin: top; }
.notif-btn:hover .notif-bell { animation: bellRing .9s both; }
.notif-count {
  position: absolute; top: -4px; right: -6px;
  font-size: .65rem; border: 2px solid var(--c-surface);
}
[data-bs-theme="dark"] .notif-btn,
[data-bs-theme="dark"] .theme-toggle,
[data-bs-theme="dark"] .preview-btn { background: #2a3550; color: #fff; }
[data-bs-theme="dark"] .notif-btn:hover,
[data-bs-theme="dark"] .notif-btn[aria-expanded="true"],
[data-bs-theme="dark"] .theme-toggle:hover,
[data-bs-theme="dark"] .preview-btn:hover { background: #36446a; }
/* Menú y listado de notificaciones: icono por tipo, de qué servicio es, título,
   detalle y fecha con hora. Lo no leído lleva franja y punto. */
.notif-menu {
  width: 380px; max-width: 94vw; padding: 0; overflow: hidden;
  border: 1px solid var(--c-line); border-radius: var(--radius);
  background: var(--c-surface); box-shadow: var(--shadow);
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .65rem .9rem; border-bottom: 1px solid var(--c-line);
}
.notif-head-title { font-weight: 600; color: var(--c-ink); }
.notif-scroll { max-height: min(60vh, 440px); overflow-y: auto; }
.notif-item {
  position: relative; display: flex; align-items: flex-start; gap: .75rem;
  padding: .8rem .9rem; border-bottom: 1px solid var(--c-line);
  color: var(--c-ink); text-decoration: none;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--c-hover); color: var(--c-ink); text-decoration: none; }
.notif-item.is-unread { background: var(--c-brand-soft); box-shadow: inset 3px 0 0 var(--c-brand); }
.notif-item.is-unread:hover { background: var(--c-hover); }
.notif-icon { flex: 0 0 auto; font-size: 1.35rem; line-height: 1; margin-top: .1rem; }
.notif-tone-info { color: #2d9cdb; }
.notif-tone-task { color: #1fae9a; }
.notif-tone-ok { color: #2e9e5b; }
.notif-tone-warn { color: #d99411; }
.notif-tone-danger { color: #dc4c4c; }
.notif-tone-muted { color: var(--c-muted); }
.notif-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.notif-context {
  font-size: .75rem; font-style: italic; color: var(--c-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-title { font-weight: 500; line-height: 1.3; }
.notif-item.is-unread .notif-title { font-weight: 700; }
.notif-body { font-size: .875rem; color: var(--c-muted); line-height: 1.35; overflow-wrap: anywhere; }
.notif-time { font-size: .75rem; color: var(--c-muted); margin-top: .2rem; font-variant-numeric: tabular-nums; }
.notif-dot {
  flex: 0 0 auto; width: .55rem; height: .55rem; border-radius: 50%;
  background: #dc4c4c; margin-top: .45rem;
}
.notif-empty { padding: 1.75rem 1rem; text-align: center; color: var(--c-muted); }
.notif-foot {
  display: block; padding: .6rem; text-align: center; font-size: .875rem; font-weight: 500;
  border-top: 1px solid var(--c-line); color: var(--c-brand); text-decoration: none;
}
.notif-foot:hover { background: var(--c-hover); color: var(--c-brand-dark); text-decoration: none; }
.notif-list { overflow: hidden; }
.notif-list .notif-item { padding: .95rem 1.1rem; }
@keyframes bellRing {
  0%, 100% { transform: rotateZ(0); }
  15% { transform: rotateZ(10deg); }
  30% { transform: rotateZ(-10deg); }
  45% { transform: rotateZ(5deg); }
  60% { transform: rotateZ(-5deg); }
  75% { transform: rotateZ(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .notif-btn:hover .notif-bell { animation: none; }
  .theme-toggle:hover .bi { transform: none; }
}

.content { padding: 1.5rem;
  background: radial-gradient(1200px 500px at 85% -10%, rgba(37, 99, 235, .07), transparent 60%), var(--c-bg); }

/* --------------------------------------------------------------- Cards ---- */
/* Estilo 1.48: tarjetas blancas muy redondeadas, sin borde duro (un anillo
   de 1px con sombra suave) y encabezado sin franja gris con su icono en azul. */
.card {
  --bs-card-border-width: 0;
  --bs-card-border-radius: var(--radius-lg);
  --bs-card-inner-border-radius: var(--radius-lg);
  --bs-card-cap-padding-y: .9rem;
  --bs-card-cap-padding-x: 1.2rem;
  background: var(--c-surface);
  color: var(--c-ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 1px var(--c-line), 0 8px 24px rgba(15, 23, 42, .05);
}
[data-bs-theme="dark"] .card { box-shadow: 0 0 0 1px var(--c-line), 0 8px 24px rgba(0, 0, 0, .25); }
.card .card-header { background: transparent; border-bottom: 1px solid var(--c-line); font-weight: 700; color: var(--c-ink); }
.card > .card-header > .bi:first-child,
.card > .card-header > span:first-child > .bi:first-child,
.card > .card-header > div:first-child > .bi:first-child { color: var(--c-brand); font-size: 1.1em; }
.card .card-footer { background: transparent; border-top: 1px solid var(--c-line); }
/* Tarjetas con borde de color (avisos): el anillo toma ese color. */
.card.border-warning { box-shadow: 0 0 0 1px #f59e0b, 0 8px 24px rgba(15, 23, 42, .05); }
.card.border-danger { box-shadow: 0 0 0 1px #dc2626, 0 8px 24px rgba(15, 23, 42, .05); }
.card.border-success { box-shadow: 0 0 0 1px #16a34a, 0 8px 24px rgba(15, 23, 42, .05); }
.card.border-primary { box-shadow: 0 0 0 1px var(--c-brand), 0 8px 24px rgba(15, 23, 42, .05); }
.bg-light { background: var(--c-surface-2) !important; color: var(--c-ink) !important; }
.list-group-item { background: var(--c-surface); color: var(--c-ink); border-color: var(--c-line); }

/* Stat / KPI cards */
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-label { color: var(--c-muted); font-size: .8rem; font-weight: 500; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--c-ink); }
.stat-card .stat-icon {
  position: absolute; top: 1rem; right: 1rem;
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.25rem;
  background: var(--c-brand-soft); color: var(--c-brand);
}
.stat-card.accent-success .stat-icon { background: rgba(22, 163, 74, .15); color: #16a34a; }
.stat-card.accent-warning .stat-icon { background: rgba(217, 119, 6, .15); color: #d97706; }
.stat-card.accent-danger  .stat-icon { background: rgba(220, 38, 38, .15); color: #ef4444; }
[data-bs-theme="dark"] .stat-card.accent-success .stat-icon { color: #4ade80; }
[data-bs-theme="dark"] .stat-card.accent-warning .stat-icon { color: #fbbf24; }
[data-bs-theme="dark"] .stat-card.accent-danger  .stat-icon { color: #f87171; }

/* -------------------------------------------------------------- Tables ---- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--c-ink);
  margin-bottom: 0;
}
.table > thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--c-muted); font-weight: 700;
  border-bottom: 1px solid var(--c-line); background: var(--c-surface-2);
}
.table > tbody td { border-color: var(--c-line); vertical-align: middle; color: var(--c-ink); }
.table-hover > tbody > tr:hover > * { background: var(--c-hover); color: var(--c-ink); }

/* Las celdas no parten en varias líneas: la tabla conserva el ancho de su
   contenido y el contenedor se desplaza. Las columnas de texto largo usan
   .text-truncate (con max-width) o .text-wrap, que llevan !important y ganan. */
.table > :not(caption) > * > * { white-space: nowrap; }
/* Campos dentro de tablas (p. ej. contactos del cliente): ancho mínimo usable
   en lugar de comprimirse hasta quedar ilegibles. */
.table td .form-control, .table td .form-select { min-width: 9rem; }

/* El contenedor recorta a las esquinas redondeadas del card. Antes usaba
   overflow:hidden, que cortaba las columnas de la derecha en vez de
   permitir desplazarlas. */
.card > .table-responsive { border-radius: var(--radius-lg); }

/* --------------------------------------------- Scroll horizontal (tableros) */
/* Todo tablero ancho (tablas, calendario, cruz) se desplaza en lugar de
   recortarse: así se alcanzan todas las columnas y botones en cualquier
   resolución. La barra se deja visible para que el desplazamiento se note. */
.table-responsive,
.scroll-x {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--c-line) transparent;
}
.table-responsive::-webkit-scrollbar,
.scroll-x::-webkit-scrollbar { height: 9px; }
.table-responsive::-webkit-scrollbar-track,
.scroll-x::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb,
.scroll-x::-webkit-scrollbar-thumb {
  background: var(--c-line); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
.table-responsive:hover::-webkit-scrollbar-thumb,
.scroll-x:hover::-webkit-scrollbar-thumb { background: var(--c-muted); background-clip: content-box; }

/* -------------------------------------------------------------- Badges ---- */
.badge { font-weight: 600; letter-spacing: .2px; padding: .42em .68em; border-radius: 7px; }

/* -------------------------------------------------------- Page header ---- */
.page-header { margin-bottom: 1.4rem; }
.page-header h1 { font-size: clamp(1.35rem, 1.1rem + .9vw, 1.75rem); font-weight: 800; letter-spacing: -.01em;
  margin: 0; color: var(--c-ink); line-height: 1.2; }
/* El icono del título va en una caja redondeada del color del icono. */
.page-header h1 > .bi:first-child {
  display: inline-grid; place-items: center; width: 46px; height: 46px; margin-right: .55rem;
  border-radius: 13px; font-size: 1.35rem; vertical-align: middle;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.page-header h1 > .bi:first-child:not([class*="text-"]) { color: var(--c-brand); }
@media (max-width: 575.98px) {
  .page-header h1 > .bi:first-child { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 11px; }
}
.page-header .subtitle { color: var(--c-muted); font-size: .9rem; margin-top: .15rem; }

/* --------------------------------------------------------------- Forms ---- */
.form-control, .form-select { border-color: var(--c-line); border-radius: var(--radius-ctl); }
.form-control-sm, .form-select-sm { border-radius: 8px; }
.input-group > .form-control, .input-group > .form-select { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--radius-ctl) !important; border-bottom-left-radius: var(--radius-ctl) !important; }
.input-group > :last-child { border-top-right-radius: var(--radius-ctl) !important; border-bottom-right-radius: var(--radius-ctl) !important; }

/* Botones, alertas, menús y ventanas con las mismas esquinas */
.btn { --bs-btn-border-radius: var(--radius-ctl); --bs-btn-font-weight: 600; }
.btn-sm { --bs-btn-border-radius: 8px; }
.btn-lg { --bs-btn-border-radius: 12px; }
.btn-primary { box-shadow: 0 4px 12px rgba(37, 99, 235, .22); }
.btn-primary:hover { box-shadow: 0 6px 16px rgba(37, 99, 235, .3); }
.alert { --bs-alert-border-radius: 14px; }
.alert-danger { --bs-alert-bg: rgba(220, 38, 38, .08); --bs-alert-border-color: rgba(220, 38, 38, .18); }
.dropdown-menu { --bs-dropdown-border-radius: 12px; --bs-dropdown-border-color: var(--c-line);
  box-shadow: 0 12px 32px rgba(15, 23, 42, .14); padding: .4rem; }
.dropdown-menu .dropdown-item { border-radius: 8px; }
.modal-content { --bs-modal-border-radius: var(--radius-lg); border: 0; box-shadow: 0 24px 60px rgba(2, 6, 23, .35); }
.modal-header { border-bottom-color: var(--c-line); }
.modal-footer { border-top-color: var(--c-line); }
.list-group { --bs-list-group-border-color: var(--c-line); }
.form-control:focus, .form-select:focus {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .2);
}
.form-label { font-weight: 500; font-size: .88rem; color: var(--c-ink); }
.text-muted { color: var(--c-muted) !important; }

/* --------------------------------------------------------------- Login ---- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: radial-gradient(1200px 600px at 0% 0%, #1e3a8a 0%, #0b1322 55%); }
.login-card {
  width: 100%; max-width: 400px; background: var(--c-surface); color: var(--c-ink);
  border-radius: 1rem; box-shadow: 0 20px 50px rgba(2, 6, 23, .45); overflow: hidden;
}
.login-card .login-head { text-align: center; padding: 2rem 2rem .5rem; }
.login-card .login-logo { width: 64px; height: 64px; margin: 0 auto .75rem; }
.login-card .login-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-card .login-body { padding: .5rem 2rem 2rem; }

/* --------------------------------------------------------------- Misc ---- */
/* Dentro de una tabla hereda el nowrap de la celda; aquí sí debe fluir. */
.empty-state { text-align: center; color: var(--c-muted); padding: 3rem 1rem; white-space: normal; }
.empty-state i { font-size: 2.5rem; opacity: .4; display: block; margin-bottom: .5rem; }

/* ----------------------------------------------- Audit evaluation form ---- */
.audit-toolbar {
  position: sticky; top: 56px; z-index: 1000;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: .6rem .9rem; margin-bottom: 1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem;
}
.audit-toolbar .counters { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .9rem; font-size: .85rem; }
.audit-toolbar .progress { width: 100%; height: 6px; margin-top: .2rem; background: var(--c-surface-2); }
.audit-toolbar .progress-bar { background: var(--c-brand); }
.audit-score-live { font-weight: 700; font-size: 1.05rem; }

.audit-cat .card-header { display: flex; justify-content: space-between; align-items: center; }
.audit-cat .cat-progress { font-size: .75rem; color: var(--c-muted); font-weight: 500; }

.audit-item { padding: .8rem 1rem; border-bottom: 1px solid var(--c-line); }
.audit-item:last-child { border-bottom: 0; }
.audit-item.is-bad { background: rgba(220, 38, 38, .05); }
.audit-item .ai-q { font-size: .9rem; line-height: 1.35; }
.audit-item .ai-num {
  display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem;
  border-radius: 6px; background: var(--c-surface-2); color: var(--c-muted);
  font-size: .75rem; font-weight: 700; margin-right: .5rem; padding: 0 .3rem;
}
.audit-item .ai-pts { color: var(--c-muted); font-size: .78rem; white-space: nowrap; }
.audit-item .ai-controls { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .6rem; }
.audit-item .result-seg .btn { font-weight: 600; }
.audit-item .ai-ng { flex: 1 1 240px; min-width: 200px; }
.audit-item .ai-ng.d-none { display: none !important; }

.audit-savebar {
  position: sticky; bottom: 0; z-index: 1000;
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
  padding: .7rem 1rem; margin-top: 1rem;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .6rem;
}


/* ==========================================================================
   Optimización móvil (formularios llenados normalmente en celular)
   ========================================================================== */
@media (max-width: 767.98px) {
  /* Menos padding para aprovechar la pantalla */
  .content { padding: 1rem .85rem; }
  .card-body { padding: 1rem; }
  .page-header { margin-bottom: 1rem; }
  .page-header h1 { font-size: 1.25rem; }
  .page-header .subtitle { font-size: .85rem; }

  /* Campos: 16px evita el zoom automático de iOS al enfocar; altura táctil */
  .form-control, .form-select,
  .form-control-sm, .form-select-sm {
    font-size: 16px;
    min-height: 46px;
    padding-top: .5rem; padding-bottom: .5rem;
  }
  textarea.form-control { min-height: 84px; }
  .form-label { font-size: .95rem; margin-bottom: .25rem; }

  /* Botones cómodos para tocar */
  .btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
  .btn-sm { min-height: 40px; }

  /* Checkboxes/radios más grandes y con área de toque amplia */
  .form-check { padding: .3rem 0 .3rem 1.9rem; min-height: 40px; }
  .form-check-input { width: 1.25rem; height: 1.25rem; margin-left: -1.9rem; }

  /* Los botones de acción de un formulario ocupan el ancho y se apilan */
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { width: 100%; }
}

/* ------------------------------------- Auditoría (evaluación) en móvil --- */
@media (max-width: 575.98px) {
  .audit-toolbar { top: 56px; padding: .6rem .7rem; }
  .audit-toolbar .ms-auto { width: 100%; justify-content: space-between; }
  .audit-toolbar #markRest { flex: 1; }

  .audit-item { padding: .8rem .75rem; }
  .audit-item .ai-controls { flex-direction: column; align-items: stretch; gap: .5rem; }
  .audit-item .result-seg { width: 100%; display: flex; }
  .audit-item .result-seg .btn { flex: 1; min-height: 46px; font-size: .95rem; }
  .audit-item .ai-ng { min-width: 0; }
  .audit-item .ai-ng .form-control { width: 100%; }

  .audit-savebar { padding: .7rem .8rem; }
  .audit-savebar .d-flex { width: 100%; }
  .audit-savebar .btn { flex: 1; }
}

/* ------------------------------ Orden de servicio del cliente (obligatoria) */
/* Destacada dentro del formulario: es el comprobante de que el cliente
