@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800&family=Outfit:wght@400;700&display=swap');

:root {
    --primary-color: #4E308C;
    --secondary-color: #f38220;
    --text-color: #333;
    --font-title: 'Montserrat', sans-serif;
    --font-body: 'Montserrat', sans-serif;
}

html {
    zoom: 1.7; /* Zoom padrão para Desktop */
}

body {
    margin: 0;
    padding: 20px 0;
    background-color: #333333;
    /* Fundo escuro do visualizador PDF */
    font-family: var(--font-body);
    color: var(--text-color);
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* --- Folha A4 Perfeita --- */
.page {
    width: 210mm;
    min-height: 297mm;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    padding: 5mm 8mm 23mm 8mm;
    /* Mais margem na base para o footer, menos no topo/lados */
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    /* Garante que a marca d'água não vaze */
}

.watermark {
    position: absolute;
    top: 10%;
    /* Centralizado: (100 - 80) / 2 */
    left: 10%;
    /* Aumentado horizontalmente (margens menores) */
    right: 10%;
    height: 80%;
    background-image: url('assets/logo2.png');
    background-size: 100% 100%;
    /* Força o estiramento/encolhimento */
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}

/* Garante que o conteúdo fique sobre a marca d'água */
.header-banner,
.main-content,
.section-divider-purple,
.radiografias-section {
    position: relative;
    z-index: 1;
}

/* --- Cabeçalho Estilo Banner --- */
.header-banner {
    background-color: #4E308C;
    /* Roxo da imagem */
    color: #fff;
    margin: -5mm -8mm 15px -8mm;
    /* Faz o banner encostar nas bordas da folha, ajustado para o novo padding */
    padding: 10px 30px 5px 30px;
    /* Reduced top padding */
    border-bottom: 4px solid var(--secondary-color);
    /* Reduzido de 6px para 4px */
    font-family: var(--font-title);
}

.banner-grid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.logo-area {
    display: flex;
    justify-content: center;
    /* Centraliza o logo horizontalmente aqui */
    align-items: center;
    width: 220px;
    /* Reduzido de 280px para 220px */
    flex-shrink: 0;
}

.info-and-footer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Reduzido de 12px para deixar mais perto do estacionamento */
    flex-grow: 1;
    margin-top: 10px;
    /* Abaixa toda a parte de informações */
}

.header-logo {
    height: 50px;
    /* Reduzido de 60px para 50px */
    margin: 0;
    /* Remove margens manuais */
}

.info-area {
    display: flex;
    gap: 20px;
    font-size: 8.5px;
    font-weight: 600;
    line-height: 1.2;
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Reduzido o espaço vertical entre linhas */
}

.info-column p {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.insta-icon {
    width: 12px;
    height: 12px;
}

.divider {
    width: 2px;
    /* Linha mais grossa conforme pedido */
    background-color: rgba(255, 255, 255, 0.4);
}

.banner-footer {
    text-align: left;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #fff;
    width: 100%;
    margin: 0;
}

/* --- Identificação (Paciente e Profissional) --- */
.identification {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.box-title {
    background-color: #4E308C;
    /* Mesmo roxo do cabeçalho */
    color: #fff;
    font-family: var(--font-title);
    font-size: 11px;
    /* Reduzido de 12px para 11px */
    font-weight: 800;
    padding: 1px 12px;
    /* Reduzido padding */
    border-radius: 20px;
    /* Bordas totalmente arredondadas */
    display: inline-block;
    margin-bottom: 8px;
    /* Reduzido de 10px para 8px */
}

.form-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 5px;
    /* Reduzido de 10px para 5px */
}

.input-group {
    display: flex;
    align-items: flex-end;
    border-bottom: 1.5px solid var(--secondary-color);
    /* Engrossado de 1px para 1.5px */
    padding-bottom: 2px;
}

.input-group label {
    font-size: 8px;
    /* Reduzido de 9px para 8px */
    font-weight: 800;
    color: #555;
    margin-bottom: 0;
    margin-right: 5px;
    white-space: nowrap;
}

.ml-15 {
    margin-left: 15px;
}

.label-align {
    padding-left: 15px;
}

.form-row label {
    font-weight: 700;
    font-size: 10px;
    /* Ajustado para 10px conforme PDF */
    color: #000;
    margin-right: 5px;
    white-space: nowrap;
}

/* Inputs de Texto Perfeitos (Linha embaixo) */
.input-line {
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 10px;
    /* Reduzido de 11px para 10px */
    color: #333;
    flex-grow: 1;
    padding: 2px 0;
    /* Reduzido de 5px para 2px */
    outline: none !important;
    /* Remove o contorno azul/preto do navegador */
    box-shadow: none !important;
    text-transform: lowercase;
}

input[name="paciente_nome"],
input[name="profissional_nome"],
.doc-pers-input {
    text-transform: none;
}

.input-line:focus {
    /* Removido o efeito de borda extra ao focar */
    outline: none;
}

.flex-grow {
    flex-grow: 1;
}

.w-150 {
    width: 150px;
}

/* --- Quadros de Assinatura e Suspeita --- */
.additional-info {
    display: flex;
    gap: 15px;
    margin-top: auto;
    /* Empurra para a base, alinhando com o lado direito */
    margin-bottom: 0;
}

.info-box {
    flex: 1;
    border-radius: 15px;
    padding: 6px;
    /* Reduzido de 8px para 6px */
    min-height: 70px;
    /* Reduzido de 80px para 70px */
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Permite truncamento do conteúdo filho (carimbo) */
}

.info-box label {
    font-size: 11px;
    font-weight: 800;
    color: #4E308C;
    margin-bottom: 10px;
}

.purple-box {
    border: 1.5px solid #4E308C;
}

.orange-box {
    border: 1.5px solid var(--secondary-color);
}

.box-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 15px;
}

