/* ============================================================================
   DESIGN SYSTEM · 05 · COMPONENTS
   ----------------------------------------------------------------------------
   Buttons, cards, forms, badges/chips, tables, modals, toasts, navigation.
   All sizes follow control-h-sm/md/lg tokens. All branded variants use
   color-mix(--brand-color) — never hardcode.
   ============================================================================ */

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
  --btn-h: var(--ds-control-h-md);
  --btn-px: var(--ds-space-4);
  --btn-fs: var(--ds-text-sm);
  --btn-fw: var(--ds-weight-semibold);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-space-2);
  height: var(--btn-h);
  min-width: var(--btn-h);
  padding-inline: var(--btn-px);
  font-family: var(--ds-font-sans);
  font-size: var(--btn-fs);
  font-weight: var(--btn-fw);
  letter-spacing: -0.005em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--ds-radius-md);
  background: transparent;
  color: var(--ds-text-default);
  transition:
    background-color var(--ds-motion-quick) var(--ds-ease-out),
    border-color var(--ds-motion-quick) var(--ds-ease-out),
    color var(--ds-motion-quick) var(--ds-ease-out),
    box-shadow var(--ds-motion-quick) var(--ds-ease-out),
    transform var(--ds-motion-quick) var(--ds-ease-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus);
}

.btn:disabled,
.btn[aria-disabled="true"],
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:active { transform: translateY(0.5px) scale(0.985); }

/* Sizes */
.btn-xs { --btn-h: 28px; --btn-px: var(--ds-space-2); --btn-fs: var(--ds-text-2xs); }
.btn-sm { --btn-h: var(--ds-control-h-sm); --btn-px: var(--ds-space-3); --btn-fs: var(--ds-text-xs); }
.btn-md { --btn-h: var(--ds-control-h-md); --btn-px: var(--ds-space-4); --btn-fs: var(--ds-text-sm); }
.btn-lg { --btn-h: var(--ds-control-h-lg); --btn-px: var(--ds-space-5); --btn-fs: var(--ds-text-base); }

/* Block (full width) */
.btn-block { width: 100%; }

/* On small screens: optional auto-block via parent .cluster-stack-mobile */
@media (max-width: 480px) {
  .cluster-stack-mobile > .btn { width: 100%; }
  .cluster-stack-mobile { flex-direction: column; align-items: stretch; }
}

/* Icon-only square */
.btn-icon { padding: 0; min-width: var(--btn-h); width: var(--btn-h); }

/* ── Variants ───────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--ds-brand);
  color: #fff;
  border-color: var(--ds-brand);
  box-shadow: var(--ds-shadow-sm);
}
@media (hover: hover) {
  .btn-primary:hover {
    background: var(--ds-brand-strong);
    border-color: var(--ds-brand-strong);
    box-shadow: var(--ds-shadow-brand);
  }
}

.btn-secondary {
  background: var(--ds-surface-0);
  color: var(--ds-text-default);
  border-color: var(--ds-border-default);
}
@media (hover: hover) {
  .btn-secondary:hover {
    border-color: var(--ds-brand);
    color: var(--ds-brand);
    background: var(--ds-brand-softer);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--ds-text-default);
}
@media (hover: hover) {
  .btn-ghost:hover {
    background: var(--ds-surface-2);
    color: var(--ds-text-strong);
  }
}

.btn-brand-ghost {
  background: transparent;
  color: var(--ds-brand);
}
@media (hover: hover) {
  .btn-brand-ghost:hover {
    background: var(--ds-brand-tint);
  }
}

.btn-outline {
  background: transparent;
  color: var(--ds-brand);
  border-color: var(--ds-brand);
}
@media (hover: hover) {
  .btn-outline:hover {
    background: var(--ds-brand);
    color: #fff;
  }
}

.btn-danger {
  background: var(--ds-danger);
  color: #fff;
  border-color: var(--ds-danger);
}
@media (hover: hover) {
  .btn-danger:hover { filter: brightness(1.08); }
}

.btn-danger-ghost {
  background: transparent;
  color: var(--ds-danger);
}
@media (hover: hover) {
  .btn-danger-ghost:hover { background: var(--ds-danger-soft); }
}

/* Loading state — append .is-loading and content stays but spinner overlays */
.btn.is-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: '';
  position: absolute;
  width: 1em; height: 1em;
  top: 50%; left: 50%;
  margin: -0.5em 0 0 -0.5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  color: var(--ds-text-default);
  animation: ds-spin 0.7s linear infinite;
}
.btn-primary.is-loading::after,
.btn-danger.is-loading::after,
.btn-outline.is-loading::after { color: #fff; }

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
  background: var(--ds-surface-0);
  border: 1px solid var(--ds-border-default);
  border-radius: var(--ds-radius-xl);
  padding: var(--ds-space-5);
  box-shadow: var(--ds-shadow-xs);
  transition:
    border-color var(--ds-motion-base) var(--ds-ease-out),
    box-shadow var(--ds-motion-base) var(--ds-ease-out),
    transform var(--ds-motion-base) var(--ds-ease-out-expo);
}

