/* =========================================================
   EMPÓRIO MILENAR — SISTEMA DE PRESCRITORES
   Arquivo: assets/css/style.css
   Versão organizada e corrigida
   ========================================================= */


/* =========================================================
   1. VARIÁVEIS GERAIS
   ========================================================= */

:root {
    --blue: #1d9dbc;
    --blue-dark: #075a78;
    --blue-soft: #e9f7fb;

    --text: #153241;
    --muted: #6f8190;
    --line: #dbe7ec;
    --bg: #f4f9fb;
    --white: #ffffff;
    --danger: #b42318;

    --shadow-soft: 0 12px 36px rgba(6, 60, 82, .06);
    --shadow-rx: 0 18px 50px rgba(5, 58, 79, .18);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 22px;
}


/* =========================================================
   2. RESET / BASE
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    background: var(--white);
    color: var(--text);
}

textarea {
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 800;
    color: #315160;
    font-size: 13px;
}


/* =========================================================
   3. LAYOUT GERAL
   ========================================================= */

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
}

.main {
    padding: 28px 0 48px;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    font-weight: 800;
    color: var(--blue-dark);
    font-size: 20px;
}

.brand span {
    color: var(--blue);
}

.nav {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.nav a {
    font-weight: 700;
    color: #315160;
    font-size: 14px;
}

.site-footer {
    border-top: 1px solid var(--line);
    padding: 22px 0;
    color: var(--muted);
    font-size: 13px;
    background: var(--white);
}


/* =========================================================
   4. TÍTULOS, BOTÕES E AÇÕES
   ========================================================= */

.page-title {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin: 0 0 24px;
}

.page-title h1 {
    margin: 0 0 6px;
    font-size: 30px;
}

.page-title p {
    margin: 0;
    color: var(--muted);
    max-width: 760px;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    font-weight: 800;
    cursor: pointer;
    background: var(--white);
    color: var(--blue-dark);
    font-size: 14px;
    line-height: 1.2;
}

.btn.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--white);
}

.btn.secondary {
    background: var(--white);
}

.btn.small {
    padding: 7px 10px;
    font-size: 12px;
}

.btn.large {
    padding: 14px 22px;
    font-size: 16px;
}


/* =========================================================
   5. PAINÉIS, CARDS E FORMULÁRIOS
   ========================================================= */

.panel,
.kit-card,
.login-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 24px;
}

.form {
    display: grid;
    gap: 22px;
}

.form-section {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 18px;
    background: var(--white);
}

.form-section h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 14px;
}

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

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

.span-2 {
    grid-column: span 2;
}

.full {
    grid-column: 1 / -1;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-line input {
    width: 18px;
    height: 18px;
}

.muted {
    color: var(--muted);
}

.tag {
    display: inline-block;
    align-self: flex-start;
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-size: 12px;
    font-weight: 900;
    padding: 6px 10px;
    border-radius: 999px;
}


/* =========================================================
   6. ALERTAS
   ========================================================= */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-weight: 700;
}

.alert.error {
    background: #fff1f0;
    color: var(--danger);
    border: 1px solid #ffd2ce;
}

.alert.info {
    background: #eef9fc;
    color: var(--blue-dark);
    border: 1px solid #ccebf3;
}

.small-alert {
    font-size: 13px;
    margin: 0;
}


/* =========================================================
   7. LOGIN
   ========================================================= */

.login-wrap {
    min-height: 65vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: min(440px, 100%);
}

.login-card h1 {
    margin: 0 0 6px;
    color: var(--blue-dark);
}

.login-card p {
    margin: 0 0 20px;
    color: var(--muted);
}

.whatsapp-check-actions {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.whatsapp-confirm {
    align-items: flex-start;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.35;
}

.whatsapp-confirm span {
    color: #315160;
}


/* =========================================================
   8. TABELAS
   ========================================================= */

.table-wrap {
    overflow: auto;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 14px;
}

th {
    background: #f6fbfd;
    color: var(--blue-dark);
    font-weight: 900;
}


/* =========================================================
   9. CARDS DOS KITS
   ========================================================= */

.kit-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.kit-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kit-card h2 {
    margin: 0;
    font-size: 20px;
}

.kit-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
    flex: 1;
}

.kit-card-products {
    display: grid;
    gap: 10px;
    margin: 4px 0 6px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fcfd;
}

.kit-card-products-title {
    font-size: 12px;
    font-weight: 900;
    color: var(--blue-dark);
    text-transform: uppercase;
    letter-spacing: .07em;
}

.kit-card-product-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
}

