:root {
    /* Blessed Nutrition Design Tokens */
    --bn-background: #FDF4EF;
    --bn-surface: #FFFBF8;
    --bn-surface-alt: #F9E9E1;
    --bn-card: rgba(255, 252, 249, 0.96);
    --bn-border: #EBCBC2;
    --bn-border-subtle: #F3DED6;

    /* Pink / Rose Palette */
    --bn-pink-light: #EBC9C1;
    --bn-primary: #D99089;
    --bn-primary-dark: #AE6E67;

    /* Gold / Accent Palette */
    --bn-gold-light: #E0B36D;
    --bn-gold: #C79248;
    --bn-gold-dark: #8D612F;
    --bn-accent: #C79248;

    /* Text Colors */
    --bn-text: #4B332E;
    --bn-text-secondary: #806963;
    --bn-text-muted: #A48D87;
    --bn-white: #FFFFFF;

    /* Semantic Status */
    --bn-success: #388E3C;
    --bn-success-bg: #E8F5E9;
    --bn-warning: #F57C00;
    --bn-warning-bg: #FFF3E0;
    --bn-danger: #D32F2F;
    --bn-danger-bg: #FFEBEE;
    --bn-info: #1976D2;
    --bn-info-bg: #E3F2FD;

    /* Touch & Layout Dimensions (Proportionate Desktop & Tablet Standard) */
    --bn-touch-min-height: 34px;
    --bn-touch-btn-height: 34px;
    --bn-touch-pos-btn-height: 44px;
    --bn-radius-sm: 6px;
    --bn-radius-md: 10px;
    --bn-radius-lg: 16px;
    --bn-radius-full: 9999px;

    /* Shadows */
    --bn-shadow-sm: 0 2px 7px rgba(111, 69, 59, 0.05);
    --bn-shadow-md: 0 6px 18px rgba(111, 69, 59, 0.08);
    --bn-shadow-lg: 0 14px 36px rgba(111, 69, 59, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background:
        radial-gradient(circle at 82% 8%, rgba(232, 190, 167, 0.18), transparent 25rem),
        linear-gradient(135deg, #FFF8F4 0%, var(--bn-background) 48%, #F9E7DF 100%);
    color: var(--bn-text);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

h1, h2, h3, h4, .brand-font {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--bn-text);
}

/* Touch Control Standards */
button, input, select, textarea {
    font-family: inherit;
    font-size: 0.85rem;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease-in-out;
}

button:active {
    transform: scale(0.98);
}

/* Common Reusable UI Elements */
.bn-card {
    background: var(--bn-card);
    border: 1px solid var(--bn-border);
    border-radius: 14px;
    box-shadow: var(--bn-shadow-sm);
    padding: 0.85rem 1rem;
    transition: box-shadow 0.2s ease;
}

.bn-card:hover {
    box-shadow: var(--bn-shadow-md);
}

.bn-btn-primary {
    background: linear-gradient(135deg, var(--bn-primary) 0%, var(--bn-primary-dark) 100%);
    color: var(--bn-white);
    min-height: var(--bn-touch-btn-height);
    padding: 0.3rem 0.95rem;
    border-radius: var(--bn-radius-md);
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: 0 2px 7px rgba(164, 110, 101, 0.22);
}

.bn-btn-primary:hover {
    filter: brightness(1.05);
}

.bn-btn-gold {
    background: linear-gradient(135deg, var(--bn-gold) 0%, var(--bn-gold-dark) 100%);
    color: var(--bn-white);
    min-height: var(--bn-touch-btn-height);
    padding: 0.3rem 0.95rem;
    border-radius: var(--bn-radius-md);
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    box-shadow: 0 2px 7px rgba(199, 146, 72, 0.25);
}

.bn-btn-outline {
    background: transparent;
    border: 1.5px solid var(--bn-border);
    color: var(--bn-text);
    min-height: var(--bn-touch-btn-height);
    padding: 0.3rem 0.95rem;
    border-radius: var(--bn-radius-md);
    font-weight: 600;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    text-decoration: none;
}

.bn-btn-outline:hover:not(:disabled) {
    background: var(--bn-surface-alt);
    border-color: var(--bn-primary);
    color: var(--bn-primary-dark);
}

.bn-btn-outline:active:not(:disabled) {
    transform: scale(0.98);
}

.bn-btn-outline:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
}

.bn-input {
    min-height: var(--bn-touch-min-height);
    background: rgba(255, 252, 249, 0.92);
    border: 1.2px solid var(--bn-border);
    border-radius: var(--bn-radius-md);
    padding: 0.25rem 0.75rem;
    color: var(--bn-text);
    width: 100%;
    outline: none;
    font-size: 0.84rem;
    transition: border-color 0.2s;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--bn-text);
    font-size: 0.83rem;
}