.card-tight { padding: var(--ds-space-4); }
.card-loose { padding: var(--ds-space-6); }

.card-elevated { box-shadow: var(--ds-shadow-md); }

.card-interactive { cursor: pointer; }
@media (hover: hover) {
  .card-interactive:hover {
    border-color: var(--ds-brand);
    box-shadow: var(--ds-shadow-lg);
    transform: translateY(-2px);
  }
}

.card-hero {
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--ds-brand) 70%, #6366f1) 0%, transparent 55%),
    radial-gradient(90%  120% at 100% 0%, color-mix(in srgb, var(--ds-brand) 55%, #ec4899) 0%, transparent 60%),
    radial-gradient(80%  100% at 50% 100%, #0f172a 0%, #0b1120 70%);
  color: var(--ds-text-inverse);
  border: 0;
  box-shadow:
    0 30px 60px -30px color-mix(in srgb, var(--ds-brand) 55%, #0f172a),
    inset 0 1px 0 rgba(255,255,255,0.12);
  border-radius: var(--ds-radius-2xl);
  padding: var(--ds-space-6);
}
.card-hero h1, .card-hero h2, .card-hero h3, .card-hero .h1, .card-hero .h2, .card-hero .h3 {
  color: var(--ds-text-inverse);
}

/* Card header / body / footer slots */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-3);
  margin-bottom: var(--ds-space-4);
}
.card-header__title {
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-lg);
  font-weight: var(--ds-weight-semibold);
  color: var(--ds-text-strong);
  letter-spacing: var(--ds-tracking-snug);
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ds-space-2);
  margin-top: var(--ds-space-4);
  padding-top: var(--ds-space-4);
  border-top: 1px solid var(--ds-border-subtle);
}

