        * { box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
        html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; background: #1c1c1e; color: #333; }
        body { display: flex; flex-direction: column; }

        /* Navigation Tab Bar */
        .app-nav-bar {
            height: 48px;
            background: #000000;
            display: flex;
            align-items: center;
            padding: 0 16px;
            gap: 12px;
            border-bottom: 1px solid #333;
            flex-shrink: 0;
            z-index: 100;
        }
        .app-brand-badge {
            color: #fff;
            font-weight: 900;
            font-size: 0.95rem;
            letter-spacing: 1px;
            margin-right: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .nav-tab-btn {
            background: #2c2c2e;
            color: #aaa;
            border: 1px solid #444;
            padding: 6px 16px;
            border-radius: 6px;
            font-size: 0.82rem;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.2s ease;
        }
        .nav-tab-btn:hover { background: #3a3a3c; color: #fff; }
        .nav-tab-btn.active {
            background: #ffffff;
            color: #000000;
            border-color: #ffffff;
        }

        .main-workspace {
            display: flex;
            flex-grow: 1;
            height: calc(100vh - 48px);
            width: 100%;
            overflow: hidden;
            position: relative;
        }

        /* TAB 1: DIET PLAN MANAGER STYLES */
        .sidebar {
            width: 440px;
            min-width: 380px;
            height: 100%;
            background: #ffffff;
            border-right: 1px solid #d1d1d6;
            display: flex;
            flex-direction: column;
            z-index: 10;
            box-shadow: 2px 0 10px rgba(0,0,0,0.15);
        }
        .sidebar-header {
            padding: 12px 16px;
            background: #111111;
            color: #ffffff;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-shrink: 0;
        }
        .sidebar-header h2 { margin: 0; font-size: 1.05rem; letter-spacing: 0.5px; }
        
        .header-btn-group { display: flex; gap: 6px; }

        .header-btn {
            background: #ffffff;
            color: #000000;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 0.78rem;
            font-weight: 800;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 4px;
        }
        .header-btn:hover { background: #e0e0e0; }

        .sidebar-content {
            padding: 16px;
            overflow-y: auto;
            flex-grow: 1;
        }
        
        .db-card {
            background: #f4f4f6;
            border: 1.5px solid #000;
            border-radius: 6px;
            padding: 10px;
            margin-bottom: 16px;
        }
        .db-title { font-size: 0.8rem; font-weight: 800; text-transform: uppercase; margin-bottom: 6px; color: #000; display: flex; justify-content: space-between; }
        .sync-badge { font-size: 0.7rem; color: #2e7d32; font-weight: 700; background: #e8f5e9; padding: 1px 6px; border-radius: 10px; }
        .sync-badge.offline { color: #b8860b; background: #fff3cd; }
        .db-search { width: 100%; padding: 7px 9px; font-size: 0.8rem; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 6px; }
        .db-select { width: 100%; padding: 8px; font-size: 0.85rem; border: 1px solid #999; border-radius: 4px; font-weight: 600; margin-bottom: 8px; }
        .btn-row { display: flex; gap: 6px; margin-bottom: 6px; }
        .btn-row:last-child { margin-bottom: 0; }
        .btn-sm { flex: 1; padding: 7px; font-size: 0.75rem; font-weight: 700; border-radius: 4px; border: 1px solid #000; cursor: pointer; background: #fff; }
        .btn-sm:hover { background: #e5e5e5; }
        .btn-sm.btn-busy, .btn-sm:disabled { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
        .btn-save { background: #000; color: #fff; }
        .btn-save:hover { background: #222; }
        .btn-danger { background: #fff; color: #d9534f; border-color: #d9534f; }
        .btn-danger:hover { background: #fdf7f7; }

        .section-group {
            margin-bottom: 16px;
            border-bottom: 1px dashed #ccc;
            padding-bottom: 12px;
        }
        .section-group:last-child { border-bottom: none; }
        
        .section-title-bar {
            font-size: 0.82rem;
            font-weight: 800;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: #000;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            user-select: none;
            background: #eef2f5;
            padding: 8px 10px;
            border-radius: 4px;
            border-left: 4px solid #000;
        }
        .section-title-bar:hover { background: #e2e8ed; }

        .form-row { display: flex; gap: 8px; margin-bottom: 8px; }
        .form-group { flex: 1; margin-bottom: 8px; }
        .form-group label { display: block; font-size: 0.76rem; font-weight: 700; margin-bottom: 3px; color: #333; }
        .form-group input, .form-group textarea, .form-group select {
            width: 100%;
            padding: 7px 9px;
            border: 1px solid #c7c7cc;
            border-radius: 5px;
            font-size: 0.83rem;
            background: #fafafa;
        }
        .form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: #000; background: #fff; }
        .form-group textarea { height: 85px; resize: vertical; line-height: 1.35; font-family: inherit; }
        #in_inv_client_address { height: 50px; }
        .calc-input { background: #eef2f5 !important; font-weight: bold; color: #000; }

        .unit-input-group { display: flex; gap: 4px; }

        .meal-block {
            background: #f9f9fb;
            border: 1px solid #e1e1e8;
            border-radius: 6px;
            padding: 8px;
            margin-bottom: 10px;
            position: relative;
        }
        .meal-block-header {
            font-size: 0.75rem;
            font-weight: 800;
            color: #000;
            margin-bottom: 6px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .reorder-btns { display: flex; gap: 4px; }
        .btn-order { background: #fff; border: 1px solid #ccc; border-radius: 3px; font-size: 0.65rem; padding: 2px 6px; cursor: pointer; }
        .btn-order:hover { background: #e0e0e0; }

        .btn-order-del { background: #fff; color: #d9534f; border: 1px solid #d9534f; border-radius: 3px; font-size: 0.65rem; padding: 2px 6px; cursor: pointer; }
        .btn-order-del:hover { background: #fdf7f7; }

        .section-toggle-label {
            display: flex; align-items: center; gap: 4px;
            font-size: 0.68rem; font-weight: 700; text-transform: none; letter-spacing: normal;
            color: #444; cursor: pointer; white-space: nowrap;
        }
        .section-toggle-label input { cursor: pointer; }
        .row-toggle-checkbox { margin-right: 4px; vertical-align: middle; cursor: pointer; }
        .btn-add-meal { width: 100%; padding: 8px; background: #eef2f5; color: #000; border: 1.5px dashed #000; border-radius: 4px; font-weight: 800; font-size: 0.75rem; cursor: pointer; margin-top: 6px; }
        .btn-add-meal:hover { background: #e2e8ed; }

        .formatting-help {
            background: #eef6ff;
            border: 1px solid #b6d4fe;
            border-radius: 5px;
            padding: 8px 10px;
            font-size: 0.75rem;
            color: #084298;
            margin-bottom: 12px;
            line-height: 1.4;
        }

        .format-toolbar { display: flex; gap: 4px; margin-bottom: 4px; }
        .fmt-btn {
            background: #fff; border: 1px solid #c7c7cc; border-radius: 4px;
            padding: 3px 8px; font-size: 0.72rem; font-weight: 700; color: #333;
            cursor: pointer;
        }
        .fmt-btn:hover { background: #eef2f5; border-color: #999; }
        .fmt-btn:active { background: #e0e0e0; }

        .btn-container {
            padding: 12px 16px;
            background: #f2f2f7;
            border-top: 1px solid #d1d1d6;
            flex-shrink: 0;
            display: flex;
            gap: 8px;
        }
        .btn-print {
            flex: 1; padding: 12px; background: #000000; color: #ffffff; font-size: 0.88rem; font-weight: 800;
            border: none; border-radius: 6px; cursor: pointer; letter-spacing: 0.5px; box-shadow: 0 4px 6px rgba(0,0,0,0.15);
            display: flex; align-items: center; justify-content: center; gap: 6px;
        }
        .btn-print:hover { background: #222222; }

        /* Preview Pane */
        .preview-pane {
            flex-grow: 1;
            height: 100%;
            background: #525659;
            overflow-y: auto;
            padding: 25px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
        }
        /* Two-class selector out-specifies the single-class print rule
           below (.preview-pane { display: block !important }), so the
           inactive tab's pane stays hidden during print/PDF fallback
           instead of both panes showing at once. */
        .preview-pane.tab-hidden { display: none !important; }

        /* Printable Pages */
        .page {
            width: 210mm; height: 297mm; background: #ffffff; padding: 10mm 12px 12px 12px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.3); box-sizing: border-box; position: relative;
            font-size: 10pt; line-height: 1.38; color: #000; flex-shrink: 0;
            overflow: hidden;
        }

        /* Black & White Print Mode Styles */
        .bw-mode .header-container { background-color: #000000 !important; color: #ffffff !important; }
        .bw-mode .sec-header { background-color: #000000 !important; color: #ffffff !important; }
        .bw-mode .time-badge { border-color: #000000 !important; color: #000000 !important; background: #ffffff !important; }
        .bw-mode .note-tag { background-color: #f0f0f0 !important; border-color: #000000 !important; color: #000000 !important; }

        /* Non-Branded Mode (for corporate contracts) */
        /* Applied directly to .page (not an ancestor) so it survives the
           cloneNode() used for PDF export and carries through to print. */
        .generic-header-title {
            display: none;
            color: #ffffff !important;
            font-weight: 800;
            letter-spacing: 1.2px;
            text-transform: uppercase;
        }
        .page.non-branded .logo-flex-wrap { display: none !important; }
        .page.non-branded .header-contact-cell { display: none !important; }
        .page.non-branded .generic-header-title { display: block; }

        .draft-status { font-size: 0.7rem; color: #8e8e93; font-weight: 600; text-align: right; margin-top: 4px; transition: color 0.3s; }

        /* TOAST NOTIFICATIONS */
        .toast-container {
            position: fixed;
            bottom: 24px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            gap: 8px;
            z-index: 9999;
            pointer-events: none;
        }
        .toast {
            min-width: 220px;
            max-width: 420px;
            padding: 11px 18px;
            border-radius: 8px;
            font-size: 0.85rem;
            font-weight: 700;
            color: #fff;
            box-shadow: 0 4px 14px rgba(0,0,0,0.25);
            opacity: 0;
            transform: translateY(12px);
            transition: opacity 0.25s ease, transform 0.25s ease;
            text-align: center;
        }
        .toast.show { opacity: 1; transform: translateY(0); }
        .toast.toast-success { background: #2e7d32; }
        .toast.toast-error { background: #d9534f; }
        .toast.toast-info { background: #222; }

        /* PIN LOCK SCREEN */
        .pin-lock-overlay {
            position: fixed;
            inset: 0;
            z-index: 100000;
            background: radial-gradient(circle at 50% 30%, #232326 0%, #0a0a0b 70%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #fff;
            text-align: center;
            padding: 24px;
            opacity: 1;
            visibility: visible;
            transition: opacity 0.35s ease, visibility 0.35s ease;
        }
        .pin-lock-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
        .pin-lock-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 30px; }
        .pin-lock-logo {
            width: 62px; height: 62px; border-radius: 16px; background: #fff; color: #000;
            display: flex; align-items: center; justify-content: center;
            font-weight: 900; font-size: 1.5rem; letter-spacing: 1px;
            box-shadow: 0 6px 20px rgba(255,255,255,0.08);
        }
        .pin-lock-title { font-size: 1.05rem; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
        .pin-lock-subtitle { font-size: 0.8rem; color: #9a9a9e; font-weight: 600; letter-spacing: 0.3px; }
        .pin-dots { display: flex; gap: 16px; margin: 8px 0 24px; }
        .pin-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid #555; transition: all 0.15s ease; }
        .pin-dot.filled { background: #fff; border-color: #fff; }
        .pin-dots.shake { animation: pinShake 0.4s; }
        @keyframes pinShake {
            10%, 90% { transform: translateX(-2px); }
            20%, 80% { transform: translateX(4px); }
            30%, 50%, 70% { transform: translateX(-7px); }
            40%, 60% { transform: translateX(7px); }
        }
        .pin-lock-error { color: #ff6b6b; font-size: 0.78rem; font-weight: 700; height: 18px; margin-bottom: 14px; }
        .pin-keypad { display: grid; grid-template-columns: repeat(3, 66px); gap: 16px; }
        .pin-key {
            width: 66px; height: 66px; border-radius: 50%;
            background: #1e1e20; border: 1px solid #333; color: #fff;
            font-size: 1.35rem; font-weight: 700; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            transition: background 0.15s ease, transform 0.1s ease;
            -webkit-tap-highlight-color: transparent;
        }
        .pin-key:hover { background: #2a2a2d; }
        .pin-key:active { transform: scale(0.92); background: #333; }
        .pin-key-empty { visibility: hidden; cursor: default; }
        .pin-key-back { font-size: 1.15rem; }
        .draft-status.active { color: #2e7d32; font-weight: 700; }

        /* A4 Overflow Warning Badge */
        .overflow-banner {
            position: absolute;
            top: 4px;
            right: 12px;
            background: #d9534f;
            color: #ffffff;
            font-size: 7.5pt;
            font-weight: 800;
            padding: 2px 8px;
            border-radius: 4px;
            display: none;
            z-index: 100;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }

        /* Formatting Elements Inside Preview */
        .header-container { width: 100%; background-color: #000000 !important; color: #ffffff !important; padding: 10px 14px; border-radius: 4px; margin-bottom: 8px; }
        .header-table { width: 100%; border-collapse: collapse; }
        .logo-flex-wrap { display: table; width: 100%; }
        .logo-svg-col { display: table-cell; vertical-align: middle; width: 46px; padding-right: 10px; }
        .logo-text-col { display: table-cell; vertical-align: middle; }
        .brand-title { font-size: 18pt; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; margin: 0; color: #ffffff !important; line-height: 1; }
        .brand-subtitle { font-size: 8pt; color: #e0e0e0 !important; letter-spacing: 1.8px; text-transform: uppercase; margin-top: 4px; font-weight: 600; }
        .header-contact-cell { text-align: right; vertical-align: middle; font-size: 8.5pt; color: #ffffff !important; line-height: 1.4; font-weight: 500; }
        .header-contact-cell a { color: #ffffff !important; text-decoration: none !important; }

        .patient-card { width: 100%; border: 1.5px solid #000000; background-color: #ffffff; border-radius: 4px; padding: 6px 12px; margin-bottom: 8px; }
        .patient-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
        .patient-table td { padding: 3px 4px; font-size: 9pt; vertical-align: middle; }
        .label { font-weight: 800; color: #000000; white-space: nowrap; }
        .value-box { border-bottom: 1.5px solid #000000; color: #000000; font-weight: 700; padding-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

        .sec-header { background-color: #000000 !important; color: #ffffff !important; padding: 6px 10px; font-size: 10pt; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; border-radius: 3px; margin-top: 6px; margin-bottom: 6px; }

        .meal-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
        .meal-table th { background-color: #f0f0f0 !important; color: #000000 !important; font-size: 9pt; font-weight: 800; text-align: left; padding: 5px 8px; border-top: 1.5px solid #000; border-bottom: 1.5px solid #000; text-transform: uppercase; }
        .meal-table td { padding: 5px 8px; border-bottom: 1px solid #bbbbbb; vertical-align: top; font-size: 9pt; }
        .meal-table tr:nth-child(even) td { background-color: #fafafa !important; }
        .time-badge { display: block; background-color: #ffffff !important; color: #000 !important; padding: 3px 4px; border-radius: 3px; font-size: 8.5pt; text-align: center; border: 1.5px solid #000; font-weight: 800; white-space: nowrap; }
        .meal-name { font-weight: 800; font-size: 9.5pt; color: #000; margin-bottom: 2px; }

        .note-tag {
            font-size: 8.5pt; color: #000000 !important; background-color: #f0f0f0 !important; padding: 2px 6px;
            border-radius: 3px; border: 1px solid #000000; margin-top: 3px; display: inline-block; font-weight: 700;
        }

        .card { border: 1.5px solid #000000; background-color: #ffffff; border-radius: 4px; padding: 8px 12px; margin-bottom: 8px; }
        .card-title { font-size: 9.5pt; font-weight: 800; margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1.5px solid #000; text-transform: uppercase; letter-spacing: 0.5px; }
        .guideline-list { margin: 0; padding-left: 14px; }
        .guideline-list li { margin-bottom: 4px; font-size: 9pt; color: #000000; line-height: 1.35; }
        .metrics-table { width: 100%; border-collapse: collapse; }
        .metrics-table td { padding: 4px 6px; font-size: 9pt; border-bottom: 1px solid #cccccc; vertical-align: top; }
        .metrics-table tr:last-child td { border-bottom: none; }
        .metric-label { font-weight: 800; color: #000000; width: 26%; white-space: nowrap; }

        .grid-2col { display: flex; gap: 8px; margin-bottom: 8px; }
        .grid-col { flex: 1; }

        .golden-rule-box { background-color: #000000 !important; color: #ffffff !important; text-align: center; padding: 8px 12px; border-radius: 4px; margin-top: 6px; border: 1.5px solid #000000; }
        .golden-rule-title { font-size: 9.5pt; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
        .golden-rule-text { font-size: 9pt; margin-top: 2px; font-weight: 700; }

        .footer-bar { position: absolute; bottom: 8mm; left: 12px; right: 12px; font-size: 8.5pt; font-weight: bold; display: flex; justify-content: space-between; border-top: 1px solid #ccc; padding-top: 4px; }

        .floating-pdf-btn {
            position: fixed; bottom: 24px; right: 28px; z-index: 99999; background: #000000; color: #ffffff;
            border: 2px solid #ffffff; padding: 14px 26px; border-radius: 50px; font-size: 1rem; font-weight: 800;
            cursor: pointer; box-shadow: 0 8px 25px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 8px;
        }

        .fit-toggle-btn {
            position: fixed; bottom: 24px; left: 28px; z-index: 99999; background: #ffffff; color: #000000;
            border: 2px solid #000000; padding: 10px 18px; border-radius: 50px; font-size: 0.85rem; font-weight: 800;
            cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 6px;
        }
        .fit-toggle-btn:hover { background: #f0f0f0; }
        .fit-toggle-btn.active { background: #000000; color: #ffffff; }

        /* Modal Popups */
        .modal-overlay {
            position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
            background: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center;
            z-index: 999999;
        }
        .modal-card {
            background: #fff; padding: 24px; border-radius: 8px; width: 420px; max-width: 92vw;
            box-shadow: 0 10px 30px rgba(0,0,0,0.3); border: 2px solid #000;
            max-height: 90vh; overflow-y: auto;
        }
        .modal-card h3 { margin-top: 0; font-size: 1.1rem; border-bottom: 2px solid #000; padding-bottom: 8px; }

        .tag-list-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 6px 10px;
            background: #f8f9fa;
            border: 1px solid #e1e1e8;
            border-radius: 4px;
            margin-bottom: 6px;
        }
        /* INVOICE GENERATOR — deliberately its own visual style
           (indigo/slate) rather than the diet plan's black-and-white
           branded look, per request. Still a .page (A4, same PDF/print
           plumbing) — only the content styling inside it is distinct. */
        .invoice-page { position: relative; overflow: hidden; }

        .inv-header-table { width: 100%; border-collapse: collapse; margin-bottom: 6mm; }
        .inv-header-table td { vertical-align: top; }
        .inv-biz-name { font-size: 18pt; font-weight: 800; letter-spacing: -0.3px; color: #0f172a; }
        .inv-biz-meta { font-size: 9pt; color: #64748b; margin-top: 3px; }
        .inv-title-cell { text-align: right; }
        .inv-title { font-size: 27pt; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; color: #4f46e5; line-height: 1; }
        .inv-meta-row { font-size: 9pt; margin-top: 7px; display: flex; justify-content: flex-end; gap: 8px; color: #334155; }
        .inv-meta-label { color: #94a3b8; font-weight: 700; text-transform: uppercase; font-size: 7.5pt; letter-spacing: 0.5px; align-self: center; }

        .inv-divider { height: 3px; background: linear-gradient(90deg, #4f46e5, #c7d2fe); border-radius: 3px; margin-bottom: 6mm; }

        .inv-billto { margin-bottom: 8mm; }
        .inv-billto-label { font-size: 8pt; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; margin-bottom: 4px; }
        .inv-billto-name { font-size: 12pt; font-weight: 800; color: #0f172a; }
        .inv-billto-meta { font-size: 9pt; color: #64748b; margin-top: 2px; }
        #out_inv_client_address { white-space: pre-line; }

        .inv-items-table { width: 100%; border-collapse: collapse; margin-bottom: 6mm; table-layout: fixed; }
        .inv-items-table th {
            background: #4f46e5 !important; color: #ffffff !important; text-align: left; padding: 7px 10px;
            font-size: 8.5pt; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
        }
        .inv-items-table th:first-child { border-radius: 5px 0 0 5px; }
        .inv-items-table th:last-child { border-radius: 0 5px 5px 0; }
        .inv-items-table td { padding: 8px 10px; font-size: 9.5pt; border-bottom: 1px solid #e2e8f0; word-wrap: break-word; }
        .inv-items-table tr:nth-child(even) td { background: #f8fafc !important; }
        .inv-col-qty, .inv-col-rate, .inv-col-amount { text-align: right; white-space: nowrap; width: 15%; }
        .inv-col-desc { width: 55%; }

        .inv-totals-wrap { display: flex; justify-content: flex-end; margin-bottom: 8mm; }
        .inv-totals-box { width: 65mm; }
        .inv-totals-row { display: flex; justify-content: space-between; font-size: 9.5pt; padding: 5px 2px; color: #475569; }
        .inv-total-final {
            margin-top: 5px; padding: 9px 10px; background: #4f46e5 !important; color: #ffffff !important; border-radius: 6px;
            font-size: 12pt; font-weight: 800;
        }

        .inv-notes-block { border-top: 1px solid #e2e8f0; padding-top: 5mm; margin-bottom: 6mm; }
        .inv-notes-label { font-size: 8pt; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; margin-bottom: 4px; }
        .inv-notes-block .guideline-list { font-size: 9pt; color: #475569; }

        .inv-payment-grid { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 12px; }
        .inv-payment-row { display: flex; justify-content: space-between; gap: 12px; font-size: 9pt; padding: 4px 0; color: #334155; }
        .inv-payment-row:not(:last-child) { border-bottom: 1px dashed #e2e8f0; }
        .inv-payment-row span:first-child { color: #94a3b8; font-weight: 700; text-transform: uppercase; font-size: 7.5pt; letter-spacing: 0.5px; align-self: center; }

        .inv-footer { text-align: center; font-size: 9pt; color: #94a3b8; font-style: italic; position: absolute; bottom: 10mm; left: 12mm; right: 12mm; }

        .inv-paid-stamp {
            display: none; position: absolute; top: 42mm; right: 22mm;
            border: 4px solid #16a34a; color: #16a34a; font-size: 26pt; font-weight: 900;
            padding: 4px 22px; border-radius: 8px; transform: rotate(-10deg); opacity: 0.85;
            letter-spacing: 4px; align-items: center; justify-content: center; z-index: 5;
        }

        /* RESPONSIVE LAYOUT FOR TABLET / PHONE SCREENS */
        @media (max-width: 860px) {
            html, body { overflow: auto; height: auto; }

            .app-nav-bar {
                height: auto;
                flex-wrap: wrap;
                padding: 8px 12px;
                gap: 8px;
            }
            .app-brand-badge { margin-right: 0; font-size: 0.85rem; }
            .nav-tab-btn { padding: 6px 10px; font-size: 0.75rem; }

            .main-workspace {
                flex-direction: column;
                height: auto;
                min-height: calc(100vh - 48px);
                overflow: visible;
            }

            .sidebar {
                width: 100%;
                min-width: 0;
                height: auto;
                max-height: 60vh;
                border-right: none;
                border-bottom: 1px solid #d1d1d6;
            }

            .preview-pane {
                width: 100%;
                height: auto;
                overflow-x: auto;
                overflow-y: visible;
                padding: 16px 10px;
            }

            .floating-pdf-btn {
                bottom: 14px;
                right: 14px;
                padding: 10px 18px;
                font-size: 0.85rem;
            }
        }

        /* PERFECT NATIVE A4 PRINT ENGINE RULES */
        @media print {
            @page { size: A4 portrait; margin: 0mm; }
            * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
            html, body { width: 210mm !important; height: auto !important; overflow: visible !important; background: #ffffff !important; margin: 0 !important; padding: 0 !important; }
            .app-nav-bar, .sidebar, .floating-pdf-btn, .fit-toggle-btn, .overflow-banner, .pin-lock-overlay, .toast-container { display: none !important; }
            .preview-pane { display: block !important; position: static !important; width: 100% !important; height: auto !important; padding: 0 !important; margin: 0 !important; background: #ffffff !important; overflow: visible !important; }
            .main-workspace { display: block !important; height: auto !important; overflow: visible !important; position: static !important; }
            .page { box-shadow: none !important; margin: 0 !important; padding: 10mm 12px 12px 12px !important; width: 210mm !important; height: 297mm !important; page-break-inside: avoid !important; box-sizing: border-box !important; }
            .page:not(:last-child) { page-break-after: always !important; }
        }
