/* ============================================================
   COMPONENTS — Componentes reutilizables
   Portal de Administración de RAMs
   ============================================================ */

/* ============================================================
   TIPOGRAFÍA
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-1);
}

h1 { font-size: 20px; margin-bottom: 16px; }
h2 { font-size: 17px; margin-bottom: 14px; }
h3 { font-size: 15px; margin-bottom: 12px; }
h4 { font-size: 14px; margin-bottom: 10px; }

p { 
  font-size: 14px; 
  color: var(--text-2); 
  margin-bottom: 12px; 
}

.text-mono { font-family: var(--mono); }
.text-muted { color: var(--text-3); }
.text-secondary { color: var(--text-2); }
.text-primary { color: var(--accent-fg); }
.text-success { color: var(--green); }
.text-warning { color: var(--amber); }
.text-danger { color: var(--red); }
.text-info { color: var(--blue-mid); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Variantes */
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover:not(:disabled) {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border-2);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border);
}

.btn-success {
  background: var(--green);
  color: var(--on-accent);
  border-color: var(--green);
}
.btn-success:hover:not(:disabled) {
  background: var(--green-h);
}

.btn-warning {
  background: var(--amber);
  color: var(--on-accent);
  border-color: var(--amber);
}
.btn-warning:hover:not(:disabled) {
  background: var(--amber-h);
}

.btn-danger {
  background: var(--red);
  color: var(--on-accent);
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  background: var(--red-h);
}

.btn-outline {
  background: transparent;
  color: var(--accent-fg);
  border-color: var(--navy);
}
.btn-outline:hover:not(:disabled) {
  background: var(--blue-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--text-1);
}

/* Tamaños */
.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  font-family: var(--mono);
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--sans);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  color: var(--text-1);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--blue-bg);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-3);
}

.form-select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 32px;
  /* Chevron en gris-cálido legible (≈ --text-3 claro #6d6b60). El SVG data-URI
     no admite var(); el modo oscuro lo sobreescribe abajo. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236d6b60' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

/* Chevron más claro en modo oscuro (≈ --text-3 oscuro #9aa0ab) para contraste. */
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa0ab' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
  font-family: var(--sans);
}

.form-help {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.form-error {
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

.form-group.has-error .form-input,
.form-group.has-error .form-select,
.form-group.has-error .form-textarea {
  border-color: var(--red);
}

/* Checkbox y radio personalizados */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-1);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--navy);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.card-body {
  font-size: 13px;
  color: var(--text-2);
}

.card-footer {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ============================================================
   TABLAS
   ============================================================ */
.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--surface-2);
}

.data-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--mono);
  border-bottom: 1px solid var(--border);
}

.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table tbody tr.selected {
  background: var(--blue-bg);
}

.data-table .text-mono {
  font-family: var(--mono);
  font-size: 12px;
}

/* ============================================================
   BADGES (Etiquetas de estado)
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--mono);
}

.badge-primary { background: var(--blue-bg); color: var(--accent-fg); }
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-warning { background: var(--amber-bg); color: var(--amber); }
.badge-danger { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--blue-bg); color: var(--blue-mid); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }

/* Badges específicos de RAMs */
.badge-ram-abierta { 
  background: var(--ram-abierta-bg); 
  color: var(--ram-abierta); 
}
.badge-ram-para-cierre { 
  background: var(--ram-para-cierre-bg); 
  color: var(--ram-para-cierre); 
}
.badge-ram-cerrada { 
  background: var(--ram-cerrada-bg); 
  color: var(--ram-cerrada); 
}

/* Badges de estatus de unidades */
.badge-habilitada { 
  background: var(--unidad-habilitada-bg); 
  color: var(--unidad-habilitada); 
}
.badge-inhabilitada { 
  background: var(--unidad-inhabilitada-bg); 
  color: var(--unidad-inhabilitada); 
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 14px;
  border-radius: var(--r);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
  margin-bottom: 16px;
}

.alert-icon {
  flex-shrink: 0;
  font-size: 16px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.alert-info {
  background: var(--blue-bg);
  color: var(--blue);
  border-color: var(--blue-bd);
}

.alert-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-bd);
}

.alert-warning {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber-bd);
}

.alert-danger {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-bd);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 39, 68, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  position: relative; /* ancla de los handles de resize (modal-resize.js) */
  background: var(--surface);
  border-radius: var(--r2);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlide 0.25s ease-out;
}

/* Variante ancha (detalle RAM/inspección). Promovida de rams.css e
   inspecciones.css (vivía duplicada y con !important, que le ganaba al
   style inline del resize). */
.modal.modal-large {
  max-width: 780px;
}

@keyframes modalSlide {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
}

.modal-close {
  background: none;
  font-size: 20px;
  color: var(--text-3);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--surface-2);
}

/* Combobox: ítems NO seleccionables (Fase 8 — unidades No disponibles con
   motivo). Texto en --text-3 (NO opacity global: mataría el contraste del
   motivo) y cursor de bloqueo; combobox.js impide seleccionarlos. */
