/* =========================================================================
   Componentes reutilizables (spec §23): botones, tarjetas, campos, chips,
   badges, tablas, pestañas, KPIs, gráficas, modal, drawer, toast, estados.
   Las pantallas solo agregan layout propio en css/screens/*.css.
   ========================================================================= */

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: var(--fw-heavy);
  line-height: 1; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--gradient-primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover { background: var(--gradient-primary-hover); }
.btn-secondary { background: var(--surface-3); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-outline { background: var(--surface); color: var(--brand-blue); border-color: var(--brand-blue); }
.btn-outline:hover { background: var(--info-bg); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.btn-danger:hover { filter: brightness(.97); }
.btn-ai { background: var(--gradient-ai); color: #fff; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; border-radius: var(--radius-sm); }
.btn-icon.btn-sm { width: 30px; min-height: 30px; }
.btn .spinner { width: 14px; height: 14px; }
.btn.is-busy { pointer-events: none; }
.btn.is-busy .btn-label { opacity: .7; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: var(--space-4);
}
.card-soft { background: var(--gradient-soft); border-color: var(--border); }
.card-flat { box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.card-title { font-size: 15px; font-weight: var(--fw-heavy); display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 3px; }
.section-title { font-size: 15px; font-weight: var(--fw-heavy); margin-bottom: var(--space-3); }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--space-4); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: var(--space-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); }

/* ---------- Campos ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field-label {
  display: flex; justify-content: flex-start; align-items: baseline; gap: 4px;
  font-size: var(--fs-xs); font-weight: var(--fw-heavy); color: var(--text);
}
/* Contadores y notas opcionales van a la derecha; el asterisco queda junto al texto. */
.field > label .counter, .field-label .counter, .field > label .opt { margin-left: auto; }
.field .req { color: var(--danger); }
.input, .select, .textarea,
.field input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
.field select, .field textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  background: var(--surface-sunken); color: var(--text); font-size: var(--fs-md);
  transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}
.field textarea, .textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
.field select, .select {
  appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.input:focus, .select:focus, .textarea:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-blue); box-shadow: var(--focus-ring); outline: none;
}
.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--text-subtle); }
.field :is(input, select, textarea):disabled, :is(.input, .select, .textarea):disabled {
  background-color: var(--surface-2); color: var(--text-muted); border-style: dashed; cursor: not-allowed; opacity: .8;
}
.field .hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field .error, .field-error { font-size: var(--fs-xs); color: var(--danger-fg); font-weight: var(--fw-bold); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.counter { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.input-group { display: flex; gap: 6px; }
.input-group > :first-child { flex: 1; min-width: 0; }

.search { position: relative; }
.search input { padding-left: 36px !important; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--text-muted); font-size: 18px; }

input[type=range] { width: 100%; accent-color: var(--brand-blue); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand-blue); width: 16px; height: 16px; }

/* Interruptor (checkbox con role=switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: var(--fw-semibold); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  position: relative; flex: 0 0 auto; width: 40px; height: 22px; border-radius: var(--radius-pill);
  background: var(--border-strong); transition: background-color var(--transition);
}
.switch__track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-xs); transition: transform var(--transition);
}
.switch input:checked + .switch__track { background: var(--success); }
.switch input:checked + .switch__track::after { background: #fff; }
.switch:has(input:disabled) { cursor: not-allowed; }
.switch input:disabled + .switch__track { opacity: .5; }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--focus-ring); }

/* Control segmentado (Día / Semana / Mes) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--surface-3); border: 1px solid var(--border); }
.segmented button {
  min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-heavy);
}
.segmented button[aria-pressed="true"], .segmented button[aria-selected="true"] { background: var(--surface); color: var(--brand-blue); box-shadow: var(--shadow-xs); }

/* ---------- Chips, pills y badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
button.chip:hover { border-color: var(--brand-blue); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--info-bg); border-color: var(--brand-blue); color: var(--info-fg); }
.chip-add { border-style: dashed; color: var(--text-muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-heavy); white-space: nowrap; background: var(--surface-3); color: var(--text-muted);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success, .badge-ok, .badge-high { background: var(--success-bg); color: var(--success-fg); }
.badge-warning, .badge-med, .badge-warn { background: var(--warning-bg); color: var(--warning-fg); }
.badge-danger, .badge-low { background: var(--danger-bg); color: var(--danger-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-ai, .badge-transfer { background: var(--ai-bg); color: var(--ai-fg); }
/* Estados de oportunidad (BadgeVariant del catálogo) */
.badge-qual { background: var(--success-bg); color: var(--success-fg); }
.badge-diag { background: var(--info-bg); color: var(--info-fg); }
.badge-prop { background: var(--ai-bg); color: var(--ai-fg); }
.badge-follow { background: var(--warning-bg); color: var(--warning-fg); }
.badge-new { background: var(--surface-3); color: var(--text-muted); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-xs); font-weight: var(--fw-heavy); }
.delta.is-good { color: var(--success-fg); }
.delta.is-bad { color: var(--danger-fg); }
.delta.is-flat { color: var(--text-muted); }

