/* ==========================================================================
   Manivela UI · Componentes
   Clases mv-* para vistas nuevas. No dependen de Bootstrap.
   Ver demo/componentes.html para el marcado de cada uno.
   ========================================================================== */

/* ---------- Encabezado de página ---------- */
.mv-pagehead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.mv-pagehead-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mv-pagehead h1, .mv-title { margin: 0; font-size: var(--mv-fs-h1); line-height: 1.2; font-weight: 700; letter-spacing: -.01em; color: var(--mv-ink); }
.mv-pagehead p, .mv-subtitle { margin: 2px 0 0; font-size: var(--mv-fs); color: var(--mv-muted); }
.mv-pagehead-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Tarjeta ---------- */
.mv-card { background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg); padding: 18px 20px; }
.mv-card + .mv-card { margin-top: var(--mv-gap); }
.mv-card--flush { padding: 0; overflow: hidden; }
.mv-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.mv-card-head h2, .mv-card-head h3, .mv-card-head h4 { margin: 0; font-size: 15px; font-weight: 600; color: var(--mv-ink); }
.mv-muted { color: var(--mv-muted); font-size: var(--mv-fs-sm); }
.mv-stack { display: flex; flex-direction: column; gap: var(--mv-gap); }

/* ---------- Rejillas ---------- */
.mv-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mv-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mv-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mv-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mv-span-all { grid-column: 1 / -1; }
.mv-span-2 { grid-column: span 2; }
@media (max-width: 991.98px) { .mv-grid--3, .mv-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .mv-grid--2, .mv-grid--3, .mv-grid--4 { grid-template-columns: minmax(0, 1fr); } .mv-span-2 { grid-column: auto; } }

/* ---------- Botones ---------- */
.mv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--mv-control-h); padding: 0 18px; border: 1px solid var(--mv-border); border-radius: var(--mv-radius-md);
  background: var(--mv-surface); color: var(--mv-ink); font: inherit; font-size: var(--mv-fs); font-weight: 600;
  line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