.autocomplete-item.is-disabled {
  cursor: not-allowed;
}
.autocomplete-item.is-disabled .nombre,
.autocomplete-item.is-disabled .codigo,
.autocomplete-item.is-disabled .meta {
  color: var(--text-3);
}
.autocomplete-item .motivo {
  display: block;
  font-size: 11px;
  color: var(--color-danger);
}

/* ============================================================
   MODAL RESIZE (handles que inyecta shared/js/modal-resize.js)
   Los handles viven DENTRO del .modal (overflow:hidden recorta lo
   externo); hit interno de 10px, esquinas 18px. Indicador visible
   solo en hover/focus; grip permanente solo en la esquina inf-der.
   Se desactiva <768px (el propio JS no inyecta handles ahí).
   ============================================================ */
.mrz-handle {
  position: absolute;
  z-index: 5;
  touch-action: none;
  background: transparent;
  padding: 0;
  border: none;
}
.mrz-n  { top: 0; left: 18px; right: 18px; height: 10px; cursor: ns-resize; }
.mrz-s  { bottom: 0; left: 18px; right: 18px; height: 10px; cursor: ns-resize; }
.mrz-e  { right: 0; top: 18px; bottom: 18px; width: 10px; cursor: ew-resize; }
.mrz-w  { left: 0; top: 18px; bottom: 18px; width: 10px; cursor: ew-resize; }
.mrz-ne { top: 0; right: 0; width: 18px; height: 18px; cursor: nesw-resize; z-index: 6; }
.mrz-nw { top: 0; left: 0; width: 18px; height: 18px; cursor: nwse-resize; z-index: 6; }
.mrz-se { bottom: 0; right: 0; width: 18px; height: 18px; cursor: nwse-resize; z-index: 6; }
.mrz-sw { bottom: 0; left: 0; width: 18px; height: 18px; cursor: nesw-resize; z-index: 6; }

/* Indicador: línea de 3px del lado correspondiente, solo hover/focus */
.mrz-handle:hover::after,
.mrz-handle:focus-visible::after {
  content: '';
  position: absolute;
  background: var(--accent-fg);
  opacity: .6;
  border-radius: 2px;
}
.mrz-n:hover::after,  .mrz-n:focus-visible::after  { top: 0; left: 0; right: 0; height: 3px; }
.mrz-s:hover::after,  .mrz-s:focus-visible::after  { bottom: 0; left: 0; right: 0; height: 3px; }
.mrz-e:hover::after,  .mrz-e:focus-visible::after  { right: 0; top: 0; bottom: 0; width: 3px; }
.mrz-w:hover::after,  .mrz-w:focus-visible::after  { left: 0; top: 0; bottom: 0; width: 3px; }
.mrz-ne:hover::after, .mrz-ne:focus-visible::after { top: 0; right: 0; width: 12px; height: 12px; border-radius: 0 var(--r2) 0 4px; }
.mrz-nw:hover::after, .mrz-nw:focus-visible::after { top: 0; left: 0; width: 12px; height: 12px; border-radius: var(--r2) 0 4px 0; }
.mrz-se:hover::after, .mrz-se:focus-visible::after { bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 4px 0 var(--r2) 0; }
.mrz-sw:hover::after, .mrz-sw:focus-visible::after { bottom: 0; left: 0; width: 12px; height: 12px; border-radius: 0 4px 0 var(--r2); }

.mrz-handle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Grip sutil SIEMPRE visible en la esquina inferior-derecha
   (única affordance en reposo; usa token tematizado en dark) */
.mrz-se::before {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 10px;
  height: 10px;
  background: repeating-linear-gradient(135deg,
    transparent 0 3px, var(--text-3) 3px 4px);
  opacity: .55;
  pointer-events: none;
}

/* Botón "Restablecer tamaño" (misma anatomía que .modal-close);
   solo se pinta cuando hay tamaño custom. margin-left:auto lo pega a la
   ✕ (el header es space-between y con 3 hijos lo dejaría al centro). */
.mrz-reset {
  background: none;
  border: none;
  margin-left: auto;
  font-size: 16px;
  color: var(--text-3);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.mrz-reset:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

/* Candados durante el drag */
body.mrz-resizing {
  user-select: none;
  -webkit-user-select: none;
}
body.mrz-resizing iframe {
  pointer-events: none;
}
.modal.mrz-active {
  animation: none; /* que un re-open no dispare modalSlide a media arrastrada */
}

/* ============================================================
   STAT CARDS (Para Dashboard)
   ============================================================ */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: box-shadow var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
}

.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }

/* ============================================================
   SPINNER / LOADING
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 38px;
  height: 38px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: var(--z-loading);
}

.loading-text {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
}

/* ============================================================
   TOAST (Notificaciones)
   ============================================================ */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text-1);
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 9999;
  pointer-events: none;
  max-width: 340px;
}

#toast.show {
  transform: none;
  opacity: 1;
}

