/* ============================================================
   MonTech · Biblioteca de componentes
   Todo componente usa exclusivamente tokens de tokens.css
   ============================================================ */

/* ---------- Tarjeta ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.card--flat { box-shadow: none; }
.card--pad { padding: var(--s-5); }
.card--hover { transition: box-shadow var(--t), transform var(--t), border-color var(--t); }
.card--hover:hover { border-color: var(--mt-navy-600); }
.card--brand { border-top: 3px solid var(--brand); }

.card__head {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card__head h3 { font-size: var(--fs-15); font-weight: 700; }
.card__head p { font-size: var(--fs-12); color: var(--text-muted); margin-top: 1px; }
.card__head .u-right { margin-left: auto; }
.card__body { padding: var(--s-5); }
.card__body--tight { padding: var(--s-3) var(--s-4); }
.card__body--flush { padding: 0; }
.card__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
  font-size: var(--fs-12);
  color: var(--text-muted);
  display: flex; align-items: center; gap: var(--s-3);
}

/* ---------- KPI ---------- */
.kpi {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition: box-shadow var(--t), transform var(--t);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--kpi-accent, var(--brand));
}
.kpi__top { display: flex; align-items: flex-start; gap: var(--s-3); }
.kpi__icon {
  width: 40px; height: 40px; border-radius: var(--r);
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--kpi-soft, var(--brand-soft)); color: var(--kpi-accent, var(--brand));
}
.kpi__icon svg { width: 20px; height: 20px; }
.kpi__label { font-size: var(--fs-12); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi__value { font-size: var(--fs-30); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; margin-top: var(--s-3); }
.kpi__value small { font-size: var(--fs-16); font-weight: 700; color: var(--text-muted); margin-left: 3px; }
.kpi__meta { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-2); font-size: var(--fs-12); color: var(--text-muted); }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.kpi__delta svg { width: 13px; height: 13px; }
.kpi__delta--up { color: var(--ok); }
.kpi__delta--down { color: var(--danger); }
.kpi__delta--flat { color: var(--text-muted); }
.kpi__spark { margin-top: var(--s-3); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 38px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid transparent;
  font-size: var(--fs-13); font-weight: 700; white-space: nowrap;
  transition: all var(--t-fast);
  background: var(--bg-surface); color: var(--text-primary);
}
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(138, 49, 12, 0.24); }
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--navy { background: var(--mt-navy-800); color: #fff; }
.btn--navy:hover:not(:disabled) { background: var(--mt-navy-600); }
.btn--ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-inset); color: var(--text-primary); border-color: var(--border-strong); }
.btn--soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn--soft:hover:not(:disabled) { background: var(--mt-orange-100); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn--ok { background: var(--ok); color: #fff; }
.btn--ok:hover:not(:disabled) { filter: brightness(1.08); }
.btn--sm { height: 30px; padding: 0 11px; font-size: var(--fs-12); border-radius: var(--r-sm); }
.btn--sm svg { width: 14px; height: 14px; }
.btn--lg { height: 44px; padding: 0 22px; font-size: var(--fs-14); }
.btn--block { width: 100%; }
.btn--icon { width: 38px; padding: 0; }

/* ---------- Insignias / etiquetas ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--r-sm);
  font-size: var(--fs-11); font-weight: 800; letter-spacing: 0.01em;
  background: var(--neutral-soft); color: var(--neutral-ink);
  white-space: nowrap; line-height: 1.5;
}
.badge svg { width: 12px; height: 12px; }
.badge--ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge--warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge--danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge--info { background: var(--info-soft); color: var(--info-ink); }
.badge--brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge--gold { background: var(--mt-gold-100); color: var(--warn-ink); }
.badge--solid { background: var(--brand); color: #fff; }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-secondary); }
.badge--lg { padding: 5px 12px; font-size: var(--fs-12); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--danger { background: var(--danger); }
.dot--info { background: var(--info); }
.dot--brand { background: var(--brand); }
.dot--pulse { animation: pulseRing 2s infinite; }

/* ---------- Avatar ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex: 0 0 auto;
  background: var(--accent-soft); color: var(--info-ink);
  font-size: var(--fs-12); font-weight: 800; letter-spacing: -0.02em;
}
.avatar--sm { width: 26px; height: 26px; font-size: 10px; border-radius: 2px; }
.avatar--lg { width: 52px; height: 52px; font-size: var(--fs-16); }
.avatar--brand { background: var(--brand-soft); color: var(--brand-ink); }
.avatar--navy { background: var(--mt-navy-800); color: #fff; }

/* ---------- Tabla ---------- */
.tbl-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; font-size: var(--fs-13); }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-muted);
  text-align: left; font-size: var(--fs-11); font-weight: 800;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted);
  padding: 10px var(--s-4); border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}