.kit-card-product-row:first-of-type {
    border-top: none;
    padding-top: 0;
}

.kit-card-product-text {
    min-width: 0;
}

.kit-card-product-text strong {
    display: block;
    font-size: 11px;
    line-height: 1.2;
    color: var(--blue-dark);
    text-transform: uppercase;
    letter-spacing: .05em;
}

.kit-card-product-text span {
    display: block;
    margin-top: 3px;
    font-weight: 800;
    font-size: 13px;
    line-height: 1.3;
    color: var(--text);
}

.kit-product-info-btn {
    white-space: nowrap;
    padding: 7px 9px;
}

.kit-card-main-action {
    margin-top: auto;
}


/* =========================================================
   10. SELEÇÃO DE PRODUTOS NA PRESCRIÇÃO
   ========================================================= */

.product-selector-list {
    display: grid;
    gap: 14px;
}

.product-selector {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
    background: #f9fcfd;
}

.product-selector-title strong {
    display: block;
    color: var(--blue-dark);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.product-selector-title h3 {
    margin: 4px 0 12px;
    font-size: 18px;
}

.product-selector-title-with-action {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.product-selector-title-with-action .btn {
    flex: 0 0 auto;
    margin-top: 2px;
}


/* =========================================================
   11. TELA DE DADOS DO PRODUTO
   ========================================================= */

.product-info-page {
    display: grid;
    gap: 22px;
}

.product-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 18px;
}

.product-info-header h2 {
    margin: 10px 0 0;
    font-size: 28px;
    color: var(--blue-dark);
}

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

.info-box {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #f9fcfd;
    padding: 18px;
}

.info-box h3 {
    margin: 0 0 10px;
    color: var(--blue-dark);
    font-size: 17px;
}

.info-box p {
    margin: 0;
    color: var(--text);
    line-height: 1.6;
}


/* =========================================================
   12. ADMIN — EDIÇÃO FLEXÍVEL DE COMPONENTES DO KIT
   ========================================================= */

.section-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-top: 8px;
}

.section-heading-row h2 {
    margin: 0 0 6px;
}

.section-heading-row p {
    margin: 0;
    max-width: 760px;
}

.admin-components-list {
    display: grid;
    gap: 18px;
}

.component-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.component-toolbar h3 {
    margin: 0;
    color: var(--blue-dark);
}

.admin-product-editor {
    background: #fbfdfe;
    border: 1px solid var(--line);
}

.admin-product-editor h3 {
    margin: 0 0 12px;
    color: var(--blue-dark);
}

.compact-form {
    margin-bottom: 18px;
}

.form-actions-bottom {
    display: flex;
    gap: 10px;
    align-items: end;
    padding-top: 23px;
}


/* =========================================================
   13. MODELO DE PRESCRIÇÃO — TELA
   Layout inspirado no modelo enviado
   ========================================================= */

.rx-sheet {
    width: 210mm;
    min-height: 297mm;
    max-width: 100%;
    margin: 0 auto 40px;
    padding: 0 18mm 18mm;
    background: var(--white);
    color: #0c5977;
    box-shadow: var(--shadow-rx);
    position: relative;
    overflow: hidden;
    font-family: "Trebuchet MS", Arial, sans-serif;
    display: flex;
    flex-direction: column;
}

.rx-header {
    height: 42mm;
    padding-top: 8mm;
    margin: 0 -18mm;
    background: var(--white);
}

