/* ==========================================================================
   Centris · Tema de la plataforma (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 — claro en modo claro (texto y título oscuros y legibles) */
  --c-sidebar: #ffffff;
  --c-sidebar-hover: #eef3ff;
  --c-sidebar-text: #334155;
  --c-sidebar-muted: #64748b;
  --c-sidebar-title: #16203a;
  --c-sidebar-hover-text: #1d4ed8;
  --c-sidebar-border: #e6eaf2;

  /* 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;
  --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: var(--c-sidebar);
  color: var(--c-sidebar-text);
  border-right: 1px solid var(--c-sidebar-border);
  --bs-offcanvas-width: 230px;
  --bs-offcanvas-bg: var(--c-sidebar);
  --bs-offcanvas-color: var(--c-sidebar-text);
}
.sidebar .sidebar-brand {
  display: flex; align-items: center; gap: .55rem;
  padding: .9rem 1rem;
  color: var(--c-sidebar-title); font-weight: 700; font-size: 1.15rem; 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: .8rem 1rem .3rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--c-sidebar-muted);
}
.sidebar .nav-link {
  display: flex; align-items: center; gap: .6rem;
  margin: .1rem .5rem; padding: .5rem .65rem;
  border-radius: .55rem;
  color: var(--c-sidebar-text); font-weight: 500; font-size: .875rem;
  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 4px 12px rgba(37, 99, 235, .4);
}
.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 .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);
}

@media (min-width: 992px) {
  .sidebar {
    width: 210px; flex: 0 0 210px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
}

/* -------------------------------------------------------------- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .75rem;
  background: var(--c-surface); border-bottom: 1px solid var(--c-line);
  padding: .6rem 1.1rem; min-height: 56px;
}
.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); }
.theme-toggle {
  border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-ink);
  width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
  font-size: 1.05rem; line-height: 1;
}
.theme-toggle:hover { background: var(--c-hover); color: var(--c-brand); }

.content { padding: 1.5rem 1.75rem; }
@media (min-width: 1400px) { .content { padding: 1.75rem 2.25rem; } }

/* --------------------------------------------------------------- Cards ---- */
.card {
  background: var(--c-surface);
  color: var(--c-ink);
  border: 1px solid var(--c-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card .card-header { background: var(--c-surface); border-bottom: 1px solid var(--c-line); font-weight: 600; color: var(--c-ink); }
.card .card-footer { background: var(--c-surface-2); border-top: 1px solid var(--c-line); }
.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); }

/* --------------------------------------------- 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; }

/* -------------------------------------------------------- Page header ---- */
.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; color: var(--c-ink); }
.page-header .subtitle { color: var(--c-muted); font-size: .9rem; margin-top: .15rem; }

/* --------------------------------------------------------------- Forms ---- */
.form-control, .form-select { 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;
}

/* ----------------------------------------------- Evidence photo grid ---- */
.evidence-grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.evidence-item {
  margin: 0; border: 1px solid var(--c-line); border-radius: var(--radius);
  overflow: hidden; background: var(--c-surface-2);
}
.evidence-item img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  transition: transform .2s ease;
}
.evidence-item a:hover img { transform: scale(1.04); }
.evidence-item figcaption {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: .4rem .55rem; font-size: .8rem; color: var(--c-muted);
}
.evidence-item figcaption .text-truncate { max-width: 80%; }

