/* ============================================================
   SISTEMA DE SEGUIMIENTO TUTORIAL ITSMT — DESIGN SYSTEM
   ------------------------------------------------------------
   Hoja única de estilos. Sustituye a app.css y app-ui.css, que
   compartían 15+ selectores y se sobrescribían entre sí.

   Estructura:
     1. Tokens          6. Tablas
     2. Base            7. Formularios
     3. Layout          8. Estados (vacío, carga, toast)
     4. Componentes     9. Utilidades
     5. Botones        10. Responsive / accesibilidad
   ============================================================ */

/* ===== 1. TOKENS ========================================== */
:root {
  /* Marca institucional — azul profundo ITSMT.
     Sustituye al #0d6efd por defecto de Bootstrap: identidad
     propia y mejor contraste sobre blanco (>7:1 en brand-700). */
  --brand-900: #0B2545;
  --brand-700: #123A6B;
  --brand-500: #1D5BA6;
  --brand-300: #6FA0D6;
  --brand-100: #E8F0FA;

  /* Semánticos — SOLO para comunicar estado, nunca decoración */
  --ok:        #14713D;
  --ok-bg:     #E7F4EC;
  --warn:      #8A5A00;
  --warn-bg:   #FDF3E2;
  --risk:      #A5231C;
  --risk-bg:   #FCEDEC;
  --info:      #0F5E80;
  --info-bg:   #E6F3F8;

  /* Neutros */
  --ink-900: #14181F;
  --ink-700: #39414F;
  --ink-500: #626C7D;
  --ink-400: #8A93A2;
  --surface:    #FFFFFF;
  --surface-2:  #F5F7FA;
  --surface-3:  #EDF1F6;
  --line:       #DCE3EC;
  --line-strong:#C3CDDB;

  /* Tipografía — una sola escala */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --fs-xs:   0.75rem;   /* 12px  metadatos, ayuda */
  --fs-sm:   0.875rem;  /* 14px  tablas, formularios */
  --fs-base: 0.9375rem; /* 15px  cuerpo */
  --fs-lg:   1.125rem;  /* 18px  subtítulos */
  --fs-xl:   1.5rem;    /* 24px  título de página */
  --fs-kpi:  2rem;      /* 32px  cifras KPI */
  --lh-tight: 1.25;
  --lh-base:  1.55;

  /* Espaciado — escala de 4px */
  --sp-1: .25rem; --sp-2: .5rem;  --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.25rem; --sp-6: 1.5rem; --sp-8: 2rem;

  /* Forma y elevación */
  --r-sm: 6px; --r-md: 10px; --r-pill: 999px;
  --sh-1: 0 1px 2px rgba(11,37,69,.06), 0 1px 3px rgba(11,37,69,.08);
  --sh-2: 0 4px 12px rgba(11,37,69,.10);
  --focus: 0 0 0 3px rgba(29,91,166,.35);

  /* Layout */
  --sidebar-width: 250px;
  --sidebar-width-collapsed: 68px;
  --topbar-height: 56px;
  --sidebar-bg: var(--brand-900);
  --sidebar-hover: rgba(255,255,255,.08);
  --sidebar-active: var(--brand-500);
  --topbar-bg: var(--surface);

  --t-fast: .15s ease;
  --t-base: .25s ease;
}

/* ===== 2. BASE ============================================ */
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink-900);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4,h5,h6 { line-height: var(--lh-tight); font-weight: 600; color: var(--ink-900); }
h1 { font-size: var(--fs-xl); }
h2 { font-size: 1.25rem; }
h3 { font-size: var(--fs-lg); }
h4,h5,h6 { font-size: var(--fs-base); }
a { color: var(--brand-500); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
code { font-size: var(--fs-xs); color: var(--ink-700); background: var(--surface-3);
       padding: 1px 5px; border-radius: var(--r-sm); }

/* Foco visible y consistente: requisito de accesibilidad */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible,
.form-control:focus-visible, .form-select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  box-shadow: none;
}