.rx-brand-band {
    height: 25mm;
    width: 152mm;
    background: linear-gradient(90deg, #1aa0c3, #cbeef4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 14mm;
    padding-right: 8mm;
    color: var(--white);

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

.rx-doctor-name {
    font-size: 25px;
    line-height: 1.08;
    font-weight: 900;
    letter-spacing: .02em;
    margin-bottom: 1.8mm;
}

.rx-doctor-meta {
    font-size: 13px;
    line-height: 1.25;
    color: #eefbff;
    font-weight: 800;
    letter-spacing: .06em;
}

.rx-doctor-specialty {
    margin-top: .8mm;
    font-size: 12px;
    line-height: 1.25;
    color: #eefbff;
    font-weight: 700;
    letter-spacing: .03em;
}

.rx-doctor-meta span {
    opacity: .75;
    padding: 0 5px;
}

.rx-qualification {
    display: none !important;
}

.rx-stripes {
    display: flex;
    gap: 4mm;
    transform: skew(28deg);
}

.rx-stripes span {
    display: block;
    width: 5mm;
    height: 25mm;
    background: rgba(255, 255, 255, .85);

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

.rx-stripes span:nth-child(3) {
    background: #e6e6e6;
}


/* =========================================================
   14. PRESCRIÇÃO — DADOS DO PACIENTE
   ========================================================= */

.rx-patient-clean {
    display: grid;
    grid-template-columns: 1fr 42mm;
    gap: 7mm 7mm;
    margin-top: 1mm;
    font-size: 14px;
}

.rx-patient-clean .rx-field {
    display: flex;
    align-items: flex-end;
    gap: 3mm;
    border-bottom: 1px solid #1b6b89;
    min-height: 8mm;
}

.rx-patient-clean .rx-field span {
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: .04em;
}

.rx-patient-clean .rx-field strong {
    font-weight: 600;
    color: #1c4353;
    min-height: 5mm;
}

.rx-patient-clean .rx-field.full {
    grid-column: 1 / -1;
}

.rx-patient-clean .rx-field.large {
    grid-column: auto;
}

.rx-patient-clean .rx-field.date {
    grid-column: auto;
}


/* Campos antigos removidos visualmente */
.rx-patient-grid,
.rx-symbol,
.rx-qualification {
    display: none !important;
}


/* =========================================================
   15. PRESCRIÇÃO — CORPO
   ========================================================= */

.rx-watermark {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 150mm;
    line-height: 1;
    color: rgba(29, 157, 188, .04);
    z-index: 0;
    pointer-events: none;
}

.rx-body {
    position: relative;
    z-index: 1;
    flex: 1;
    margin-top: 16mm;
    color: #111;
}

.rx-body.clean {
    margin-top: 28mm;
}

.rx-use-title {
    font-size: 18px;
    font-weight: 900;
    color: #0d5a7b;
    margin-bottom: 9mm;
}

.rx-item {
    margin-bottom: 10mm;
    page-break-inside: avoid;
}

.rx-product-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
    gap: 6px;
    font-size: 18px;
}

.rx-product-row strong {
    font-weight: 900;
    max-width: 122mm;
}

.rx-product-row span {
    border-bottom: 1px dashed #333;
    transform: translateY(-3px);
}

.rx-product-row em {
    font-style: normal;
    font-weight: 900;
    white-space: nowrap;
}

.rx-dosage {
    margin-top: 5mm;
    margin-left: 0;
    font-size: 17px;
    line-height: 1.55;
    color: #111;
}

.rx-date {
    text-align: center;
    font-size: 18px;
    color: #111;
    margin: 12mm 0 17mm;
}


/* =========================================================
   16. PRESCRIÇÃO — ASSINATURA E RODAPÉ
   ========================================================= */

.rx-signature {
    text-align: center;
    color: #111;
    margin-bottom: 13mm;
}

.rx-sign-line {
    width: 70mm;
    border-bottom: 1px solid #0d5a7b;
    margin: 0 auto 3mm;
}

.rx-signature strong {
    display: block;
    font-size: 16px;
    text-decoration: underline;
    font-style: italic;
}

.rx-signature span {
    display: block;
    font-size: 15px;
    margin-top: 1mm;
}

.rx-footer {
    height: 22mm;
    margin: 0 -18mm -18mm;
    background: #f7f7f7;
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 52mm;

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

.footer-stripes {
    position: absolute;
    left: 14mm;
    bottom: 0;
    display: flex;
    gap: 3mm;
    transform: skew(28deg);
}

.footer-stripes span {
    display: block;
    width: 5mm;
    height: 22mm;
    background: #dddddd;

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

.rx-footer-info {
    display: flex;
    gap: 18mm;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding-right: 14mm;
    color: #0d5a7b;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .03em;
}

.rx-footer-info span:first-child::before {
    content: '📍 ';
}

.rx-footer-info span:last-child::before {
    content: '☎ ';
}


/* =========================================================
   17. RESPONSIVO
   ========================================================= */

@media (max-width: 900px) {
    .kit-grid,
    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .page-title {
        flex-direction: column;
    }

    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        gap: 10px;
    }

    .product-selector-title-with-action,
    .product-info-header,
    .section-heading-row,
    .component-toolbar {
        flex-direction: column;
    }

    .product-info-grid {
        grid-template-columns: 1fr;
    }

    .form-actions-bottom {
        padding-top: 0;
    }

    .rx-sheet {
        transform-origin: top left;
        overflow: auto;
    }
}

@media (max-width: 720px) {
    .kit-card-product-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .kit-product-info-btn {
        justify-self: start;
    }
}


/* =========================================================
   18. IMPRESSÃO — PRESCRIÇÃO A4
   Importante:
   - O CSS força cores de fundo.
   - No Chrome/Edge, também marque "Gráficos de segundo plano".
   ========================================================= */

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    html,
    body {
        width: 210mm;
        min-height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body * {
        visibility: hidden !important;
    }

    .rx-sheet,
    .rx-sheet * {
        visibility: visible !important;
    }

    .rx-sheet {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        min-height: 297mm !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 18mm 18mm !important;
        box-shadow: none !important;
        border: none !important;
        transform: none !important;
        background: #ffffff !important;
        overflow: hidden !important;
    }

    .rx-header {
        height: 42mm !important;
        padding-top: 8mm !important;
        margin: 0 -18mm !important;
        background: #ffffff !important;
    }

    .rx-brand-band {
        height: 25mm !important;
        width: 152mm !important;
        background: linear-gradient(90deg, #1aa0c3, #cbeef4) !important;
        color: #ffffff !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding-left: 14mm !important;
        padding-right: 8mm !important;

        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-stripes span {
        background: rgba(255, 255, 255, .85) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-stripes span:nth-child(3) {
        background: #e6e6e6 !important;
    }

    .rx-footer {
        background: #f7f7f7 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .footer-stripes span {
        background: #dddddd !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-patient-clean {
        display: grid !important;
        grid-template-columns: 1fr 42mm !important;
        gap: 7mm 7mm !important;
        margin-top: 1mm !important;
    }

    .rx-body.clean {
        margin-top: 28mm !important;
    }

    .rx-item {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .rx-symbol,
    .rx-qualification,
    .rx-patient-grid {
        display: none !important;
        visibility: hidden !important;
    }

    .no-print,
    .topbar,
    .site-footer,
    .page-title,
    .actions,
    nav {
        display: none !important;
        visibility: hidden !important;
    }

    .main,
    .container {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }
}
/* =========================================================
   V11 - Correção de impressão do cabeçalho colorido
   Mantém a faixa azul e os elementos gráficos no modo impressão.
   No Chrome/Edge, também marcar "Gráficos de segundo plano".
   ========================================================= */

.rx-brand-band,
.rx-stripes span,
.rx-footer,
.footer-stripes span {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-brand-band {
        background: linear-gradient(90deg, #1aa0c3, #cbeef4) !important;
        color: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-stripes span {
        background: rgba(255,255,255,.85) !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .rx-stripes span:nth-child(3) {
        background: #e6e6e6 !important;
    }

    .rx-footer {
        background: #f7f7f7 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .footer-stripes span {
        background: #dddddd !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* =========================================================
   V20 - Remodelagem Empório Milenar
   ========================================================= */

:root {
    --blue: #0f8fb0;
    --blue-dark: #06465b;
    --blue-soft: #e9f8fb;
    --green: #34856f;
    --green-soft: #edf8f3;
    --gold: #b98b2f;
    --gold-soft: #fff7e4;
    --ink: #153241;
    --text: #1d3440;
    --muted: #6b7d88;
    --line: #dbe7ec;
    --line-strong: #c6d8df;
    --bg: #f5f8f7;
    --white: #ffffff;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --shadow-soft: 0 14px 34px rgba(8, 58, 73, .08);
    --shadow-lift: 0 22px 46px rgba(8, 58, 73, .13);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
}

body {
    background:
        radial-gradient(circle at top left, rgba(15, 143, 176, .09), transparent 32rem),
        linear-gradient(180deg, #f9fbfa 0%, var(--bg) 40%, #eef5f4 100%);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1240px;
}

.main {
    padding: 30px 0 56px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid rgba(198, 216, 223, .85);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    max-width: 1240px;
    min-height: 72px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 218px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    color: #fff;
    font-size: 13px;
    letter-spacing: .04em;
    box-shadow: 0 12px 22px rgba(15, 143, 176, .22);
}

.brand-copy {
    display: grid;
    gap: 1px;
    line-height: 1.1;
}

.brand-copy strong {
    color: var(--blue-dark);
    font-size: 17px;
}

.brand-copy small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav {
    flex: 1;
    gap: 6px;
    justify-content: center;
}

.nav a {
    border-radius: 999px;
    color: #395864;
    font-size: 13px;
    padding: 9px 12px;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.nav a:hover,
.nav a.active {
    background: var(--blue-soft);
    color: var(--blue-dark);
    box-shadow: inset 0 0 0 1px #c9ecf3;
}

.user-menu {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.user-menu span {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu a {
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--blue-dark);
    padding: 8px 11px;
    background: #fff;
}

.page-title {
    align-items: center;
    background: rgba(255, 255, 255, .74);
    border: 1px solid rgba(219, 231, 236, .9);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 22px;
    padding: 22px;
}

.page-title h1 {
    color: var(--ink);
    font-size: 28px;
    letter-spacing: 0;
}

.page-title p {
    color: var(--muted);
    line-height: 1.55;
}

.btn {
    border-radius: 10px;
    min-height: 40px;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(8, 58, 73, .09);
}

.btn.primary {
    background: linear-gradient(135deg, var(--blue-dark), var(--blue));
    border-color: var(--blue);
}

.btn.secondary {
    background: #fff;
    border-color: var(--line-strong);
}

.panel,
.kit-card,
.login-card,
.table-wrap {
    border-color: rgba(198, 216, 223, .9);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.form-section {
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #fff 0%, #fbfdfc 100%);
}

.form-section h2 {
    color: var(--blue-dark);
    font-size: 18px;
}

input,
textarea,
select {
    border-color: #cfdfe5;
    border-radius: 10px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(15, 143, 176, .12);
    outline: none;
}

.tag {
    border: 1px solid #c8e9ee;
    border-radius: 999px;
}

.alert {
    border-radius: 12px;
}

.alert.success {
    background: var(--green-soft);
    border: 1px solid #c6e8d9;
    color: #17604b;
}

.login-wrap {
    min-height: calc(100vh - 174px);
}

.login-card {
    width: min(460px, 100%);
    padding: 30px;
}

.login-card h1 {
    font-size: 28px;
}

.compact-login-card {
    box-shadow: none;
    margin-top: 12px;
    padding: 0;
}

.compact-login-card .btn {
    width: 100%;
}

.whatsapp-check-actions {
    grid-template-columns: 1fr;
}

.kit-grid {
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 18px;
}

.overview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.overview-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    display: grid;
    gap: 6px;
    padding: 18px;
}

.overview-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.overview-card strong {
    color: var(--blue-dark);
    font-size: 24px;
    line-height: 1.2;
}

.category-filter {
    display: flex;
    gap: 8px;
    margin: 0 0 18px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.category-filter button {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: #395864;
    cursor: pointer;
    font-size: 13px;
    font-weight: 900;
    padding: 9px 12px;
    white-space: nowrap;
}

.category-filter button.active {
    background: var(--blue-dark);
    border-color: var(--blue-dark);
    color: #fff;
}

.category-filter span {
    opacity: .72;
}

.status-pill {
    display: inline-flex !important;
    align-items: center;
    border-radius: 999px;
    font-size: 11px !important;
    font-weight: 900 !important;
    margin-top: 7px !important;
    padding: 4px 8px;
}

.status-pill.danger {
    background: #fee2e2;
    color: #991b1b !important;
}

.status-pill.warning {
    background: var(--gold-soft);
    color: #8a5a08 !important;
}

.kit-card {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    overflow: hidden;
    position: relative;
}

.kit-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--blue), var(--green), var(--gold));
}

.kit-card h2 {
    color: var(--ink);
    font-size: 21px;
    line-height: 1.2;
}

.kit-card p {
    line-height: 1.55;
}

.kit-card-products {
    background: #f7fbfb;
    border-color: #d7e8ed;
    border-radius: 14px;
}

.kit-card-products-title {
    color: var(--blue-dark);
    letter-spacing: .06em;
}

.kit-card-product-row {
    gap: 12px;
}

.kit-card-product-text strong {
    color: var(--green);
}

.kit-card-main-action {
    margin-top: auto;
}

.product-selector-list {
    gap: 16px;
}

.product-selector {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(8, 58, 73, .05);
}

.product-selector-title h3 {
    color: var(--ink);
}

.product-unavailable {
    border-color: #f3b9b5 !important;
    background: #fff8f7 !important;
}

.substitute-box,
.substitute-item {
    border-radius: 14px !important;
}

.product-info-grid {
    gap: 16px;
}

.info-box {
    border-radius: 14px;
    background: #fbfdfc;
}

.info-box h3 {
    color: var(--blue-dark);
}

.table-wrap {
    overflow: hidden;
}

.table-wrap table {
    min-width: 760px;
}

th {
    background: #eef8fa;
    color: var(--blue-dark);
    font-size: 12px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

td {
    background: rgba(255, 255, 255, .74);
    color: #294753;
}

tbody tr:hover td {
    background: #f8fcfd;
}

.site-footer {
    background: rgba(255,255,255,.8);
}

.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-footer strong {
    color: var(--blue-dark);
}

.rx-sheet {
    border-radius: 10px;
    box-shadow: var(--shadow-lift);
}

.rx-brand-band {
    background: linear-gradient(100deg, var(--blue-dark), var(--blue)) !important;
}

.rx-product-row strong {
    color: var(--ink);
}

@media (max-width: 980px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .brand {
        min-width: 0;
    }

    .nav {
        justify-content: flex-start;
        width: 100%;
    }

    .user-menu {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 14px;
    }

    .page-title {
        align-items: flex-start;
        flex-direction: column;
        padding: 18px;
    }

    .page-title h1 {
        font-size: 24px;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 22px;
    }

    .kit-grid {
        grid-template-columns: 1fr;
    }

    .overview-grid {
        grid-template-columns: 1fr;
    }

    .site-footer .container {
        align-items: flex-start;
        flex-direction: column;
    }
}


/* =========================================================
   V21 - Correção final da prescrição em uma página
   Projeto exclusivo: emporiomilenar.org
   - Remove excesso vertical na impressão.
   - Evita segunda página em prescrições usuais.
   - Mantém a prescrição dentro da área A4.
   ========================================================= */

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

    html,
    body {
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
        max-height: 297mm !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #ffffff !important;
    }

    .rx-sheet {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
        max-height: 297mm !important;
        margin: 0 !important;
        padding: 0 14mm 12mm !important;
        box-shadow: none !important;
        border: 0 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        break-after: avoid-page !important;
        break-before: avoid-page !important;
    }

    .rx-header {
        height: 32mm !important;
        min-height: 32mm !important;
        padding-top: 5mm !important;
        margin: 0 -14mm !important;
        flex: 0 0 auto !important;
    }

    .rx-brand-band {
        height: 21mm !important;
        width: 148mm !important;
        padding-left: 11mm !important;
        padding-right: 7mm !important;
    }

    .rx-doctor-name {
        font-size: 20px !important;
        line-height: 1.05 !important;
        margin-bottom: 1mm !important;
    }

    .rx-doctor-meta {
        font-size: 11px !important;
        line-height: 1.15 !important;
    }

    .rx-doctor-specialty {
        margin-top: .5mm !important;
        font-size: 10.5px !important;
        line-height: 1.15 !important;
    }

    .rx-stripes span {
        width: 4mm !important;
        height: 21mm !important;
    }

    .rx-patient-clean {
        grid-template-columns: 1fr 36mm !important;
        gap: 4mm 6mm !important;
        margin-top: 0 !important;
        font-size: 12px !important;
        flex: 0 0 auto !important;
    }

    .rx-patient-clean .rx-field {
        min-height: 6mm !important;
    }

    .rx-patient-clean .rx-field strong {
        min-height: 4mm !important;
    }

    .rx-body.clean,
    .rx-body {
        margin-top: 13mm !important;
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .rx-use-title {
        font-size: 15px !important;
        margin-bottom: 5mm !important;
    }

    .rx-item {
        margin-bottom: 5mm !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .rx-product-row {
        font-size: 14px !important;
        gap: 4px !important;
    }

    .rx-product-row strong {
        max-width: 130mm !important;
    }

    .rx-dosage {
        margin-top: 2mm !important;
        font-size: 12.5px !important;
        line-height: 1.28 !important;
    }

    .rx-date {
        flex: 0 0 auto !important;
        font-size: 13px !important;
        margin: 5mm 0 7mm !important;
    }

    .rx-signature {
        flex: 0 0 auto !important;
        margin-bottom: 6mm !important;
    }

    .rx-sign-line {
        width: 58mm !important;
        margin-bottom: 2mm !important;
    }

    .rx-signature strong {
        font-size: 13px !important;
    }

    .rx-signature span {
        font-size: 12px !important;
        margin-top: 0.5mm !important;
    }

    .rx-footer {
        height: 15mm !important;
        min-height: 15mm !important;
        margin: 0 -14mm -12mm !important;
        padding-left: 42mm !important;
        flex: 0 0 auto !important;
    }

    .footer-stripes {
        left: 11mm !important;
        gap: 2mm !important;
    }

    .footer-stripes span {
        width: 4mm !important;
        height: 15mm !important;
    }

    .rx-footer-info {
        gap: 8mm !important;
        padding-right: 10mm !important;
        font-size: 10px !important;
        line-height: 1.2 !important;
    }

    .rx-watermark {
        font-size: 115mm !important;
    }
}

.status-pill.success {
    background: #e7f6ee;
    color: #116138 !important;
}

.kit-auto-substitute-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: #244250;
}

.kit-auto-substitute-line small {
    color: #5f7380;
    font-weight: 700;
    margin-left: 4px;
}

.kit-auto-substitute-line.no-substitute {
    color: #8a5a08;
}

.kit-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Dashboard: quando houver substituição automática, mostra apenas o substituto no card do kit. */
.kit-card-product-row-substituted {
    background: rgba(17, 97, 56, .045);
    border-radius: 12px;
    padding-left: 8px;
    padding-right: 8px;
}

/* Menu administrativo organizado por categorias */
.nav-categorized {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.nav-group {
    position: relative;
}

.nav-group summary {
    align-items: center;
    background: #fff;
    border: 1px solid rgba(198, 216, 223, .9);
    border-radius: 999px;
    color: #395864;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 800;
    gap: 6px;
    list-style: none;
    padding: 9px 13px;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease, border-color .15s ease;
    user-select: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    content: "▾";
    font-size: 10px;
    line-height: 1;
    opacity: .7;
}

.nav-group.active summary,
.nav-group[open] summary,
.nav-group summary:hover {
    background: var(--blue-soft);
    border-color: #c9ecf3;
    color: var(--blue-dark);
    box-shadow: inset 0 0 0 1px #c9ecf3;
}

.nav-dropdown {
    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(198, 216, 223, .92);
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(8, 58, 73, .16);
    display: grid;
    gap: 4px;
    left: 0;
    min-width: 230px;
    padding: 8px;
    position: absolute;
    top: calc(100% + 8px);
    z-index: 80;
}

.nav-dropdown a {
    border-radius: 12px;
    color: #395864;
    display: block;
    font-size: 13px;
    font-weight: 800;
    padding: 10px 12px;
    white-space: nowrap;
}

.nav-dropdown a:hover,
.nav-dropdown a.active {
    background: var(--blue-soft);
    color: var(--blue-dark);
    box-shadow: none;
}

@media (max-width: 980px) {
    .nav-categorized {
        justify-content: flex-start;
    }

    .nav-group {
        width: auto;
    }

    .nav-dropdown {
        left: 0;
        max-width: calc(100vw - 32px);
    }
}

@media (max-width: 720px) {
    .nav-categorized {
        align-items: stretch;
        flex-direction: column;
    }

    .nav-group summary {
        justify-content: space-between;
        width: 100%;
    }

    .nav-dropdown {
        margin-top: 8px;
        position: static;
        width: 100%;
    }

    .nav-dropdown a {
        white-space: normal;
    }
}


/* =========================================================
   V22 - Ajuste cabeçalho/rodapé da prescrição
   - Centraliza nome, CRM e especialidade no cabeçalho.
   - Permite quebra de linha no endereço e WhatsApp/telefone do rodapé.
   - Usa melhor a largura útil da área impressa, sem cortar texto.
   ========================================================= */

.rx-brand-band > div:first-child {
    flex: 1 1 auto;
    text-align: center;
    min-width: 0;
}

.rx-doctor-name,
.rx-doctor-meta,
.rx-doctor-specialty {
    text-align: center;
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

.rx-footer {
    height: auto;
    min-height: 24mm;
    padding: 4mm 12mm 4mm 42mm;
    align-items: center;
}

.rx-footer-info {
    display: block;
    width: 100%;
    max-width: 100%;
    padding-right: 0;
    text-align: center;
    font-size: 12px;
    line-height: 1.35;
    letter-spacing: .01em;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.rx-footer-info span {
    display: block;
    width: 100%;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.rx-footer-info span + span {
    margin-top: 1.4mm;
}

@media print {
    .rx-brand-band > div:first-child {
        flex: 1 1 auto !important;
        text-align: center !important;
        min-width: 0 !important;
    }

    .rx-doctor-name,
    .rx-doctor-meta,
    .rx-doctor-specialty {
        text-align: center !important;
        width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    .rx-sheet {
        padding-bottom: 13mm !important;
    }

    .rx-body.clean,
    .rx-body {
        margin-top: 10mm !important;
    }

    .rx-footer {
        height: auto !important;
        min-height: 22mm !important;
        margin: 0 -14mm -13mm !important;
        padding: 3mm 10mm 3mm 36mm !important;
        align-items: center !important;
    }

    .footer-stripes span {
        height: 22mm !important;
    }

    .rx-footer-info {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding-right: 0 !important;
        text-align: center !important;
        font-size: 10.2px !important;
        line-height: 1.25 !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
    }

    .rx-footer-info span {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: normal !important;
    }

    .rx-footer-info span + span {
        margin-top: .8mm !important;
    }
}


/* =========================================================
   V23 - Receituário: cabeçalho centralizado e rodapé sem corte
   ========================================================= */
.rx-sheet .rx-brand-band { position: relative !important; justify-content: center !important; }
.rx-sheet .rx-header-text { width: 100% !important; max-width: 100% !important; min-width: 0 !important; text-align: center !important; padding: 0 4mm !important; box-sizing: border-box !important; z-index: 2 !important; }
.rx-sheet .rx-doctor-name, .rx-sheet .rx-doctor-meta, .rx-sheet .rx-doctor-specialty { display: block !important; width: 100% !important; text-align: center !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; }
.rx-sheet .rx-doctor-specialty { margin-top: 1.2mm !important; font-size: 12px !important; line-height: 1.2 !important; color: #eefbff !important; font-weight: 800 !important; letter-spacing: .04em !important; }
.rx-sheet .rx-stripes { position: absolute !important; right: 8mm !important; top: 0 !important; height: 25mm !important; z-index: 1 !important; pointer-events: none !important; }
.rx-sheet .rx-footer { height: auto !important; min-height: 24mm !important; margin-left: -18mm !important; margin-right: -18mm !important; margin-bottom: -18mm !important; padding: 4mm 8mm !important; box-sizing: border-box !important; align-items: center !important; justify-content: center !important; }
.rx-sheet .footer-stripes { display: none !important; }
.rx-sheet .rx-footer-info { display: block !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; margin: 0 !important; text-align: center !important; font-size: 12px !important; line-height: 1.35 !important; letter-spacing: 0 !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; }
.rx-sheet .rx-footer-info span { display: block !important; width: 100% !important; max-width: 100% !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; }
.rx-sheet .rx-footer-info span + span { margin-top: 1.2mm !important; }
@media print {
    .rx-sheet { padding-bottom: 14mm !important; overflow: hidden !important; }
    .rx-sheet .rx-brand-band { position: relative !important; justify-content: center !important; }
    .rx-sheet .rx-header-text { width: 100% !important; max-width: 100% !important; text-align: center !important; padding: 0 4mm !important; box-sizing: border-box !important; }
    .rx-sheet .rx-doctor-name, .rx-sheet .rx-doctor-meta, .rx-sheet .rx-doctor-specialty { text-align: center !important; width: 100% !important; white-space: normal !important; overflow-wrap: anywhere !important; }
    .rx-sheet .rx-doctor-specialty { font-size: 11px !important; line-height: 1.15 !important; margin-top: .8mm !important; color: #eefbff !important; }
    .rx-sheet .rx-stripes { position: absolute !important; right: 7mm !important; top: 0 !important; height: 21mm !important; }
    .rx-sheet .rx-footer { height: auto !important; min-height: 24mm !important; margin: 0 -14mm -14mm !important; padding: 3mm 7mm !important; box-sizing: border-box !important; align-items: center !important; justify-content: center !important; }
    .rx-sheet .footer-stripes { display: none !important; }
    .rx-sheet .rx-footer-info { display: block !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; margin: 0 !important; text-align: center !important; font-size: 9.6px !important; line-height: 1.22 !important; letter-spacing: 0 !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; }
    .rx-sheet .rx-footer-info span { display: block !important; width: 100% !important; max-width: 100% !important; white-space: normal !important; overflow-wrap: anywhere !important; word-break: normal !important; }
    .rx-sheet .rx-footer-info span + span { margin-top: .7mm !important; }
}

/* =========================================================
   BOTÃO GLOBAL VOLTAR — TODAS AS PÁGINAS COM render_header()
   ========================================================= */
.global-back-bar {
    background: rgba(244, 249, 251, .92);
    border-bottom: 1px solid var(--line);
}

.global-back-inner {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-top: 10px;
    padding-bottom: 10px;
}

.global-back-btn {
    appearance: none;
    border: 1px solid #c9dce5;
    background: #ffffff;
    color: var(--blue-dark);
    border-radius: 999px;
    padding: 9px 16px;
    font-weight: 800;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(6, 60, 82, .07);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}

.global-back-btn:hover,
.global-back-btn:focus {
    background: var(--blue-soft);
    border-color: #9ecedc;
    box-shadow: 0 12px 26px rgba(6, 60, 82, .10);
    outline: none;
    transform: translateY(-1px);
}

@media print {
    .global-back-bar {
        display: none !important;
    }
}