/* KPI card */
.card-kpi {
  background: var(--ds-surface-0);
  border: 1px solid var(--ds-border-default);
  border-radius: var(--ds-radius-xl);
  padding: var(--ds-space-4) var(--ds-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  position: relative;
  overflow: hidden;
  transition: border-color var(--ds-motion-base), box-shadow var(--ds-motion-base);
}
.card-kpi::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ds-brand);
  opacity: 0;
  transition: opacity var(--ds-motion-base);
}
@media (hover: hover) {
  .card-kpi:hover { border-color: var(--ds-brand); box-shadow: var(--ds-shadow-md); }
  .card-kpi:hover::before { opacity: 1; }
}
.card-kpi__label {
  font-size: var(--ds-text-2xs);
  font-weight: var(--ds-weight-semibold);
  letter-spacing: var(--ds-tracking-wider);
  text-transform: uppercase;
  color: var(--ds-text-muted);
}
.card-kpi__value {
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-3xl);
  font-weight: var(--ds-weight-bold);
  color: var(--ds-text-strong);
  letter-spacing: var(--ds-tracking-tight);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.card-kpi__delta {
  font-size: var(--ds-text-xs);
  font-weight: var(--ds-weight-medium);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.card-kpi__delta--up   { color: var(--ds-success); }
.card-kpi__delta--down { color: var(--ds-danger); }

/* ============================================================================
   FORMS
   ============================================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-1);
  min-width: 0;
}

.field-label {
  font-size: var(--ds-text-xs);
  font-weight: var(--ds-weight-semibold);
  color: var(--ds-text-default);
  letter-spacing: -0.005em;
}
.field-label--required::after {
  content: '*';
  color: var(--ds-danger);
  margin-left: 2px;
}

.field-input,
.field-select,
.field-textarea {
  width: 100%;
  height: var(--ds-control-h-md);
  padding: 0 var(--ds-space-3);
  font-family: var(--ds-font-sans);
  font-size: var(--ds-text-sm);
  color: var(--ds-text-strong);
  background: var(--ds-surface-0);
  border: 1px solid var(--ds-border-default);
  border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-xs) inset;
  transition:
    border-color var(--ds-motion-quick) var(--ds-ease-out),
    box-shadow var(--ds-motion-quick) var(--ds-ease-out),
    background var(--ds-motion-quick) var(--ds-ease-out);
  -webkit-appearance: none;
  appearance: none;
}

.field-textarea {
  height: auto;
  min-height: calc(var(--ds-control-h-md) * 2.4);
  padding: var(--ds-space-3);
  line-height: var(--ds-leading-normal);
  resize: vertical;
}

.field-input::placeholder,
.field-textarea::placeholder { color: var(--ds-text-subtle); }

.field-input:hover,
.field-select:hover,
.field-textarea:hover { border-color: var(--ds-border-strong); }

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
  outline: none;
  border-color: var(--ds-brand);
  box-shadow: var(--ds-shadow-focus);
  background: var(--ds-surface-0);
}

.field-input:disabled,
.field-select:disabled,
.field-textarea:disabled {
  background: var(--ds-surface-2);
  color: var(--ds-text-muted);
  cursor: not-allowed;
}

.field-hint  { font-size: var(--ds-text-2xs); color: var(--ds-text-muted); }
.field-error { font-size: var(--ds-text-2xs); color: var(--ds-danger); font-weight: var(--ds-weight-medium); }

.field.is-error .field-input,
.field.is-error .field-select,
.field.is-error .field-textarea {
  border-color: var(--ds-danger);
}
.field.is-error .field-input:focus,
.field.is-error .field-select:focus,
.field.is-error .field-textarea:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ds-danger) 25%, transparent);
}

/* Select chevron */
.field-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

/* Search input with icon (use .field-input--search and place icon separately) */
.field-with-icon { position: relative; }
.field-with-icon > .field-input { padding-left: 2.25rem; }
.field-with-icon > .field-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ds-text-subtle);
  pointer-events: none;
  width: 1rem;
  height: 1rem;
}

/* Mobile: 16px font prevents iOS zoom on focus */
@media (max-width: 767px) {
  .field-input,
  .field-select,
  .field-textarea { font-size: 16px; }
}