.tbl thead th.is-sortable { cursor: pointer; user-select: none; }
.tbl thead th.is-sortable:hover { color: var(--text-primary); }
.tbl thead th .sort-ind { display: inline-block; margin-left: 4px; opacity: 0.45; font-size: 9px; }
.tbl thead th.is-sorted .sort-ind { opacity: 1; color: var(--brand); }
.tbl tbody td { padding: 11px var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--bg-muted); }
.tbl tbody tr.is-clickable { cursor: pointer; }
.tbl tbody tr.is-selected { background: var(--brand-soft); }
.tbl tbody tr.row-danger { background: var(--danger-soft); }
.tbl tbody tr.row-danger:hover { background: var(--danger-soft); filter: brightness(0.98); }
.tbl tbody tr.row-warn { background: var(--warn-soft); }
.tbl tbody tr.row-warn:hover { background: var(--warn-soft); filter: brightness(0.98); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .tight { width: 1%; white-space: nowrap; }
.tbl__primary { font-weight: 700; color: var(--text-primary); }
.tbl__sub { font-size: var(--fs-11); color: var(--text-muted); margin-top: 1px; }

.tbl-empty { padding: var(--s-8) var(--s-5); text-align: center; color: var(--text-muted); }
.tbl-empty svg { width: 40px; height: 40px; margin: 0 auto var(--s-3); opacity: 0.4; }

.tbl-foot {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border);
  font-size: var(--fs-12); color: var(--text-muted); background: var(--bg-muted);
}
.pager { display: flex; gap: 4px; margin-left: auto; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: var(--fs-12); font-weight: 700; color: var(--text-secondary);
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: var(--fs-12); font-weight: 700; color: var(--text-secondary); }
.field > label .req { color: var(--danger); }
.field__hint { font-size: var(--fs-11); color: var(--text-muted); }
.field__err { font-size: var(--fs-11); color: var(--danger); font-weight: 700; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: var(--fs-13); outline: none; transition: all var(--t-fast);
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a879f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(220, 110, 12, 0.13);
}
.input:disabled, .select:disabled, .textarea:disabled { background: var(--bg-inset); color: var(--text-muted); cursor: not-allowed; }
.input.is-error, .select.is-error { border-color: var(--danger); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form-grid .col-span { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.check { display: flex; align-items: flex-start; gap: var(--s-2); cursor: pointer; font-size: var(--fs-13); }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); cursor: pointer; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  width: 40px; height: 22px; border-radius: var(--r-full);
  background: var(--border-strong); transition: background var(--t-fast); flex: 0 0 auto;
}
.switch__track::after {
  content: ""; display: block; width: 18px; height: 18px; margin: 2px;
  border-radius: 50%; background: #fff; box-shadow: var(--sh-1);
  transition: transform var(--t-fast);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }

