/* WP Invoice Builder — Rent Receipt Generator */

.wib-rr-wrap {
    --wib-rr-accent: #0044BB;
    --wib-rr-text: #1d2327;
    --wib-rr-border: #e5e5e5;
    --wib-rr-bg: #f7f8fa;

    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 24px;
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--wib-rr-text);
    box-sizing: border-box;
}

/* `[hidden] { display: none }` de la hoja del navegador pierde contra cualquier
   regla de autor con `display`, así que un `.hidden = true` desde JS puede no
   ocultar nada. Este candado cubre todos los toggles de golpe. */
.wib-rr-wrap [hidden] {
    display: none !important;
}

/* El recibo también se rasteriza fuera del wrap (pestaña del PDF): mismo
   candado para el saldo, las notas y la firma. */
.wib-rr-doc [hidden] {
    display: none !important;
}

/* Sin flechitas en los campos numéricos: en importes y cantidades no aportan
   nada, roban ~20px de ancho y disparan cambios accidentales con la rueda del
   ratón. Se aplica a todo el generador en vez de clase por clase, así los
   campos que se añadan mañana también salen limpios. */
.wib-rr-wrap input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.wib-rr-wrap input[type="number"]::-webkit-outer-spin-button,
.wib-rr-wrap input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.wib-rr-wrap * {
    box-sizing: border-box;
}

.wib-rr-editor-panel {
    min-width: 0;
    background: #fff;
    border: 1px solid var(--wib-rr-border);
    border-radius: 12px;
    padding: 28px;
}

.wib-rr-header {
    margin-bottom: 24px;
}

/* Los títulos del generador son <p> (auditoría SEO: sin headings dentro del
   widget). Se fija todo lo tipográfico para que ni los defaults del navegador
   ni el `p { … }` del tema cambien nada respecto a los antiguos h2/h3. */
.wib-rr-title {
    margin: 0 0 6px !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: 22px !important;
    font-weight: 700 !important;
    line-height: normal !important;
    letter-spacing: normal !important;
    color: var(--wib-rr-text) !important;
}

.wib-rr-sub {
    margin: 0;
    color: #555;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

.wib-rr-section {
    padding: 18px 0;
    border-top: 1px solid var(--wib-rr-border);
}

.wib-rr-section:first-of-type {
    border-top: none;
}

.wib-rr-section-title {
    margin: 0 0 14px !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    line-height: normal !important;
    letter-spacing: normal !important;
    color: var(--wib-rr-text) !important;
}

.wib-rr-req {
    color: #d63638;
}

.wib-rr-field {
    margin-bottom: 14px;
    flex: 1;
    min-width: 0;
}

.wib-rr-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 5px;
}

.wib-rr-field input,
.wib-rr-field select,
.wib-rr-field textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--wib-rr-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--wib-rr-text);
    font-family: inherit;
}