/* ============================================================================
   BADGES & CHIPS
   ============================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  height: 22px;
  padding: 0 var(--ds-space-2);
  font-size: var(--ds-text-2xs);
  font-weight: var(--ds-weight-semibold);
  letter-spacing: 0.01em;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-surface-2);
  color: var(--ds-text-default);
  white-space: nowrap;
}

.badge-brand   { background: var(--ds-brand-tint);     color: var(--ds-brand); }
.badge-success { background: var(--ds-success-soft);   color: var(--ds-success); }
.badge-warning { background: var(--ds-warning-soft);   color: var(--ds-warning); }
.badge-danger  { background: var(--ds-danger-soft);    color: var(--ds-danger); }
.badge-info    { background: var(--ds-info-soft);      color: var(--ds-info); }
.badge-neutral { background: var(--ds-surface-2);      color: var(--ds-text-muted); }

.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Chip = badge with delete affordance / interactive */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-1);
  height: 28px;
  padding: 0 var(--ds-space-3);
  font-size: var(--ds-text-xs);
  font-weight: var(--ds-weight-medium);
  border-radius: var(--ds-radius-pill);
  background: var(--ds-surface-2);
  color: var(--ds-text-default);
  border: 1px solid transparent;
  cursor: default;
}
.chip-interactive { cursor: pointer; transition: background var(--ds-motion-quick); }
@media (hover: hover) {
  .chip-interactive:hover { background: var(--ds-surface-3); }
}
.chip-brand { background: var(--ds-brand-tint); color: var(--ds-brand); }
.chip-success { background: color-mix(in srgb, var(--ds-success) 14%, transparent); color: var(--ds-success); }
.chip-warning { background: color-mix(in srgb, var(--ds-warning) 16%, transparent); color: var(--ds-warning); }
.chip-danger  { background: color-mix(in srgb, var(--ds-danger) 14%, transparent); color: var(--ds-danger); }
.chip-info    { background: color-mix(in srgb, var(--ds-info) 14%, transparent); color: var(--ds-info); }

/* ============================================================================
   TABLES
   ============================================================================ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--ds-text-sm);
  color: var(--ds-text-default);
}

.table thead th {
  text-align: left;
  font-size: var(--ds-text-2xs);
  font-weight: var(--ds-weight-semibold);
  letter-spacing: var(--ds-tracking-wider);
  text-transform: uppercase;
  color: var(--ds-text-muted);
  padding: var(--ds-space-3) var(--ds-space-4);
  background: var(--ds-surface-1);
  border-bottom: 1px solid var(--ds-border-default);
  white-space: nowrap;
}

.table tbody td {
  padding: var(--ds-space-3) var(--ds-space-4);
  border-bottom: 1px solid var(--ds-border-subtle);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--ds-motion-quick);
}
@media (hover: hover) {
  .table tbody tr:hover { background: var(--ds-surface-1); }
}

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

.table-zebra tbody tr:nth-child(odd) { background: var(--ds-surface-1); }
@media (hover: hover) {
  .table-zebra tbody tr:nth-child(odd):hover { background: var(--ds-surface-2); }
}

.table-card {
  background: var(--ds-surface-0);
  border: 1px solid var(--ds-border-default);
  border-radius: var(--ds-radius-xl);
  overflow: hidden;
}
.table-card thead th:first-child { padding-left: var(--ds-space-5); }
.table-card thead th:last-child  { padding-right: var(--ds-space-5); }
.table-card tbody td:first-child { padding-left: var(--ds-space-5); }
.table-card tbody td:last-child  { padding-right: var(--ds-space-5); }

/* Sticky header */
.table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ============================================================================
   MODALS / DIALOGS
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--ds-surface-overlay);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: var(--ds-z-overlay);
  animation: ds-fade-in var(--ds-motion-base) var(--ds-ease-out);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--ds-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--ds-space-4);
  pointer-events: none;
}

/* Honrar el ocultamiento de Tailwind / atributo HTML hidden.
   Sin esto, el DS .modal { display:flex } gana sobre .hidden por orden de carga
   y los modales con `class="hidden modal"` quedan SIEMPRE visibles capturando
   clicks (panel transparente encima de todo). */
.modal.hidden,
.modal[hidden] { display: none !important; }

/* Asegurar que cualquier panel dentro de .modal quede por ENCIMA del .modal-backdrop
   (que es position:fixed con blur). Sin esto, el blur del backdrop se pinta sobre
   el contenido del panel y el modal se ve borroso.
   Nota: el backdrop tiene z-index:--ds-z-overlay (60) propio, por eso forzamos
   un valor mayor en los hermanos no-backdrop. */
.modal > .modal-backdrop { z-index: 0 !important; }
.modal > *:not(.modal-backdrop) {
  position: relative;
  z-index: 1;
}

.modal-panel {
  pointer-events: auto;
  background: var(--ds-surface-0);
  border-radius: var(--ds-radius-xl);
  box-shadow: var(--ds-shadow-2xl);
  width: 100%;
  max-width: 32rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ds-scale-in var(--ds-motion-base) var(--ds-ease-out-expo);
}

