/* =========================================================================
   RV3 · reservas.css
   CSS único del módulo. Usa las CSS variables del sistema LK (--c-brand,
   --bg-card, --tx-base, etc.) y define las suyas con prefijo --rv3-.
   ========================================================================= */

:root {
  --rv3-radius:      8px;
  --rv3-radius-sm:   6px;
  --rv3-radius-pill: 999px;
  --rv3-bg:          var(--bg-app,    #f5f7fa);
  --rv3-card:        var(--bg-card,   #ffffff);
  --rv3-border:      var(--border,    #e5e7eb);
  --rv3-border-soft: var(--border-soft, #eef0f3);
  --rv3-text:        var(--tx-base,   #1f2937);
  --rv3-text-mut:    var(--tx-mut,    #6b7280);
  --rv3-text-soft:   var(--tx-soft,   #9ca3af);
  --rv3-brand:       var(--c-brand,   #5b6cff);
  --rv3-brand-soft:  var(--c-brand-soft, rgba(91,108,255,0.12));
  --rv3-danger:      var(--c-danger,  #dc2626);
  --rv3-danger-soft: rgba(220,38,38,0.10);
  --rv3-success:     var(--c-success, #16a34a);
  --rv3-warn:        var(--c-warn,    #d97706);
  --rv3-shadow:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --rv3-shadow-lg:   0 10px 30px rgba(0,0,0,0.12);
  --rv3-row-h:       44px;
  --rv3-head-h:      40px;
}

[data-density="compact"]     { --rv3-row-h: 36px; --rv3-head-h: 36px; }
[data-density="comfortable"] { --rv3-row-h: 56px; --rv3-head-h: 44px; }

/* ── Root ──────────────────────────────────────────────────────────────── */
.rv3-root {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  background: var(--rv3-bg);
  color: var(--rv3-text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rv3-no-scroll { overflow: hidden; }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.rv3-topbar {
  flex: 0 0 auto;
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 10px 16px;
  background: var(--rv3-card);
  border-bottom: 1px solid var(--rv3-border);
}
.rv3-topbar-l { display: flex; align-items: center; gap: 10px; }
.rv3-topbar-c { display: flex; justify-content: center; }
.rv3-topbar-r { display: flex; justify-content: flex-end; }
.rv3-topbar-mod-icon { display: inline-flex; color: var(--rv3-brand); }
.rv3-topbar-mod-icon svg { width: 20px; height: 20px; }
.rv3-topbar-title { font-size: 15px; font-weight: 600; margin: 0; }

.rv3-topbar-badge.is-hidden { display: none; }
.rv3-topbar-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--rv3-danger); color: #fff;
  border-radius: var(--rv3-radius-pill);
  font-size: 11px; font-weight: 600;
}
.rv3-pend-badge.is-hidden { display: none; }

/* Pills (tabs) */
.rv3-pills { display: inline-flex; gap: 2px; background: var(--rv3-bg); padding: 3px; border-radius: var(--rv3-radius); }
.rv3-pill-tab {
  appearance: none; border: 0; background: transparent;
  padding: 6px 14px; border-radius: var(--rv3-radius-sm);
  font: inherit; color: var(--rv3-text-mut); cursor: pointer;
}
.rv3-pill-tab.is-active { background: var(--rv3-card); color: var(--rv3-text); box-shadow: var(--rv3-shadow); }
.rv3-pill-tab:hover:not(.is-active) { color: var(--rv3-text); }

.rv3-topbar-new { padding: 6px 12px; }

/* ── SmartView host ────────────────────────────────────────────────────── */
.rv3-smartview-host { flex: 0 0 auto; }

/* ── Body ──────────────────────────────────────────────────────────────── */
.rv3-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px; gap: 10px; }
.rv3-body--lista { padding: 12px 16px; }
.rv3-body-toolbar { flex: 0 0 auto; }
.rv3-body-table   { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.rv3-tlb {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--rv3-card);
  border: 1px solid var(--rv3-border);
  border-radius: var(--rv3-radius);
}
.rv3-tlb-pills { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 6px; }
.rv3-tlb-actions { display: flex; gap: 6px; align-items: center; }

.rv3-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--rv3-brand-soft); color: var(--rv3-text);
  border: 1px solid transparent; border-radius: var(--rv3-radius-pill);
  font-size: 12px; cursor: default;
}
.rv3-pill-text { line-height: 1; }
.rv3-pill-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  color: var(--rv3-text-mut); cursor: pointer;
}
.rv3-pill-x:hover { background: rgba(0,0,0,0.06); color: var(--rv3-text); }
.rv3-pill-x svg { width: 12px; height: 12px; }
.rv3-pill--clear { background: transparent; border-color: var(--rv3-border); color: var(--rv3-text-mut); cursor: pointer; }
.rv3-pill--clear:hover { color: var(--rv3-text); border-color: var(--rv3-text-mut); }

.rv3-tlb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; height: 32px;
  background: var(--rv3-card); color: var(--rv3-text);
  border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm);
  font: inherit; cursor: pointer;
}
.rv3-tlb-btn svg { width: 14px; height: 14px; }
.rv3-tlb-btn:hover { background: var(--rv3-bg); }
.rv3-tlb-btn.icon-only { width: 32px; padding: 0; justify-content: center; }
.rv3-tlb-btn--primary { background: var(--rv3-brand); color: #fff; border-color: var(--rv3-brand); }
.rv3-tlb-btn--primary:hover { filter: brightness(0.95); }

/* Search */
.rv3-search { position: relative; display: inline-flex; align-items: center; }
.rv3-search-btn {
  appearance: none; background: var(--rv3-card); border: 1px solid var(--rv3-border);
  width: 32px; height: 32px; border-radius: var(--rv3-radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rv3-text-mut); cursor: pointer;
}
.rv3-search-btn svg { width: 14px; height: 14px; }
.rv3-search-input {
  width: 0; opacity: 0; padding: 0; border: 0;
  transition: width 0.18s ease, opacity 0.18s ease, padding 0.18s ease;
  height: 32px; font: inherit; outline: none;
  background: var(--rv3-card); color: var(--rv3-text);
  border-radius: var(--rv3-radius-sm);
  pointer-events: none;
}
.rv3-search.open .rv3-search-input { width: 260px; opacity: 1; padding: 0 28px 0 10px; border: 1px solid var(--rv3-border); pointer-events: auto; }
.rv3-search-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 22px; height: 22px; border: 0; background: transparent;
  display: none; align-items: center; justify-content: center;
  color: var(--rv3-text-mut); cursor: pointer; border-radius: 50%;
}
.rv3-search.open.has-q .rv3-search-clear { display: inline-flex; }
.rv3-search-clear:hover { background: rgba(0,0,0,0.06); color: var(--rv3-text); }
.rv3-search-clear svg { width: 12px; height: 12px; }

/* Dropdown wrappers */
.rv3-filters-wrap, .rv3-prefs-wrap { position: relative; }
.rv3-filters-dd, .rv3-prefs-dd {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 340px; max-width: 420px;
  background: var(--rv3-card); border: 1px solid var(--rv3-border);
  border-radius: var(--rv3-radius); box-shadow: var(--rv3-shadow-lg);
  z-index: 20; display: none;
}
.rv3-filters-wrap[data-expanded="1"] .rv3-filters-dd,
.rv3-prefs-wrap[data-expanded="1"]   .rv3-prefs-dd { display: block; }
.rv3-filters-head, .rv3-prefs-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--rv3-border-soft); }
.rv3-filters-body, .rv3-prefs-body { padding: 12px 14px; max-height: 60vh; overflow: auto; }
.rv3-filters-foot, .rv3-prefs-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--rv3-border-soft); }
.rv3-filters-close { background: transparent; border: 0; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--rv3-text-mut); border-radius: 50%; }
.rv3-filters-close:hover { background: rgba(0,0,0,0.06); color: var(--rv3-text); }
.rv3-filters-close svg { width: 14px; height: 14px; }
.rv3-filters-grp { margin-bottom: 14px; }
.rv3-filters-grp:last-child { margin-bottom: 0; }
.rv3-filters-grp-t { font-size: 11px; font-weight: 600; color: var(--rv3-text-mut); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.rv3-filters-grp-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.rv3-filters-empty { color: var(--rv3-text-mut); font-size: 12px; padding: 6px 0; }
.rv3-chk { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; font-size: 12px; cursor: pointer; }
.rv3-chk input { width: 14px; height: 14px; accent-color: var(--rv3-brand); }
.rv3-filters-fechas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; }
.rv3-filters-fechas label { display: flex; flex-direction: column; gap: 2px; color: var(--rv3-text-mut); }
.rv3-filters-fechas input { padding: 4px 6px; border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm); font: inherit; }