.wib-rr-field input:focus,
.wib-rr-field select:focus,
.wib-rr-field textarea:focus {
    outline: none;
    border-color: var(--wib-rr-accent, #0044BB);
    box-shadow: 0 0 0 3px var(--wib-rr-accent-line, #dfe5f2);
}

.wib-rr-row {
    display: flex;
    gap: 14px;
}

.wib-rr-tabs {
    display: inline-flex;
    border: 1px solid var(--wib-rr-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 14px;
}

.wib-rr-tab {
    padding: 8px 18px !important;
    background: #fff;
    border: none;
    border-right: 1px solid var(--wib-rr-border) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer;
    color: #666 !important;
}

.wib-rr-tab:last-child {
    border-right: none;
}

.wib-rr-tab--active {
    background: var(--wib-rr-accent, #0044BB);
    color: #fff !important;
}

.wib-rr-sig-mode {
    margin-bottom: 12px;
}

.wib-rr-sig-canvas {
    width: 100%;
    height: 140px;
    border: 1px dashed var(--wib-rr-border);
    border-radius: 8px;
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}

.wib-rr-link-btn {
    margin-top: 8px;
    background: none;
    border: none;
    color: var(--wib-rr-accent, #0044BB) !important;
    font-size: 13px !important;
    cursor: pointer;
    padding: 0 !important;
}

.wib-rr-sig-typed-input {
    width: 100% !important;
    padding: 14px 12px;
    border: 1px dashed var(--wib-rr-border) !important;
    border-radius: 8px !important;
    font-size: 28px !important;
    font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive !important;
    color: #1a1a4d !important;
}

.wib-rr-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--wib-rr-border);
}

.wib-rr-btn {
    padding: 11px 22px !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
}

.wib-rr-btn--ghost {
    background: #fff;
    border-color: var(--wib-rr-border);
    color: #444 !important;
}

.wib-rr-btn--primary {
    background: var(--wib-rr-accent, #0044BB);
    color: #fff;
}

/* Botón con icono + texto (el de abrir el popup). */
.wib-rr-btn--icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.wib-rr-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.wib-rr-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 16px 0 0;
    padding: 12px 14px;
    background: var(--wib-rr-bg);
    border: 1px solid var(--wib-rr-border);
    border-radius: 8px;
    font-size: 12px !important;
    line-height: 1.55 !important;
    color: #6b7280;
}

.wib-rr-disclaimer-icon {
    flex-shrink: 0;
    margin-top: 1px;
    color: #9aa1ac;
}

/* ── Preview panel ────────────────────────────────────────────────── */

.wib-rr-preview-panel {
    min-width: 0;
    position: sticky;
    top: 24px;
    align-self: start;
    background: #fff;
    border: 1px solid var(--wib-rr-border);
    border-radius: 12px;
    padding: 18px;
}

.wib-rr-preview-title {
    margin: 0 0 12px !important;
    padding: 0 !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    line-height: normal !important;
    letter-spacing: normal !important;
    color: var(--wib-rr-text) !important;
}

.wib-rr-preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.wib-rr-preview-actions .wib-rr-btn {
    flex: 1;
    padding: 10px 14px !important;
    font-size: 13px !important;
}

.wib-rr-missing {
    margin: 0 0 14px;
    font-size: 12px !important;
    line-height: 1.45 !important;
    color: #b8590a;
}

.wib-rr-scaler {
    transform-origin: top left;
    /* El JS le fija width/height ya escalados; así esto lo centra de verdad. */
    margin-inline: auto;
}

.wib-rr-preview-container {
    border-radius: 8px;
    overflow: hidden auto;
    background: var(--wib-rr-bg);
    max-height: calc(100vh - 220px);
}
/* ── The receipt document ─────────────────────────────────────────────
 *
 * Dirección: registro contable grabado / papel de seguridad. Un recibo de
 * alquiler es un comprobante cuasi-legal, así que se aleja del look "app web"
 * y toma prestado el lenguaje del cheque bancario y el libro de contabilidad:
 * serif con autoridad para los títulos, monoespaciada para las cifras
 * (alineación tabular real), versalitas espaciadas para las etiquetas y un
 * sello de goma como remate.
 *
 * Se usan STACKS del sistema a propósito, no webfonts: el PDF se rasteriza en
 * una pestaña nueva y una fuente que aún no ha cargado saldría con la
 * tipografía de reserva en el documento final.
 *
 * html2canvas 1.4.1: sin color-mix()/oklch (los tintes vienen precalculados
 * como rgba desde PHP), sin backdrop-filter, sin conic-gradient.
 */

/* Ancho FIJO idéntico al de captura del PDF (WIB_RR_DOC_WIDTH en el JS): el
   preview se encaja escalándolo con transform, nunca reflowando. Así lo que se
   ve en pantalla es exactamente lo que sale en el PDF. */
.wib-rr-doc {
    width: 700px;

    /* Autosuficiente: el documento se captura solo, fuera de .wib-rr-wrap, así
       que declara aquí su familia base y su box-sizing en vez de heredarlos. */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --wib-rr-ink: #16181d;
    --wib-rr-muted: #6c7280;
    --wib-rr-rule: #e3e5ea;
    --wib-rr-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --wib-rr-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    background: #fff;
    color: var(--wib-rr-ink);
    font-size: 14px;
    line-height: 1.5;
}

.wib-rr-doc,
.wib-rr-doc * {
    box-sizing: border-box;
}

/* ── Header band ── */

.wib-rr-doc-band {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 26px 32px 22px;
    background: linear-gradient(135deg, var(--wib-rr-accent, #0044BB) 0%, var(--wib-rr-accent-dark, #003288) 100%);
    color: #fff;
}

/* Trama diagonal del papel de seguridad. */
.wib-rr-doc-band-hatch {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.07) 0px,
        rgba(255, 255, 255, 0.07) 1px,
        rgba(255, 255, 255, 0) 1px,
        rgba(255, 255, 255, 0) 7px
    );
}

.wib-rr-doc-band-main,
.wib-rr-doc-band-meta {
    position: relative;
}

.wib-rr-doc-eyebrow {
    font-family: var(--wib-rr-mono);
    font-size: 9px;
    letter-spacing: 2.4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 7px;
}

.wib-rr-doc-title {
    margin: 0 !important;
    padding: 0 !important;
    font-family: var(--wib-rr-serif) !important;
    font-size: 31px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    letter-spacing: -0.4px !important;
    color: #fff !important;
}

.wib-rr-doc-band-meta {
    text-align: right;
    flex-shrink: 0;
}

.wib-rr-doc-band-no {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 6px;
}

.wib-rr-doc-band-no-label {
    font-size: 10px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

.wib-rr-doc-band-no-val {
    font-family: var(--wib-rr-mono);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.wib-rr-doc-band-date {
    margin-top: 4px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.82);
}

/* Doble filete bajo la banda — cita del certificado grabado. */
.wib-rr-doc-body {
    border-top: 3px solid var(--wib-rr-accent, #0044BB);
    box-shadow: inset 0 4px 0 #fff, inset 0 5px 0 var(--wib-rr-accent-line, #dfe5f2);
    padding: 26px 32px 30px;
}

/* ── Shared label ── */

.wib-rr-doc-label {
    font-family: var(--wib-rr-mono);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 1.7px;
    text-transform: uppercase;
    color: var(--wib-rr-muted);
    margin-bottom: 6px;
}

/* ── Parties ── */

.wib-rr-doc-parties {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
}

.wib-rr-doc-party {
    flex: 1;
    min-width: 0;
    padding-right: 22px;
}

/* Filete divisorio entre las dos partes (hairline de libro contable). */
.wib-rr-doc-party + .wib-rr-doc-party {
    padding-right: 0;
    padding-left: 22px;
    border-left: 1px solid var(--wib-rr-rule);
}

.wib-rr-doc-party-text {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.45;
    color: var(--wib-rr-ink);
}

/* ── Hero: amount + stamp ── */

.wib-rr-doc-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
}

.wib-rr-doc-amount-box {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
    background: var(--wib-rr-accent-soft, #f4f6fb);
    border-left: 3px solid var(--wib-rr-accent, #0044BB);
    border-radius: 0 8px 8px 0;
}

.wib-rr-doc-amount-label {
    display: block;
    font-family: var(--wib-rr-mono);
    font-size: 9px;
    letter-spacing: 1.7px;
    text-transform: uppercase;
    color: var(--wib-rr-muted);
    margin-bottom: 5px;
}

.wib-rr-doc-amount-val {
    display: block;
    font-family: var(--wib-rr-mono);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.5px;
    color: var(--wib-rr-accent, #0044BB);
}

.wib-rr-doc-balance {
    display: block;
    margin-top: 7px;
    font-size: 11.5px;
    color: #9a5111;
}

.wib-rr-doc-balance b {
    font-family: var(--wib-rr-mono);
    font-weight: 700;
}

/* Sello de goma. El doble aro se hace con box-shadow (border-style:double no
   lo rasteriza html2canvas de forma fiable). */
.wib-rr-doc-stamp {
    flex-shrink: 0;
    width: 112px;
    padding: 9px 6px 8px;
    text-align: center;
    border: 2px solid var(--wib-rr-accent, #0044BB);
    border-radius: 7px;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--wib-rr-accent-line, #dfe5f2);
    transform: rotate(-7deg);
    opacity: 0.9;
}

.wib-rr-doc-stamp-word {
    display: block;
    font-family: var(--wib-rr-serif);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--wib-rr-accent, #0044BB);
}

.wib-rr-doc-stamp-sub {
    display: block;
    margin-top: 3px;
    font-family: var(--wib-rr-mono);
    font-size: 8px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--wib-rr-accent, #0044BB);
    opacity: 0.75;
}

/* Estado parcial: el sello cambia de mensaje y de color, no solo de texto. */
.wib-rr-doc-stamp--partial {
    border-color: #c2740f;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(194, 116, 15, 0.24);
}

.wib-rr-doc-stamp--partial .wib-rr-doc-stamp-word,
.wib-rr-doc-stamp--partial .wib-rr-doc-stamp-sub {
    color: #a8620b;
}

/* ── Facts (ledger rows) ── */

.wib-rr-doc-facts {
    margin: 0 0 22px;
    border-top: 1px solid var(--wib-rr-rule);
}

.wib-rr-doc-fact {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 0;
    border-bottom: 1px solid var(--wib-rr-rule);
}

.wib-rr-doc-fact .wib-rr-doc-label {
    margin-bottom: 0;
    flex-shrink: 0;
}

.wib-rr-doc-fact-val {
    margin: 0;
    text-align: right;
    font-size: 14px;
    font-weight: 500;
    color: var(--wib-rr-ink);
}

/* ── Statement ── */

.wib-rr-doc-statement {
    margin: 0 0 20px !important;
    padding: 15px 18px;
    background: #fafbfc;
    border: 1px solid var(--wib-rr-rule);
    border-radius: 8px;
    font-family: var(--wib-rr-serif);
    font-size: 14.5px !important;
    line-height: 1.62 !important;
    color: #2c3138;
}

.wib-rr-doc-notes {
    margin-bottom: 20px;
}

/* ── Perforated divider ── */

.wib-rr-doc-perf {
    height: 0;
    margin: 26px 0 22px;
    border-top: 2px dashed var(--wib-rr-rule);
}

/* ── Signature ── */

.wib-rr-doc-signature {
    max-width: 280px;
    margin-left: auto;
    text-align: center;
}

.wib-rr-doc-sig-box {
    height: 62px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.wib-rr-doc-sig-img {
    max-height: 58px;
    max-width: 100%;
    object-fit: contain;
}

.wib-rr-doc-sig-typed {
    font-size: 30px;
    line-height: 1.1;
    font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive;
    color: #1a1a4d;
}

.wib-rr-doc-sig-line {
    border-top: 1px solid var(--wib-rr-ink);
    margin: 5px 0 7px;
}

.wib-rr-doc-sig-caption {
    line-height: 1.35;
}

.wib-rr-doc-sig-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--wib-rr-ink);
}

.wib-rr-doc-sig-role {
    display: block;
    margin-top: 2px;
    font-family: var(--wib-rr-mono);
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--wib-rr-muted);
}

/* ── Preview popup (<dialog>) ─────────────────────────────────────────
 * Esc, bloqueo de scroll del fondo y foco atrapado los da el elemento
 * nativo; aquí solo va el aspecto y el encaje responsive.
 */

.wib-rr-modal {
    /* Centrado explícito en lugar de heredar el del navegador.
     *
     * Un <dialog> modal se centra porque la hoja del navegador le da
     * `inset: 0` + `margin: auto`. Basta un reset del tema tipo
     * `* { margin: 0 }` — habitual en WordPress — para anular ese margin auto:
     * con inset:0 y margin:0 el popup se clava contra la esquina superior
     * izquierda de la pantalla. Reponerlo aquí gana por especificidad (una
     * clase > `*`) y deja el centrado fuera del alcance del tema.
     */
    position: fixed;
    inset: 0;
    margin: auto;

    width: min(94vw, 860px);
    max-width: 94vw;
    max-height: 92dvh;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    overflow: hidden;
}

.wib-rr-modal::backdrop {
    background: rgba(14, 16, 22, 0.62);
}

.wib-rr-modal:not([open]) {
    display: none;
}

.wib-rr-modal-inner {
    display: flex;
    flex-direction: column;
    max-height: 92dvh;
}

.wib-rr-modal-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px 12px 18px;
    border-bottom: 1px solid var(--wib-rr-border);
    background: #fff;
}

.wib-rr-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--wib-rr-text);
}

/* 40px de área táctil: el aspa debe cerrarse cómodamente con el pulgar. */
.wib-rr-modal-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 !important;
    border: 1px solid var(--wib-rr-border);
    border-radius: 9px;
    background: #fff;
    color: #444 !important;
    cursor: pointer;
}

.wib-rr-modal-close:hover {
    background: var(--wib-rr-bg);
    color: #000 !important;
}

.wib-rr-modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px;
    background: #eef0f4;
}

/* Dentro del popup el recibo se ve como una hoja sobre la mesa. */
.wib-rr-modal-body .wib-rr-doc {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13);
    border-radius: 6px;
    overflow: hidden;
}

