:root {
    --gbdm-blue: #0b4f8a;
    --gbdm-blue-light: #19a8e0;
    --gbdm-green: #39a852;
    --gbdm-ink: #1f2d3d;
    --gbdm-muted: #6a7785;
    --gbdm-line: #dce5eb;
    --gbdm-soft: #f3f7f9;
    --gbdm-page-width: 210mm;
    --gbdm-page-height: 297mm;
    --gbdm-page-top: 16mm;
    --gbdm-page-right: 18mm;
    --gbdm-page-bottom: 14mm;
    --gbdm-page-left: 18mm;
    --gbdm-font: Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --gbdm-watermark-opacity: 0.04;
}

.gbdm-shell {
    width: 100%;
    background: #f1f4f6;
    padding: 28px 16px 48px;
    color: var(--gbdm-ink);
    font-family: var(--gbdm-font);
    font-size: 11px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.gbdm-toolbar {
    width: min(100%, var(--gbdm-page-width));
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.gbdm-button {
    appearance: none;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 17px;
    font: 700 12px/1.2 var(--gbdm-font);
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.gbdm-button:hover,
.gbdm-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(11, 79, 138, 0.16);
}

.gbdm-button:focus-visible {
    outline: 3px solid rgba(25, 168, 224, 0.35);
    outline-offset: 2px;
}

.gbdm-button-primary {
    color: #fff;
    background: var(--gbdm-blue);
}

.gbdm-button-primary:hover,
.gbdm-button-primary:focus-visible {
    background: #083d6b;
}

.gbdm-button-secondary {
    color: var(--gbdm-blue);
    background: #fff;
    border: 1px solid var(--gbdm-line);
}

.gbdm-button-secondary:hover,
.gbdm-button-secondary:focus-visible {
    background: #f8fbfc;
}

.gbdm-document {
    width: min(100%, var(--gbdm-page-width));
    margin: 0 auto;
    display: block;
}

.gbdm-page {
    position: relative;
    box-sizing: border-box;
    width: var(--gbdm-page-width);
    min-height: var(--gbdm-page-height);
    height: var(--gbdm-page-height);
    margin: 0 auto 22px;
    padding: var(--gbdm-page-top) var(--gbdm-page-right) var(--gbdm-page-bottom) var(--gbdm-page-left);
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 13px 42px rgba(30, 55, 74, 0.13);
    overflow: hidden;
    page-break-after: always;
    break-after: page;
}

.gbdm-page:last-child {
    page-break-after: auto;
    break-after: auto;
}

.gbdm-page-header {
    flex: 0 0 auto;
    min-height: 19mm;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15mm;
    padding-bottom: 7mm;
    border-bottom: 1px solid var(--gbdm-line);
    position: relative;
    z-index: 1;
}

.gbdm-page-header::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 54mm;
    height: 3px;
    background: linear-gradient(90deg, var(--gbdm-blue), var(--gbdm-blue-light), var(--gbdm-green));
    border-radius: 3px;
}

.gbdm-brand {
    width: 56mm;
    min-height: 14mm;
    display: flex;
    align-items: center;
}

.gbdm-brand img {
    display: block;
    width: auto;
    max-width: 54mm;
    max-height: 16mm;
    object-fit: contain;
}

.gbdm-document-meta {
    max-width: 66mm;
    padding-top: 1mm;
    text-align: right;
    color: var(--gbdm-muted);
    font-size: 9px;
    line-height: 1.5;
}

.gbdm-document-meta > * {
    display: block;
}

.gbdm-document-meta strong {
    margin: 1px 0 2px;
    color: var(--gbdm-blue);
    font-size: 13px;
    line-height: 1.25;
    font-weight: 800;
}

.gbdm-document-kicker {
    color: var(--gbdm-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 8px;
    font-weight: 800;
}

.gbdm-page-main {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding-top: 7mm;
}

.gbdm-document:not(.gbdm-ready) .gbdm-page-main {
    overflow: visible;
}

.gbdm-document.gbdm-ready .gbdm-page-main {
    overflow: hidden;
}

.gbdm-page-main-inner {
    position: relative;
    z-index: 1;
    min-height: 0;
}

.gbdm-watermark {
    position: absolute;
    top: 48%;
    left: 50%;
    z-index: 0;
    transform: translate(-50%, -50%) rotate(-18deg);
    color: var(--gbdm-blue);
    font-size: 128px;
    font-weight: 900;
    letter-spacing: -0.12em;
    line-height: 1;
    opacity: var(--gbdm-watermark-opacity);
    pointer-events: none;
    user-select: none;
}

.gbdm-identification-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    gap: 5mm;
    margin-bottom: 8mm;
}

.gbdm-identification-block {
    min-width: 0;
    padding: 4mm 4.5mm 3.2mm;
    border: 1px solid var(--gbdm-line);
    border-radius: 5px;
    background: linear-gradient(135deg, #fff 0%, var(--gbdm-soft) 100%);
}

.gbdm-block-label {
    margin: 0 0 2.5mm;
    color: var(--gbdm-blue);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.gbdm-identification-block dl {
    margin: 0;
}

.gbdm-data-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 3mm;
    margin: 0;
    padding: 1.2mm 0;
    border-bottom: 1px solid rgba(220, 229, 235, 0.72);
}

.gbdm-data-row:last-child {
    border-bottom: 0;
}

.gbdm-data-row dt {
    color: var(--gbdm-muted);
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
}

.gbdm-data-row dd {
    min-width: 0;
    margin: 0;
    color: var(--gbdm-ink);
    font-size: 10px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.gbdm-title-area {
    display: flex;
    align-items: center;
    gap: 4mm;
    margin: 2mm 0 8mm;
}

.gbdm-title-area h1 {
    flex: 0 0 auto;
    margin: 0;
    color: var(--gbdm-blue);
    font-size: 21px;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-align: center;
}

.gbdm-title-rule {
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gbdm-line));
}

.gbdm-title-rule:last-child {
    background: linear-gradient(90deg, var(--gbdm-line), transparent);
}

.gbdm-medical-sections {
    min-width: 0;
}

.gbdm-section {
    margin: 0 0 6mm;
    padding: 0 0 4.5mm;
    border-bottom: 1px solid var(--gbdm-line);
    break-inside: avoid;
    page-break-inside: avoid;
}

.gbdm-section:last-child {
    margin-bottom: 0;
    border-bottom: 0;
}

.gbdm-section-title {
    display: flex;
    align-items: center;
    gap: 2.5mm;
    margin: 0 0 2.5mm;
    color: var(--gbdm-blue);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.25;
}

.gbdm-section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 6mm;
    height: 6mm;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, var(--gbdm-blue), var(--gbdm-blue-light));
    font-size: 9px;
    font-weight: 800;
}