.pautado-input {
    width: 100%;
    height: 100%;
    border: none;
    background-image: linear-gradient(#ddd 1px, transparent 1px);
    background-size: 100% 24px;
    /* Altura de cada linha */
    line-height: 24px;
    padding: 0;
    margin: 0;
    resize: none;
    font-family: var(--font-body);
    font-size: 10px;
    color: #333;
    outline: none;
    background-attachment: local;
    text-transform: lowercase;
}

/* --- Layout Principal (Duas Colunas) --- */
.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-top: 15px;
    /* Adicionado respiro para os banners não vazarem no topo */
}

.left-side {
    flex: 1;
    /* Ocupa o restante (aprox 65%) */
    display: flex;
    flex-direction: column;
}

.right-side {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 0;
    margin-top: 12px;
    /* Compensação para que o topo do círculo laranja alinhe com o Paciente */
}

/* --- Boxes Laterais (Atendimento e Envio) --- */
.side-box {
    border-radius: 12px;
    position: relative;
    padding: 8px 6px 5px 6px;
    width: 100%;
    max-width: 235px;
    align-self: center;
    /* Centralizado na coluna */
}

.purple-border {
    border: 1.5px solid #4E308C;
}

.orange-border {
    border: 1.5px solid var(--secondary-color);
}

.side-box:last-child {
    margin-top: 16px;
    margin-bottom: 5px;
}