/* Ícono de canal (círculo con color de marca) */
.ch-ico {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  color: #fff; background: var(--ch-color, var(--brand-blue));
}
.ch-ico svg { width: 15px; height: 15px; }
.ch-whatsapp { --ch-color: var(--ch-whatsapp); }
.ch-instagram { --ch-color: var(--ch-instagram); }
.ch-facebook { --ch-color: var(--ch-facebook); }
.ch-webchat { --ch-color: var(--ch-webchat); }
.ch-email { --ch-color: var(--ch-email); }

.logo-mark {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  background: var(--info-bg); color: var(--info-fg); font-size: var(--fs-xs); font-weight: var(--fw-black);
}

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 4px; border-radius: var(--radius-lg); background: var(--surface-3); border: 1px solid var(--border); }
.tab {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 16px; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--text-muted); font-size: var(--fs-md); font-weight: var(--fw-heavy); white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--surface-hover); }
.tab[aria-selected="true"] { background: var(--nav-active-bg); color: #fff; box-shadow: 0 6px 16px rgba(8, 42, 71, .18); }
.tab-panel { padding-top: var(--space-4); }
.tab-panel[hidden] { display: none; }

/* ---------- KPIs ---------- */
.kpi-row { display: grid; gap: var(--space-3); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 14px 16px;
}
.kpi__ico {
  grid-row: span 3; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 18px;
  background: var(--info-bg); color: var(--info-fg);
}
.kpi__ico.is-green { background: var(--success-bg); color: var(--success-fg); }
.kpi__ico.is-purple { background: var(--ai-bg); color: var(--ai-fg); }
.kpi__ico.is-amber { background: var(--warning-bg); color: var(--warning-fg); }
.kpi__ico.is-red { background: var(--danger-bg); color: var(--danger-fg); }
.kpi__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); }
.kpi__value { font-size: var(--fs-2xl); font-weight: var(--fw-black); letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.05; }
.kpi__foot { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-muted); flex-wrap: wrap; }
.kpi__spark { grid-column: 1 / -1; height: 28px; }

/* ---------- Tablas ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.data-table { width: 100%; font-size: var(--fs-sm); }
.data-table th {
  position: sticky; top: 0; z-index: 1; text-align: left; padding: 11px 12px; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-heavy);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tr.is-selected { background: var(--surface-selected); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .cell-main { font-weight: var(--fw-heavy); }
.data-table .cell-sub { display: block; color: var(--text-muted); font-size: var(--fs-xs); }
.data-table .empty-row td { text-align: center; padding: 28px; color: var(--text-muted); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: 10px 2px 0; font-size: var(--fs-sm); color: var(--text-muted); }
.pagination__pages { display: flex; gap: 4px; }
.pagination__pages button {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: var(--fw-bold);
}
.pagination__pages button[aria-current="page"] { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }

/* Tabla → tarjetas en móvil: agregar .table-cards y data-label en cada <td>. */
@media (max-width: 640px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 12px; border-bottom: 1px solid var(--border); }
  .table-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table-cards td { flex-wrap: wrap; align-items: center; }
  .table-cards td::before { content: attr(data-label); color: var(--text-muted); font-weight: var(--fw-bold); font-size: var(--fs-xs); text-align: left; margin-right: auto; }
  .table-cards td[data-label=""]::before { content: none; }
}

/* ---------- Gráficas (SVG generado por js/core/charts.js) ---------- */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis-label { fill: var(--chart-axis); font-size: 10px; }
.chart .track { stroke: var(--chart-track); }
.chart .point { fill: var(--chart-point-fill); stroke-width: 2; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 3; padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--toast-bg); color: var(--toast-fg); font-size: var(--fs-xs); font-weight: var(--fw-bold);
  box-shadow: var(--shadow-md); transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
}
.donut { position: relative; display: grid; place-items: center; }
.donut__center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut__center b { font-size: var(--fs-xl); font-weight: var(--fw-black); line-height: 1; font-variant-numeric: tabular-nums; }
.donut__center small { color: var(--text-muted); font-size: var(--fs-xs); }
.legend { display: grid; gap: 8px; list-style: none; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--chart-1)); }
.legend b { font-weight: var(--fw-bold); }
.legend strong { font-weight: var(--fw-black); font-variant-numeric: tabular-nums; }
.legend span { color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.legend li:has(> button) { display: block; }
.legend li > button {
  all: unset; box-sizing: border-box; display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: center;
  width: 100%; padding: 2px 4px; margin: -2px -4px; border-radius: var(--radius-xs); cursor: pointer;
}
.legend li > button:hover { background: var(--surface-hover); }
.legend li > button:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 1px; }
@media (pointer: coarse) { .legend li > button { min-height: 40px; } }
.legend li.is-muted { opacity: .4; }
.bar-list { display: grid; gap: 10px; list-style: none; }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: var(--fs-sm); }
.bar-list .bar { grid-column: 1 / -1; height: 8px; border-radius: var(--radius-pill); background: var(--chart-track); overflow: hidden; }
.bar-list .bar i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--chart-1)); transition: width .4s ease; }
.series-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); }
.series-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: var(--c); }