body.mv-theme a.mv-btn { color: var(--mv-ink); }
.mv-btn:hover { background: var(--mv-fill); }
.mv-btn:disabled, .mv-btn.is-disabled { background: #E6EAF0; border-color: #E6EAF0; color: #7C879B; cursor: not-allowed; }
.mv-btn--primary, body.mv-theme a.mv-btn--primary { background: var(--mv-primary); border-color: var(--mv-primary); color: #fff; }
.mv-btn--primary:hover, body.mv-theme a.mv-btn--primary:hover { background: var(--mv-primary-hover); border-color: var(--mv-primary-hover); color: #fff; }
.mv-btn--accent, body.mv-theme a.mv-btn--accent { background: var(--mv-accent); border-color: var(--mv-accent); color: #fff; }
.mv-btn--accent:hover, body.mv-theme a.mv-btn--accent:hover { background: var(--mv-accent-hover); border-color: var(--mv-accent-hover); color: #fff; }
.mv-btn--violet, body.mv-theme a.mv-btn--violet { background: var(--mv-violet); border-color: var(--mv-violet); color: #fff; }
.mv-btn--violet:hover { background: #5200B3; border-color: #5200B3; color: #fff; }
.mv-btn--danger, body.mv-theme a.mv-btn--danger { background: var(--mv-danger-soft); border-color: #F3C4CA; color: var(--mv-danger-ink); }
.mv-btn--danger:hover { background: #FADDE1; }
.mv-btn--ghost { border-color: transparent; background: transparent; }
.mv-btn--link, body.mv-theme .mv-btn--link { border-color: transparent; background: transparent; color: var(--mv-accent); padding: 0 6px; }
.mv-btn--sm { height: var(--mv-control-h-sm); padding: 0 12px; border-radius: var(--mv-radius); font-size: var(--mv-fs-sm); gap: 6px; }
.mv-btn--block { width: 100%; }
.mv-btn--icon { width: var(--mv-control-h); padding: 0; }
.mv-btn--icon.mv-btn--sm { width: var(--mv-control-h-sm); }

/* ---------- Campos ---------- */
.mv-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mv-label, body.mv-theme .mv-field > label { margin: 0; font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-ink-2); }
.mv-req { color: var(--mv-danger); }
.mv-help { font-size: var(--mv-fs-xs); color: var(--mv-muted); }
.mv-error { font-size: var(--mv-fs-xs); color: var(--mv-danger-ink); }

.mv-input {
  position: relative; display: flex; align-items: center; gap: 8px;
  min-height: var(--mv-control-h); padding: 0 14px;
  border: 1px solid var(--mv-border); border-radius: var(--mv-radius); background: var(--mv-surface);
  color: var(--mv-muted); transition: border-color .15s, box-shadow .15s;
}
.mv-input:focus-within { border-color: var(--mv-accent); box-shadow: 0 0 0 3px var(--mv-accent-ring); }
.mv-input > input, .mv-input > select, .mv-input > textarea {
  flex: 1; min-width: 0; width: 100%; height: calc(var(--mv-control-h) - 2px);
  border: 0; outline: 0; background: transparent; padding: 0; margin: 0; box-shadow: none;
  font: inherit; font-size: var(--mv-fs-input); color: var(--mv-ink);
}
/* El anillo de foco lo dibuja el contenedor (.mv-input:focus-within); el campo interno no lleva contorno propio */
body.mv-theme .mv-input > input:focus-visible, body.mv-theme .mv-input > select:focus-visible,
body.mv-theme .mv-input > textarea:focus-visible { outline: 0; }
.mv-input > input::placeholder, .mv-input > textarea::placeholder { color: #8A94A7; opacity: 1; }
.mv-affix { flex: none; font-size: var(--mv-fs); color: var(--mv-muted); display: inline-flex; align-items: center; }
.mv-input--select { padding-right: 0; }
.mv-input--select > select { appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer; }
.mv-input--select::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 1.8px solid var(--mv-muted); border-bottom: 1.8px solid var(--mv-muted); transform: rotate(45deg); pointer-events: none;
}
.mv-input--area { align-items: stretch; padding: 10px 14px; }
.mv-input--area > textarea { height: auto; min-height: 84px; resize: vertical; line-height: 1.5; }
.mv-input--readonly { background: var(--mv-fill); border-color: transparent; color: var(--mv-ink); font-weight: 700; font-size: var(--mv-fs-input); }
.mv-input.is-disabled, .mv-input:has(> input:disabled) { background: var(--mv-fill); }
.mv-field.is-invalid .mv-input, .mv-input.is-invalid { border-color: var(--mv-danger); box-shadow: 0 0 0 3px rgba(210, 56, 74, .12); }

/* Contador − / + */
.mv-stepper { display: flex; align-items: stretch; height: var(--mv-control-h); border: 1px solid var(--mv-border); border-radius: var(--mv-radius); overflow: hidden; background: var(--mv-surface); }
.mv-stepper button { width: 46px; border: 0; background: var(--mv-fill); font: inherit; font-size: 18px; color: var(--mv-ink); cursor: pointer; }
.mv-stepper button:hover { background: #E6EAF0; }
.mv-stepper input { flex: 1; min-width: 0; border: 0; outline: 0; text-align: center; font: inherit; font-size: var(--mv-fs-input); font-weight: 600; color: var(--mv-ink); }

/* Checkbox, radio, switch (inputs nativos) */
.mv-check, .mv-radio, .mv-switch { display: inline-flex; align-items: center; gap: 10px; font-size: var(--mv-fs); color: var(--mv-ink); cursor: pointer; margin: 0; }
.mv-check input, .mv-radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--mv-accent); cursor: pointer; }
.mv-switch input { appearance: none; -webkit-appearance: none; position: relative; width: 38px; height: 22px; margin: 0; border-radius: 999px; background: #CBD3DF; cursor: pointer; transition: background .15s; flex: none; }
.mv-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s var(--mv-ease); }
.mv-switch input:checked { background: var(--mv-accent); }
.mv-switch input:checked::after { transform: translateX(16px); }
.mv-choices { display: flex; flex-wrap: wrap; gap: 12px 20px; }

/* Control segmentado (radios) */
.mv-segmented { display: flex; height: var(--mv-control-h); padding: 4px; gap: 4px; border-radius: var(--mv-radius-md); background: var(--mv-bg); }
.mv-segmented label { flex: 1; margin: 0; position: relative; display: flex; }
.mv-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.mv-segmented span {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 12px; border-radius: 9px;
  font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-neutral-ink); cursor: pointer; white-space: nowrap;
}
.mv-segmented input:checked + span { background: var(--mv-surface); color: var(--mv-ink); box-shadow: 0 1px 2px rgba(17, 26, 46, .12); }
.mv-segmented input:focus-visible + span { outline: 2px solid var(--mv-accent); outline-offset: 1px; }

/* Tarjetas de opción (radio con ícono) */
.mv-options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.mv-option { position: relative; margin: 0; }
.mv-option input { position: absolute; opacity: 0; pointer-events: none; }
.mv-option span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 96px; padding: 12px;
  border: 1px solid var(--mv-border); border-radius: var(--mv-radius-md); background: var(--mv-surface);
  font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-ink-2); text-align: center; cursor: pointer;
}
.mv-option input:checked + span { border: 1.5px solid var(--mv-accent); background: #F1F4FE; color: var(--mv-accent-hover); box-shadow: 0 0 0 3px rgba(47, 85, 212, .12); }
.mv-option input:focus-visible + span { outline: 2px solid var(--mv-accent); outline-offset: 2px; }

/* ---------- Chips y etiquetas ---------- */
.mv-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.mv-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--mv-border); border-radius: 999px; background: var(--mv-surface);
  font: inherit; font-size: var(--mv-fs-sm); font-weight: 500; color: var(--mv-ink); cursor: pointer; white-space: nowrap;
}
.mv-chip:hover { background: var(--mv-fill); }
.mv-chip.is-active, .mv-chip[aria-pressed="true"] { background: var(--mv-primary); border-color: var(--mv-primary); color: #fff; font-weight: 600; }
.mv-chip--filter { height: 30px; padding: 0 6px 0 12px; border: 0; background: var(--mv-accent-soft); color: var(--mv-accent-hover); cursor: default; }
.mv-chip-remove { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.mv-chip-remove:hover { background: rgba(47, 85, 212, .14); }

.mv-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: var(--mv-fs-xs); font-weight: 600; white-space: nowrap; background: var(--mv-neutral-soft); color: var(--mv-neutral-ink); }
.mv-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.mv-badge--plain::before { display: none; }
.mv-badge--success { background: var(--mv-success-soft); color: var(--mv-success-ink); }
.mv-badge--warning { background: var(--mv-warning-soft); color: var(--mv-warning-ink); }
.mv-badge--info    { background: var(--mv-accent-soft); color: var(--mv-accent-hover); }
.mv-badge--danger  { background: var(--mv-danger-soft); color: var(--mv-danger-ink); }
.mv-badge--dark    { background: var(--mv-primary); color: #fff; }
.mv-badge--violet  { background: #EFE5FD; color: #5200B3; }

/* ---------- Avisos ---------- */
.mv-alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--mv-radius-md); font-size: var(--mv-fs); background: var(--mv-info-soft); color: var(--mv-info-ink); }
.mv-alert .mv-icon { margin-top: 1px; }
.mv-alert--success { background: #E6F6EF; color: var(--mv-success-ink); }
.mv-alert--warning { background: #FDF3E2; color: var(--mv-warning-ink); }
.mv-alert--danger  { background: var(--mv-danger-soft); color: var(--mv-danger-ink); }

/* ---------- Barra de filtros ---------- */
.mv-filters { display: flex; flex-direction: column; gap: 14px; padding: 16px; margin-bottom: var(--mv-gap); background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg); }
.mv-filters-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.mv-filters-row > .mv-field, .mv-filters-row > .mv-input { flex: 1 1 170px; }
.mv-filters-row > .mv-filters-search { flex: 2 1 280px; }
.mv-filters-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--mv-line-soft); font-size: var(--mv-fs-sm); color: var(--mv-muted); }
.mv-filters-active[hidden] { display: none; }

/* ---------- Tabla ---------- */
.mv-table-card { background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg); }
.mv-table-wrap { overflow-x: auto; border-radius: var(--mv-radius-lg); }
.mv-table { width: 100%; border-collapse: collapse; font-size: var(--mv-fs); color: var(--mv-ink); }
.mv-table th { padding: 14px 12px; text-align: left; font-size: var(--mv-fs-xs); font-weight: 600; color: var(--mv-muted); border-bottom: 1px solid var(--mv-line); white-space: nowrap; background: transparent; }
.mv-table td { padding: 14px 12px; border-bottom: 1px solid var(--mv-line-soft); vertical-align: middle; color: var(--mv-ink-2); }
.mv-table th:first-child, .mv-table td:first-child { padding-left: 20px; }
.mv-table th:last-child, .mv-table td:last-child { padding-right: 20px; }
.mv-table tbody tr:hover { background: #F8FAFD; }
.mv-table tbody tr:last-child td { border-bottom: 0; }
.mv-table .mv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-table .mv-actions { text-align: right; white-space: nowrap; }
.mv-table .mv-actions > * { vertical-align: middle; }
.mv-cell-main { display: flex; align-items: center; gap: 12px; }
.mv-cell-main strong, .mv-cell-main a, body.mv-theme .mv-cell-main a { font-weight: 600; color: var(--mv-ink); }
body.mv-theme .mv-cell-main a:hover { color: var(--mv-accent); }
.mv-cell-main small { display: block; font-size: var(--mv-fs-sm); color: var(--mv-muted); }
.mv-thumb { width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--mv-fill); color: var(--mv-ink-2); display: inline-flex; align-items: center; justify-content: center; }
.mv-table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--mv-line-soft); font-size: var(--mv-fs-sm); color: var(--mv-muted); }