.table thead th {
    background: rgba(246, 229, 219, 0.62);
    color: var(--bn-text-secondary);
    border-bottom-color: var(--bn-border);
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.table tbody td {
    padding: 0.45rem 0.75rem;
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color .18s ease;
}

.table tbody tr:hover {
    background: rgba(255, 242, 237, 0.72);
}

.btn-outline-secondary {
    color: var(--bn-primary-dark);
    border-color: var(--bn-border);
    background: rgba(255, 251, 248, 0.72);
    border-radius: 9px;
    font-size: 0.82rem;
    padding: 0.25rem 0.75rem;
    min-height: var(--bn-touch-btn-height);
}

.btn-outline-secondary:hover {
    color: #fff;
    border-color: var(--bn-primary);
    background: var(--bn-primary);
}

.bn-input:focus {
    border-color: var(--bn-gold);
    box-shadow: 0 0 0 2.5px rgba(199, 146, 72, 0.15);
}

.bn-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--bn-radius-full);
    font-size: 0.74rem;
    font-weight: 600;
}

.bn-badge-success { background: var(--bn-success-bg); color: var(--bn-success); }
.bn-badge-warning { background: var(--bn-warning-bg); color: var(--bn-warning); }
.bn-badge-danger { background: var(--bn-danger-bg); color: var(--bn-danger); }
.bn-badge-gold { background: #FFF4E5; color: var(--bn-gold-dark); border: 1px solid var(--bn-gold-light); }

/* Unified Standard Tabs */
.bn-tabs {
    display: flex;
    gap: 0.35rem;
    border-bottom: 1.5px solid var(--bn-border);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    margin-bottom: 0.85rem !important;
}

.bn-tabs::-webkit-scrollbar {
    display: none;
}

.bn-tab {
    background: transparent;
    border: none;
    padding: 0.32rem 0.8rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--bn-text-secondary);
    border-radius: 8px 8px 0 0;
    min-height: 30px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 2.5px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.bn-tab:hover {
    color: var(--bn-primary);
    background: rgba(217, 144, 137, 0.08);
}

.bn-tab.active {
    background: var(--bn-surface);
    color: var(--bn-primary-dark);
    border-bottom: 2.5px solid var(--bn-primary);
}

/* Unified Period Filter Bar */
.period-filter-bar {
    background-color: var(--bn-surface);
    border: 1px solid var(--bn-border);
    border-radius: 10px;
    padding: 0.3rem 0.75rem;
    box-shadow: var(--bn-shadow-sm);
    margin-bottom: 0.85rem !important;
}

.period-btn {
    min-height: 28px;
    padding: 0.18rem 0.65rem;
    border-radius: 9999px;
    border: 1px solid var(--bn-border);
    background-color: #ffffff;
    color: var(--bn-text);
    font-size: 0.76rem;
    font-weight: 600;
    transition: all 0.18s ease;
    cursor: pointer;
}

.period-btn:hover, .period-btn.active {
    background-color: var(--bn-primary);
    color: #ffffff;
    border-color: var(--bn-primary);
    box-shadow: 0 2px 6px rgba(217, 144, 137, 0.25);
}

/* Unified Modal Standard */
.bn-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(45, 30, 27, 0.58);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 0.75rem;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
}

.bn-modal-dialog {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    max-height: 90dvh;
    background: #ffffff;
    border: 1px solid var(--bn-border);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(50, 25, 20, 0.22);
    position: relative;
    margin: auto;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
}