/* ── Sin JS (progressive enhancement) ───────────────────────────────
 * El servidor ya pinta el estado inicial completo; el JS quita .wib-no-js
 * al arrancar. Estas reglas solo cubren lo que normalmente hace el JS.
 */

/* Con scripting desactivado el <canvas> no se pinta como elemento reemplazado
   (muestra su contenido fallback). inline-block reproduce la caja punteada
   de 140px — y su línea base — que se ve con JS. */
.wib-no-js .wib-rr-sig-canvas {
    display: inline-block;
    vertical-align: baseline;
}

/* scalePreview() encaja el recibo (700px fijos) con transform. Sin JS se
   encaja con `zoom` escalonado según el ancho del contenedor; cada tramo usa
   el ancho MÍNIMO del tramo, así nunca desborda. `zoom`, a diferencia de
   transform, sí reduce el tamaño en el flujo. */
.wib-no-js .wib-rr-preview-container {
    container: wib-rr-preview / inline-size;
}

.wib-no-js .wib-rr-scaler {
    width: 700px;
    zoom: 1;
}

@container wib-rr-preview (max-width: 699.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9857; }
}
@container wib-rr-preview (max-width: 689.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9714; }
}
@container wib-rr-preview (max-width: 679.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9571; }
}
@container wib-rr-preview (max-width: 669.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9429; }
}
@container wib-rr-preview (max-width: 659.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9286; }
}
@container wib-rr-preview (max-width: 649.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9143; }
}
@container wib-rr-preview (max-width: 639.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.9000; }
}
@container wib-rr-preview (max-width: 629.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8857; }
}
@container wib-rr-preview (max-width: 619.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8714; }
}
@container wib-rr-preview (max-width: 609.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8571; }
}
@container wib-rr-preview (max-width: 599.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8429; }
}
@container wib-rr-preview (max-width: 589.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8286; }
}
@container wib-rr-preview (max-width: 579.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8143; }
}
@container wib-rr-preview (max-width: 569.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.8000; }
}
@container wib-rr-preview (max-width: 559.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7857; }
}
@container wib-rr-preview (max-width: 549.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7714; }
}
@container wib-rr-preview (max-width: 539.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7571; }
}
@container wib-rr-preview (max-width: 529.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7429; }
}
@container wib-rr-preview (max-width: 519.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7286; }
}
@container wib-rr-preview (max-width: 509.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7143; }
}
@container wib-rr-preview (max-width: 499.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.7000; }
}
@container wib-rr-preview (max-width: 489.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6857; }
}
@container wib-rr-preview (max-width: 479.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6714; }
}
@container wib-rr-preview (max-width: 469.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6571; }
}
@container wib-rr-preview (max-width: 459.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6429; }
}
@container wib-rr-preview (max-width: 449.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6286; }
}
@container wib-rr-preview (max-width: 439.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6143; }
}
@container wib-rr-preview (max-width: 429.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.6000; }
}
@container wib-rr-preview (max-width: 419.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5857; }
}
@container wib-rr-preview (max-width: 409.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5714; }
}
@container wib-rr-preview (max-width: 399.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5571; }
}
@container wib-rr-preview (max-width: 389.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5429; }
}
@container wib-rr-preview (max-width: 379.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5286; }
}
@container wib-rr-preview (max-width: 369.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5143; }
}
@container wib-rr-preview (max-width: 359.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.5000; }
}
@container wib-rr-preview (max-width: 349.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4857; }
}
@container wib-rr-preview (max-width: 339.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4714; }
}
@container wib-rr-preview (max-width: 329.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4571; }
}
@container wib-rr-preview (max-width: 319.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4429; }
}
@container wib-rr-preview (max-width: 309.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4286; }
}
@container wib-rr-preview (max-width: 299.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4143; }
}
@container wib-rr-preview (max-width: 289.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.4000; }
}
@container wib-rr-preview (max-width: 279.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.3857; }
}
@container wib-rr-preview (max-width: 269.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.3714; }
}
@container wib-rr-preview (max-width: 259.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.3571; }
}
@container wib-rr-preview (max-width: 249.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.3429; }
}
@container wib-rr-preview (max-width: 239.99px) {
    .wib-no-js .wib-rr-scaler { zoom: 0.3; }
}