/* ------------------------------------------------- Cruz de Seguridad ---- */
.cruz-grid {
  --cell: 46px;
  display: grid; grid-template-columns: repeat(9, var(--cell));
  gap: 4px; margin: 0 auto;
  /* Ancho exacto del contenido: centrada cuando cabe y desplazable dentro de
     .scroll-x cuando no, sin que se pierdan columnas fuera de la pantalla. */
  width: max-content;
}
.cruz-grid.cruz-lg { --cell: 64px; }
.cruz-grid.cruz-sm { --cell: 30px; gap: 3px; }
.cruz-cell {
  aspect-ratio: 1 / 1; border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  user-select: none;
}
.cruz-grid.cruz-sm .cruz-cell { font-size: .68rem; border-radius: 5px; }
.cruz-empty { background: transparent; }
.cruz-green  { background: #16a34a; }
.cruz-yellow { background: #f59e0b; color: #3a2a00; }
.cruz-red    { background: #dc2626; }
.cruz-future { background: var(--c-surface-2); color: var(--c-muted); border: 1px dashed var(--c-line); }
[data-bs-theme="dark"] .cruz-green  { background: #1f9d57; }
[data-bs-theme="dark"] .cruz-yellow { background: #d99411; color: #1a1300; }

.cruz-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .4rem 1.1rem; font-size: .82rem; color: var(--c-muted); }
.cruz-dot { display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; vertical-align: -1px; margin-right: .25rem; }
.cruz-dot.cruz-future { border: 1px dashed var(--c-line); }

/* ------------------------------------------- Phase track (servicios) ---- */
.phase-track { display: flex; align-items: flex-start; justify-content: space-between; gap: .25rem; }
/* min-width: por debajo de eso el contenedor .scroll-x desplaza el timeline en
   vez de encimar las etiquetas de cada fase. */
.phase-step { flex: 1 0 auto; min-width: 96px; text-align: center; position: relative; }
.phase-step::before {
  content: ""; position: absolute; top: 16px; left: -50%; width: 100%; height: 3px;
  background: var(--c-line); z-index: 0;
}
.phase-step:first-child::before { display: none; }
.phase-step .dot {
  position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto .35rem;
  background: var(--c-surface-2); color: var(--c-muted);
  border: 2px solid var(--c-line); font-weight: 700; font-size: .85rem;
}
.phase-step .lbl { font-size: .76rem; color: var(--c-muted); }
.phase-step.current .dot { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.phase-step.current .lbl { color: var(--c-ink); font-weight: 600; }
.phase-step.done .dot { background: var(--c-success, #16a34a); color: #fff; border-color: var(--c-success, #16a34a); }
.phase-step.done::before { background: var(--c-success, #16a34a); }

/* ------------------------------------------------ Calendario servicios -- */
/* Ancho mínimo para que los 7 días sigan siendo legibles; por debajo de eso el
   contenedor .scroll-x desplaza el mes en vez de aplastar las celdas. */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(96px, 1fr)); gap: 4px; min-width: 700px; }
.cal-head { text-align: center; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--c-muted); padding: .3rem 0; }
.cal-cell { min-height: 96px; border: 1px solid var(--c-line); border-radius: 8px;
  background: var(--c-surface); padding: .3rem; display: flex; flex-direction: column; gap: 3px; }
.cal-cell.cal-out { background: var(--c-surface-2); opacity: .55; }
.cal-cell.cal-today { border-color: var(--c-brand); box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.cal-day { font-size: .78rem; font-weight: 600; color: var(--c-muted); }
.cal-cell.cal-today .cal-day { color: var(--c-brand); }
.cal-event { display: block; font-size: .72rem; font-weight: 600; color: #fff !important;
  padding: .12rem .35rem; border-radius: 5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; text-decoration: none; }
.cal-event:hover { text-decoration: none; filter: brightness(1.05); color: #fff !important; }
.cal-event.text-dark, .cal-event.bg-warning { color: #3a2a00 !important; }
/* Días de continuación de un servicio de varios días */
.cal-event.cal-event-cont { opacity: .75; font-weight: 500; }
/* Hora de llegada asignada, al inicio del evento */
.cal-event .cal-time { font-weight: 800; margin-right: .3em;
  font-variant-numeric: tabular-nums; opacity: .9; }
@media (max-width: 575px) {
  /* Celdas más bajas para no alargar el mes; el ancho lo resuelve el scroll. */
  .cal-cell { min-height: 72px; }
}

/* ==========================================================================
   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; }
  .btn-sm { min-height: 40px; }
  .theme-toggle { 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
   autorizó el servicio, no un adjunto más. */
.client-order-box {
  border: 1px solid var(--c-line); border-left: 3px solid var(--c-brand);
  border-radius: var(--radius); padding: .85rem 1rem;
  background: var(--c-surface-2);
}
.client-order-box .form-label { font-weight: 600; margin-bottom: .4rem; }
.client-order-box .form-text { margin-bottom: 0; }

/* ------------------------------------ Lista de personal (asignar servicio) - */
.personnel-checks {
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--c-line); border-radius: var(--radius);
  padding: .5rem .75rem; background: var(--c-surface);
}
/* Cada renglón es [checkbox] Nombre … Sucursal, para leer la sucursal como
   columna alineada a la derecha. */
.personnel-checks .form-check,
.personnel-checks .personnel-head {
  display: flex; align-items: center; gap: .5rem;
  margin: 0; padding: .2rem 0; min-height: 0;
}
.personnel-checks .form-check-input { float: none; margin: 0; flex: 0 0 auto; }
/* Un renglón por persona: los nombres largos se recortan (el completo queda en
   el title) para que la columna de sucursal no se desalinee. */
.personnel-checks .form-check-label {
  /* base 0: el nombre cede espacio y se recorta en vez de empujar la sucursal
     al siguiente renglón. */
  flex: 1 1 0; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.personnel-checks .personnel-branch {
  flex: 0 0 auto; min-width: 8rem; max-width: 14rem; text-align: right;
  font-size: .78rem; color: var(--c-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  /* Holgura para que la cursiva de "sin sucursal" no se recorte al voladizo. */
  padding-right: .12rem;
}
/* Encabezado de las dos columnas, pegado al borde superior de la caja. */
.personnel-checks .personnel-head {
  position: sticky; top: -.5rem; z-index: 1;
  background: var(--c-surface);
  margin: -.5rem -.75rem .25rem; padding: .5rem .75rem .3rem;
  border-bottom: 1px solid var(--c-line);
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--c-muted);
}
.personnel-checks .personnel-head > :first-child { flex: 1 1 auto; }

@media (max-width: 575.98px) {
  /* Sin ancho para las tres cosas: el aviso de "ya agendado" baja a su propio
     renglón para no dejar el nombre en cero. */
  .personnel-checks .form-check { flex-wrap: wrap; }
  .personnel-checks .busy-badge {
    order: 3; flex: 0 0 100%; margin-left: 0 !important;
    text-align: left; white-space: normal;
  }
  .personnel-checks .personnel-branch { min-width: 6.5rem; }
}

/* ==========================================================================
   SITH · Componentes propios (portados al tema Centris)
   ========================================================================== */

/* Envolturas de tarjeta heredadas de SITH: ya son .card, no necesitan extra. */
.form-card, .page-card, .dashboard-card { }

/* Títulos y textos semánticos de SITH */
.title, .form-title, .page-title { font-weight: 700; color: var(--c-ink); }
.form-title { font-size: 1.4rem; }
.subtitle, .login-subtitle { color: var(--c-muted); }
.label, .detail-label-small {
  font-weight: 600; color: var(--c-muted);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
}
.value { color: var(--c-ink); font-weight: 500; }
.clickable-row { cursor: pointer; }
.divider { border-color: var(--c-line); }

/* Foto de empleado */
.avatar {
  width: 120px; height: 120px; object-fit: cover;
  border-radius: var(--radius); border: 3px solid var(--c-line);
}

/* Chips / badges suaves */
.meta-chip, .user-badge {
  background: var(--c-brand-soft); border: 1px solid transparent;
  color: var(--c-brand); border-radius: 999px;
  padding: .35rem .7rem; font-size: .82rem; font-weight: 600;
  white-space: nowrap;
}

/* Gráficos del dashboard */
.chart-wrapper { max-width: 100%; display: flex; justify-content: center; }
.chart-canvas-doughnut { max-width: 300px; max-height: 300px; }
.chart-canvas-bar { max-width: 400px; max-height: 350px; }

/* Tabla de carga masiva */
.employee-cell { min-width: 240px; }
.input-time { min-width: 130px; }
.bulk-tools { background: var(--c-surface-2); border: 1px solid var(--c-line); border-radius: var(--radius); }

/* ------------------------------------------------------------- Firmas ---- */
.signature-box {
  border: 1.5px dashed var(--c-line); border-radius: var(--radius);
  background: var(--c-surface); padding: .75rem; text-align: center;
  cursor: pointer; transition: border-color .2s; min-height: 140px;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  color: var(--c-muted);
}
.signature-box.firma-ok { border-color: #10b981; border-style: solid; }
.signature-box .preview-img {
  width: 100%; max-height: 100px; object-fit: contain;
  border-radius: .5rem; display: none; background: #fff;
}
.signature-box.firma-ok .preview-img { display: block; }
.signature-box.firma-ok .placeholder-firma { display: none; }
.placeholder-firma { color: var(--c-muted); font-size: .85rem; padding: .5rem 0; }
.placeholder-firma span { font-size: 2rem; display: block; margin-bottom: .3rem; line-height: 1; }

.firma-box {
  border: 1px dashed var(--c-line); border-radius: var(--radius);
  background: #fff; min-height: 180px; display: flex; align-items: center;
  justify-content: center; padding: .75rem; overflow: hidden;
}
.firma-img { width: 100%; max-height: 160px; object-fit: contain; display: block; }

/* Modal de firma a pantalla completa */
.modal-firma .modal-dialog { margin: 0; max-width: 100%; height: 100%; }
.modal-firma .modal-content { height: 100dvh; border-radius: 0; border: 0; display: flex; flex-direction: column; }
.modal-firma .modal-header { background: var(--c-surface-2); border-bottom: 1px solid var(--c-line); padding: .75rem 1rem; flex-shrink: 0; }
.modal-firma .modal-body { flex: 1; padding: 0; display: flex; flex-direction: column; min-height: 0; }
.modal-firma .modal-footer { flex-shrink: 0; background: var(--c-surface-2); border-top: 1px solid var(--c-line); padding: .75rem 1rem; gap: .5rem; }
.firma-canvas-modal { flex: 1; width: 100%; height: 100%; touch-action: none; cursor: crosshair; background: #fff; display: block; }
.instruccion-firma { text-align: center; color: var(--c-muted); font-size: .8rem; padding: .4rem; background: var(--c-surface-2); border-bottom: 1px solid var(--c-line); flex-shrink: 0; margin: 0; }

@media (max-width: 576px) {
  .mobile-stack-actions { flex-direction: column; }
  .mobile-stack-actions .btn { width: 100%; }
  .firma-box { min-height: 140px; }
}

/* ------------------------------------------- Tom Select (buscador) --------- */
.ts-wrapper .ts-control {
  background: var(--c-surface); border-color: var(--c-line); color: var(--c-ink);
  border-radius: .375rem; min-height: calc(1.5em + .75rem + 2px);
}
.ts-wrapper.focus .ts-control {
  border-color: var(--c-brand); box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .2);
}
.ts-control input, .ts-control .item { color: var(--c-ink) !important; }
.ts-dropdown {
  background: var(--c-surface); border-color: var(--c-line); color: var(--c-ink);
  box-shadow: var(--shadow);
}
.ts-dropdown .option { color: var(--c-ink); }
.ts-dropdown .option.active { background: var(--c-brand); color: #fff; }
.ts-dropdown .no-results { color: var(--c-muted); }