/* ---------- Segmentos / filtros ---------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg-inset); border-radius: var(--r); border: 1px solid var(--border);
}
.segmented button {
  padding: 6px 13px; border: none; background: transparent; border-radius: var(--r-sm);
  font-size: var(--fs-12); font-weight: 700; color: var(--text-secondary);
  transition: all var(--t-fast); white-space: nowrap;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button.is-active { background: var(--bg-surface); color: var(--brand); box-shadow: var(--sh-1); }

.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: var(--fs-12); font-weight: 700; color: var(--text-secondary);
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.chip.is-active { background: var(--mt-navy-800); border-color: var(--mt-navy-800); color: #fff; }
.chip__count { font-size: 10px; padding: 1px 5px; border-radius: var(--r-full); background: var(--bg-inset); color: var(--text-muted); }
.chip.is-active .chip__count { background: rgba(255,255,255,0.2); color: #fff; }

.toolbar {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border); background: var(--bg-surface);
}
.searchbox { position: relative; flex: 0 1 280px; }
.searchbox input { height: 34px; padding-left: 34px; }
.searchbox svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; color: var(--text-muted); }

/* ---------- Barra de progreso / medidor ---------- */
.meter { height: 6px; border-radius: 2px; background: var(--bg-inset); overflow: hidden; position: relative; }
.meter__fill { height: 100%; border-radius: 2px; background: var(--brand); transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1); }
.meter--sm { height: 5px; }
.meter--lg { height: 10px; }
.meter__fill--ok { background: var(--ok); }
.meter__fill--warn { background: var(--warn); }
.meter__fill--danger { background: var(--danger); }
.meter__fill--info { background: var(--info); }
.meter__mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-muted); opacity: 0.6; }

/* ---------- Alertas en línea ---------- */
.note {
  display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg-muted); font-size: var(--fs-13);
}
.note svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.note b { display: block; margin-bottom: 2px; }
.note--danger { background: var(--danger-soft); border-color: transparent; color: var(--danger-ink); }
.note--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn-ink); }
.note--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok-ink); }
.note--info { background: var(--info-soft); border-color: transparent; color: var(--info-ink); }
.note--brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }

/* ---------- Lista de actividad / línea de tiempo ---------- */
.timeline { position: relative; padding-left: var(--s-6); }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding: 0 0 var(--s-5) 0; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-surface); border: 2.5px solid var(--brand);
}
.tl-item--ok::before { border-color: var(--ok); }
.tl-item--danger::before { border-color: var(--danger); }
.tl-item--warn::before { border-color: var(--warn); }
.tl-item--info::before { border-color: var(--info); }
.tl-item__time { font-size: var(--fs-11); color: var(--text-muted); font-weight: 700; }
.tl-item__title { font-size: var(--fs-13); font-weight: 700; margin-top: 1px; }
.tl-item__body { font-size: var(--fs-12); color: var(--text-secondary); margin-top: 2px; }

.feed { display: flex; flex-direction: column; }
.feed__row {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.feed__row:last-child { border-bottom: none; }
.feed__row:hover { background: var(--bg-muted); }
.feed__icon {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex: 0 0 auto;
  display: grid; place-items: center; background: var(--bg-inset); color: var(--text-secondary);
}
.feed__icon svg { width: 16px; height: 16px; }
.feed__icon--ok { background: var(--ok-soft); color: var(--ok); }
.feed__icon--warn { background: var(--warn-soft); color: var(--warn); }
.feed__icon--danger { background: var(--danger-soft); color: var(--danger); }
.feed__icon--brand { background: var(--brand-soft); color: var(--brand); }
.feed__icon--info { background: var(--info-soft); color: var(--info); }
.feed__title { font-size: var(--fs-13); font-weight: 600; }
.feed__meta { font-size: var(--fs-11); color: var(--text-muted); margin-top: 2px; }
.feed__time { font-size: var(--fs-11); color: var(--text-muted); white-space: nowrap; margin-left: auto; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(10, 22, 41, 0.5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: var(--s-6);
  animation: fadeIn 160ms ease both;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 80px);
  background: var(--bg-elevated); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); display: flex; flex-direction: column; overflow: hidden;
  animation: popIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 760px; }