/* Salto al contenido para lectores de pantalla / teclado */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand-700); color: #fff; padding: var(--sp-3) var(--sp-4);
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ===== 3. LAYOUT ========================================== */
#sidebar, .sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg);
  min-height: 100vh; position: fixed; top: 0; left: 0; z-index: 100;
  display: flex; flex-direction: column; overflow-y: auto;
  transition: width var(--t-base), left var(--t-base);
}
.sidebar-brand {
  padding: var(--sp-4); color: #fff; border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: var(--sp-3);
}
.brand-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.12); display: grid; place-items: center; flex: none;
}
.sidebar-user {
  padding: var(--sp-3) var(--sp-4); display: flex; align-items: center; gap: var(--sp-3);
  border-bottom: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.9);
}
.nav-section-label {
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.45); padding: var(--sp-4) var(--sp-4) var(--sp-1);
  font-weight: 600;
}
.sidebar-link {
  color: rgba(255,255,255,.82); padding: var(--sp-2) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-1);
  font-size: var(--fs-sm); border-left: 3px solid transparent;
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.sidebar-link.active {
  background: var(--sidebar-active); color: #fff; font-weight: 600;
  border-left-color: #fff;
}
.sidebar-link i { flex: none; width: 20px; text-align: center; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-bottom: var(--sp-2); }

/* Sidebar colapsado (con memoria en localStorage) */
body.sidebar-collapsed #sidebar { width: var(--sidebar-width-collapsed); }
body.sidebar-collapsed #sidebar .sidebar-link span,
body.sidebar-collapsed #sidebar .nav-section-label,
body.sidebar-collapsed #sidebar .sidebar-brand > div:not(.brand-icon),
body.sidebar-collapsed #sidebar .sidebar-user > div:not(.avatar-circle) { display: none; }
body.sidebar-collapsed #sidebar .sidebar-link { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-width-collapsed); }

.main-content {
  margin-left: var(--sidebar-width); min-height: 100vh;
  transition: margin-left var(--t-base);
}
.topbar {
  height: var(--topbar-height); background: var(--topbar-bg);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 var(--sp-5); position: sticky; top: 0; z-index: 50;
}
.content-area { padding: var(--sp-5); }
.page-header {
  margin-bottom: var(--sp-5); padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.page-header h1 { margin: 0; display: flex; align-items: center; }
.page-header p { margin: var(--sp-1) 0 0; color: var(--ink-500); font-size: var(--fs-sm); }

/* Breadcrumbs — orientación permanente */
.breadcrumb { font-size: var(--fs-xs); margin: 0; padding: 0; background: none; }
.breadcrumb-item, .breadcrumb-item a { color: var(--ink-500); }
.breadcrumb-item a:hover { color: var(--brand-500); }
.breadcrumb-item.active { color: var(--ink-700); font-weight: 500; }


/* Submenús plegables de Configuración */
.sidebar-link[data-bs-toggle="collapse"] .ti-chevron-down {
  transition: transform var(--t-fast);
}
.sidebar-link[data-bs-toggle="collapse"][aria-expanded="true"] .ti-chevron-down {
  transform: rotate(180deg);
}
#sidebar .nav .nav .sidebar-link {
  font-size: var(--fs-xs); padding-block: var(--sp-1);
  color: rgba(255,255,255,.68); border-left-width: 3px;
}
#sidebar .nav .nav .sidebar-link:hover { color: #fff; }
#sidebar .nav .nav .sidebar-link.active {
  background: var(--sidebar-hover); color: #fff; border-left-color: var(--brand-300);
}
/* Colapsado: los submenús estorban, se ocultan */
body.sidebar-collapsed #sidebar .nav .nav,
body.sidebar-collapsed #sidebar .ti-chevron-down { display: none; }
body.sidebar-collapsed #sidebar .badge { display: none; }

/* ===== 4. COMPONENTES ===================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-1);
}
.card-header {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); font-weight: 600;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.card-footer {
  background: var(--surface-2); border-top: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4); font-size: var(--fs-xs); color: var(--ink-500);
  border-radius: 0 0 var(--r-md) var(--r-md);
}

/* KPI / tarjeta estadística */
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-4); box-shadow: var(--sh-1);
  height: 100%; transition: box-shadow var(--t-fast), transform var(--t-fast);
}
a.stat-card:hover, .stat-card.is-link:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
.stat-value {
  font-size: var(--fs-kpi); font-weight: 700; line-height: 1.1;
  color: var(--ink-900); font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: var(--fs-xs); color: var(--ink-500); text-transform: uppercase;
  letter-spacing: .04em; font-weight: 600; margin-top: var(--sp-1);
}
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 20px;
  background: var(--brand-100); color: var(--brand-700);
}