/* Barra de unidades (disponible / apartado / vendido) */
.mv-unitbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--mv-line-soft); min-width: 140px; }
.mv-unitbar span { display: block; height: 100%; }
.mv-unitbar .is-disp { background: var(--mv-success); }
.mv-unitbar .is-apart { background: var(--mv-warning); }
.mv-unitbar .is-vend { background: var(--mv-accent); }
.mv-unitlegend { display: flex; gap: 12px; margin-top: 8px; font-size: var(--mv-fs-xs); color: var(--mv-muted); }
.mv-unitlegend strong { color: var(--mv-ink); font-weight: 600; }

/* Paginación */
.mv-pagination { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; }
.mv-pagination a, .mv-pagination span, body.mv-theme .mv-pagination a {
  min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--mv-border); border-radius: 9px; background: var(--mv-surface); font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-ink); text-decoration: none;
}
.mv-pagination .is-current, body.mv-theme .mv-pagination .is-current { background: var(--mv-primary); border-color: var(--mv-primary); color: #fff; }

/* Estado vacío */
.mv-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; text-align: center; }
.mv-empty strong { font-size: 15px; color: var(--mv-ink); }
.mv-empty span { font-size: var(--mv-fs); color: var(--mv-muted); max-width: 420px; }

/* ---------- Resultado (fila gris con texto calculado) ---------- */
.mv-result { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 8px 12px; border-radius: var(--mv-radius); background: var(--mv-fill); font-size: var(--mv-fs-sm); color: var(--mv-ink-2); }
.mv-result strong { color: var(--mv-ink); }