/* Prefs */
.rv3-prefs-density { display: inline-flex; gap: 4px; background: var(--rv3-bg); padding: 3px; border-radius: var(--rv3-radius-sm); }
.rv3-prefs-density-btn { appearance: none; border: 0; background: transparent; padding: 5px 10px; border-radius: 4px; font: inherit; color: var(--rv3-text-mut); cursor: pointer; }
.rv3-prefs-density-btn.is-active { background: var(--rv3-card); color: var(--rv3-text); box-shadow: var(--rv3-shadow); }
.rv3-prefs-cols { display: flex; flex-direction: column; gap: 2px; }
.rv3-prefs-col-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--rv3-radius-sm); cursor: grab; }
.rv3-prefs-col-row:hover { background: var(--rv3-bg); }
.rv3-prefs-col-row.is-dragging { opacity: 0.4; }
.rv3-prefs-col-row.is-drag-over { background: var(--rv3-brand-soft); }
.rv3-prefs-col-drag { display: inline-flex; color: var(--rv3-text-soft); }
.rv3-prefs-col-drag svg { width: 12px; height: 12px; }
.rv3-prefs-col-name { flex: 1 1 auto; font-size: 12px; }
.rv3-prefs-col-toggle { display: inline-flex; align-items: center; cursor: pointer; }
.rv3-prefs-col-toggle.is-disabled { opacity: 0.5; cursor: not-allowed; }
.rv3-prefs-col-toggle input { display: none; }
.rv3-switch { width: 28px; height: 16px; background: var(--rv3-border); border-radius: var(--rv3-radius-pill); position: relative; transition: background 0.15s; }
.rv3-switch-knob { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: #fff; border-radius: 50%; transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.rv3-prefs-col-toggle input:checked + .rv3-switch { background: var(--rv3-brand); }
.rv3-prefs-col-toggle input:checked + .rv3-switch .rv3-switch-knob { left: 14px; }

/* ── Tabla ─────────────────────────────────────────────────────────────── */
.rv3-tbl-wrap {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--rv3-card);
  border: 1px solid var(--rv3-border);
  border-radius: var(--rv3-radius);
  overflow: hidden;
}
.rv3-tbl {
  flex: 1 1 auto; min-height: 0; overflow: auto;
}
.rv3-tbl-head, .rv3-tbl-row {
  display: grid;
  grid-template-columns: var(--rv3-grid-cols, 32px 112px 100px 70px minmax(220px, 320px) 200px 130px 130px 40px);
  align-items: center;
}
.rv3-tbl-head {
  position: sticky; top: 0; z-index: 2;
  background: var(--rv3-card);
  border-bottom: 1px solid var(--rv3-border);
  height: var(--rv3-head-h);
}
.rv3-head-cell {
  display: flex; align-items: center; gap: 4px;
  padding: 0 10px; height: 100%;
  font-size: 11px; font-weight: 600; color: var(--rv3-text-mut);
  text-transform: uppercase; letter-spacing: 0.04em;
  position: relative; user-select: none;
}
.rv3-sortable { cursor: pointer; }
.rv3-sortable:hover { color: var(--rv3-text); }
.rv3-sortable--on { color: var(--rv3-text); }
.rv3-sort { width: 12px; height: 12px; flex: 0 0 auto; }
.rv3-sort--off { opacity: 0; transition: opacity 0.1s; }
.rv3-sortable:hover .rv3-sort--off { opacity: 0.5; }
.rv3-col-resize {
  position: absolute; right: 0; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 3;
}
.rv3-col-resize:hover { background: var(--rv3-brand-soft); }
body.rv3-resizing { cursor: col-resize !important; user-select: none; }
body.rv3-resizing * { cursor: col-resize !important; user-select: none; }