#toast.success { border-left: 3px solid var(--green); }
#toast.error { border-left: 3px solid var(--red); }
#toast.warning { border-left: 3px solid var(--amber); }
#toast.info { border-left: 3px solid var(--blue-mid); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group .form-select,
.filter-group .form-input {
  min-width: 180px;
}

/* ============================================================
   UTILIDADES
   ============================================================ */
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-block { display: block; }
.d-none { display: none; }

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 24px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

/* ============================================================
   PAGINACIÓN — barra inferior compartida (controles + page-size)
   ============================================================ */
.paginacion-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2, #f8fafc);
  border-top: 1px solid var(--border);
  margin-top: -1px;
}
.paginacion-bar .paginacion-tamano {
  display: flex;
  align-items: center;
  gap: 6px;
}
.paginacion-bar .paginacion-controles {
  display: flex;
  align-items: center;
  gap: 8px;
}
.paginacion-bar .paginacion-info {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-3);
  min-width: 60px;
  text-align: center;
}
@media (max-width: 640px) {
  .paginacion-bar { justify-content: center; }
}

/* ============================================================
   RESPONSIVE MÓVIL — ajustes genéricos (no afectan escritorio)
   ============================================================
   Aplican a TODAS las páginas que usan .table-container/.data-table y
   .filter-bar. En pantallas chicas:
   - las tablas anchas se vuelven desplazables en horizontal en vez de
     aplastar las columnas (antes .table-container recortaba con overflow:hidden);
   - la barra de filtros se apila a ancho completo en vez de desbordar. */
@media (max-width: 768px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;  /* scroll suave en iOS */
  }
  .data-table {
    min-width: 560px;  /* fuerza scroll horizontal en lugar de columnas ilegibles */
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-group {
    width: 100%;
  }
  .filter-group .form-select,
  .filter-group .form-input {
    min-width: 0;
    width: 100%;
  }
}

/* ============================================================
   CANON DE TABLA/FILTROS (compartido Flota + Rutas)
   Extraído de flota.css para reuso. NOTA: flota.css aún tiene su copia
   local (idéntica); no borrarla sin verificar Flota. Deuda de dedup.
   ============================================================ */

/* Acciones del encabezado (export/nuevo) */
.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.page-header-actions .btn i { margin-right: 4px; }

/* Separador hairline entre grupos de filtros (cascada vs. ejes independientes) */
.filters-sep {
  width: 1px;
  align-self: stretch;
  min-height: 36px;
  margin: 0 2px;
  background: var(--border);
  flex: 0 0 auto;
}
@media (max-width: 768px) {
  .filters-sep { width: 100%; min-height: 0; height: 1px; margin: 4px 0; }
}

/* Chips de filtros activos */
.filtros-activos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.filtro-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: 12px;
}
.filtro-chip-label { color: var(--text-3); }
.filtro-chip-valor {
  color: var(--text-1);
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filtro-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
}
.filtro-chip-x:hover { background: var(--surface-3); color: var(--text-1); }
.filtro-chip-limpiar {
  border: none;
  background: transparent;
  color: var(--accent-fg);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 6px;
}
.filtro-chip-limpiar:hover { text-decoration: underline; }

/* Encabezados sorteables */
.data-table thead th.th-sort {
  cursor: pointer;
  user-select: none;
}
.data-table thead th.th-sort:hover {
  color: var(--text-1);
  background: var(--surface-3);
}
.data-table thead th.th-sort:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: -2px;
}
.data-table thead th.th-sort--activo,
.data-table thead th.th-sort--activo .th-sort-ico {
  color: var(--accent-fg);
}
.th-sort-ico {
  font-size: 11px;
  color: var(--text-3);
  margin-left: 2px;
}

/* Combobox buscable (lista desplegable + búsqueda) */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--r) var(--r);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow);
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--surface-2); }
.autocomplete-item .codigo {
  font-family: var(--mono);
  color: var(--accent-fg);
  font-weight: 600;
  font-size: 11px;
}
.autocomplete-item .nombre { color: var(--text-1); font-size: 12px; }
.autocomplete-item .meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
}
.autocomplete-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
}

/* Celda "Sin asignar" (ausencia neutra, nunca alarma) */
.cell-sin-asignar {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-style: italic;
  color: var(--text-3);
}
.cell-sin-asignar > i { font-size: 13px; }

/* ---- SortableTable: encabezados ordenables por clic (genérico) ---- */
.data-table thead th.st-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.data-table thead th.st-th:hover { color: var(--accent-fg); }
.data-table thead th.st-th:focus-visible { outline: 2px solid var(--focus-ring, var(--accent-fg)); outline-offset: -2px; }
.data-table thead th.st-th .st-ico {
  font-size: 11px;
  opacity: .55;
  margin-left: 2px;
}
.data-table thead th.st-th[aria-sort="ascending"] .st-ico,
.data-table thead th.st-th[aria-sort="descending"] .st-ico {
  opacity: 1;
  color: var(--accent-fg);
}