.bn-modal-dialog > .bn-card {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    width: 100% !important;
    margin: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 1.25rem 1.4rem;
}

.bn-modal-dialog-lg {
    max-width: 760px;
}

.bn-modal-dialog-sm {
    max-width: 420px;
}

/* Modals with header / body / footer structure */
.bn-modal-dialog:has(.bn-modal-body) {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.bn-modal-header {
    padding: 1.15rem 1.4rem 0.95rem;
    border-bottom: 1px solid var(--bn-border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #ffffff;
    flex-shrink: 0;
}

.bn-modal-body {
    padding: 1.25rem 1.4rem;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    background: #ffffff;
    flex: 1 1 auto;
    min-height: 0 !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    overscroll-behavior-y: contain;
}

.bn-modal-footer {
    padding: 0.85rem 1.4rem;
    border-top: 1px solid var(--bn-border);
    background: rgba(253, 248, 245, 0.7);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
}

/* Responsive Mobile Modals */
@media (max-width: 768px) {
    .bn-modal-backdrop {
        padding: 0.5rem 0.35rem 2.5rem 0.35rem !important;
        align-items: flex-start !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }

    .bn-modal-dialog {
        max-width: 100% !important;
        width: 100% !important;
        max-height: 92vh !important;
        max-height: 92dvh !important;
        margin: 0.5rem auto 1.5rem auto !important;
        border-radius: 14px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }

    .bn-modal-dialog > .bn-card {
        padding: 1rem 0.85rem !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .bn-modal-header {
        padding: 0.85rem 1rem 0.75rem;
    }

    .bn-modal-body {
        padding: 1rem 0.9rem;
        max-height: calc(92dvh - 120px) !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
    }

    .bn-modal-footer {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .bn-modal-footer button,
    .bn-modal-dialog > .bn-card .d-flex.justify-content-end button {
        flex: 1 1 auto;
        min-height: 44px;
    }
}

.bn-currency-prefix {
    background: rgba(246, 229, 219, 0.5);
    border-color: var(--bn-border);
    color: var(--bn-primary-dark);
    font-weight: 600;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-thumb {
    background: var(--bn-pink-light);
    border-radius: 4px;
}
::-webkit-scrollbar-track {
    background: var(--bn-surface-alt);
}

/* Global Blessed Nutrition Pagination Component */
.bn-pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--bn-border);
}

.bn-pagination-info {
    font-size: 0.78rem;
    color: var(--bn-text-secondary);
}

.bn-pagination-info strong {
    color: var(--bn-text);
}

.bn-pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bn-page-size-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--bn-text-secondary);
}

.bn-page-size-select {
    height: 28px;
    padding: 0.1rem 1.6rem 0.1rem 0.5rem;
    font-size: 0.76rem;
    border-radius: 6px;
    border: 1px solid var(--bn-border);
    background-color: #FFFFFF;
    color: var(--bn-text);
    cursor: pointer;
}

.bn-pagination-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.bn-btn-page {
    min-width: 30px;
    height: 28px;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--bn-border);
    background-color: #FFFFFF;
    color: var(--bn-text);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.bn-btn-page:hover:not(:disabled) {
    background-color: var(--bn-surface-alt);
    border-color: var(--bn-primary);
    color: var(--bn-primary);
}

.bn-btn-page.active {
    background: linear-gradient(135deg, var(--bn-primary) 0%, var(--bn-primary-dark) 100%);
    color: #FFFFFF;
    border-color: var(--bn-primary-dark);
    box-shadow: 0 2px 4px rgba(217, 150, 145, 0.3);
}

.bn-btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #F8F9FA;
    border-color: #E9ECEF;
    color: #ADB5BD;
}

.bn-btn-page-dots {
    padding: 0 0.2rem;
    font-size: 0.76rem;
    color: var(--bn-text-secondary);
}

/* ========================================================
   PRINT PREVIEW & PRINTABLE REPORTS (BLESSED NUTRITION)
   ======================================================== */
.bn-print-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 21, 20, 0.78);
    backdrop-filter: blur(6px);
    z-index: 10050;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.25rem 1rem;
    overflow-y: auto;
}