/* ---------- Panel de resumen oscuro ---------- */
.mv-summary { background: var(--mv-primary); color: #fff; border-radius: var(--mv-radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.mv-summary-label { font-size: var(--mv-fs-sm); color: #B7C0D3; }
.mv-summary-total { font-size: 30px; font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.mv-summary-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #2A3550; }
.mv-summary-rows { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; padding-top: 12px; border-top: 1px solid #2A3550; font-size: var(--mv-fs); }
.mv-summary-rows dt { color: #B7C0D3; font-weight: 400; }
.mv-summary-rows dd { margin: 0; font-weight: 600; text-align: right; }
.mv-summary .mv-btn { background: #fff; border-color: #fff; color: var(--mv-primary); }

/* ---------- Tarjetas de módulo (Inicio) ---------- */
.mv-modules { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.mv-module {
  display: flex; align-items: center; gap: 16px; padding: 20px;
  background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg);
  text-decoration: none; transition: border-color .15s, transform .15s;
}
body.mv-theme a.mv-module { color: var(--mv-ink); }
.mv-module:hover { border-color: #B9C6EE; transform: translateY(-1px); }
.mv-module-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mv-module-text strong { font-size: var(--mv-fs-lg); font-weight: 600; }
.mv-module-text span { font-size: var(--mv-fs-sm); color: var(--mv-muted); }
.mv-module > .mv-icon:last-child { color: var(--mv-subtle); }

/* ---------- Modal propio (para vistas nuevas; los modales Bootstrap se restilizan en mv-legacy.css) ---------- */
.mv-modal-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px; background: var(--mv-surface); border-bottom: 1px solid var(--mv-line); }
.mv-modal-head h2, .mv-modal-head h3, .mv-modal-head h5 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.mv-modal-body { padding: 20px 22px; background: var(--mv-surface-2); display: flex; flex-direction: column; gap: var(--mv-gap); }
.mv-modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 16px 22px; background: var(--mv-surface); border-top: 1px solid var(--mv-line); }

/* Utilidades mínimas */
.mv-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mv-between { justify-content: space-between; }
.mv-hidden { display: none !important; }

/* Bootstrap le pone margin-bottom a todos los <label>: los componentes que usan <label> como contenedor no lo llevan */
body.mv-theme .mv-input, body.mv-theme .mv-check, body.mv-theme .mv-radio, body.mv-theme .mv-switch,
body.mv-theme .mv-option, body.mv-theme .mv-segmented label, body.mv-theme .mv-field > label { margin-bottom: 0; }

/* ==========================================================================
   Vistas con secciones (configuradores, fichas con muchas partes)
   mv-tabs · mv-sectionhead · mv-loader
   ========================================================================== */

/* Pestañas en píldoras con ícono. Se acomodan en varias filas: nunca llevan scroll.
   Funcionan con Bootstrap (ul.nav > li > a.nav-link[data-toggle="tab"], .active)
   o solas (a.mv-tab.is-active). */
.mv-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 20px; padding: 0 0 16px; list-style: none;
  border: 0; border-bottom: 1px solid var(--mv-line);
}
.mv-tabs > li { margin: 0; }
.mv-tabs .nav-link, .mv-tab,
body.mv-theme .mv-tabs .nav-link {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--mv-line); border-radius: 999px;
  background: var(--mv-surface); color: var(--mv-ink-2);
  font-size: var(--mv-fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.mv-tabs .nav-link .mv-icon, .mv-tab .mv-icon { width: 16px; height: 16px; flex: none; color: var(--mv-subtle); transition: color .15s; }
.mv-tabs .nav-link:hover, .mv-tab:hover,
body.mv-theme .mv-tabs .nav-link:hover { background: var(--mv-fill); border-color: var(--mv-border); color: var(--mv-ink); }
.mv-tabs .nav-link:hover .mv-icon, .mv-tab:hover .mv-icon { color: var(--mv-ink-2); }
.mv-tabs .nav-link.active, .mv-tab.is-active, .mv-tab[aria-selected="true"],
body.mv-theme .mv-tabs .nav-link.active {
  background: var(--mv-primary); border-color: var(--mv-primary); color: #fff;
}
.mv-tabs .nav-link.active .mv-icon, .mv-tab.is-active .mv-icon { color: #fff; }
.mv-tabs .nav-link:focus-visible, .mv-tab:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--mv-accent-ring); }
@media (max-width: 575.98px) {
  .mv-tabs { gap: 6px; }
  .mv-tabs .nav-link, .mv-tab, body.mv-theme .mv-tabs .nav-link { padding: 0 12px; }
}

/* Encabezado de sección: título y descripción a la izquierda, acciones a la derecha en la misma línea.
   Se usa al inicio de cada pestaña o bloque grande dentro de una página (no reemplaza a mv-pagehead). */
.mv-sectionhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; margin: 0 0 16px; }
.mv-sectionhead-main { display: flex; align-items: center; gap: 12px; flex: 1 1 280px; min-width: 0; }
.mv-sectionhead h2, .mv-sectionhead-title { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; color: var(--mv-ink); }
.mv-sectionhead p { margin: 3px 0 0; font-size: var(--mv-fs); line-height: 1.45; color: var(--mv-muted); }
.mv-sectionhead-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; }
.mv-sectionhead--sub { margin-top: 28px; }
@media (max-width: 575.98px) {
  .mv-sectionhead-actions { width: 100%; justify-content: flex-start; margin-left: 0; }
}

/* Cargando. Se personaliza con estas variables (en :root, en el módulo o en el contenedor). */
:root {
  --mv-loader-color: var(--mv-violet);      /* barra y spinner */
  --mv-loader-track: var(--mv-line-soft);   /* fondo de la barra */
  --mv-loader-logo-h: 34px;                 /* alto del logo animado */
  --mv-loader-min-h: 320px;                 /* alto del recuadro grande */
}
.mv-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; color: var(--mv-muted); }
.mv-loader--logo { min-height: var(--mv-loader-min-h); padding: 48px 20px; background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg); }
.mv-loader--logo .mv-logo-swap { --mv-logo-h: var(--mv-loader-logo-h); }
.mv-loader--logo img { width: auto; max-width: none; }
.mv-loader-text { font-size: var(--mv-fs-sm); font-weight: 500; }
.mv-loader-bar { position: relative; display: block; width: 160px; height: 4px; overflow: hidden; border-radius: 999px; background: var(--mv-loader-track); }
.mv-loader-bar > span { position: absolute; top: 0; left: -40%; width: 40%; height: 100%; border-radius: inherit; background: var(--mv-loader-color); animation: mvCargaBarra 1.1s ease-in-out infinite; }
.mv-loader--mini { flex-direction: row; gap: 10px; padding: 36px 20px; font-size: var(--mv-fs-sm); }
.mv-spinner { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2.5px solid var(--mv-loader-track); border-top-color: var(--mv-loader-color); animation: mvCargaGiro .8s linear infinite; }
@keyframes mvCargaBarra { from { left: -40%; } to { left: 100%; } }
@keyframes mvCargaGiro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .mv-loader-bar > span, .mv-spinner { animation-duration: 2.4s; }
}