.side-banner {
    position: absolute;
    top: -8px;
    /* Reduzido de -12px para -8px para não vazar no topo */
    left: 50%;
    transform: translateX(-50%);
    /* Centralizado no box */
    background-color: #4E308C;
    color: #fff;
    font-size: 7.5px;
    /* Reduzido de 8.5px para 7.5px */
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    padding: 5px 30px;
    /* Padding aumentado para um banner mais largo */
    border-radius: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.center-banner {
    width: fit-content;
    justify-content: center;
}

.center-banner {
    width: fit-content;
    /* Ajustado para ficar menor, apenas no tamanho do texto */
    justify-content: center;
    padding: 4px 15px;
    /* Padding reduzido para um visual mais compacto */
}

.side-icon-orange {
    background-color: var(--secondary-color);
    width: 26px;
    /* Reduzido de 32px para 26px */
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.float-icon {
    position: absolute;
    left: -15px;
    /* Movido um pouco para a direita (era -20px) */
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.qrcode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    /* Reduzido de 15px para 8px */
    text-align: center;
    padding-top: 10px;
    /* Afasta o conteúdo do título roxo no topo */
}

.qr-placeholder,
.qr-code-img {
    width: 65px;
    height: 65px;
    border: 2px solid var(--secondary-color);
    border-radius: 5px;
    margin: 0 auto 5px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    box-sizing: border-box;
    background-color: #fff;
    object-fit: contain;
}

.qr-label {
    font-size: 6.5px;
    /* Reduzido para dar contraste */
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 3px;
    color: #555;
}

.orange-text {
    color: var(--secondary-color);
    font-size: 9px;
    /* Aumentado para destacar o público-alvo */
    font-weight: 800;
    display: block;
    margin-top: 1px;
}

.qr-phone {
    font-size: 9.5px;
    /* Reduzido de 11px para 9.5px */
    font-weight: 700;
    color: #4E308C;
    margin: 1px 0;
    white-space: nowrap;
}

.qr-sub {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
}

/* Envio de Exames */
.exams-delivery {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Reduzido o espaço entre as linhas de opções */
    padding-top: 10px;
    /* Afasta o conteúdo do título laranja no topo */
}

.delivery-row {
    display: grid;
    grid-template-columns: 48px 65px 70px;
    /* Larguras fixas para todas as colunas */
    justify-content: center;
    /* Centraliza o conjunto de colunas horizontalmente */
    align-items: flex-start;
    gap: 8px;
    /* Espaço entre as colunas do grid */
    margin-bottom: 8px;
    white-space: nowrap;
}

.delivery-label {
    font-weight: 800;
    color: #4E308C;
    font-size: 8px;
    margin-top: 3px;
    text-align: left;
}

.delivery-options {
    display: flex;
    gap: 6px;
    /* Espaço reduzido entre as opções para não vazar */
    align-items: center;
}

.divider-line {
    border-top: 1.5px solid #000;
    margin: 5px 0;
}

/* Estilo específico para o grupo urgente */
.urgente-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.taxa-extra {
    font-size: 7.5px;
    font-weight: 700;
    color: #333;
    margin-left: 18px;
    margin-top: -3px;
    /* Puxado para mais perto de Urgente */
    line-height: 1.2;
}

.orange-mark {
    border-color: var(--secondary-color) !important;
}

.checkbox-wrapper input:checked+.mark.orange-mark {
    background-color: var(--secondary-color) !important;
    border-color: var(--secondary-color) !important;
}

/* --- Layout das Bolinhas (Grid) --- */
.exams-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.exam-category {
    margin-bottom: 10px;
    /* Reduzido de 25px para 10px */
}

.category-title {
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 800;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 4px;
    margin-bottom: 12px;
}

/* --- A Mágica das Bolinhas Customizadas --- */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    /* Centralizado verticalmente com a opção */
    font-size: 8.5px;
    /* Aumentado de 7.5px */
    color: #333;
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 800;
    /* Engrossado de 700 para 800 */
    gap: 6px;
    /* Espaço entre círculo e texto */
}

.checkbox-wrapper input[type="checkbox"],
.checkbox-wrapper input[type="radio"] {
    display: none !important;
    /* Esconde o seletor original do navegador */
}

.checkbox-wrapper .mark {
    width: 12px !important;
    height: 12px !important;
    min-width: 12px;
    min-height: 12px;
    border: 1.2px solid #000;
    border-radius: 50% !important;
    margin-right: 0;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    /* Transição suave para cores */
    flex-shrink: 0;
    position: relative;
}

/* O ponto interno sempre existe, mas invisível e pequeno */
.checkbox-wrapper .mark::after {
    content: '';
    width: 6px;
    height: 6px;
    background-color: #fff;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Efeito elástico suave */
}

/* O estado de "marcado" */
.checkbox-wrapper input:checked+.mark {
    background-color: #000 !important;
    border-color: #000;
}

/* Efeito de Hover suave */
.checkbox-wrapper:hover .mark {
    background-color: rgba(0, 0, 0, 0.1);
}

.checkbox-wrapper:hover .mark.orange-mark {
    background-color: rgba(243, 130, 32, 0.1);
}

/* Garante que se estiver marcado, o hover não tire a cor sólida */
.checkbox-wrapper input:checked+.mark {
    background-color: var(--primary-color) !important;
}

.checkbox-wrapper input:checked+.mark::after {
    opacity: 1;
    transform: scale(1);
}

/* --- Botão Gerar PDF (Flutuante) --- */
.action-bar {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

/* .banner-footer removido daqui e consolidado acima */

.btn-submit {
    background-color: var(--secondary-color);
    color: #fff;
    border: 1px solid #fff;
    padding: 14px 29px; /* Adjusted slightly for the 1px border */
    font-size: 16px;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-submit:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), 0 6px 12px rgba(0, 0, 0, 0.2);
}

.section-divider-purple {
    width: 100%;
    height: 2px;
    background-color: #4E308C;
    margin: 0 0 10px 0;
    /* Margem superior removida para ficar bem perto */
}

.mt-10 {
    margin-top: 5px;
}

.mt-15 {
    margin-top: 8px;
}

.mt-20 {
    margin-top: 12px;
}


/* --- Seção de Radiografias --- */
.radiografias-section {
    margin-top: 5px;
    /* Reduzido de 10px */
}

.section-title-orange {
    color: var(--secondary-color);
    font-size: 24px;
    font-weight: 800;
    margin-top: 0;
    /* Garante alinhamento com a coluna ao lado */
    margin-bottom: 5px;
    /* Reduzido de 15px */
    text-transform: uppercase;
    letter-spacing: 1px;
}

.radiografias-grid {
    display: grid;
    grid-template-columns: 55% 1fr;
    /* Dividido em 55% e 45% (restante) */
    gap: 30px;
}

.category-pill {
    background-color: var(--primary-color);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 1px 15px;
    /* Reduzido de 2px */
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 5px;
    /* Reduzido de 10px */
    text-transform: uppercase;
    width: fit-content;
    align-self: flex-start;
}

.options-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

/* Odontograma */
.odontogram-wrapper {
    display: flex;
    gap: 10px;
    margin: 8px 0;
}

.odontogram-box {
    flex: 1;
}

.odontogram-separator {
    width: 1px;
    background-color: var(--primary-color);
    margin: 15px 5px 0 5px;
}

.odontogram-title {
    font-size: 8px;
    font-weight: 800;
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 5px;
    white-space: nowrap;
}

.odontogram-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--primary-color);
    /* Borda externa roxa */
}