.modal--xl { max-width: 1040px; }
.modal__head {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.modal__head h3 { font-size: var(--fs-18); }
.modal__head p { font-size: var(--fs-13); color: var(--text-muted); margin-top: 2px; }
.modal__close { margin-left: auto; }
.modal__body { padding: var(--s-5); overflow-y: auto; flex: 1 1 auto; }
.modal__body--flush { padding: 0; }
.modal__foot {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border);
  background: var(--bg-muted);
}
.modal__foot .u-right { margin-left: auto; }

/* ---------- Panel lateral (drawer) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 780;
  background: rgba(10, 22, 41, 0.42);
  animation: fadeIn 160ms ease both;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 790;
  width: min(720px, 94vw);
  background: var(--bg-surface); box-shadow: var(--sh-3);
  display: flex; flex-direction: column;
  animation: slideInRight 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.drawer--wide { width: min(980px, 96vw); }
.drawer__head { padding: var(--s-5); border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: var(--s-4); }
.drawer__body { flex: 1 1 auto; overflow-y: auto; }
.drawer__foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); background: var(--bg-muted); display: flex; gap: var(--s-3); align-items: center; }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--border); padding: 0 var(--s-5); }
.tabs button {
  padding: 12px 0; border: none; background: none;
  font-size: var(--fs-13); font-weight: 700; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all var(--t-fast); white-space: nowrap;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tabpanel { animation: viewIn 200ms ease both; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 950;
  display: flex; flex-direction: column; gap: var(--s-3); width: 380px; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r); box-shadow: var(--sh-3);
  animation: slideInRight 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.toast.is-out { animation: fadeOut 240ms ease both; }
.toast__icon { width: 20px; height: 20px; flex: 0 0 auto; color: var(--brand); margin-top: 1px; }
.toast__title { font-size: var(--fs-13); font-weight: 700; }
.toast__msg { font-size: var(--fs-12); color: var(--text-secondary); margin-top: 2px; }
.toast--ok { border-left-color: var(--ok); } .toast--ok .toast__icon { color: var(--ok); }
.toast--warn { border-left-color: var(--warn); } .toast--warn .toast__icon { color: var(--warn); }
.toast--danger { border-left-color: var(--danger); } .toast--danger .toast__icon { color: var(--danger); }
.toast--info { border-left-color: var(--info); } .toast__close { margin-left: auto; }

/* ---------- Popover / menú ---------- */
.menu {
  position: absolute; z-index: 860; min-width: 200px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-3); padding: var(--s-2);
  animation: popIn 140ms ease both;
}
.menu__item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); border: none; background: none;
  font-size: var(--fs-13); color: var(--text-primary); text-align: left;
}
.menu__item:hover { background: var(--bg-inset); }
.menu__item svg { width: 16px; height: 16px; color: var(--text-muted); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger svg { color: var(--danger); }
.menu__sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }
.menu__title { font-size: var(--fs-11); font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); padding: 6px 10px; }

/* ---------- Panel de notificaciones ---------- */
.notif-panel {
  position: absolute; top: calc(var(--topbar-h) - 8px); right: var(--s-6); z-index: 870;
  width: 400px; max-height: 560px; display: flex; flex-direction: column;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: popIn 160ms ease both; overflow: hidden;
}

/* ---------- Estado vacío ---------- */
.empty { padding: var(--s-8) var(--s-5); text-align: center; }
.empty__icon {
  width: 56px; height: 56px; border-radius: var(--r-lg); margin: 0 auto var(--s-4);
  display: grid; place-items: center; background: var(--bg-inset); color: var(--text-muted);
}
.empty__icon svg { width: 26px; height: 26px; }
.empty h4 { font-size: var(--fs-15); }
.empty p { font-size: var(--fs-13); color: var(--text-muted); margin-top: var(--s-2); max-width: 380px; margin-inline: auto; }

/* ---------- Gráficas ---------- */
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__legend { display: flex; flex-wrap: wrap; gap: var(--s-4); margin-top: var(--s-3); }
.chart__legend span { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-secondary); }
.chart__legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.chart-tip {
  position: fixed; z-index: 900; pointer-events: none;
  background: var(--mt-navy-900); color: #fff;
  padding: 7px 11px; border-radius: var(--r-sm); font-size: var(--fs-12);
  box-shadow: var(--sh-2); white-space: nowrap; transform: translate(-50%, -130%);
}
.chart-tip b { color: var(--mt-orange-300); }