/* Menú ⋮ dentro de una tabla con desplazamiento: oculto no estira la tabla
   (si no, aparece una barra vertical y se recorta la columna Acciones). Al abrirse, manivela-ui.js lo coloca. */
.mv-table-wrap .mv-dropdown-menu { position: fixed; }

/* ==== Agregado en la migración (copia de crm/tema_pendiente/css/mv-components.agregar.css) ==== */
/* ==========================================================================
   AGREGAR AL FINAL de Themes/Manivela/css/mv-components.css (opcional)
   Ajustes que salieron al migrar ad/ y sirven para cualquier módulo.
   ========================================================================== */

/* Foto dentro de la miniatura de una celda (Usuarios: foto de perfil 40×40 sin deformarse) */
.mv-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }

/* Validaciones viejas que agregan .campo-requerido al <input>: el borde rojo
   se pinta en la caja mv-input, no en el input interno (Escrituración, Categoría
   de egresos, Socios, Esquema de comisiones). */
.mv-input:has(> .campo-requerido) { border-color: var(--mv-danger); }
.mv-input > .campo-requerido { border: 0 !important; box-shadow: none !important; }

/* ==========================================================================
   Maestro / detalle (patrón H) · lista a la izquierda, detalle a la derecha
   Lo usan Permisos del perfil y Permisos por estatus (ad/Seguridad/Perfil/PerfilxPermiso).
   El comportamiento (elegir, buscar, contadores) está en js/mv-maestro.js.
   ========================================================================== */