.odontogram-table td {
    border: 0.5px solid var(--secondary-color);
    /* Bordas internas laranjas */
    text-align: center;
    padding: 2px 1px;
    cursor: pointer;
    transition: background-color 0.2s;
    vertical-align: top;
    position: relative;
}

.odontogram-table td.quadrant-divider {
    border-left: 1px solid var(--primary-color);
    /* Linha divisória roxa entre quadrantes */
}

.odontogram-table tr:first-child td {
    border-bottom: 1px solid var(--primary-color);
    /* Linha horizontal roxa */
}

.upper-arch td {
    border-bottom: 1.5px solid var(--primary-color) !important;
}

.tooth-num {
    color: var(--primary-color);
    font-size: 7px;
    font-weight: 700;
    margin: 1px 0;
}

.tooth-svg {
    width: 10px;
    height: 18px;
    fill: transparent;
    stroke: var(--primary-color);
    stroke-width: 1.5;
    margin: 1px auto;
    display: block;
    transition: stroke 0.2s, fill 0.2s;
}

/* Tooth Image Sprite */
.tooth-img-sprite {
    width: 10px;
    height: 18px;
    background-image: url('assets/molares_odontograma.png');
    background-size: 300% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t48 {
    background-position: 0% 0%;
}

.t47 {
    background-position: 50% 0%;
}

.t46 {
    background-position: 100% 0%;
}

/* Inverted for the other side (36, 37, 38) */
.t36 {
    background-position: 100% 0%;
    transform: scaleX(-1);
}

.t37 {
    background-position: 50% 0%;
    transform: scaleX(-1);
}

.t38 {
    background-position: 0% 0%;
    transform: scaleX(-1);
}

/* Molares Superiores */
.tooth-img-sprite-sup {
    width: 10px;
    height: 18px;
    background-image: url('assets/molares_superiores.png');
    background-size: 300% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t18 {
    background-position: 0% 0%;
}

.t17 {
    background-position: 50% 0%;
}

.t16 {
    background-position: 100% 0%;
}

.t26 {
    background-position: 100% 0%;
    transform: scaleX(-1);
}

.t27 {
    background-position: 50% 0%;
    transform: scaleX(-1);
}

.t28 {
    background-position: 0% 0%;
    transform: scaleX(-1);
}

/* Pré-molares Superiores */
.tooth-img-sprite-pre {
    width: 10px;
    height: 18px;
    background-image: url('assets/pre_molares_superiores.png');
    background-size: 200% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t15 {
    background-position: 0% 0%;
}

.t14 {
    background-position: 100% 0%;
}

.t24 {
    background-position: 100% 0%;
    transform: scaleX(-1);
}

.t25 {
    background-position: 0% 0%;
    transform: scaleX(-1);
}

/* Pré-molares Inferiores (Reaproveitando imagem superior com inversão vertical) */
.t45 {
    background-position: 0% 0%;
    transform: scaleY(-1);
}

.t44 {
    background-position: 100% 0%;
    transform: scaleY(-1);
}

.t34 {
    background-position: 100% 0%;
    transform: scaleX(-1) scaleY(-1);
}

.t35 {
    background-position: 0% 0%;
    transform: scaleX(-1) scaleY(-1);
}

/* Caninos */
.tooth-img-sprite-can {
    width: 10px;
    height: 18px;
    background-image: url('assets/caninos.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t43 {
    transform: none;
}

.t33 {
    transform: scaleX(-1);
}

.t13 {
    transform: scaleY(-1);
}

.t23 {
    transform: scaleX(-1) scaleY(-1);
}

/* Incisivos */
.tooth-img-sprite-inc {
    width: 10px;
    height: 18px;
    background-image: url('assets/incisivos.png');
    background-size: 200% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

/* Inferiores */
.t42 {
    background-position: 0% 0%;
}

.t41 {
    background-position: 100% 0%;
}

.t31 {
    background-position: 100% 0%;
    transform: scaleX(-1);
}

.t32 {
    background-position: 0% 0%;
    transform: scaleX(-1);
}

/* Superiores (Invertidos) */
.t12 {
    background-position: 0% 0%;
    transform: scaleY(-1);
}

.t11 {
    background-position: 100% 0%;
    transform: scaleY(-1);
}

.t21 {
    background-position: 100% 0%;
    transform: scaleX(-1) scaleY(-1);
}

.t22 {
    background-position: 0% 0%;
    transform: scaleX(-1) scaleY(-1);
}

/* Anteriores Superiores Reais (Caninos e Laterais) */
.tooth-img-sprite-ant-sup {
    width: 10px;
    height: 18px;
    background-image: url('assets/anteriores_superiores.png');
    background-size: 200% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t13 {
    background-position: 0% 0%;
    transform: none;
}

.t12 {
    background-position: 100% 0%;
    transform: none;
}

.t22 {
    background-position: 100% 0%;
    transform: scaleX(-1);
}

.t23 {
    background-position: 0% 0%;
    transform: scaleX(-1);
}

/* Incisivos Centrais Superiores Reais */
.tooth-img-sprite-inc-sup {
    width: 10px;
    height: 18px;
    background-image: url('assets/incisivos_centrais_superiores.png');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t11 {
    transform: none;
}

.t21 {
    transform: scaleX(-1);
}

/* Molares Decíduos */
.tooth-img-sprite-mol-dec {
    width: 10px;
    height: 18px;
    background-image: url('assets/molares_deciduos.png');
    background-size: 200% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

/* Inferiores */
.t85 {
    background-position: 5% 0%;
}

.t84 {
    background-position: 106% 0%;
}

.t74 {
    background-position: 106% 0%;
    transform: scaleX(-1);
}

.t75 {
    background-position: 5% 0%;
    transform: scaleX(-1);
}

/* Molares Decíduos Superiores Reais */
.tooth-img-sprite-mol-dec-sup {
    width: 10px;
    height: 18px;
    background-image: url('assets/molares_deciduos_superiores.png');
    background-size: 200% 100%;
    background-repeat: no-repeat;
    margin: 1px auto;
    display: block;
}

.t55 {
    background-position: 5% 0%;
    transform: none;
}

.t54 {
    background-position: 106% 0%;
    transform: none;
}

.t64 {
    background-position: 106% 0%;
    transform: scaleX(-1);
}

.t65 {
    background-position: 5% 0%;
    transform: scaleX(-1);
}

.odontogram-table td.marked-tooth {
    background-color: var(--secondary-color) !important;
    border-color: var(--secondary-color);
}

.odontogram-table td.marked-tooth .tooth-num {
    color: #fff;
}

.odontogram-table td.marked-tooth .tooth-svg {
    stroke: #fff;
    fill: rgba(255, 255, 255, 0.4);
}

.odontogram-table td:hover {
    background-color: rgba(243, 130, 32, 0.15);
}

.bottom-tooth {
    transform: scaleY(-1);
}

/* Bite-Wing specific */
.bite-wing-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.sub-options {
    margin-left: 18px;
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sub-options .checkbox-wrapper .mark {
    width: 10px !important;
    height: 10px !important;
    min-width: 10px;
    min-height: 10px;
    border-color: var(--secondary-color);
}

/* Analises Especiais */
.analises-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.maxila-mandibula-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr;
    align-items: center;
    margin-bottom: 5px;
}

.label-orange {
    color: var(--secondary-color);
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
}

.exams-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Iniciando com 3 colunas de exames */
    gap: 20px;
    padding: 0 10px;
}

.thin-divider-purple {
    width: 100%;
    height: 1px;
    background-color: #4E308C;
    margin: 6px 0;
}

.analises-cef-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1.3fr;
    gap: 10px;
    margin-bottom: 15px;
}

.analises-cef-grid .col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flex-row-input {
    display: flex;
    align-items: center;
    gap: 5px;
}

.outro-label {
    white-space: nowrap;
}

.outro-input {
    border-bottom: 1px solid #000;
    flex-grow: 1;
    width: 100%;
    padding: 0;
}

.align-start {
    align-items: flex-start !important;
}

.align-start .mark {
    margin-top: 2px !important;
}

.multiline-label {
    line-height: 1.2;
}

.multiline-label small {
    font-size: 7.5px;
    font-weight: 600;
    display: block;
}

.doc-options-container {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.doc-type-column {
    flex: 0 0 120px;
    display: flex;
    flex-direction: column;
}

.doc-details-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.orange-bg-box {
    background-color: var(--secondary-color);
    border: 1.5px solid var(--primary-color);
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
}

.orange-bg-box .text-white {
    color: #fff;
    font-size: 8.5px;
    font-weight: 800;
}

.flex-col-align {
    flex-direction: column;
    gap: 5px;
}

.row-align {
    display: flex;
    align-items: center;
    gap: 6px;
}

.white-line-input {
    border-bottom: 1px solid #fff;
    color: #fff;
    width: 100%;
    margin-top: 2px;
}

.white-mark {
    background-color: #fff !important;
    border-color: var(--primary-color) !important;
}

.checkbox-wrapper input:checked+.mark.white-mark {
    background-color: #fff !important;
}

.checkbox-wrapper input:checked+.mark.white-mark::after {
    background-color: var(--primary-color) !important;
}

.doc-detail-item {
    display: flex;
    align-items: flex-start;
}

.doc-desc {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.doc-title-pill {
    font-size: 8px;
    font-weight: 800;
    color: #fff;
    padding: 2px 10px;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}

.purple-pill {
    background-color: var(--primary-color);
}

.doc-subtitle {
    font-size: 7.5px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    line-height: 1.2;
}

.w-full {
    width: 100%;
}

.doc-pers-input {
    border-bottom: 1px solid var(--primary-color);
    width: 100%;
    margin-top: 5px;
}

/* Modelos Impressos */
.modelos-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.modelos-grid .col {
    display: flex;
    flex-direction: column;
}

.purple-mark {
    border-color: var(--primary-color) !important;
}

.pill-label {
    font-size: 8px;
    font-weight: 800;
    color: #fff;
    padding: 2px 12px;
    border-radius: 12px;
    border: 1px solid var(--primary-color);
    display: inline-block;
}

.orange-pill {
    background-color: var(--secondary-color);
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.section-subtitle-purple {
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.foto-options-row {
    display: grid;
    grid-template-columns: auto auto;
    gap: 8px 20px;
    margin-top: 10px;
    width: fit-content;
}

.foto-grid-container {
    display: flex;
    flex-direction: column;
}

.purple-bg {
    background-color: var(--primary-color) !important;
}

.foto-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-left: 5px;
}

.foto-grid .col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mt-5 {
    margin-top: 5px;
}

/* --- Modo de Impressão Perfeito --- */
@media print {
    body {
        background-color: transparent;
        padding: 0;
        margin: 0;
        zoom: 1 !important;
    }

    .page {
        box-shadow: none;
        padding: 0;
        /* A impressora já coloca margem */
        page-break-after: always;
    }

    .action-bar {
        display: none;
        /* Esconde o botão na hora de imprimir */
    }

    /* Garante que as cores de fundo saiam na impressão */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Remove a cor de fundo cinza dos inputs focados se estiverem preenchidos na hora de imprimir */
    .input-line {
        border-bottom: 1px solid #000;
    }
}

/* --- Footer Banner --- */
.footer-banner {
    background-color: var(--primary-color);
    border-top: 4px solid var(--secondary-color);
    padding: 12px 30px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: #fff;
    z-index: 10;
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.footer-budget {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.5px;
}

.footer-budget strong {
    font-weight: 800;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.access-text {
    font-size: 8.5px;
    text-align: right;
    line-height: 1.3;
}

.access-text strong {
    font-weight: 800;
}

.access-info-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.store-buttons.row-buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.store-btn {
    background-color: #fff;
    border: none;
    border-radius: 3px;
    padding: 2px 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    min-width: 65px;
    /* Reduzido de 90px */
}

.store-btn .btn-txt {
    color: var(--primary-color);
    font-size: 6px;
    /* Reduzido de 8px */
    font-weight: 700;
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.store-btn .btn-txt span {
    font-size: 4px;
    /* Reduzido de 5px */
    font-weight: 400;
    margin-bottom: 0px;
}

.store-btn svg {
    fill: var(--primary-color);
    width: 10px;
    /* Reduzido de 14px */
    height: 10px;
}

.footer-qr {
    background-color: #fff;
    padding: 3px;
    border-radius: 4px;
    border: 2px solid var(--secondary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-qr img {
    width: 45px;
    height: 45px;
}

/* --- Page 2 Specialized Styles --- */
.grid-2-cols {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 8mm;
    margin-top: 3mm;
    align-items: start;
}

.p2-column {
    display: flex;
    flex-direction: column;
}

.exam-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4mm;
}

.exam-title-text h1 {
    font-family: var(--font-title);
    font-size: 20px;
    font-weight: 800;
    color: var(--secondary-color);
    margin: 0;
    line-height: 1;
}

.exam-title-text h1 div {
    color: var(--secondary-color);
    font-size: 16px;
    margin-top: 2px;
}

.exam-title-text .subtitle {
    font-size: 9px;
    font-weight: 800;
    color: var(--primary-color);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exam-image-container {
    width: 110px;
    height: 75px;
    border: 1.5px solid var(--primary-color);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.exam-image-container img {
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.category-pill-p2 {
    background-color: var(--primary-color);
    color: #fff;
    padding: 1px 15px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 800;
    width: fit-content;
    margin: 10px 0 5px 0;
    text-transform: uppercase;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 10px;
}

.instruction-box-p2 {
    margin-top: 10px;
    border: 2px solid var(--secondary-color);
    border-radius: 15px;
    padding: 6px;
}

.instruction-box-p2.purple {
    border-color: var(--primary-color);
}

.instruction-box-p2 .box-title {
    font-size: 9px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
    text-transform: uppercase;
    background-color: transparent;
    padding: 1px 0;
    border-radius: 0;
}

.instruction-box-p2 .pautado-input {
    background-size: 100% 18px;
    line-height: 18px;
    font-size: 10px;
}

.instruction-box-p2.purple .box-title {
    color: var(--primary-color);
}

.line-field {
    border-bottom: 1px solid #333;
    height: 18px;
    margin-bottom: 4px;
}

.tomography-options {
    font-size: 9px;
    line-height: 1.2;
}

.tomography-options .group-label {
    font-weight: 800;
    color: var(--primary-color);
    margin: 8px 0 3px 0;
    text-transform: uppercase;
    font-size: 9px;
}

.sub-options {
    margin-left: 15px;
}

.sub-options .checkbox-wrapper {
    font-size: 8.5px;
    margin-bottom: 1px;
}

.sub-options .mark {
    width: 10px;
    height: 10px;
    border-color: var(--secondary-color);
}

.sub-options .mark::after {
    left: 3px;
    top: 1px;
    width: 3px;
    height: 6px;
}

/* Estilos para a geração do PDF e Impressão */
body.generating-pdf {
    padding: 0 !important;
    margin: 0 !important;
    background-color: #fff !important;
    overflow: visible !important;
    zoom: 1 !important;
}

body.generating-pdf .page-wrapper {
    display: block !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    /* Corrige a margem esquerda: remove flex centering */
    align-items: initial !important;
    justify-content: initial !important;
    gap: 0 !important;
}

body.generating-pdf .action-bar {
    display: none !important;
}

body.generating-pdf .page {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 5mm 8mm 23mm 8mm !important;
    width: 210mm !important;
    height: 297mm !important;
    max-height: 297mm !important;
    min-height: 297mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
    page-break-after: auto !important;
    position: relative !important;
    float: none !important;
    display: block !important;
}

/* ============================================================
   COMPACTAÇÃO PARA CABER EM 297mm — EVITAR SOBREPOSIÇÃO DO FOOTER
   ============================================================ */

/* Padding geral das páginas reduzido na base */
body.generating-pdf .page {
    padding: 2mm 8mm 14mm 8mm !important;
}

/* Reduz espaços apenas onde não afeta o design */
body.generating-pdf .header-banner {
    margin-bottom: 2px !important;
}

body.generating-pdf .main-content {
    margin-top: 2px !important;
    gap: 8px !important;
}

/* Identificação */
body.generating-pdf .identification {
    gap: 4px !important;
    margin-bottom: 4px !important;
}

body.generating-pdf .form-row {
    margin-bottom: 1px !important;
}

body.generating-pdf .additional-info {
    gap: 8px !important;
}

/* Coluna Direita (Atendimento/Envio) */
body.generating-pdf .qrcode-grid {
    padding-top: 2px !important;
    gap: 4px !important;
}

body.generating-pdf .exams-delivery {
    padding-top: 4px !important;
    gap: 2px !important;
}

/* Radiografias */
body.generating-pdf .radiografias-section {
    margin-top: 0 !important;
}

body.generating-pdf .radiografias-grid {
    gap: 10px !important;
}

body.generating-pdf .options-row {
    margin-bottom: 4px !important;
    gap: 10px !important;
}

body.generating-pdf .odontogram-wrapper {
    margin: 2px 0 !important;
}

/* Análises Especiais e Cefalométricas */
body.generating-pdf .analises-grid {
    gap: 2px !important;
}

body.generating-pdf .analises-cef-grid {
    gap: 5px !important;
    margin-bottom: 2px !important;
}

/* Documentações e Modelos */
body.generating-pdf .doc-options-container {
    margin-top: 2px !important;
    gap: 8px !important;
}

body.generating-pdf .modelos-grid {
    margin-bottom: 2px !important;
    gap: 10px !important;
}

/* Fotografias */
body.generating-pdf .foto-options-row {
    margin-top: 2px !important;
}

body.generating-pdf .foto-grid-container {
    margin-top: 2px !important;
}

/* Compactação específica para Página 2 */
body.generating-pdf .category-pill-p2 {
    margin: 4px 0 2px 0 !important;
}

body.generating-pdf .instruction-box-p2 {
    margin-top: 4px !important;
    padding: 3px !important;
}

body.generating-pdf .instruction-box-p2 .box-title {
    margin-bottom: 4px !important;
}

body.generating-pdf .tomography-options .group-label {
    margin: 4px 0 1px 0 !important;
}

body.generating-pdf .exam-header {
    margin-bottom: 2mm !important;
}

body.generating-pdf .exam-image-container {
    height: 65px !important;
}

body.generating-pdf .odontogram-box {
    padding: 3px !important;
}

body.generating-pdf .odontogram-title {
    margin-bottom: 2px !important;
}

body.generating-pdf .line-field {
    height: 16px !important;
    margin-bottom: 2px !important;
}

.generating-pdf .tooth-svg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Footer Banner */
body.generating-pdf .footer-banner {
    padding: 10px 30px !important;
}

@media print {
    @page {
        margin: 0;
        size: A4;
    }

    body {
        margin: 0;
        padding: 0;
        background-color: #fff;
    }

    .page-wrapper {
        gap: 0;
    }

    .page {
        margin: 0;
        box-shadow: none;
        page-break-after: always;
        width: 210mm;
        height: 297mm;
        position: relative;
        display: block;
    }

    .action-bar {
        display: none;
    }

    .footer-banner {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
    }
}

/* --- Footer Página 2 Especial --- */
.footer-p2 {
    background-color: var(--secondary-color) !important;
    border-top: 5px solid var(--primary-color) !important;
    display: flex !important;
    align-items: center !important;
    gap: 35px !important;
    min-height: 70px !important;
    padding: 0 30px !important;
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
}

.footer-p2-logo {
    height: 50px;
    width: auto;
    filter: brightness(0) saturate(100%) invert(18%) sepia(55%) saturate(1637%) hue-rotate(231deg) brightness(96%) contrast(92%);
}

.footer-p2-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.footer-p2-title {
    color: var(--primary-color);
    font-weight: 900;
    font-size: 16px;
    letter-spacing: 0.5px;
    line-height: 1.2;
    text-transform: uppercase;
}

.footer-p2-subtitle {
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
}

/* --- Estilo do Carimbo --- */
.stamp-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 80px;
    position: relative;
    min-width: 0;
    width: 100%;
}

.visual-stamp {
    border: 2px solid #4E308C;
    padding: 6px 10px;
    border-radius: 5px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    pointer-events: none;
    background: rgba(78, 48, 140, 0.03);
    box-shadow: 0 0 1px rgba(78, 48, 140, 0.2);
    text-align: center;
    max-width: 95%;
    /* Prevent expanding beyond container */
    width: 95%;
    /* Force a predictable width for text truncation */
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.visual-stamp.active {
    display: flex !important;
}

.stamp-name {
    font-weight: 800;
    font-size: 11px;
    /* Reduced to avoid expanding */
    color: #4E308C;
    text-transform: none;
    line-height: 1.1;
    margin-bottom: 2px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    width: 100%;
}

.stamp-cro {
    font-weight: 700;
    font-size: 9.5px;
    color: #4E308C;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    width: 100%;
}