.rv3-tbl-row {
  height: var(--rv3-row-h); min-height: var(--rv3-row-h);
  border-bottom: 1px solid var(--rv3-border-soft);
  cursor: pointer;
  transition: background 0.08s;
}
.rv3-tbl-row:hover { background: var(--rv3-bg); }
.rv3-tbl-row.is-selected { background: var(--rv3-brand-soft); }
.rv3-tbl-row.is-selected:hover { background: var(--rv3-brand-soft); filter: brightness(0.97); }

/* Celdas */
.rv3-cell-cb { padding: 0 8px; display: flex; align-items: center; justify-content: center; }
.rv3-cb {
  width: 16px; height: 16px;
  border: 1.5px solid var(--rv3-border); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.rv3-cb:hover { border-color: var(--rv3-brand); }
.rv3-cb.is-on { background: var(--rv3-brand); border-color: var(--rv3-brand); }
.rv3-cb.is-on::after {
  content: ""; width: 8px; height: 8px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
  background-size: 100% 100%;
}

.rv3-cell-folio-wrap { display: flex; align-items: center; gap: 4px; padding: 0 10px; min-width: 0; }
.rv3-cell-folio { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--rv3-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.rv3-cell-folio:hover { color: var(--rv3-brand); }
.rv3-cell-folio-cp {
  appearance: none; background: transparent; border: 0; padding: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rv3-text-soft); cursor: pointer; border-radius: 3px;
  opacity: 0; transition: opacity 0.1s;
}
.rv3-tbl-row:hover .rv3-cell-folio-cp { opacity: 1; }
.rv3-cell-folio-cp:hover { color: var(--rv3-brand); background: var(--rv3-brand-soft); }
.rv3-cell-folio-cp.copied { color: var(--rv3-success); }
.rv3-cell-folio-cp svg { width: 12px; height: 12px; }

.rv3-cell-fecha, .rv3-cell-hora { padding: 0 10px; font-variant-numeric: tabular-nums; font-size: 12px; }

.rv3-cell-paciente { display: flex; flex-direction: column; padding: 0 10px; min-width: 0; gap: 1px; }
.rv3-cell-paciente-nm { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv3-cell-paciente-ids { display: flex; gap: 6px; font-size: 11px; color: var(--rv3-text-mut); }
.rv3-cell-paciente-sep { width: 2px; height: 2px; background: currentColor; border-radius: 50%; align-self: center; }

.rv3-cell-prof { display: flex; align-items: center; gap: 8px; padding: 0 10px; min-width: 0; }
.rv3-cell-prof-av { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; overflow: hidden; background: var(--rv3-bg); display: inline-flex; align-items: center; justify-content: center; color: var(--rv3-text-soft); }
.rv3-cell-prof-av img { width: 100%; height: 100%; object-fit: cover; }
.rv3-cell-prof-av svg { width: 16px; height: 16px; }
.rv3-cell-prof-nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rv3-cell-mod { display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 12px; }
.rv3-cell-mod svg { width: 13px; height: 13px; color: var(--rv3-text-mut); }

.rv3-cell-estado { padding: 0 10px; }
.rv3-st {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 6px;
  border-radius: var(--rv3-radius-pill);
  font-size: 11px; font-weight: 500;
  background: var(--rv3-bg); color: var(--rv3-text);
  border: 1px solid var(--rv3-border-soft);
  white-space: nowrap;
}
.rv3-st-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.rv3-st-reservada    { background: rgba(91,108,255,0.10); color: #4f5fe6; border-color: transparent; }
.rv3-st-confirmada   { background: rgba(16,163,127,0.10); color: #0e8765; border-color: transparent; }
.rv3-st-en_espera    { background: rgba(217,119,6,0.10);  color: #b56500; border-color: transparent; }
.rv3-st-no_pagada    { background: rgba(220,38,38,0.08);  color: #b32020; border-color: transparent; }
.rv3-st-pagada       { background: rgba(22,163,74,0.10);  color: #15803d; border-color: transparent; }
.rv3-st-atendida     { background: rgba(75,85,99,0.10);   color: #374151; border-color: transparent; }
.rv3-st-cancelada    { background: rgba(75,85,99,0.08);   color: #6b7280; border-color: transparent; }
.rv3-st-no_presenta  { background: rgba(220,38,38,0.10);  color: #b32020; border-color: transparent; }
.rv3-st-reagendada   { background: rgba(124,58,237,0.10); color: #6d28d9; border-color: transparent; }
.rv3-st-adicional    { background: rgba(8,145,178,0.10);  color: #0e7490; border-color: transparent; }
.rv3-st-pend_canc    { background: rgba(217,119,6,0.14);  color: #b56500; border-color: transparent; }

.rv3-cell-act { padding: 0 4px; display: flex; align-items: center; justify-content: center; }
.rv3-row-menu {
  appearance: none; background: transparent; border: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rv3-text-mut); cursor: pointer;
  opacity: 0; transition: opacity 0.1s, background 0.1s;
}
.rv3-tbl-row:hover .rv3-row-menu { opacity: 1; }
.rv3-row-menu:hover { background: var(--rv3-bg); color: var(--rv3-text); }
.rv3-row-menu svg { width: 14px; height: 14px; }

/* Empty / Error / Skeleton */
.rv3-tbl-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 48px 16px;
  color: var(--rv3-text-mut);
}
.rv3-tbl-empty svg { width: 32px; height: 32px; opacity: 0.5; }
.rv3-tbl-empty small { font-size: 11px; }
.rv3-tbl-error { color: var(--rv3-danger); }
.rv3-tbl-error svg { color: var(--rv3-danger); }
.rv3-tbl-retry {
  margin-top: 6px; padding: 6px 14px;
  background: var(--rv3-card); border: 1px solid var(--rv3-border);
  border-radius: var(--rv3-radius-sm); font: inherit; color: var(--rv3-text); cursor: pointer;
}
.rv3-tbl-retry:hover { background: var(--rv3-bg); }
.rv3-skel { display: inline-block; background: linear-gradient(90deg, var(--rv3-border-soft) 0%, var(--rv3-bg) 50%, var(--rv3-border-soft) 100%); background-size: 200% 100%; animation: rv3-skel 1.4s ease-in-out infinite; border-radius: 3px; }
.rv3-skel--circle { border-radius: 50%; }
@keyframes rv3-skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.rv3-tbl-row--sk { cursor: default; }
.rv3-tbl-row--sk:hover { background: transparent; }

/* ── Footer / Pager ────────────────────────────────────────────────────── */
.rv3-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: var(--rv3-card);
  border-top: 1px solid var(--rv3-border-soft);
  font-size: 12px;
}
.rv3-foot-info { color: var(--rv3-text-mut); }
.rv3-foot-info strong { color: var(--rv3-text); font-weight: 600; }
.rv3-foot-spacer { flex: 1 1 auto; }
.rv3-page-size { padding: 4px 8px; font: inherit; border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm); background: var(--rv3-card); color: var(--rv3-text); }
.rv3-pager { display: inline-flex; align-items: center; gap: 2px; }
.rv3-pager-btn, .rv3-pager-page {
  appearance: none; background: var(--rv3-card); border: 1px solid var(--rv3-border);
  height: 28px; min-width: 28px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--rv3-radius-sm); font: inherit; color: var(--rv3-text); cursor: pointer;
}
.rv3-pager-btn svg { width: 14px; height: 14px; }
.rv3-pager-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rv3-pager-btn:not(:disabled):hover, .rv3-pager-page:hover { background: var(--rv3-bg); }
.rv3-pager-page.current { background: var(--rv3-brand); color: #fff; border-color: var(--rv3-brand); }
.rv3-pager-gap { padding: 0 4px; color: var(--rv3-text-mut); }

/* ── Modales ───────────────────────────────────────────────────────────── */
.rv3-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.rv3-modal {
  position: relative;
  background: var(--rv3-card); border-radius: var(--rv3-radius);
  box-shadow: var(--rv3-shadow-lg);
  width: 100%; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rv3-modal--sm { max-width: 460px; }
.rv3-modal--md { max-width: 640px; }
.rv3-modal--lg { max-width: 880px; }
.rv3-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--rv3-border-soft);
}
.rv3-modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.rv3-modal-close { appearance: none; background: transparent; border: 0; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: var(--rv3-text-mut); cursor: pointer; border-radius: 50%; }
.rv3-modal-close:hover { background: var(--rv3-bg); color: var(--rv3-text); }
.rv3-modal-close svg { width: 14px; height: 14px; }
.rv3-modal-body { padding: 16px 18px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.rv3-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--rv3-border-soft); }
.rv3-modal-prose { margin: 0 0 4px; color: var(--rv3-text); line-height: 1.5; }
.rv3-modal-prose--danger { color: var(--rv3-danger); }
.rv3-modal-busy {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.7);
  align-items: center; justify-content: center;
  z-index: 5;
}

/* Form */
.rv3-form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.rv3-form-row:last-child { margin-bottom: 0; }
.rv3-form-row label { font-size: 11px; font-weight: 600; color: var(--rv3-text-mut); text-transform: uppercase; letter-spacing: 0.04em; }
.rv3-form-static { font-size: 13px; color: var(--rv3-text); padding: 4px 0; }
.rv3-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.rv3-input {
  width: 100%; padding: 7px 10px;
  background: var(--rv3-card); color: var(--rv3-text);
  border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm);
  font: inherit; outline: none;
}
.rv3-input:focus { border-color: var(--rv3-brand); box-shadow: 0 0 0 3px var(--rv3-brand-soft); }
.rv3-input--ta { resize: vertical; min-height: 60px; font-family: inherit; }
.rv3-radio-group { display: flex; gap: 14px; }
.rv3-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.rv3-radio input { accent-color: var(--rv3-brand); }

.rv3-btn {
  appearance: none; padding: 7px 14px;
  background: var(--rv3-card); color: var(--rv3-text);
  border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm);
  font: inherit; cursor: pointer;
}
.rv3-btn:hover:not(:disabled) { background: var(--rv3-bg); }
.rv3-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.rv3-btn--primary { background: var(--rv3-brand); border-color: var(--rv3-brand); color: #fff; }
.rv3-btn--primary:hover:not(:disabled) { filter: brightness(0.95); background: var(--rv3-brand); }
.rv3-btn--danger  { background: var(--rv3-danger); border-color: var(--rv3-danger); color: #fff; }
.rv3-btn--danger:hover:not(:disabled) { filter: brightness(0.95); background: var(--rv3-danger); }

/* Spinner */
.rv3-spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--rv3-border);
  border-top-color: var(--rv3-brand);
  border-radius: 50%; animation: rv3-spin 0.7s linear infinite;
}
.rv3-spinner--sm { width: 14px; height: 14px; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes rv3-spin { to { transform: rotate(360deg); } }
.rv3-loading-row { display: flex; align-items: center; gap: 8px; color: var(--rv3-text-mut); padding: 16px 0; }
.rv3-empty-inline { padding: 16px; color: var(--rv3-text-mut); text-align: center; }
.rv3-empty-inline--err { color: var(--rv3-danger); }

/* ── Visor (panel lateral) ─────────────────────────────────────────────── */
.rv3-visor {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 800;
  width: 420px; max-width: 90vw;
  background: var(--rv3-card);
  border-left: 1px solid var(--rv3-border);
  box-shadow: var(--rv3-shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease-out;
}
.rv3-visor.is-open { transform: translateX(0); }
.rv3-visor-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--rv3-border-soft); }
.rv3-visor-head-l { display: flex; align-items: center; gap: 10px; }
.rv3-visor-folio { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.rv3-icon-btn {
  appearance: none; background: transparent; border: 0;
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--rv3-text-mut); cursor: pointer;
}
.rv3-icon-btn:hover { background: var(--rv3-bg); color: var(--rv3-text); }
.rv3-icon-btn svg { width: 14px; height: 14px; }
.rv3-visor-body { flex: 1 1 auto; overflow: auto; padding: 12px 16px; }
.rv3-visor-sec { margin-bottom: 18px; }
.rv3-visor-sec-t { font-size: 11px; font-weight: 600; color: var(--rv3-text-mut); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.rv3-visor-kv { display: grid; grid-template-columns: 20px 110px 1fr; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.rv3-visor-kv-i { color: var(--rv3-text-soft); display: inline-flex; }
.rv3-visor-kv-i svg { width: 14px; height: 14px; }
.rv3-visor-kv-i--spacer { width: 14px; }
.rv3-visor-kv-k { color: var(--rv3-text-mut); font-size: 12px; }
.rv3-visor-kv-v { color: var(--rv3-text); }
.rv3-visor-pac { padding: 4px 0 8px; }
.rv3-visor-pac-name { font-weight: 600; font-size: 14px; }
.rv3-visor-pac-ids { display: flex; gap: 6px; font-size: 12px; color: var(--rv3-text-mut); margin-top: 2px; }
.rv3-visor-prof { display: flex; align-items: center; gap: 10px; }
.rv3-visor-prof-av { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--rv3-bg); display: inline-flex; align-items: center; justify-content: center; color: var(--rv3-text-soft); }
.rv3-visor-prof-av img { width: 100%; height: 100%; object-fit: cover; }
.rv3-visor-prof-av svg { width: 18px; height: 18px; }
.rv3-visor-prof-nm { font-weight: 500; }
.rv3-visor-nota { font-size: 13px; color: var(--rv3-text); white-space: pre-wrap; padding: 8px 10px; background: var(--rv3-bg); border-radius: var(--rv3-radius-sm); }
.rv3-visor-foot { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 10px 12px; border-top: 1px solid var(--rv3-border-soft); }
.rv3-visor-act {
  appearance: none; background: transparent; border: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px; border-radius: var(--rv3-radius-sm);
  font: inherit; font-size: 11px; color: var(--rv3-text); cursor: pointer;
}
.rv3-visor-act:hover { background: var(--rv3-bg); }
.rv3-visor-act svg { width: 16px; height: 16px; color: var(--rv3-text-mut); }
.rv3-sep { width: 3px; height: 3px; background: currentColor; border-radius: 50%; align-self: center; }

/* ── Bulk bar ──────────────────────────────────────────────────────────── */
.rv3-bulk-host { flex: 0 0 auto; }
.rv3-bulk-bar {
  position: sticky; bottom: 0;
  background: var(--rv3-card);
  border-top: 1px solid var(--rv3-border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  transform: translateY(0); transition: transform 0.2s, opacity 0.2s;
}
.rv3-bulk-bar.is-hidden { transform: translateY(110%); opacity: 0; pointer-events: none; }
.rv3-bulk-inner { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.rv3-bulk-count { font-weight: 600; font-size: 13px; }
.rv3-bulk-spacer { flex: 1 1 auto; }
.rv3-bulk-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; background: var(--rv3-card); color: var(--rv3-text);
  border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius-sm);
  font: inherit; cursor: pointer;
}
.rv3-bulk-btn:hover { background: var(--rv3-bg); }
.rv3-bulk-btn svg { width: 14px; height: 14px; }
.rv3-bulk-btn--danger { color: var(--rv3-danger); border-color: var(--rv3-danger); }
.rv3-bulk-btn--danger:hover { background: var(--rv3-danger-soft); }
.rv3-bulk-btn--ghost { background: transparent; border-color: transparent; color: var(--rv3-text-mut); }
.rv3-bulk-btn--ghost:hover { background: var(--rv3-bg); color: var(--rv3-text); }

/* ── Sub-tabs (Operaciones) ────────────────────────────────────────────── */
.rv3-subtabs { display: flex; gap: 2px; padding: 6px; background: var(--rv3-card); border: 1px solid var(--rv3-border); border-radius: var(--rv3-radius); width: fit-content; }
.rv3-subtab { appearance: none; background: transparent; border: 0; padding: 7px 14px; border-radius: var(--rv3-radius-sm); font: inherit; color: var(--rv3-text-mut); cursor: pointer; }
.rv3-subtab.is-active { background: var(--rv3-brand-soft); color: var(--rv3-text); }
.rv3-subtab:hover:not(.is-active) { color: var(--rv3-text); }
.rv3-subbody { flex: 1 1 auto; }

/* ── Placeholder (vistas vacías) ───────────────────────────────────────── */
.rv3-placeholder {
  flex: 1 1 auto; min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 48px 16px; text-align: center;
  background: var(--rv3-card); border: 1px dashed var(--rv3-border); border-radius: var(--rv3-radius);
  color: var(--rv3-text-mut);
}
.rv3-placeholder-t { font-size: 15px; font-weight: 600; color: var(--rv3-text); }
.rv3-placeholder-s { font-size: 13px; max-width: 360px; }

/* ── Timeline (historial) ──────────────────────────────────────────────── */
.rv3-timeline { list-style: none; padding: 0; margin: 0; }
.rv3-timeline-item { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--rv3-border-soft); }
.rv3-timeline-item:last-child { border-bottom: 0; }
.rv3-timeline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rv3-brand); margin-top: 4px; justify-self: center; }
.rv3-timeline-head { font-size: 13px; }
.rv3-timeline-trans { color: var(--rv3-text-mut); font-weight: 400; }
.rv3-timeline-meta { font-size: 11px; color: var(--rv3-text-mut); margin-top: 2px; }
.rv3-timeline-detail { font-size: 12px; color: var(--rv3-text); margin-top: 6px; padding: 6px 8px; background: var(--rv3-bg); border-radius: var(--rv3-radius-sm); }