.mv-master { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 20px; align-items: start; }
.mv-master-aside, .mv-master-main { background: var(--mv-surface); border: 1px solid var(--mv-line); border-radius: var(--mv-radius-lg); min-width: 0; }
.mv-master-aside { position: sticky; top: calc(var(--mv-topbar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--mv-topbar-h) - 40px); }
.mv-master-asidehead { padding: 14px 14px 10px; }
.mv-master-eyebrow { display: block; font-size: var(--mv-fs-xs); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--mv-muted); }
.mv-master-asidehead .mv-master-eyebrow { padding: 2px 2px 0; }
.mv-master-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.mv-master-item { display: block; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid transparent; border-radius: var(--mv-radius-md); background: transparent; color: var(--mv-ink); font: inherit; cursor: pointer; }
.mv-master-item:hover { background: var(--mv-fill); }
.mv-master-item.is-active { background: var(--mv-accent-soft); border-color: var(--mv-accent); }
.mv-master-item[hidden] { display: none; }
.mv-master-itemhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mv-master-itemhead strong { font-size: var(--mv-fs); font-weight: 600; }
.mv-master-count { font-size: var(--mv-fs-xs); color: var(--mv-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-progress { display: block; height: 4px; margin-top: 8px; border-radius: 2px; background: var(--mv-line-soft); overflow: hidden; }
.mv-progress > span { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--mv-accent); transition: width .2s var(--mv-ease); }
.mv-master-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 18px 24px; border-bottom: 1px solid var(--mv-line-soft); }
.mv-master-head h2 { margin: 2px 0 0; font-size: var(--mv-fs-h2); font-weight: 700; color: var(--mv-ink); }
.mv-master-headactions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.mv-master-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.mv-master-panel[hidden] { display: none; }
.mv-master-empty { margin: 0; color: var(--mv-muted); }

/* Grupo de opciones con título (casilla del grupo + título + contador) */
.mv-optgroup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mv-optgroup-head strong { font-size: 15px; font-weight: 600; color: var(--mv-ink); }
.mv-optgroup-head .mv-check { gap: 10px; }
.mv-optgroup-head .mv-check strong { font-weight: 600; }
.mv-optgroup-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Píldora que es un checkbox real (oculto). Activa = acento suave. */
.mv-pillcheck { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--mv-border); border-radius: 999px; background: var(--mv-surface); color: var(--mv-ink-2); font-size: var(--mv-fs-sm); font-weight: 500; cursor: pointer; user-select: none; margin: 0; }
.mv-pillcheck input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.mv-pillcheck .mv-icon { display: none; width: 14px; height: 14px; }
.mv-pillcheck:hover { border-color: var(--mv-accent); }
.mv-pillcheck:has(input:checked) { background: var(--mv-accent-soft); border-color: var(--mv-accent); color: var(--mv-ink); }
.mv-pillcheck:has(input:checked) .mv-icon { display: inline-block; }
.mv-pillcheck:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--mv-accent-ring); }

/* Tarjeta con texto y switch (opciones en dos columnas) */
.mv-switchgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.mv-switchcard { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 6px 14px; border: 1px solid var(--mv-line); border-radius: var(--mv-radius-md); background: var(--mv-surface); color: var(--mv-ink-2); font-size: var(--mv-fs-sm); font-weight: 500; cursor: pointer; margin: 0; }
.mv-switchcard:has(input:checked) { background: var(--mv-accent-soft); border-color: var(--mv-accent); color: var(--mv-ink); }
.mv-switchcard input { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 36px; height: 22px; margin: 0; border-radius: 999px; background: var(--mv-subtle); cursor: pointer; transition: background .15s; }
.mv-switchcard input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--mv-surface); transition: transform .15s var(--mv-ease); }
.mv-switchcard input:checked { background: var(--mv-accent); }
.mv-switchcard input:checked::after { transform: translateX(14px); }
.mv-switchcard input:focus-visible { box-shadow: 0 0 0 3px var(--mv-accent-ring); }