.modal-panel--lg { max-width: 48rem; }
.modal-panel--xl { max-width: 64rem; }

.modal-header {
  padding: var(--ds-space-5);
  border-bottom: 1px solid var(--ds-border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--ds-space-3);
}
.modal-title {
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-xl);
  font-weight: var(--ds-weight-semibold);
  color: var(--ds-text-strong);
  letter-spacing: var(--ds-tracking-snug);
}
.modal-body {
  padding: var(--ds-space-5);
  overflow-y: auto;
}
.modal-footer {
  padding: var(--ds-space-4) var(--ds-space-5);
  border-top: 1px solid var(--ds-border-subtle);
  background: var(--ds-surface-1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--ds-space-2);
  flex-wrap: wrap;
}

/* Mobile: bottom sheet */
@media (max-width: 640px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--ds-radius-2xl) var(--ds-radius-2xl) 0 0;
    animation: ds-sheet-up var(--ds-motion-slow) var(--ds-ease-out-expo);
  }
  .modal-panel::before {
    content: '';
    display: block;
    width: 2.25rem;
    height: 4px;
    background: var(--ds-border-strong);
    border-radius: var(--ds-radius-pill);
    margin: var(--ds-space-3) auto 0;
    flex-shrink: 0;
  }
}

/* ============================================================================
   TOASTS
   ============================================================================ */
.toast-stack {
  position: fixed;
  top: var(--ds-space-4);
  right: var(--ds-space-4);
  z-index: var(--ds-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-2);
  max-width: calc(100vw - 2rem);
  width: 22rem;
  pointer-events: none;
}
@media (max-width: 640px) {
  .toast-stack {
    top: auto;
    bottom: calc(var(--ds-space-4) + env(safe-area-inset-bottom, 0px));
    left: var(--ds-space-4);
    right: var(--ds-space-4);
    width: auto;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-3) var(--ds-space-4);
  background: var(--ds-surface-0);
  color: var(--ds-text-strong);
  border: 1px solid var(--ds-border-default);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-lg);
  font-size: var(--ds-text-sm);
  animation: ds-slide-down var(--ds-motion-slow) var(--ds-ease-spring);
}
.toast-success { border-left: 3px solid var(--ds-success); }
.toast-warning { border-left: 3px solid var(--ds-warning); }
.toast-danger  { border-left: 3px solid var(--ds-danger); }
.toast-info    { border-left: 3px solid var(--ds-info); }

/* ============================================================================
   NAVIGATION (sidebar items, tabs, breadcrumbs)
   ============================================================================ */
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  padding: var(--ds-space-2) var(--ds-space-3);
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-weight-medium);
  color: var(--ds-text-muted);
  border-radius: var(--ds-radius-md);
  text-decoration: none;
  position: relative;
  transition: color var(--ds-motion-quick), background var(--ds-motion-quick);
}
@media (hover: hover) {
  .nav-item:hover { color: var(--ds-text-strong); background: var(--ds-surface-2); }
}
.nav-item.is-active {
  color: var(--ds-brand);
  background: var(--ds-brand-tint);
  font-weight: var(--ds-weight-semibold);
}

/* Tabs */
.tabs {
  display: inline-flex;
  gap: var(--ds-space-1);
  padding: 4px;
  background: var(--ds-surface-2);
  border-radius: var(--ds-radius-md);
}
.tab {
  padding: var(--ds-space-2) var(--ds-space-3);
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-weight-medium);
  color: var(--ds-text-muted);
  border-radius: calc(var(--ds-radius-md) - 2px);
  cursor: pointer;
  transition: background var(--ds-motion-quick), color var(--ds-motion-quick);
  border: 0;
  background: transparent;
}
@media (hover: hover) {
  .tab:hover { color: var(--ds-text-strong); }
}
.tab.is-active {
  background: var(--ds-surface-0);
  color: var(--ds-text-strong);
  box-shadow: var(--ds-shadow-xs);
}

