/* ===== DESIGN SYSTEM — Colors from Logo ===== */
:root {
    --navy-900: #0f1a2e;
    --navy-800: #162242;
    --navy-700: #1c2d54;
    --navy-600: #243766;
    --navy-500: #2e4578;
    --gold-500: #c9a84c;
    --gold-400: #d4b85e;
    --gold-300: #e0c976;
    --gold-200: #ebd99a;
    --gold-100: #f5ecc8;
    --white: #ffffff;
    --gray-50: #f8f9fb;
    --gray-100: #f1f3f7;
    --gray-200: #e2e6ee;
    --gray-300: #cdd3df;
    --gray-400: #9aa3b5;
    --gray-500: #6b7689;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --red-500: #e53e3e;
    --green-500: #38a169;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(15,26,46,0.08);
    --shadow-md: 0 4px 12px rgba(15,26,46,0.1);
    --shadow-lg: 0 8px 30px rgba(15,26,46,0.12);
    --shadow-xl: 0 20px 60px rgba(15,26,46,0.15);
    --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
    --sidebar-width: 260px;
    --font-display: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-700);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(175deg, var(--navy-800) 0%, var(--navy-900) 100%);
    display: flex; flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(15,26,46,0.2);
    transition: transform var(--transition);
}
.sidebar-header {
    padding: 28px 24px 20px;
    display: flex; align-items: center; gap: 14px;
    border-bottom: 1px solid rgba(201,168,76,0.15);
}
.sidebar-logo {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.sidebar-title {
    font-family: var(--font-display);
    font-size: 1.15rem; font-weight: 600;
    color: var(--white); line-height: 1.3;
}
.sidebar-title span { color: var(--gold-400); font-weight: 500; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 12px 16px;
    background: transparent; border: none;
    color: var(--gray-300); font-size: 0.9rem; font-weight: 500;
    border-radius: var(--radius-md); cursor: pointer;
    transition: all var(--transition); text-align: left;
    font-family: var(--font-body);
}
.nav-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-btn:hover { background: rgba(201,168,76,0.1); color: var(--gold-300); }
.nav-btn.active {
    background: linear-gradient(135deg, rgba(201,168,76,0.2), rgba(201,168,76,0.08));
    color: var(--gold-400); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--gold-500);
}
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(201,168,76,0.12);
}
.legal-ref { font-size: 0.72rem; color: var(--gray-400); text-align: center; opacity: 0.7; }

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    height: 60px; background: var(--navy-800);
    align-items: center; padding: 0 16px; gap: 12px; z-index: 99;
    box-shadow: 0 2px 10px rgba(15,26,46,0.2);
}
.mobile-logo { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; }
.mobile-title { font-family: var(--font-display); font-size: 1.1rem; color: var(--gold-400); font-weight: 600; }
.menu-toggle {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; gap: 5px; padding: 4px;
}
.menu-toggle span {
    display: block; width: 22px; height: 2px;
    background: var(--gold-400); border-radius: 2px;
    transition: var(--transition);
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,26,46,0.6); z-index: 99;
    backdrop-filter: blur(2px);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1; padding: 32px 40px;
    min-height: 100vh; width: calc(100% - var(--sidebar-width));
}
.form-section { display: none; animation: fadeIn 0.4s ease; }
.form-section.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== SECTION HEADER ===== */
.section-header {
    display: flex; align-items: center; gap: 16px; margin-bottom: 28px;
}
.section-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--navy-700), var(--navy-800));
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-md);
}
.section-icon svg { width: 26px; height: 26px; stroke: var(--gold-400); }
.section-title {
    font-family: var(--font-display); font-size: 1.6rem;
    color: var(--navy-800); font-weight: 700;
}
.section-subtitle { font-size: 0.88rem; color: var(--gray-500); margin-top: 2px; }

/* ===== FORM CARDS ===== */
.form-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 28px 32px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 20px;
    transition: box-shadow var(--transition);
}
.form-card:hover { box-shadow: var(--shadow-md); }
.card-title {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-size: 1.1rem;
    color: var(--navy-700); margin-bottom: 20px; font-weight: 600;
}
.card-title svg { width: 20px; height: 20px; stroke: var(--gold-500); }