.bn-print-toolbar {
    width: 100%;
    max-width: 860px;
    background: #FFFFFF;
    border-radius: 12px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    border: 1px solid var(--bn-border);
}

.bn-print-nav-tabs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.bn-print-tab-btn {
    border: 1px solid var(--bn-border);
    background: var(--bn-surface-alt);
    color: var(--bn-text);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.bn-print-tab-btn.active, .bn-print-tab-btn:hover {
    background: var(--bn-primary);
    color: #FFFFFF;
    border-color: var(--bn-primary-dark);
}

.bn-printable-sheet {
    width: 100%;
    max-width: 850px;
    min-height: 1050px;
    background: #FFFFFF;
    color: #1A1A1A;
    padding: 2.2rem 2.5rem;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
    margin: 0 auto 3rem;
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    position: relative;
    border: 1px solid #E8E2DD;
}

.print-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--bn-primary);
    padding-bottom: 1rem;
    margin-bottom: 1.25rem;
}

.print-brand-logo {
    max-height: 68px;
    width: auto;
    object-fit: contain;
}

.print-brand-info {
    text-align: right;
}

.print-report-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--bn-primary-dark);
    margin-bottom: 0.2rem;
    letter-spacing: 0.02em;
}

.print-meta-line {
    font-size: 0.75rem;
    color: #6C757D;
    line-height: 1.35;
}

.print-meta-line strong {
    color: #212529;
}

.print-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.print-kpi-card {
    border: 1px solid #E0D6CE;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    background: #FAF7F5;
    text-align: center;
}

.print-kpi-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #72625D;
    letter-spacing: 0.04em;
}

.print-kpi-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #2B211E;
    margin: 0.15rem 0;
}

.print-kpi-sub {
    font-size: 0.68rem;
    color: #8C7A75;
}

.print-section-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #2B211E;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #E0D6CE;
    padding-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    font-size: 0.78rem;
}

.print-table th {
    background: #FAF7F5;
    color: #495057;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    padding: 0.45rem 0.55rem;
    border: 1px solid #D9CFC7;
}

.print-table td {
    padding: 0.4rem 0.55rem;
    border: 1px solid #E8E2DD;
    color: #212529;
    vertical-align: middle;
}

.print-table tr:nth-child(even) td {
    background: #FCFAF8;
}

.print-notes-box {
    border: 1px dashed #C4B5AA;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    background: #FAF8F6;
    margin-bottom: 1.5rem;
    font-size: 0.75rem;
    color: #555;
    min-height: 50px;
}

.print-signatures-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-top: 2rem;
    margin-bottom: 1.25rem;
    page-break-inside: avoid;
}

.print-sign-item {
    text-align: center;
}

.print-sign-line {
    border-top: 1.5px solid #444;
    margin-bottom: 0.4rem;
    padding-top: 0.35rem;
}

.print-sign-title {
    font-weight: 700;
    font-size: 0.78rem;
    color: #2B211E;
}

.print-sign-sub {
    font-size: 0.7rem;
    color: #6C757D;
}

.print-footer-notice {
    text-align: center;
    font-size: 0.68rem;
    color: #8C7A75;
    border-top: 1px solid #E8E2DD;
    padding-top: 0.6rem;
    margin-top: 1rem;
}

/* ========================================================
   MEDIA PRINT RULES (BROWSER PRINT / PDF SAVE)
   ======================================================== */
@media print {
    @page {
        size: letter portrait;
        margin: 8mm 12mm 8mm 12mm;
    }

    body {
        background: #FFFFFF !important;
        color: #000000 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body * {
        visibility: hidden !important;
    }

    .bn-printable-sheet,
    .bn-printable-sheet * {
        visibility: visible !important;
    }

    .bn-printable-sheet {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: #FFFFFF !important;
        color: #111111 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .no-print,
    .bn-print-toolbar,
    .bn-print-modal-backdrop,
    .bn-topbar,
    .bn-sidebar,
    .btn,
    button {
        display: none !important;
    }

    .print-table th {
        background: #F0EDE8 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-kpi-card {
        background: #F7F4F0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-signatures-block {
        page-break-inside: avoid !important;
    }

    .print-table tr {
        page-break-inside: avoid !important;
    }
}