/* ---------- Misceláneos ---------- */
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: var(--s-2) var(--s-4); font-size: var(--fs-13); }
.kv dt { color: var(--text-muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-13); }
.stat-row:last-child { border-bottom: none; }
.stat-row b { font-variant-numeric: tabular-nums; }

.skeleton {
  position: relative; overflow: hidden; background: var(--bg-inset); border-radius: var(--r-sm);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent);
  animation: shimmer 1.4s infinite;
}

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

.print-only { display: none; }
@media print {
  .nav, .topbar, .toasts, .page-head__actions { display: none !important; }
  .app { display: block !important; }
  .view { overflow: visible !important; }
  .print-only { display: block; }
  body { background: #fff; }
}

/* ---------- Barras horizontales (ranking) ---------- */
.chart-hbars { display: flex; flex-direction: column; gap: var(--s-4); }
.hbar__top { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: 5px; }
.hbar__label { font-size: var(--fs-13); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar__val { margin-left: auto; font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.hbar__track { height: 8px; border-radius: var(--r-full); background: var(--bg-inset); overflow: hidden; }
.hbar__fill { height: 100%; border-radius: var(--r-full); transition: width 700ms cubic-bezier(0.22, 1, 0.36, 1); }
.hbar__sub { font-size: var(--fs-11); color: var(--text-muted); margin-top: 4px; }

/* ---------- Barra de composición ---------- */
.chart-stack { display: flex; width: 100%; border-radius: var(--r-full); overflow: hidden; background: var(--bg-inset); }
.chart-stack__seg { height: 100%; transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1); }

/* ---------- Modo presentación ---------- */
.tour {
  position: fixed; left: 50%; bottom: var(--s-6); transform: translateX(-50%);
  z-index: 940; width: min(660px, calc(100vw - 48px));
  background: var(--mt-navy-900); color: #fff;
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: popIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.tour__num {
  display: inline-block; font-size: var(--fs-11); font-weight: 800; letter-spacing: 0.1em;
  color: var(--mt-orange-400); text-transform: uppercase; margin-bottom: var(--s-2);
}
.tour h4 { font-size: var(--fs-18); color: #fff; }
.tour p { font-size: var(--fs-14); color: rgba(255, 255, 255, 0.72); margin-top: var(--s-2); line-height: 1.55; }
.tour__acciones { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); }
.tour__acciones .u-right { margin-left: auto; }
.tour .btn--ghost { color: rgba(255, 255, 255, 0.75); border-color: rgba(255, 255, 255, 0.18); background: transparent; }
.tour .btn--ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ============================================================
   Casa Médica · pares clave/valor (variante en spans) y
   secciones del panel lateral (drawer)
   ============================================================ */
.kv__row { grid-column: 1 / -1; display: grid; grid-template-columns: 150px 1fr; gap: 2px var(--s-4); font-size: var(--fs-13); padding: 6px 0; align-items: baseline; border-bottom: 1px solid var(--border); }
.kv__row:last-child { border-bottom: 0; }
.kv__k { color: var(--text-muted); font-weight: 600; }
.kv__v { font-weight: 600; color: var(--text-primary); }

.drawer__eyebrow { display: flex; align-items: center; gap: 6px; font-size: var(--fs-11); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; margin-bottom: 2px; }
.drawer__eyebrow svg { color: var(--brand); }
.drawer__section { margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--border); }
.drawer__stitle { display: flex; align-items: center; gap: 8px; font-size: var(--fs-13); font-weight: 700; margin-bottom: var(--s-3); }
.drawer__stitle svg { color: var(--brand); }
.drawer__stitle .badge { font-weight: 600; }

.select--sm { padding: 4px 8px; font-size: var(--fs-12); }
.tbl--tight th, .tbl--tight td { padding: 6px 10px; }