/* ===== FORM GRID & INPUTS ===== */
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
    font-size: 0.82rem; font-weight: 600;
    color: var(--navy-700); letter-spacing: 0.02em;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 14px; border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md); font-size: 0.92rem;
    font-family: var(--font-body); color: var(--gray-700);
    background: var(--gray-50);
    transition: all var(--transition);
    outline: none; width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--gold-400);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
    background: var(--white);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--gray-400); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7689' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ===== BUTTONS ===== */
.form-actions {
    display: flex; justify-content: flex-end; gap: 12px;
    margin-top: 24px; flex-wrap: wrap;
}
.btn-primary, .btn-next, .btn-secondary, .btn-add-med, .btn-pdf {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 24px; border: none; border-radius: var(--radius-md);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: var(--font-body); transition: all var(--transition);
}
.btn-primary {
    background: linear-gradient(135deg, var(--navy-700), var(--navy-800));
    color: var(--white);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary svg { width: 18px; height: 18px; }

.btn-next {
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-900);
}
.btn-next:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(201,168,76,0.35); }
.btn-next svg { width: 18px; height: 18px; }

.btn-secondary {
    background: var(--gray-100); color: var(--gray-600);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-secondary svg { width: 18px; height: 18px; }

.btn-add-med {
    background: linear-gradient(135deg, var(--green-500), #2f855a);
    color: var(--white); width: 100%; justify-content: center;
}
.btn-add-med:hover { transform: translateY(-1px); box-shadow: 0 4px 15px rgba(56,161,105,0.3); }
.btn-add-med svg { width: 18px; height: 18px; }

.btn-pdf {
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-900); padding: 14px 32px; font-size: 1rem;
}
.btn-pdf:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(201,168,76,0.4); }
.btn-pdf svg { width: 20px; height: 20px; }

