:root {
    --yb-green: #16874c;
    --yb-ink: #173c25;
    --yb-muted: #607361;
}

body.page-certificados-yb {
    margin: 0;
    background: #f2f7f3;
    color: #203024;
}

.yb-overlay {
    min-height: 100vh;
    padding: 36px 18px 70px;
    background:
        radial-gradient(circle at 95% 0%, rgba(46, 204, 113, 0.13), transparent 30%),
        linear-gradient(180deg, #fbfdfb, #eef5ef);
}

.yb-container {
    width: min(1500px, 100%);
    margin: 0 auto;
}

.yb-hero {
    margin-bottom: 22px;
    padding: 30px 36px;
    border-radius: 22px;
    background: linear-gradient(135deg, #102d1c, #167047);
    color: #fff;
    box-shadow: 0 18px 42px rgba(24, 64, 39, 0.15);
}

.yb-hero p {
    margin: 0 0 7px;
    color: rgba(255,255,255,.72);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.yb-hero h1 {
    margin: 0;
    font-size: clamp(32px, 5vw, 48px);
}

.yb-hero span {
    display: block;
    margin-top: 10px;
    color: rgba(255,255,255,.9);
    font-size: 16px;
}

.yb-workspace {
    display: grid;
    grid-template-columns: minmax(390px, .74fr) minmax(690px, 1.26fr);
    align-items: start;
    gap: 20px;
}

.yb-panel {
    min-width: 0;
    padding: 24px;
    border: 1px solid rgba(23, 60, 37, .1);
    border-radius: 20px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 14px 36px rgba(35, 50, 39, .08);
}

.yb-form-panel {
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.yb-heading {
    margin-bottom: 18px;
}

.yb-heading h2 {
    margin: 0;
    color: var(--yb-ink);
    font-size: 25px;
}

.yb-heading p {
    margin: 7px 0 0;
    color: var(--yb-muted);
}

.yb-form {
    display: grid;
    gap: 16px;
}

.yb-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.yb-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.yb-field-wide {
    grid-column: 1 / -1;
}

.yb-field span,
.yb-fieldset legend {
    color: #35503d;
    font-size: 12px;
    font-weight: 800;
}

.yb-field input,
.yb-field select {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    padding: 10px 11px;
    border: 1px solid rgba(23, 60, 37, .17);
    border-radius: 11px;
    background: #fff;
    color: #1f3024;
    font: inherit;
    outline: none;
}

.yb-field input:focus,
.yb-field select:focus {
    border-color: #2ecc71;
    box-shadow: 0 0 0 3px rgba(46, 204, 113, .14);
}

.yb-field input[readonly] {
    background: #e9f6ed;
    color: #116d3b;
    font-weight: 900;
}

.yb-fieldset {
    min-width: 0;
    margin: 0;
    padding: 15px;
    border: 1px solid rgba(23, 60, 37, .13);
    border-radius: 14px;
    background: #f8fbf8;
}

.yb-fieldset legend {
    padding: 0 6px;
}

.yb-check-grid {
    display: grid;
    gap: 9px 12px;
}

.yb-check-grid.treatments {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.yb-check-grid.products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.yb-check-grid label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #294331;
    font-size: 13px;
    font-weight: 700;
}

.yb-check-grid input {
    width: 17px;
    height: 17px;
    accent-color: #25bd68;
}

.yb-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.yb-button {
    min-height: 45px;
    padding: 0 17px;
    border: 0;
    border-radius: 12px;
    background: #27c86d;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.yb-button.secondary {
    background: #edf2ee;
    color: var(--yb-ink);
}

.yb-button:disabled {
    cursor: wait;
    opacity: .65;
}

.yb-status {
    min-height: 20px;
    margin: 0;
    color: var(--yb-muted);
    font-size: 13px;
    font-weight: 700;
}

.yb-status.is-error { color: #b42318; }
.yb-status.is-success { color: #168b49; }

.yb-preview-panel {
    position: sticky;
    top: 16px;
}

.yb-preview-frame {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: #dce3dd;
    box-shadow: inset 0 0 0 1px rgba(23, 60, 37, .1);
}

.yb-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 210mm;
    height: 148mm;
    transform-origin: top left;
}

.yb-certificate {
    position: relative;
    box-sizing: border-box;
    width: 210mm;
    height: 148mm;
    overflow: hidden;
    padding: 5.5mm 7mm 5mm;
    background: #fff;
    color: #111;
    font-family: "Times New Roman", Times, serif;
}

.yb-certificate-border {
    position: relative;
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
    border: .45mm solid #555;
    border-radius: 2mm;
    padding: 3mm 5mm 3mm;
}

.yb-watermark {
    position: absolute;
    inset: 0;
    width: 106mm;
    height: 62.5mm;
    margin: auto;
    overflow: hidden;
    opacity: .09;
    transform: translateX(7mm);
}

.yb-watermark img {
    position: absolute;
    top: 0;
    left: -22.7mm;
    width: 151.5mm;
    height: auto;
    max-width: none;
    filter: grayscale(1) contrast(1.15);
}

.yb-certificate.is-duplicate {
    color: #000;
    filter: grayscale(1);
}

.yb-certificate.is-duplicate .yb-brand-small img {
    filter: grayscale(1) contrast(1.2);
}

.yb-certificate.is-duplicate .yb-watermark {
    display: block !important;
    opacity: .1;
}

.yb-certificate-header {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 55mm 1fr 50mm;
    align-items: start;
    min-height: 36mm;
}

.yb-brand-small {
    text-align: center;
}

.yb-brand-small img {
    display: block;
    width: 45mm;
    height: 28mm;
    margin: 0 auto;
    object-fit: contain;
}

.yb-brand-main {
    text-align: center;
}

.yb-brand-main h2 {
    margin: -1mm 0 0;
    font-family: Impact, "Arial Black", sans-serif;
    font-size: 34pt;
    letter-spacing: .3mm;
    line-height: 1;
}

.yb-brand-main p {
    margin: 1mm 0 0;
    font-size: 8.2pt;
    font-weight: 700;
    line-height: 1.03;
}

.yb-certificate-number {
    text-align: center;
}

.yb-certificate-number strong {
    display: block;
    font-size: 10.5pt;
}

.yb-certificate-number span {
    display: block;
    margin-top: 11mm;
    font-family: Arial, sans-serif;
    font-size: 11pt;
}

.yb-certificate-body {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 2.1mm;
    margin-top: 1mm;
    font-size: 10.5pt;
}

.yb-line {
    display: flex;
    align-items: flex-end;
    min-width: 0;
    margin: 0;
    line-height: 1.1;
}

.yb-line-label {
    flex: 0 0 auto;
    margin-right: 2mm;
}

.yb-line-value {
    min-width: 0;
    flex: 1 1 auto;
    padding: 0 2mm .4mm;
    border-bottom: .35mm dotted #777;
    font-family: Arial, sans-serif;
    font-size: 10.2pt;
    text-align: center;
    text-transform: uppercase;
}

.yb-line-split {
    display: grid;
    grid-template-columns: max-content minmax(22mm, 1fr) max-content 31mm;
    align-items: end;
    column-gap: 2mm;
}

.yb-line-split .yb-line-label {
    margin-right: 0;
}

.yb-line-address {
    grid-template-columns: max-content minmax(30mm, 1fr) max-content 18mm;
}

.yb-line-owner {
    grid-template-columns: max-content minmax(30mm, 1fr) max-content 35mm;
}

.yb-line-label-secondary {
    margin-left: 1mm;
    font-weight: 700;
}

.yb-line-value-rubro,
.yb-line-value-cuit,
.yb-line-value-surface {
    width: auto;
}

.yb-line-date .yb-line-value {
    text-transform: none;
}

.yb-line-value-surface {
    text-transform: none;
}

.yb-treatments-title {
    margin: .4mm 0 -.4mm;
    font-size: 9.5pt;
}

.yb-certificate-treatments {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3mm;
    font-size: 10.2pt;
    font-weight: 700;
}

.yb-treatment {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5mm;
}

.yb-check-box {
    display: inline-grid;
    width: 4mm;
    height: 4mm;
    place-items: center;
    border: .35mm solid #555;
    font-family: Arial, sans-serif;
    font-size: 8pt;
    line-height: 1;
}

.yb-certificate-footer {
    position: absolute;
    z-index: 1;
    right: 5mm;
    bottom: 3.5mm;
    left: 5mm;
    display: grid;
    grid-template-columns: 42mm 1fr 78mm;
    align-items: end;
    gap: 4mm;
}

.yb-contact,
.yb-responsible {
    margin: 0;
    font-size: 8.2pt;
    font-weight: 700;
    line-height: 1.04;
    text-align: center;
}

.yb-products-print {
    padding: 1.4mm 1.6mm;
    border: .25mm solid rgba(60, 60, 60, .35);
    border-radius: 1.2mm;
    background: rgba(255, 255, 255, .9);
    font-family: Arial, sans-serif;
    font-size: 5.4pt;
    font-weight: 500;
    line-height: 1.14;
}

.yb-products-print strong {
    display: block;
    margin-bottom: .8mm;
    font-size: 6pt;
    line-height: 1.1;
}

.yb-products-print p {
    display: grid;
    grid-template-columns: 3.2mm 1fr;
    align-items: start;
    gap: .8mm;
    margin: 0 0 .55mm;
}

.yb-products-print p:last-child {
    margin-bottom: 0;
}

.yb-products-print p.is-selected {
    font-weight: 700;
}

.yb-products-print .yb-products-empty {
    display: block;
    margin: 0;
    font-style: italic;
    font-weight: 500;
}

.yb-product-check {
    display: inline-grid;
    box-sizing: border-box;
    width: 2.8mm;
    height: 2.8mm;
    place-items: center;
    border: .25mm solid #555;
    font-size: 5pt;
    font-style: normal;
    line-height: 1;
}

.yb-copy-label {
    position: absolute;
    right: 7mm;
    bottom: 1.2mm;
    font-family: Arial, sans-serif;
    font-size: 7pt;
}

.yb-print-output {
    display: none;
}

@media (max-width: 1180px) {
    .yb-workspace { grid-template-columns: 1fr; }
    .yb-form-panel { max-height: none; overflow: visible; }
    .yb-preview-panel { position: static; }
}

@media (max-width: 680px) {
    .yb-overlay { padding: 22px 9px 45px; }
    .yb-hero, .yb-panel { padding: 20px 16px; border-radius: 17px; }
    .yb-grid, .yb-check-grid.treatments, .yb-check-grid.products { grid-template-columns: 1fr; }
    .yb-field-wide { grid-column: auto; }
    .yb-actions { flex-direction: column-reverse; }
    .yb-button { width: 100%; }
}

@page {
    size: A5 landscape;
    margin: 0;
}

@media print {
    html,
    body {
        width: 210mm !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    body > *:not(.yb-print-output) {
        display: none !important;
    }

    .yb-print-output {
        display: block !important;
        width: 210mm !important;
        height: auto !important;
        margin: 0 !important;
        overflow: visible !important;
    }

    .yb-print-output .yb-certificate {
        display: block !important;
        width: 210mm !important;
        height: 148mm !important;
        margin: 0 !important;
        break-inside: avoid-page !important;
        page-break-inside: avoid !important;
    }

    .yb-print-output .yb-certificate:not(:last-child) {
        break-after: page !important;
        page-break-after: always !important;
    }

    .yb-print-output .yb-certificate:last-child {
        break-after: auto !important;
        page-break-after: auto !important;
    }
}