/* Tabs — variante "underline" (navegación por seccion) */
.tabs--underline {
  display: flex;
  gap: var(--ds-space-6);
  padding: 0;
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid var(--ds-border-subtle);
  align-items: stretch;
}
.tabs--underline .tab {
  position: relative;
  padding: var(--ds-space-3) var(--ds-space-1);
  border-radius: 0;
  background: transparent;
  color: var(--ds-text-muted);
  font-weight: var(--ds-weight-medium);
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
@media (hover: hover) {
  .tabs--underline .tab:hover {
    color: var(--ds-text-strong);
    border-bottom-color: var(--ds-border-strong);
  }
}
.tabs--underline .tab.is-active {
  color: var(--ds-brand);
  border-bottom-color: var(--ds-brand);
  background: transparent;
  box-shadow: none;
  font-weight: var(--ds-weight-semibold);
}
.tabs--underline .tab svg {
  width: 1.125rem;
  height: 1.125rem;
  color: currentColor;
  opacity: 0.7;
}
.tabs--underline .tab.is-active svg { opacity: 1; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--ds-space-1);
  font-size: var(--ds-text-xs);
  color: var(--ds-text-muted);
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--ds-text-muted);
  text-decoration: none;
  transition: color var(--ds-motion-quick);
}
@media (hover: hover) {
  .breadcrumb a:hover { color: var(--ds-brand); }
}
.breadcrumb__sep { color: var(--ds-text-subtle); }
.breadcrumb__current { color: var(--ds-text-strong); font-weight: var(--ds-weight-semibold); }

/* ============================================================================
   AVATAR / BRAND MARK
   ============================================================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--ds-brand-tint);
  color: var(--ds-brand);
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-xs);
  font-weight: var(--ds-weight-semibold);
  letter-spacing: 0;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: var(--ds-text-2xs); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--ds-text-sm); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--ds-text-base); }

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-2);
  font-family: var(--ds-font-display);
  font-weight: var(--ds-weight-bold);
  color: var(--ds-text-strong);
  letter-spacing: var(--ds-tracking-tight);
}
.brand-mark__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--ds-radius-sm);
  background: var(--ds-brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--ds-text-sm);
}

/* ============================================================================
   EMPTY STATE
   ============================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--ds-space-7) var(--ds-space-4);
  gap: var(--ds-space-3);
  color: var(--ds-text-muted);
}
.empty-state__icon {
  width: 56px; height: 56px;
  border-radius: var(--ds-radius-pill);
  background: var(--ds-surface-2);
  color: var(--ds-text-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.empty-state__title {
  font-family: var(--ds-font-display);
  font-size: var(--ds-text-lg);
  font-weight: var(--ds-weight-semibold);
  color: var(--ds-text-strong);
}
.empty-state__lead { max-width: 38ch; font-size: var(--ds-text-sm); }

/* Variante compacta (para usar dentro de cards / paneles pequeños) */
.empty-state--sm {
  padding: var(--ds-space-5) var(--ds-space-3);
  gap: var(--ds-space-2);
}
.empty-state--sm .empty-state__icon { width: 40px; height: 40px; }
.empty-state--sm .empty-state__title {
  font-size: var(--ds-text-sm);
  font-weight: var(--ds-weight-semibold);
}
.empty-state--sm .empty-state__lead { font-size: var(--ds-text-xs); }

/* ============================================================================
   LEGACY ADAPTERS (Tailwind utility classes → DS look)
   ----------------------------------------------------------------------------
   Auto-aplica el look del DS a controles que usan clases utilitarias antiguas
   (border-slate-200/300 + rounded-*). Permite unificar la apariencia de ~200+
   formularios y cards sin tocar plantilla por plantilla. Migración progresiva:
   reemplazar a `.field-input/.field-select/.field-textarea` o `.card` cuando
   se toque cada plantilla.
   ============================================================================ */