/* ---------- Modal (<dialog>) ---------- */
dialog.modal {
  width: min(var(--modal-w, 560px), calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0;
  border-radius: var(--radius-2xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-modal);
  overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .2s ease both; }
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(3px); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-wide { --modal-w: 760px; }
.modal-xl { --modal-w: 980px; }
.modal__head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3);
  padding: 20px 22px 14px; border-bottom: 1px solid var(--border-subtle); background: var(--gradient-soft);
}
.modal__title { font-size: var(--fs-xl); font-weight: var(--fw-heavy); }
.modal__sub { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 4px; }
.modal__close { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 20px; line-height: 1; }
.modal__close:hover { background: var(--surface-hover); }
.modal__body { padding: 18px 22px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--space-2); padding: 14px 22px 18px; border-top: 1px solid var(--border-subtle); }

@media (max-width: 640px) {
  dialog.modal { width: 100%; max-width: 100%; max-height: 92vh; margin: auto 0 0; border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; }
  .modal__foot { position: sticky; bottom: 0; background: var(--surface); }
  .modal__foot .btn { flex: 1; }
}

/* ---------- Drawer lateral ---------- */
dialog.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(520px, 100%); max-width: 100%; height: 100%; max-height: 100%; padding: 0; border: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-modal);
}
dialog.drawer[open] { display: flex; flex-direction: column; animation: drawer-in .22s ease both; }
dialog.drawer::backdrop { background: var(--overlay); }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast-host[popover] { inset: auto 22px 22px auto; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit; }
/* Con un modal abierto el aviso sube al centro superior para no tapar los botones del pie del modal. */
.toast-host.is-over-dialog, .toast-host.is-over-dialog[popover] { inset: 16px auto auto 50%; transform: translateX(-50%); justify-items: center; }
.toast-host {
  position: fixed; right: 22px; bottom: 22px; z-index: var(--z-toast); display: grid; gap: 8px; justify-items: end;
  pointer-events: none;
}
.toast {
  pointer-events: auto; max-width: 380px; padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--toast-bg); color: var(--toast-fg); box-shadow: var(--shadow-lg);
  font-size: var(--fs-md); font-weight: var(--fw-bold); display: flex; gap: 10px; align-items: center;
  animation: toast-in .22s ease both;
}
.toast.is-leaving { animation: toast-out .2s ease both; }
.toast--success::before { content: "✓"; color: var(--success); }
.toast--error::before { content: "!"; color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@media (max-width: 640px) {
  /* En teléfonos queda por encima de la barra de acciones (Atrás / Siguiente). */
  .toast-host, .toast-host[popover] { inset: auto 16px calc(76px + env(safe-area-inset-bottom)) 16px; justify-items: stretch; }
  .toast-host.is-over-dialog, .toast-host.is-over-dialog[popover] { inset: 12px 12px auto 12px; transform: none; }
  .toast { max-width: none; }
}

/* ---------- Estados: vacío, error, carga ---------- */
.empty-state, .error-state {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 32px 16px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius-lg); background: var(--surface-2);
}
.empty-state b, .error-state b { color: var(--text); }
.error-state { border-color: var(--danger); background: var(--danger-bg); color: var(--danger-fg); }
.skeleton {
  position: relative; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); min-height: 14px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.is-loading { position: relative; pointer-events: none; }
.is-loading > * { opacity: .55; transition: opacity var(--transition); }
.spinner {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Varios ---------- */
.progress { height: 8px; border-radius: var(--radius-pill); background: var(--chart-track); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--brand-blue); }
.divider { height: 1px; background: var(--border); margin: var(--space-3) 0; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-xs); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--info-bg); color: var(--info-fg); font-size: var(--fs-sm); }
.callout-ai { background: var(--ai-bg); color: var(--ai-fg); }
.callout-warning { background: var(--warning-bg); color: var(--warning-fg); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.timeline { list-style: none; display: grid; gap: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: 54px 22px 1fr; gap: 8px; padding-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: 64px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline time { font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); padding-top: 2px; font-variant-numeric: tabular-nums; }
.timeline .tl-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--info-bg); color: var(--info-fg); font-size: 11px; position: relative; z-index: 1; }
.timeline b { display: block; font-size: var(--fs-md); }
.timeline p { color: var(--text-muted); font-size: var(--fs-sm); }

/* Responsive genérico de grillas */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpi-row, .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kpi__value { font-size: var(--fs-xl); }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
  .card { padding: var(--space-3); }
}

/* Resumen de validación de formularios MVC */
.validation-summary-valid { display: none !important; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.field-validation-valid:empty { display: none; }