/* Badges de estado */
.badge {
  font-size: var(--fs-xs); font-weight: 600; padding: .3em .7em;
  border-radius: var(--r-pill); letter-spacing: .01em;
}
.badge.bg-success, .badge-ok   { background: var(--ok-bg)   !important; color: var(--ok)   !important; }
.badge.bg-warning, .badge-warn { background: var(--warn-bg) !important; color: var(--warn) !important; }
.badge.bg-danger,  .badge-risk { background: var(--risk-bg) !important; color: var(--risk) !important; }
.badge.bg-info,    .badge-info { background: var(--info-bg) !important; color: var(--info) !important; }
.badge.bg-secondary { background: var(--surface-3) !important; color: var(--ink-700) !important; }
.badge.bg-primary   { background: var(--brand-100) !important; color: var(--brand-700) !important; }

.avatar-circle {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: var(--brand-500); color: #fff; display: grid; place-items: center;
  font-weight: 600; font-size: var(--fs-sm);
}
.avatar-sm { width: 30px; height: 30px; font-size: var(--fs-xs); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Alertas */
.alert { border: 1px solid transparent; border-radius: var(--r-md);
         font-size: var(--fs-sm); padding: var(--sp-3) var(--sp-4); }
.alert-success { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok); }
.alert-warning { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.alert-danger  { background: var(--risk-bg); border-color: var(--risk); color: var(--risk); }
.alert-info    { background: var(--info-bg); border-color: var(--info); color: var(--info); }

/* Modales */
.modal-content { border: none; border-radius: var(--r-md); box-shadow: var(--sh-2); }
.modal-header { border-bottom: 1px solid var(--line); padding: var(--sp-4); }
.modal-header .modal-title { font-size: var(--fs-lg); font-weight: 600; }
.modal-footer { border-top: 1px solid var(--line); padding: var(--sp-3) var(--sp-4); }

/* Progreso */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); }
.progress-bar { border-radius: var(--r-pill); }

/* Timeline */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before { content:""; position:absolute; left:11px; top:4px; bottom:4px;
                    width:2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: var(--sp-4); }
.timeline-icon {
  position:absolute; left:calc(-1 * var(--sp-6)); width:24px; height:24px;
  border-radius:50%; background: var(--brand-100); color: var(--brand-700);
  display:grid; place-items:center; font-size:12px; border:2px solid var(--surface);
}
.timeline-content { font-size: var(--fs-sm); }

/* Tooltips */
.tooltip-inner { background: var(--ink-900); font-size: var(--fs-xs); border-radius: var(--r-sm); }

/* Pestañas */
.nav-tabs { border-bottom: 1px solid var(--line); }
.nav-tabs .nav-link { color: var(--ink-500); font-size: var(--fs-sm); border: none;
                      border-bottom: 2px solid transparent; }
.nav-tabs .nav-link:hover { color: var(--brand-500); border-bottom-color: var(--line-strong); }
.nav-tabs .nav-link.active { color: var(--brand-700); font-weight: 600;
                             border-bottom-color: var(--brand-500); background: none; }