/* --- Form controls legacy --- */
input[class*="border-slate-200"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn),
input[class*="border-slate-300"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn),
select[class*="border-slate-200"]:not(.field-select):not(.btn),
select[class*="border-slate-300"]:not(.field-select):not(.btn),
textarea[class*="border-slate-200"]:not(.field-textarea),
textarea[class*="border-slate-300"]:not(.field-textarea) {
  font-family: var(--ds-font-sans);
  color: var(--ds-text-strong);
  background-color: var(--ds-surface-0);
  border-color: var(--ds-border-default) !important;
  border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-xs) inset;
  transition:
    border-color var(--ds-motion-quick) var(--ds-ease-out),
    box-shadow var(--ds-motion-quick) var(--ds-ease-out);
}

input[class*="border-slate-200"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):hover,
input[class*="border-slate-300"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):hover,
select[class*="border-slate-200"]:not(.field-select):not(.btn):hover,
select[class*="border-slate-300"]:not(.field-select):not(.btn):hover,
textarea[class*="border-slate-200"]:not(.field-textarea):hover,
textarea[class*="border-slate-300"]:not(.field-textarea):hover {
  border-color: var(--ds-border-strong) !important;
}

input[class*="border-slate-200"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):focus,
input[class*="border-slate-300"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):focus,
select[class*="border-slate-200"]:not(.field-select):not(.btn):focus,
select[class*="border-slate-300"]:not(.field-select):not(.btn):focus,
textarea[class*="border-slate-200"]:not(.field-textarea):focus,
textarea[class*="border-slate-300"]:not(.field-textarea):focus {
  outline: none;
  border-color: var(--ds-brand) !important;
  box-shadow: var(--ds-shadow-focus);
}

input[class*="border-slate-200"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):disabled,
input[class*="border-slate-300"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn):disabled,
select[class*="border-slate-200"]:not(.field-select):not(.btn):disabled,
select[class*="border-slate-300"]:not(.field-select):not(.btn):disabled,
textarea[class*="border-slate-200"]:not(.field-textarea):disabled,
textarea[class*="border-slate-300"]:not(.field-textarea):disabled {
  background-color: var(--ds-surface-2);
  color: var(--ds-text-muted);
  cursor: not-allowed;
}

/* Mobile: prevent iOS zoom on focus for legacy inputs too */
@media (max-width: 767px) {
  input[class*="border-slate-200"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn),
  input[class*="border-slate-300"]:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.field-input):not(.btn),
  select[class*="border-slate-200"]:not(.field-select):not(.btn),
  select[class*="border-slate-300"]:not(.field-select):not(.btn),
  textarea[class*="border-slate-200"]:not(.field-textarea),
  textarea[class*="border-slate-300"]:not(.field-textarea) { font-size: 16px; }
}

/* Checkbox / radio legacy → brand color */
input[type="checkbox"][class*="border-slate-300"]:not(.btn),
input[type="checkbox"][class*="rounded"]:not([class*="border-red"]):not([class*="border-orange"]):not([class*="border-amber"]):not([class*="border-violet"]):not(.btn),
input[type="radio"][class*="border-slate-300"]:not(.btn) {
  accent-color: var(--ds-brand);
}

/* --- Card legacy adapter (bg-white + rounded-2xl + border-slate-200) --- */
/* Da consistencia visual a las cards "manuales" sin obligar a refactor masivo */
div[class*="bg-white"][class*="rounded-2xl"][class*="border-slate-200"]:not(.card):not(.card-kpi):not(.card-hero),
div[class*="bg-white"][class*="rounded-xl"][class*="border-slate-200"]:not(.card):not(.card-kpi):not(.card-hero) {
  border-color: var(--ds-border-default) !important;
  transition:
    border-color var(--ds-motion-base) var(--ds-ease-out),
    box-shadow var(--ds-motion-base) var(--ds-ease-out);
}

/* Píldoras semánticas legacy (bg-{red|emerald|amber|...}-50 + text-{*}-{600|700}) */
/* Nota: NO se uniforman porque la riqueza cromática es deseada — usar .badge-* en código nuevo */