.gbdm-section-content {
    color: #344353;
    font-size: 10.5px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.gbdm-section-content p {
    margin: 0 0 3mm;
}

.gbdm-section-content p:last-child {
    margin-bottom: 0;
}

.gbdm-section-content ul,
.gbdm-section-content ol {
    margin: 1.5mm 0 0;
    padding-left: 6mm;
}

.gbdm-section-content li + li {
    margin-top: 1.2mm;
}

.gbdm-section-content strong {
    color: var(--gbdm-ink);
    font-weight: 800;
}

.gbdm-empty-content {
    margin: 0;
    color: var(--gbdm-muted);
    font-size: 10px;
    font-style: italic;
}

.gbdm-page-footer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 5mm;
    min-height: 10mm;
    padding-top: 4mm;
    border-top: 1px solid var(--gbdm-line);
    color: var(--gbdm-muted);
    font-size: 8px;
    line-height: 1.3;
    position: relative;
    z-index: 1;
}

.gbdm-page-footer::before {
    content: "";
    position: absolute;
    top: -2px;
    left: 0;
    width: 29mm;
    height: 3px;
    background: linear-gradient(90deg, var(--gbdm-green), var(--gbdm-blue-light));
    border-radius: 3px;
}

.gbdm-footer-brand {
    color: var(--gbdm-blue);
    font-weight: 800;
}

.gbdm-footer-brand span {
    color: var(--gbdm-green);
    padding: 0 1mm;
}

.gbdm-footer-note {
    text-align: center;
}

.gbdm-page-counter {
    text-align: right;
    white-space: nowrap;
}

.gbdm-access-message {
    width: min(100%, 680px);
    margin: 32px auto;
    padding: 18px 20px;
    border: 1px solid #f0caca;
    border-radius: 6px;
    color: #8a2525;
    background: #fff8f8;
    font: 500 14px/1.5 var(--gbdm-font);
}

[data-gbdm-page-template] {
    display: none !important;
}

@media (max-width: 820px) {
    .gbdm-shell {
        padding: 18px 10px 30px;
    }

    .gbdm-toolbar {
        margin-bottom: 12px;
    }

    .gbdm-button {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 11px;
    }

    .gbdm-page {
        transform-origin: top center;
        margin-bottom: 16px;
    }
}

@media (max-width: 560px) {
    .gbdm-toolbar {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .gbdm-button {
        width: 100%;
    }

    .gbdm-page {
        /* A folha continua sendo A4; a escala é somente de visualização. */
        transform: scale(calc((100vw - 20px) / 793.7));
        margin-bottom: calc(-297mm * (1 - ((100vw - 20px) / 793.7)) + 8px);
    }
}

@page {
    size: A4 portrait;
    margin: 0;
}

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

    body {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .gbdm-shell {
        width: 210mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .no-print,
    .print-button,
    .gbdm-toolbar,
    header:not(.gbdm-page-header),
    footer:not(.gbdm-page-footer) {
        display: none !important;
    }

    .gbdm-document {
        width: 210mm;
        margin: 0 !important;
    }

    .gbdm-page {
        width: 210mm;
        min-width: 210mm;
        max-width: 210mm;
        height: 297mm;
        min-height: 297mm;
        max-height: 297mm;
        margin: 0 !important;
        box-shadow: none !important;
        overflow: hidden;
        page-break-after: always;
        break-after: page;
    }

    .gbdm-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }

    .gbdm-section,
    .gbdm-identification-block,
    .gbdm-page-header,
    .gbdm-page-footer {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