.nav-pills .nav-link { font-size: var(--fs-sm); color: var(--ink-700); border-radius: var(--r-sm); }
.nav-pills .nav-link.active { background: var(--brand-500); color: #fff; }

/* ===== 5. BOTONES ========================================= */
.btn {
  font-size: var(--fs-sm); font-weight: 500; border-radius: var(--r-sm);
  padding: .45rem .9rem; transition: background var(--t-fast), border-color var(--t-fast),
            box-shadow var(--t-fast), transform var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.btn:active { transform: translateY(1px); }
.btn-sm { font-size: var(--fs-xs); padding: .3rem .6rem; }
.btn-lg { font-size: var(--fs-base); padding: .6rem 1.2rem; }

.btn-primary { background: var(--brand-500); border-color: var(--brand-500); color:#fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-700); border-color: var(--brand-700); color:#fff; }
.btn-secondary { background: var(--surface-3); border-color: var(--line-strong); color: var(--ink-700); }
.btn-secondary:hover { background: var(--line); color: var(--ink-900); }
.btn-success { background: var(--ok); border-color: var(--ok); color:#fff; }
.btn-success:hover { filter: brightness(.92); color:#fff; }
.btn-danger  { background: var(--risk); border-color: var(--risk); color:#fff; }
.btn-danger:hover { filter: brightness(.92); color:#fff; }
.btn-warning { background: var(--warn); border-color: var(--warn); color:#fff; }
.btn-warning:hover { filter: brightness(.92); color:#fff; }
.btn-info { background: var(--info); border-color: var(--info); color:#fff; }
.btn-info:hover { filter: brightness(.92); color:#fff; }

.btn-outline-primary   { color: var(--brand-500); border-color: var(--brand-300); background:#fff; }
.btn-outline-primary:hover { background: var(--brand-500); border-color: var(--brand-500); color:#fff; }
.btn-outline-secondary { color: var(--ink-700); border-color: var(--line-strong); background:#fff; }
.btn-outline-secondary:hover { background: var(--surface-3); color: var(--ink-900); }
.btn-outline-success { color: var(--ok); border-color: var(--ok); background:#fff; }
.btn-outline-success:hover { background: var(--ok); color:#fff; }
.btn-outline-danger  { color: var(--risk); border-color: var(--risk); background:#fff; }
.btn-outline-danger:hover { background: var(--risk); color:#fff; }
.btn-outline-warning { color: var(--warn); border-color: var(--warn); background:#fff; }
.btn-outline-warning:hover { background: var(--warn); color:#fff; }
.btn-outline-info { color: var(--info); border-color: var(--info); background:#fff; }
.btn-outline-info:hover { background: var(--info); color:#fff; }
.btn-link { color: var(--brand-500); }

/* Estado deshabilitado: antes no tenía ningún estilo definido */
.btn:disabled, .btn.disabled, button[disabled] {
  opacity: .55; cursor: not-allowed; transform: none; box-shadow: none;
}
/* Botón trabajando: se activa al enviar un formulario */
.btn.is-busy { pointer-events: none; opacity: .75; }
.btn.is-busy::before {
  content: ""; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: ds-spin .6s linear infinite;
}
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ===== 6. TABLAS ========================================== */
.table { font-size: var(--fs-sm); color: var(--ink-900); margin-bottom: 0; }
.table > thead > tr > th {
  background: var(--surface-2); color: var(--ink-700); font-weight: 600;
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
  padding: var(--sp-3) var(--sp-3);
}
.table > tbody > tr > td { padding: var(--sp-3); border-bottom: 1px solid var(--line);
                           vertical-align: middle; }
.table-hover > tbody > tr:hover > td { background: var(--brand-100); }
.table td .btn-sm { min-height: 30px; }
/* Cifras alineadas por dígito */
.table .num, .table .text-center { font-variant-numeric: tabular-nums; }

/* Encabezado ordenable */
th.sortable { cursor: pointer; user-select: none; position: relative; padding-right: 22px; }
th.sortable::after {
  content: "\2195"; position: absolute; right: 8px; opacity: .3; font-size: 11px;
}
th.sortable:hover::after { opacity: .7; }
th.sortable[aria-sort="ascending"]::after  { content: "\2191"; opacity: 1; color: var(--brand-500); }
th.sortable[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--brand-500); }

/* ===== 7. FORMULARIOS ===================================== */
.form-label { font-size: var(--fs-sm); font-weight: 500; color: var(--ink-700);
              margin-bottom: var(--sp-1); }
.form-label .req { color: var(--risk); margin-left: 2px; }
.form-control, .form-select {
  font-size: var(--fs-sm); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: .45rem .7rem; color: var(--ink-900);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-500); box-shadow: var(--focus); outline: none;
}
.form-control::placeholder { color: var(--ink-400); }
.form-control:disabled, .form-select:disabled { background: var(--surface-3); color: var(--ink-500); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--risk); }
.form-control.is-valid, .form-select.is-valid { border-color: var(--ok); }
.invalid-feedback { font-size: var(--fs-xs); color: var(--risk); }
.form-text { font-size: var(--fs-xs); color: var(--ink-500); }
.input-group-text { background: var(--surface-2); border-color: var(--line-strong);
                    font-size: var(--fs-sm); color: var(--ink-500); }
.form-check-input:checked { background-color: var(--brand-500); border-color: var(--brand-500); }
.form-check-input:focus { box-shadow: var(--focus); }
.form-check-label { font-size: var(--fs-sm); }

/* Agrupación por secciones dentro de un formulario */
.form-section { border-top: 1px solid var(--line); padding-top: var(--sp-4); margin-top: var(--sp-4); }
.form-section:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-section-title {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-500); margin-bottom: var(--sp-3);
}

/* ===== 8. ESTADOS ========================================= */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--ink-500); }
.empty-state i { font-size: 44px; color: var(--line-strong); display: block; margin-bottom: var(--sp-3); }
.empty-state h6 { color: var(--ink-700); margin-bottom: var(--sp-2); font-size: var(--fs-base); }
.empty-state p { font-size: var(--fs-sm); margin-bottom: var(--sp-3); }

/* Esqueleto de carga: evita el salto de contenido */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: ds-shimmer 1.3s ease infinite;
  border-radius: var(--r-sm); min-height: 12px;
}
@keyframes ds-shimmer { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

/* Avisos temporales (toast) */
.toast-stack {
  position: fixed; top: calc(var(--topbar-height) + var(--sp-3)); right: var(--sp-4);
  z-index: 1080; display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: min(380px, calc(100vw - 2rem));
}
.ds-toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--brand-500);
  border-radius: var(--r-sm); box-shadow: var(--sh-2); padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm); display: flex; align-items: flex-start; gap: var(--sp-2);
  animation: ds-in var(--t-base) both;
}
.ds-toast.is-out { animation: ds-out var(--t-base) both; }
.ds-toast--success { border-left-color: var(--ok); }
.ds-toast--warning { border-left-color: var(--warn); }
.ds-toast--danger  { border-left-color: var(--risk); }
@keyframes ds-in  { from { opacity:0; transform: translateX(12px) } to { opacity:1; transform:none } }
@keyframes ds-out { to { opacity:0; transform: translateX(12px) } }

.fade-in { animation: ds-fade var(--t-base) both; }
@keyframes ds-fade { from { opacity:0; transform: translateY(4px) } to { opacity:1; transform:none } }

/* Semáforo de riesgo (modelo TecNM) */
.riesgo-alto  { color: var(--risk); }
.riesgo-medio { color: var(--warn); }
.riesgo-bajo  { color: var(--ok); }

/* ===== 9. UTILIDADES ====================================== */
.text-muted { color: var(--ink-500) !important; }
.bg-light   { background: var(--surface-2) !important; }
.border     { border-color: var(--line) !important; }
.text-primary { color: var(--brand-500) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.text-danger  { color: var(--risk) !important; }
.text-info    { color: var(--info) !important; }
.bg-primary-subtle   { background: var(--brand-100) !important; }
.bg-success-subtle   { background: var(--ok-bg) !important; }
.bg-warning-subtle   { background: var(--warn-bg) !important; }
.bg-danger-subtle    { background: var(--risk-bg) !important; }
.bg-info-subtle      { background: var(--info-bg) !important; }
.bg-secondary-subtle { background: var(--surface-3) !important; }
.col-lg-2-4 { flex: 0 0 20%; max-width: 20%; }
.list-group-item { font-size: var(--fs-sm); border-color: var(--line); }
.list-group-flush .list-group-item { border-left: 0; border-right: 0; }

/* Compatibilidad con librerías existentes */
.select2-container--bootstrap-5 .select2-selection { border-color: var(--line-strong);
  font-size: var(--fs-sm); border-radius: var(--r-sm); }
.flatpickr-input { background: var(--surface) !important; }

/* ===== 10. RESPONSIVE ===================================== */
@media (max-width: 992px) {
  .content-area { padding: var(--sp-4); }
  .stat-value { font-size: 1.6rem; }
}

@media (max-width: 768px) {
  #sidebar, .sidebar { left: -100%; width: 82%; max-width: 300px; box-shadow: var(--sh-2); }
  #sidebar.show, .sidebar.show { left: 0; }
  .main-content { margin-left: 0 !important; }
  body.sidebar-collapsed .main-content { margin-left: 0; }
  .content-area { padding: var(--sp-3); }
  .page-header h1 { font-size: 1.25rem; }
  .stat-value { font-size: 1.5rem; }

  /* Objetivos táctiles: mínimo 44px en móvil */
  .btn, .form-control, .form-select { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: .4rem .7rem; }

  /* Tablas densas → tarjetas apiladas.
     Se activa marcando la tabla con class="table-cards" y dando
     data-label a cada celda. Sin eso, la tabla hace scroll normal. */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr {
    border: 1px solid var(--line); border-radius: var(--r-md);
    margin-bottom: var(--sp-3); padding: var(--sp-2); background: var(--surface);
  }
  .table-cards td { border: 0; display: flex; justify-content: space-between;
                    gap: var(--sp-3); padding: var(--sp-2); text-align: right; }
  .table-cards td::before {
    content: attr(data-label); font-weight: 600; color: var(--ink-500);
    font-size: var(--fs-xs); text-transform: uppercase; text-align: left; flex: none;
  }
  .toast-stack { left: var(--sp-3); right: var(--sp-3); max-width: none; }
}

@media (max-width: 576px) {
  .col-lg-2-4 { flex: 0 0 50%; max-width: 50%; }
}

/* Respeta la preferencia de menos movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Impresión: los formatos F-05-04 se imprimen */
@media print {
  #sidebar, .sidebar, .topbar, .no-print, .toast-stack { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #999; }
  body { background: #fff; font-size: 11pt; }
}