@media (max-width: 900px) {
    /* minmax(0, 1fr), NO 1fr: con `1fr` el suelo de la pista es el min-content
       del contenido y el recibo (700px fijos) estiraba la columna hasta
       desbordar el viewport en móvil. */
    .wib-rr-wrap {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }
    .wib-rr-editor-panel {
        padding: 22px;
    }
    .wib-rr-preview-panel {
        position: static;
    }
    .wib-rr-row {
        flex-direction: column;
        gap: 0;
    }
    .wib-rr-preview-container {
        max-height: none;
    }

    /* Evita el zoom automático de Safari al enfocar (dispara con
       font-size < 16px), sin tocar el tamaño de letra del documento. */
    .wib-rr-field input,
    .wib-rr-field select,
    .wib-rr-field textarea {
        font-size: 16px;
    }

    /* Los dos botones ("Generate next month" / "Clear form") a ancho
       completo repartido; con textarea de dos líneas si no cabe en una,
       nunca desbordando el ancho del panel. */
    .wib-rr-actions {
        justify-content: stretch;
    }
    .wib-rr-actions .wib-rr-btn {
        flex: 1 1 0;
        min-width: 0;
        white-space: normal;
        text-align: center;
    }

    /* El popup ocupa la pantalla completa en móvil — a media pantalla un
       documento A4 queda ilegible. */
    .wib-rr-modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
    }
    .wib-rr-modal-inner {
        max-height: 100dvh;
        height: 100dvh;
    }
    /* Respeta la barra de gestos / notch de iOS. */
    .wib-rr-modal-body {
        padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 600px) {
    .wib-rr-editor-panel {
        padding: 18px 16px;
    }
    .wib-rr-preview-panel {
        padding: 14px;
    }
    .wib-rr-title {
        font-size: 20px !important;
    }

    /* Pestañas de firma a ancho completo — con el label centrado, en vez de
       inline-flex quedaban descentradas y con poco área táctil. */
    .wib-rr-tabs {
        display: flex;
        width: 100%;
    }
    .wib-rr-tab {
        flex: 1;
        padding: 11px 8px !important;
        text-align: center;
    }

    .wib-rr-sig-typed-input {
        font-size: 24px !important;
    }

    /* Botones gemelos apilados verticalmente: a este ancho, incluso
       repartidos al 50%, "Generate next month" en una sola línea ya no cabe
       con comodidad. */
    .wib-rr-actions {
        flex-direction: column;
    }
    .wib-rr-actions .wib-rr-btn {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .wib-rr-editor-panel {
        padding: 16px 12px;
    }
    .wib-rr-preview-panel {
        padding: 12px;
    }
    .wib-rr-btn {
        padding: 11px 14px !important;
    }
    .wib-rr-preview-actions .wib-rr-btn {
        padding: 10px 8px !important;
        font-size: 12.5px !important;
    }
}
