:root {
    --doc-ink: #111827;
    --doc-muted: #667085;
    --doc-line: #e5e7eb;
    --doc-panel: #f4f6f8;
    --doc-black: #050505;
    --doc-red: #a30d14;
    --doc-red-dark: #7f0910;
    --doc-red-soft: #fff5f5;
    --doc-green: #047857;
    --doc-green-soft: #ecfdf3;
}

* { box-sizing: border-box; }

.documentos-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body.documentos-cliente-body {
    margin: 0;
    min-width: 0;
    color: var(--doc-ink);
    background: #f3f4f6;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.documentos-shell { min-height: 100vh; }

.documentos-topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 12px max(16px, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    filter: none;
}

.documentos-brand {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}
.documentos-brand img { display: block; width: 132px; height: 34px; object-fit: contain; }
.documentos-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.documentos-button {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    background: white;
    color: #1f2937;
    font: inherit;
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
}
.documentos-button:hover { background: #f9fafb; }
.documentos-button:disabled { cursor: wait; opacity: .65; }
.documentos-button-primary { border-color: #2563eb; background: #2563eb; color: white; }
.documentos-button-primary:hover { background: #1d4ed8; }

.documentos-main { width: min(1180px, 100%); margin: 0 auto; padding: 24px 16px 64px; }
.documentos-welcome { margin-bottom: 18px; }
.documentos-welcome h1 { margin: 0; font-size: clamp(22px, 4vw, 32px); }
.documentos-welcome p { margin: 6px 0 0; color: var(--doc-muted); font-size: 14px; }

.documentos-selector {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    background: white;
}
.documentos-selector label { display: block; margin-bottom: 5px; color: #475467; font-size: 12px; font-weight: 700; }
.documentos-selector select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 0 40px 0 12px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: white;
    font: inherit;
}
.documentos-tabs { display: flex; align-items: end; gap: 8px; }
.documentos-tab { min-height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: #f2f4f7; color: #475467; font-weight: 700; cursor: pointer; }
.documentos-tab[aria-selected="true"] { background: #111827; color: white; }

.documentos-status {
    width: min(560px, calc(100% - 32px));
    margin: 12vh auto 0;
    padding: 30px;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: white;
    text-align: center;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}
.documentos-status h1 { margin: 12px 0 8px; font-size: 22px; }
.documentos-status p { margin: 0; color: var(--doc-muted); line-height: 1.6; }
.documentos-spinner { width: 38px; height: 38px; margin: 0 auto; border: 4px solid #e5e7eb; border-top-color: #2563eb; border-radius: 50%; animation: documentos-girar .8s linear infinite; }
@keyframes documentos-girar { to { transform: rotate(360deg); } }

.documento-stack { display: grid; gap: 22px; justify-items: center; }
.documento-pagina {
    position: relative;
    width: min(210mm, 100%);
    min-height: 297mm;
    overflow: hidden;
    padding: 15mm;
    background: white;
    box-shadow: 0 15px 45px rgba(15, 23, 42, .12);
    color: var(--doc-ink);
}
.documento-pagina * { box-sizing: border-box; }
.documento-header {
    position: relative;
    display: flex;
    min-height: 38mm;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7mm;
    border-radius: 4mm;
    background: var(--doc-black);
    color: white;
}
.documento-header h2 { margin: 0; font-size: 7mm; line-height: 1.05; letter-spacing: -.03em; }
.documento-header p { margin: 3mm 0 0; color: #d1d5db; font-size: 3mm; }
.documento-header small { display: block; margin-top: 4mm; font-size: 2.3mm; font-weight: 700; letter-spacing: .05em; }
.documento-header img { width: 39mm; max-height: 22mm; object-fit: contain; }
.documento-numero { position: absolute; right: 5mm; bottom: 3mm; color: #9ca3af; font-size: 2.2mm; }

.documento-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5mm; }
.documento-card { padding: 5mm; border: .3mm solid var(--doc-line); border-radius: 3.5mm; background: var(--doc-panel); }
.documento-card-blanco { background: white; }
.documento-card-rojo { border-color: #f3d3d5; background: var(--doc-red-soft); }
.documento-card-verde { border-color: #a7f3d0; background: var(--doc-green-soft); }
.documento-seccion { margin-top: 7mm; }
.documento-etiqueta { margin: 0 0 3mm; color: var(--doc-red); font-size: 2.7mm; font-weight: 800; letter-spacing: .02em; }
.documento-campo { min-width: 0; }
.documento-datos-garantia .documento-etiqueta,
.documento-datos-garantia .documento-campo,
.documento-datos-garantia .documento-campo span,
.documento-datos-garantia .documento-campo strong { font-weight: 400; text-transform: none; }
.documento-datos-garantia { padding-bottom: 7mm; }
.documento-datos-garantia .documento-campo-ancho { padding-bottom: 1mm; }
.documento-campo span { display: block; color: var(--doc-muted); font-size: 2.3mm; font-weight: 500; letter-spacing: 0; text-transform: none; }
.documento-campo strong { display: block; margin-top: 1.5mm; overflow-wrap: anywhere; font-size: 3.2mm; font-weight: 400; line-height: 1.35; }
.documento-alcance-lista { display: grid; gap: 2.5mm; margin: 0; padding-left: 5mm; }
.documento-alcance-lista li { padding-left: 1mm; }
.documento-alcance-encabezado { display: flex; flex-wrap: wrap; gap: 1.5mm; align-items: baseline; font-size: 2.9mm; line-height: 1.35; }
.documento-alcance-encabezado strong { font-weight: 700; }
.documento-alcance-encabezado span { color: var(--doc-muted); font-size: 2.5mm; font-weight: 400; }
.documento-alcance-lista p { margin: 1mm 0 0; color: var(--doc-muted); font-size: 2.4mm; font-weight: 400; line-height: 1.45; }
.documento-vigencia { display: flex; flex-wrap: wrap; gap: 1mm 4mm; font-weight: 400; }
.documento-vigencia strong { font-weight: 700; }
.documento-campo-ancho { grid-column: 1 / -1; }
.documento-datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5mm 8mm; }
.documento-texto { margin: 0; font-size: 3.2mm; line-height: 1.55; }
.documento-parrafos { display: grid; gap: 3mm; }
.documento-exclusiones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4mm; margin-top: 4mm; }
.documento-exclusiones h3 { margin: 0 0 2mm; color: var(--doc-red-dark); font-size: 3.2mm; }
.documento-nota-garantia { margin-top: 4mm; }
.documento-lista { display: grid; gap: 3mm; margin: 0; padding: 0; list-style: none; }
.documento-lista li { display: grid; grid-template-columns: 10mm minmax(0, 1fr); align-items: center; gap: 4mm; }
.documento-numero-paso { display: grid; width: 9mm; height: 9mm; place-items: center; border-radius: 50%; background: var(--doc-red); color: white; font-size: 2.8mm; font-weight: 800; }
.documento-alerta { display: flex; align-items: center; gap: 6mm; padding: 5mm; border: .3mm solid #fed7aa; border-radius: 3mm; background: #fff7ed; }
.documento-alerta strong { color: #b45309; font-size: 3mm; }
.documento-footer { position: absolute; right: 15mm; bottom: 10mm; left: 15mm; display: flex; justify-content: space-between; padding-top: 3mm; border-top: .3mm solid var(--doc-line); color: var(--doc-muted); font-size: 2.3mm; }

.documento-portada { display: flex; flex-direction: column; justify-content: space-between; background: var(--doc-black); color: white; }
.documento-portada::before, .documento-portada::after { content: ""; position: absolute; border-radius: 50%; background: var(--doc-red); }
.documento-portada::before { width: 85mm; height: 85mm; top: -25mm; right: -24mm; }
.documento-portada::after { width: 100mm; height: 100mm; bottom: -38mm; left: -38mm; background: var(--doc-red-dark); }
.documento-portada > * { position: relative; z-index: 1; }
.documento-portada img { width: 50mm; max-height: 28mm; object-fit: contain; }
.documento-portada h2 { margin: 0; font-size: 13mm; line-height: .98; letter-spacing: -.04em; }
.documento-portada p { margin: 6mm 0 0; color: #d1d5db; font-size: 4mm; }
.documento-portada small { font-size: 2.5mm; letter-spacing: .05em; }
.documento-item h3 { margin: 0; font-size: 3.5mm; }
.documento-item p { margin: 2mm 0 0; color: var(--doc-muted); font-size: 2.8mm; line-height: 1.4; }
.documento-evitar h3 { color: var(--doc-red-dark); }

.documentos-solo-impresion { display: none; }
body.documento-exportando .documento-pagina { width: 210mm !important; min-height: 297mm !important; box-shadow: none !important; }
body.documento-exportando .documento-pagina[hidden] { display: block !important; }

@media (max-width: 720px) {
    .documentos-topbar { position: sticky; align-items: center; gap: 8px; padding: 9px 10px; }
    .documentos-brand img { width: 106px; height: 31px; }
    .documentos-actions {
        display: flex;
        flex: 0 1 178px;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 5px;
        margin-left: auto;
    }
    .documentos-actions .documentos-button { display: flex; width: 100%; min-height: 31px; align-items: center; justify-content: center; padding: 0 8px; border-radius: 9px; font-size: 10px; text-align: center; }
    .documentos-main { padding: 16px 0 40px; }
    .documentos-welcome, .documentos-selector { margin-right: 12px; margin-left: 12px; }
    .documentos-selector { grid-template-columns: 1fr; }
    .documentos-tabs { display: grid; grid-template-columns: 1fr 1fr; }
    .documento-stack { gap: 12px; }
    .documento-pagina {
        width: 100%;
        min-height: auto;
        padding: 18px 14px 54px;
        box-shadow: none;
    }
    .documento-header { min-height: 118px; padding: 20px; }
    .documento-header h2 { font-size: clamp(24px, 7vw, 34px); }
    .documento-header p { margin-top: 8px; font-size: 12px; }
    .documento-header small { margin-top: 12px; font-size: 9px; }
    .documento-header img { width: 88px; }
    .documento-numero { right: 16px; bottom: 10px; font-size: 9px; }
    .documento-grid-2, .documento-datos, .documento-exclusiones { grid-template-columns: 1fr; gap: 10px; }
    .documento-campo-ancho { grid-column: auto; }
    .documento-seccion { margin-top: 22px; }
    .documento-card { padding: 16px; border-width: 1px; border-radius: 14px; }
    .documento-datos-garantia { padding-bottom: 22px; }
    .documento-datos-garantia .documento-campo-ancho { padding-bottom: 4px; }
    .documento-etiqueta { margin-bottom: 10px; font-size: 10px; }
    .documento-campo span { font-size: 9px; }
    .documento-campo strong { margin-top: 5px; font-size: 13px; }
    .documento-alcance-encabezado { gap: 6px; font-size: 13px; }
    .documento-alcance-encabezado span { font-size: 11px; }
    .documento-alcance-lista p { margin-top: 4px; font-size: 11px; }
    .documento-texto { font-size: 13px; }
    .documento-numero-paso { width: 32px; height: 32px; font-size: 11px; }
    .documento-lista li { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
    .documento-alerta { gap: 12px; padding: 14px; }
    .documento-alerta strong { font-size: 11px; }
    .documento-footer { right: 14px; bottom: 14px; left: 14px; padding-top: 10px; font-size: 9px; }
    .documento-portada { min-height: calc(100vh - 140px); padding: 26px 20px; }
    .documento-portada h2 { font-size: clamp(46px, 14vw, 72px); }
    .documento-portada p { font-size: 16px; }
    .documento-portada small { font-size: 10px; }
    .documento-item h3 { font-size: 14px; }
    .documento-item p { font-size: 12px; }
}

/* La descarga desde un teléfono debe conservar la composición A4, aunque la
   vista en pantalla use tarjetas apiladas y tipografía más grande. */
body.documento-exportando .documento-pagina { padding: 15mm !important; }
body.documento-exportando .documento-header { min-height: 38mm; padding: 7mm; }
body.documento-exportando .documento-header h2 { font-size: 7mm; }
body.documento-exportando .documento-header p { margin-top: 3mm; font-size: 3mm; }
body.documento-exportando .documento-header small { margin-top: 4mm; font-size: 2.3mm; }
body.documento-exportando .documento-header img { width: 39mm; }
body.documento-exportando .documento-numero { right: 5mm; bottom: 3mm; font-size: 2.2mm; }
body.documento-exportando .documento-grid-2,
body.documento-exportando .documento-datos,
body.documento-exportando .documento-exclusiones { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5mm; }
body.documento-exportando .documento-campo-ancho { grid-column: 1 / -1; }
body.documento-exportando .documento-seccion { margin-top: 7mm; }
body.documento-exportando .documento-card { padding: 5mm; border-width: .3mm; border-radius: 3.5mm; }
body.documento-exportando .documento-datos-garantia { padding-bottom: 7mm; }
body.documento-exportando .documento-etiqueta { margin-bottom: 3mm; font-size: 2.7mm; }
body.documento-exportando .documento-campo span { font-size: 2.3mm; }
body.documento-exportando .documento-campo strong { margin-top: 1.5mm; font-size: 3.2mm; }
body.documento-exportando .documento-texto { font-size: 3.2mm; }
body.documento-exportando .documento-numero-paso { width: 9mm; height: 9mm; font-size: 2.8mm; }
body.documento-exportando .documento-lista li { grid-template-columns: 10mm minmax(0, 1fr); gap: 4mm; }
body.documento-exportando .documento-alerta { gap: 6mm; padding: 5mm; }
body.documento-exportando .documento-alerta strong { font-size: 3mm; }
body.documento-exportando .documento-footer { right: 15mm; bottom: 10mm; left: 15mm; padding-top: 3mm; font-size: 2.3mm; }
body.documento-exportando .documento-portada { min-height: 297mm; padding: 15mm; }
body.documento-exportando .documento-portada h2 { font-size: 13mm; }
body.documento-exportando .documento-portada p { font-size: 4mm; }
body.documento-exportando .documento-portada small { font-size: 2.5mm; }
body.documento-exportando .documento-item h3 { font-size: 3.5mm; }
body.documento-exportando .documento-item p { font-size: 2.8mm; }

@media print {
    @page { size: A4; margin: 0; }
    body.documentos-cliente-body { background: white; }
    .documentos-no-imprimir { display: none !important; }
    .documentos-solo-impresion { display: block; }
    .documentos-main { width: auto; margin: 0; padding: 0; }
    .documento-stack { display: block; }
    .documento-pagina {
        width: 210mm !important;
        min-height: 297mm !important;
        margin: 0 !important;
        break-after: page;
        box-shadow: none !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    .documento-pagina:last-child { break-after: auto; }
}