/* ===== MEDICAMENTO ITEM LIST ===== */
.medicamentos-lista { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.med-item {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 20px 24px; border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm); position: relative;
    animation: fadeIn 0.3s ease;
}
.med-item-header {
    display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px;
}
.med-item-number {
    background: linear-gradient(135deg, var(--navy-700), var(--navy-800));
    color: var(--gold-400); width: 28px; height: 28px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.med-item-name {
    font-family: var(--font-display); font-size: 1.05rem;
    color: var(--navy-700); font-weight: 600; flex: 1; margin: 0 14px;
}
.med-item-remove {
    background: none; border: none; cursor: pointer;
    color: var(--gray-400); padding: 4px; border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.med-item-remove:hover { color: var(--red-500); background: rgba(229,62,62,0.08); }
.med-item-remove svg { width: 18px; height: 18px; }
.med-item-details {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px; font-size: 0.84rem;
}
.med-detail { color: var(--gray-500); }
.med-detail strong { color: var(--navy-700); font-weight: 600; }
.med-item-orientacoes {
    margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    font-size: 0.84rem; color: var(--gray-500);
}

/* ===== PDF PREVIEW ===== */
.pdf-actions-bar {
    display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap;
}
.pdf-wrapper {
    background: var(--gray-200); border-radius: var(--radius-xl);
    padding: 32px; display: flex; justify-content: center;
}
.pdf-page {
    width: 210mm; min-height: 297mm;
    background: var(--white); padding: 28mm 22mm 20mm;
    box-shadow: var(--shadow-xl);
    font-family: 'Inter', Arial, sans-serif;
    font-size: 10pt; color: #1a1a1a;
    line-height: 1.5;
}

/* PDF Internal Styles */
.pdf-header { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 12px; }
.pdf-header-logo { flex-shrink: 0; }
.pdf-logo { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
.pdf-header-info { flex: 1; }
.pdf-prof-nome {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 15pt; color: var(--navy-800); font-weight: 700; margin-bottom: 3px;
}
.pdf-prof-detalhe { font-size: 8.5pt; color: var(--gray-500); margin: 1px 0; }
.pdf-divider { height: 2px; background: linear-gradient(90deg, var(--gold-500), var(--gold-300), transparent); margin: 12px 0; }
.pdf-divider.thin { height: 1px; background: var(--gray-200); }
.pdf-title-main {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 14pt; text-align: center;
    color: var(--navy-800); letter-spacing: 2px; margin: 10px 0 2px;
}
.pdf-legal-ref { text-align: center; font-size: 7.5pt; color: var(--gray-400); margin-bottom: 10px; }

.pdf-patient-box {
    background: #f7f8fb; border-radius: 8px;
    padding: 14px 16px; margin-bottom: 16px;
    border-left: 3px solid var(--gold-500);
}
.pdf-patient-box h4 {
    font-size: 8.5pt; color: var(--navy-700);
    letter-spacing: 1.5px; margin-bottom: 8px; font-weight: 700;
}
.pdf-patient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.pdf-patient-grid p { font-size: 9pt; color: var(--gray-600); }
.pdf-patient-grid p strong { color: var(--navy-800); }

.pdf-med-section { margin-bottom: 16px; }
.pdf-med-item {
    margin-bottom: 12px; padding: 12px 14px;
    border: 1px solid var(--gray-200); border-radius: 8px;
}
.pdf-med-item-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.pdf-med-num {
    background: var(--navy-800); color: var(--gold-400);
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 8pt; font-weight: 700;
}
.pdf-med-name { font-weight: 700; font-size: 10.5pt; color: var(--navy-800); }
.pdf-med-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 3px 16px; font-size: 8.5pt; color: var(--gray-600);
}
.pdf-med-grid strong { color: var(--navy-700); }
.pdf-med-orientacoes {
    margin-top: 6px; padding-top: 6px;
    border-top: 1px dashed var(--gray-200);
    font-size: 8.5pt; color: var(--gray-500); font-style: italic;
}
.pdf-med-protocolo { font-size: 7.5pt; color: var(--gold-500); margin-top: 3px; font-weight: 600; }

.pdf-obs {
    background: #f7f8fb; border-radius: 8px;
    padding: 12px 14px; margin-bottom: 16px;
}
.pdf-obs h4 { font-size: 8.5pt; color: var(--navy-700); letter-spacing: 1px; margin-bottom: 6px; }
.pdf-obs p { font-size: 9pt; color: var(--gray-600); white-space: pre-wrap; }

.pdf-footer-section { margin-top: 30px; text-align: center; }
.pdf-date { font-size: 9pt; color: var(--gray-600); margin-bottom: 40px; }
.pdf-signature { display: inline-block; text-align: center; min-width: 250px; }
.pdf-signature-line { border-top: 1px solid var(--navy-800); margin-bottom: 6px; }
.pdf-signature-name { font-weight: 700; font-size: 9.5pt; color: var(--navy-800); }
.pdf-signature-info { font-size: 8pt; color: var(--gray-500); }

.pdf-disclaimer {
    margin-top: 24px; padding-top: 10px;
    border-top: 1px solid var(--gray-200);
}
.pdf-disclaimer p { font-size: 6.5pt; color: var(--gray-400); text-align: center; line-height: 1.4; }

/* ===== 2 VIAS / ANTIBIOTIC ===== */
.pdf-via-wrapper { display: flex; flex-direction: column; }
.pdf-page-via { padding: 28mm 22mm 20mm; background: white; }
.pdf-page-break {
  page-break-before: always;
  break-before: page;
  border-top: 2px dashed var(--gray-300);
  margin: 16px 0;
  position: relative;
}
.pdf-page-break::before {
  content: 'RECORTE AQUI — 2ª VIA';
  position: absolute; top: -8px; left: 50%;
  transform: translateX(-50%);
  background: white; padding: 0 12px;
  font-size: 7pt; color: var(--gray-400);
  letter-spacing: 1px; font-weight: 600;
  white-space: nowrap;
}
.pdf-via-badge {
  display: inline-block;
  background: var(--navy-800); color: var(--gold-400);
  font-size: 7.5pt; font-weight: 700;
  padding: 3px 10px; border-radius: 4px;
  letter-spacing: 1px; align-self: flex-start;
  margin-top: 4px;
}
.pdf-header { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pdf-header-info { flex: 1; }

/* ===== CONTROL RECEIPT (Receita Especial — Antibiótico) ===== */
.pdf-control-receipt {
  margin-top: 16px;
  border: 1.5px solid #222;
  page-break-inside: avoid;
}
.pdf-control-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.pdf-ctrl-col {
  padding: 8px 10px;
  font-size: 8pt;
  font-family: Arial, sans-serif;
}
.pdf-ctrl-col.pdf-ctrl-buyer {
  border-right: 1.5px solid #222;
}
.pdf-ctrl-title {
  font-size: 7.5pt; font-weight: 700;
  text-align: center;
  color: #111;
  border-bottom: 1px solid #999;
  padding-bottom: 4px; margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.pdf-ctrl-field {
  display: flex; align-items: flex-end;
  gap: 4px; margin-bottom: 5px;
  font-size: 7.5pt; color: #111;
}
.pdf-ctrl-field span:first-child {
  white-space: nowrap; flex-shrink: 0;
  font-weight: 600;
}
.pdf-ctrl-line {
  flex: 1; border-bottom: 1px solid #555;
  min-width: 30px; height: 12px; display: inline-block;
}
.pdf-ctrl-line.short { flex: 0 0 36px; min-width: 36px; }
.pdf-ctrl-field-row {
  display: flex; gap: 8px; margin-bottom: 5px;
}
.pdf-ctrl-field.half { flex: 1; display: flex; align-items: flex-end; gap: 3px; font-size: 7.5pt; }
.pdf-ctrl-field.half span:first-child { white-space: nowrap; font-weight: 600; flex-shrink: 0; }
.pdf-ctrl-field.grow { flex: 1; display: flex; align-items: flex-end; gap: 4px; font-size: 7.5pt; }
.pdf-ctrl-field.grow span:first-child { white-space: nowrap; font-weight: 600; flex-shrink: 0; }
.pdf-ctrl-field.tiny { flex: 0 0 52px; display: flex; align-items: flex-end; gap: 3px; font-size: 7.5pt; }
.pdf-ctrl-field.tiny span:first-child { font-weight: 600; flex-shrink: 0; }
.pdf-ctrl-seller-inner {
  display: flex; flex-direction: column;
  height: 100%; justify-content: flex-end;
  min-height: 90px;
}
.pdf-ctrl-sig-space { flex: 1; }
.pdf-ctrl-sig-line-top {
  border-top: 1px solid #333;
  margin: 0 8px 3px;
}
.pdf-ctrl-sig-label {
  font-size: 7pt; text-align: center;
  color: #333; margin-bottom: 6px;
}

/* ===== SPECIAL RECEIPT LAYOUT ===== */
.pdf-special-layout { font-family: Arial, sans-serif; color: #111; height: 100%; display: flex; flex-direction: column; }
.pdf-special-main-title { text-align: center; font-size: 11pt; font-weight: bold; margin-bottom: 12px; letter-spacing: 0.5px; }
.pdf-special-header { display: flex; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.pdf-special-emitente { border: 1.5px solid #222; padding: 6px 10px; flex: 1; border-radius: 4px; }
.pdf-emitente-title { font-size: 7pt; text-align: center; font-weight: bold; border-bottom: 1px solid #999; margin-bottom: 6px; padding-bottom: 3px; }
.pdf-emitente-nome { font-size: 10pt; font-weight: bold; text-align: center; }
.pdf-emitente-coren { font-size: 8.5pt; text-align: center; margin: 2px 0; }
.pdf-emitente-end, .pdf-emitente-cidade { font-size: 7.5pt; text-align: center; }
.pdf-special-via-box { font-size: 8.5pt; font-weight: bold; margin-top: 8px; width: 100px; text-align: right; }

.pdf-special-patient { margin-bottom: 12px; }
.pdf-sp-row { display: flex; align-items: flex-end; margin-bottom: 6px; gap: 6px; }
.pdf-sp-label { font-size: 8.5pt; font-weight: bold; flex-shrink: 0; }
.pdf-sp-val { flex: 1; border-bottom: 1px solid #444; font-size: 9.5pt; font-family: 'Inter', sans-serif; }

.pdf-special-prescricao { flex: 1; margin-bottom: 15px; }
.pdf-special-footer { margin-top: auto; }
.pdf-special-date-sig { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; padding: 0 10px; }
.pdf-sig-left { flex: 1; display: flex; align-items: flex-end; gap: 4px; }
.pdf-sig-date-val { border-bottom: 1px solid #444; width: 120px; text-align: center; font-size: 9pt; }
.pdf-sig-right { width: 180px; text-align: center; }
.pdf-sig-right .pdf-signature-line { border-top: 1px solid #222; margin-bottom: 4px; }
.pdf-sig-right p { font-size: 7.5pt; font-weight: bold; }

/* ===== PREVIEW TABS ===== */
.preview-tab-bar {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.preview-tab {
  padding: 10px 22px;
  background: var(--gray-100); border: none;
  font-family: var(--font-body); font-size: 0.88rem;
  font-weight: 600; color: var(--gray-500);
  cursor: pointer; border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: all var(--transition);
}
.preview-tab.active {
  background: var(--white); color: var(--navy-700);
  border-bottom: 2px solid var(--gold-500);
  margin-bottom: -2px;
}
.preview-tab:hover:not(.active) { background: var(--gray-200); }

/* Extra buttons */
.btn-pdf-especial { background: linear-gradient(135deg, var(--navy-700), var(--navy-800)) !important; color: var(--gold-400) !important; }
.btn-pdf-comum { background: linear-gradient(135deg, #2f7a4a, #256040) !important; color: var(--white) !important; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }

/* ===== ANTIBIOTIC NOTICE ===== */
#antibiotic-notice {
  display: none;
  align-items: center; gap: 12px;
  background: linear-gradient(135deg, #fff7e0, #fef3c7);
  border: 1.5px solid var(--gold-500);
  border-radius: var(--radius-md);
  padding: 14px 20px; margin-bottom: 16px;
  font-size: 0.88rem; color: var(--navy-800); font-weight: 500;
}
#antibiotic-notice svg { width: 22px; height: 22px; stroke: var(--gold-500); flex-shrink: 0; }

/* Posologia line in PDF */
.pdf-med-posologia { font-size: 8.5pt; color: var(--gray-600); margin: 4px 0 2px; }
.toast {
    padding: 14px 20px; border-radius: var(--radius-md);
    font-size: 0.88rem; font-weight: 500;
    color: var(--white); box-shadow: var(--shadow-lg);
    animation: toastIn 0.35s ease, toastOut 0.35s ease 2.5s forwards;
    max-width: 360px;
}
.toast.success { background: linear-gradient(135deg, var(--green-500), #2f855a); }
.toast.error { background: linear-gradient(135deg, var(--red-500), #c53030); }
.toast.info { background: linear-gradient(135deg, var(--navy-700), var(--navy-800)); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

/* ===== PRINT LAYOUT ===== */
#pdf-print-area {
  display: none;
}

@media print {
  /* Force A4 page size regardless of device */
  @page {
    size: A4 portrait;
    margin: 0;
  }

  /* Reset everything to desktop baseline */
  html {
    font-size: 16px !important;
    -webkit-text-size-adjust: 100% !important;
  }

  body {
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Cancel the flex layout that splits sidebar + main */
    display: block !important;
    overflow: visible !important;
    width: 210mm !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* Hide every UI element */
  .sidebar,
  .mobile-header,
  .main-content,
  .toast-container,
  .sidebar-overlay {
    display: none !important;
  }

  /* Show and size the print area exactly like desktop A4 */
  #pdf-print-area {
    display: block !important;
    width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Override any responsive rules that shrink the PDF page */
  .pdf-page,
  .pdf-page-via {
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 28mm 22mm 20mm !important;
    font-size: 10pt !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  /* Restore desktop grid layouts overridden by mobile breakpoints */
  .pdf-med-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .pdf-patient-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Ensure colours and backgrounds print on mobile browsers */
  .pdf-patient-box,
  .pdf-obs,
  .pdf-via-badge,
  .pdf-med-num {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
}


/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; width: 100%; padding: 80px 16px 32px; }
    .form-grid { grid-template-columns: 1fr; }
    .pdf-wrapper { padding: 12px; }
    .pdf-page { width: 100%; min-height: auto; padding: 20px 16px; }
    .pdf-med-grid { grid-template-columns: 1fr 1fr; }
    .pdf-patient-grid { grid-template-columns: 1fr; }
    .section-title { font-size: 1.3rem; }
    .form-card { padding: 20px 18px; }
}
@media (max-width: 480px) {
    .form-actions { flex-direction: column; }
    .form-actions button { width: 100%; justify-content: center; }
    .pdf-actions-bar { flex-direction: column; }
    .pdf-actions-bar button { width: 100%; justify-content: center; }
}