/* Casilla de grupo de tres estados (botón, no checkbox): aria-checked="true|false|mixed" */
.mv-boxbtn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 1.5px solid var(--mv-subtle); border-radius: 6px; background: var(--mv-surface); color: var(--mv-surface); cursor: pointer; }
.mv-boxbtn .mv-icon { width: 12px; height: 12px; display: none; }
.mv-boxbtn[aria-checked="true"], .mv-boxbtn[aria-checked="mixed"] { background: var(--mv-accent); border-color: var(--mv-accent); }
.mv-boxbtn[aria-checked="true"] .mv-icon--on, .mv-boxbtn[aria-checked="mixed"] .mv-icon--mixed { display: inline-block; }

/* Contador de cambios dentro de un botón */
.mv-btn-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--mv-surface); color: var(--mv-primary); font-size: var(--mv-fs-xs); font-weight: 700; }
.mv-btn-count[hidden] { display: none; }

/* Aviso "Guardado" que aparece y se desvanece */
.mv-savedflag { display: inline-flex; align-items: center; gap: 6px; font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-success); }

@media (max-width: 900px) {
  .mv-master { grid-template-columns: minmax(0, 1fr); }
  .mv-master-aside { position: static; max-height: 320px; }
  .mv-switchgrid { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Detalle de venta (carpeta dt/) · prefijo .mv-dt-
   dt/ se abre desde Ventas, Dirección de ventas, Jurídico y Tesorería (General() cambia
   según ?ubi=vm|dv|jd|ts), así que sus piezas van aquí y no en un css/modulos/<id>.css.
   ========================================================================== */
.mv-table-wrap .mv-dropdown-menu { position: fixed; }
.mv-dt-listado { overflow: hidden; }
.mv-dt-cardfilters { margin: 0; border: 0; border-bottom: 1px solid var(--mv-line-soft); border-radius: 0; }
.mv-dt-listado > .mv-dt-cardfilters { padding: 14px 20px; }
.mv-dt-cardfilters .mv-filters-row { align-items: flex-end; }
.mv-dt-lista .mv-table-foot { border-top: 1px solid var(--mv-line-soft); }
.mv-dt-cardhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; padding: 16px 20px; border-bottom: 1px solid var(--mv-line-soft); }
.mv-dt-cardhead h3 { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--mv-ink); }
.mv-dt-cardhead .mv-muted { font-size: var(--mv-fs-sm); }
.mv-dt-pagination .cursor-cancel { opacity: .45; cursor: not-allowed; }
.mv-dt-mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: nowrap; }
.mv-dt-buscador { display: flex; gap: 6px; align-items: stretch; }
.mv-dt-buscador > .mv-input { flex: 1 1 auto; min-width: 0; }
.mv-dt-formacciones { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 4px 0 8px; }
.mv-modal-head .mv-dt-close.close { float: none; opacity: 1; padding: 0; text-shadow: none; font-size: inherit; line-height: 1; color: var(--mv-ink); background: var(--mv-surface); border: 1px solid var(--mv-border); }
.mv-modal-head .mv-dt-close.close:hover { opacity: 1; background: var(--mv-fill); }
/* Pares etiqueta/valor de la ficha de la venta (dl) */
.mv-dt-datos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 20px; margin: 0; }
.mv-dt-datos dt { margin: 0; font-size: var(--mv-fs-xs); font-weight: 600; letter-spacing: .02em; color: var(--mv-muted); }
.mv-dt-datos dd { margin: 2px 0 0; color: var(--mv-ink); font-weight: 500; overflow-wrap: anywhere; }
/* Bitácora y comentarios de la venta (dt/Fr_comentarios.php, dt/subfr_comentarios.php) */
.mv-dt-bitacora { display: flex; flex-direction: column; }
.mv-dt-coment { display: flex; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--mv-line-soft); color: var(--mv-ink); }
.mv-dt-coment:last-child { border-bottom: 0; }
.mv-dt-coment > img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.mv-dt-coment-body { flex: 1 1 auto; min-width: 0; }
.mv-dt-coment-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 600; color: var(--mv-ink); }
.mv-dt-coment p { margin: 4px 0 0; font-size: var(--mv-fs-sm); color: var(--mv-ink-2); overflow-wrap: anywhere; }
.mv-dt-comentar { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--mv-line-soft); }
/* Participaciones del cliente y copropietarios (dt/Fr_cuenta_banco.php) */
.mv-dt-participante { padding: 14px 0; border-top: 1px solid var(--mv-line-soft); }
.mv-dt-participante:first-of-type { border-top: 0; }
.mv-dt-participante-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--mv-ink); }
.mv-dt-participante-head .mv-btn { margin-left: auto; }
/* Subtítulo entre bloques de datos (dt/Fr_contrato.php) */
.mv-dt-datostitulo { margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--mv-line-soft); font-size: var(--mv-fs-sm); font-weight: 600; color: var(--mv-ink); }
/* Editor de plantillas de contrato en dt/Editor_contrato_word.php (gemelo de .mv-jd-editor) */
.mv-dt-editor { display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); gap: var(--mv-gap); align-items: start; }
@media (max-width: 991.98px) { .mv-dt-editor { grid-template-columns: minmax(0, 1fr); } }
.mv-dt-editor > .mv-card + .mv-card { margin-top: 0; }
.mv-dt-editor-main { min-width: 0; }
.mv-dt-vars { padding: 0; overflow: hidden; }
.mv-dt-vars > .mv-card-head { padding: 16px 16px 0; margin-bottom: 8px; }
.mv-dt-vargroup + .mv-dt-vargroup { border-top: 1px solid var(--mv-line-soft); }
.mv-dt-vartoggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; padding: 10px 16px; font-weight: 600; color: var(--mv-ink); text-decoration: none; }
body.mv-theme .mv-dt-vartoggle:hover, body.mv-theme .mv-dt-vartoggle:focus { color: var(--mv-accent); text-decoration: none; }
.mv-dt-varbody { max-height: 420px; overflow-y: auto; padding: 0 16px 14px; }
.mv-dt-varlist { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.mv-dt-varlist .mv-chip { height: auto; min-height: 32px; padding: 5px 12px; white-space: normal; text-align: left; cursor: grab; }
.mv-dt-varlist .mv-chip strong { font-weight: 500; }
.mv-dt-varsub { display: block; margin: 12px 0 6px; }
/* Pestaña Crédito (dt/Fr_credito.php): datos + resumen arriba, apartados + amortización abajo */
.mv-dt-credito-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: var(--mv-gap); align-items: start; }
.mv-dt-credito-tablas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--mv-gap); align-items: start; }
.mv-dt-credito-lado { gap: var(--mv-gap); }
.mv-dt-credito-tablas > .mv-table-card + .mv-table-card, .mv-dt-credito-top .mv-card + .mv-card { margin-top: 0; }
@media (max-width: 1199.98px) { .mv-dt-credito-top, .mv-dt-credito-tablas { grid-template-columns: minmax(0, 1fr); } }
.mv-dt-datos--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 575.98px) { .mv-dt-datos--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mv-dt-unidad { display: flex; align-items: center; gap: 6px; }
.mv-dt-resumen { display: flex; flex-direction: column; gap: 6px; }
.mv-dt-resumen-label { font-size: var(--mv-fs-xs); font-weight: 600; letter-spacing: .02em; color: var(--mv-muted); }
.mv-dt-resumen-total { font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--mv-ink); }
.mv-dt-resumen-barra { display: flex; height: 6px; margin: 4px 0; border-radius: 3px; overflow: hidden; background: var(--mv-line-soft); }
.mv-dt-resumen-barra > span { display: block; height: 100%; background: var(--mv-accent); }
.mv-dt-resumen-fila { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--mv-line-soft); font-size: var(--mv-fs-sm); color: var(--mv-ink-2); }
.mv-dt-resumen-fila > span:last-child { font-weight: 600; color: var(--mv-ink); }
.mv-dt-comentario { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--mv-line-soft); }
.mv-dt-comentarios .mv-card-head + .mv-dt-comentario { border-top: 0; }
.mv-dt-comentario-texto { min-width: 0; font-size: var(--mv-fs-sm); color: var(--mv-ink-2); overflow-wrap: anywhere; }
.mv-dt-comentario-texto strong { display: block; font-weight: 600; color: var(--mv-ink); }
.mv-dt-concepto strong { font-weight: 600; color: var(--mv-ink); }
.mv-dt-concepto small, .mv-dt-tabla-compacta td small { display: block; margin-top: 2px; font-size: var(--mv-fs-xs); color: var(--mv-muted); }
.mv-dt-tabla-compacta th, .mv-dt-tabla-compacta td { padding-top: 10px; padding-bottom: 10px; }
.mv-dt-tabla-compacta .mv-actions { white-space: nowrap; }
.mv-dt-scroll { max-height: 520px; overflow-y: auto; }
.mv-dt-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--mv-surface); }
