/* ==========================================================================
   myBillBook Billing & Invoicing Suite Stylesheet
   Designed for Tripathy Telecom Premium Services
   ========================================================================== */

:root {
    --mbb-primary: #084298;
    --mbb-primary-dark: #06357a;
    --mbb-primary-light: #e8f0fe;
    --mbb-accent: #0d6efd;
    --mbb-success: #198754;
    --mbb-success-light: #d1e7dd;
    --mbb-warning: #f59e0b;
    --mbb-warning-light: #fef3c7;
    --mbb-danger: #dc3545;
    --mbb-danger-light: #f8d7da;
    --mbb-dark: #1e293b;
    --mbb-muted: #64748b;
    --mbb-border: #e2e8f0;
    --mbb-card-bg: #ffffff;
    --mbb-body-bg: #f8fafc;
    --mbb-radius: 10px;
    --mbb-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --mbb-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* Module Sub-Navigation */
.mbb-nav-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 22px;
    max-width: 100%;
    box-sizing: border-box;
}

.mbb-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: var(--mbb-muted);
    font-weight: 600;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mbb-tab-btn:hover {
    color: var(--mbb-primary);
    background: rgba(255, 255, 255, 0.6);
}

.mbb-tab-btn.active {
    background: #ffffff;
    color: var(--mbb-primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.mbb-tab-content {
    display: none;
}

.mbb-tab-content.active {
    display: block;
    animation: mbbFadeIn 0.25s ease-in-out;
}

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

/* Dual Column Billing Workspace */
.mbb-workspace {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 25px;
    align-items: start;
}

@media (max-width: 1366px) {
    .mbb-workspace {
        grid-template-columns: 1fr;
    }
}

/* Form Container & Section Cards */
.mbb-form-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mbb-card {
    background: var(--mbb-card-bg);
    border: 1px solid var(--mbb-border);
    border-radius: var(--mbb-radius);
    padding: 22px;
    box-shadow: var(--mbb-shadow);
    transition: box-shadow 0.2s ease;
}

.mbb-card:hover {
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
}

.mbb-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--mbb-border);
}

.mbb-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--mbb-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mbb-card-title span.icon {
    font-size: 18px;
}

/* Grid Forms */
.mbb-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.mbb-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

.mbb-grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 15px;
}

.mbb-grid-5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

@media (max-width: 1200px) {
    .mbb-grid-5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .mbb-grid-2, .mbb-grid-3, .mbb-grid-4, .mbb-grid-5 {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.mbb-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mbb-field label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.mbb-field label span.req {
    color: var(--mbb-danger);
    margin-left: 2px;
}

.mbb-input, .mbb-select, .mbb-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--mbb-dark);
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
    font-family: inherit;
}

.mbb-input:focus, .mbb-select:focus, .mbb-textarea:focus {
    border-color: var(--mbb-primary);
    box-shadow: 0 0 0 3px rgba(8, 66, 152, 0.12);
}

.mbb-input[readonly], .mbb-input:disabled {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

/* Popular Items Pills */
.mbb-quick-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.mbb-pill {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mbb-pill:hover {
    background: var(--mbb-primary);
    color: #ffffff;
    border-color: var(--mbb-primary);
    transform: translateY(-1px);
}

/* Items Table Container */
.mbb-items-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--mbb-border);
    border-radius: 8px;
    margin-bottom: 15px;
}

.mbb-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 680px;
}

.mbb-items-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--mbb-border);
    text-align: left;
}

.mbb-items-table td {
    padding: 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.mbb-items-table tr:hover {
    background: #fcfdfe;
}

.mbb-items-table .table-input {
    width: 100%;
    padding: 7px 8px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-sizing: border-box;
}

.mbb-items-table .table-input:focus {
    border-color: var(--mbb-primary);
    outline: none;
}

.mbb-btn-row-action {
    background: transparent;
    border: none;
    color: var(--mbb-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 15px;
    transition: all 0.15s ease;
}

.mbb-btn-row-action:hover {
    background: #fee2e2;
    color: var(--mbb-danger);
}

.mbb-btn-add-row {
    background: #f1f5f9;
    color: var(--mbb-primary);
    border: 1px dashed #cbd5e1;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    width: 100%;
    justify-content: center;
}

.mbb-btn-add-row:hover {
    background: #e2e8f0;
    border-color: var(--mbb-primary);
}

/* Calculation & Summary Panel */
.mbb-calc-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .mbb-calc-grid {
        grid-template-columns: 1fr;
    }
}

.mbb-calc-table {
    width: 100%;
    border-collapse: collapse;
}

.mbb-calc-table td {
    padding: 8px 0;
    font-size: 14px;
    color: #475569;
}

.mbb-calc-table td.val {
    text-align: right;
    font-weight: 600;
    color: var(--mbb-dark);
}

.mbb-calc-table tr.grand-total-row td {
    border-top: 2px solid var(--mbb-border);
    padding-top: 12px;
    font-size: 18px;
    font-weight: 800;
    color: var(--mbb-primary);
}

.mbb-calc-table tr.grand-total-row td.val {
    color: var(--mbb-primary);
}

.mbb-words-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #334155;
    margin-top: 10px;
}

.mbb-words-box b {
    color: #0f172a;
}

/* Payment Status Radios & Badges */
.mbb-pay-status-group {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.mbb-pay-label {
    flex: 1;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    user-select: none;
}

.mbb-pay-label input[type="radio"] {
    display: none;
}

.mbb-pay-label.paid {
    color: #166534;
}

.mbb-pay-label.paid.active {
    background: #dcfce7;
    border-color: #22c55e;
}

.mbb-pay-label.partial {
    color: #9a3412;
}

.mbb-pay-label.partial.active {
    background: #ffedd5;
    border-color: #f97316;
}

.mbb-pay-label.unpaid {
    color: #991b1b;
}

.mbb-pay-label.unpaid.active {
    background: #fee2e2;
    border-color: #ef4444;
}

/* Right Column: Live Invoice Preview Toolbar */
.mbb-preview-col {
    position: sticky;
    top: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mbb-action-toolbar {
    background: #ffffff;
    border: 1px solid var(--mbb-border);
    border-radius: var(--mbb-radius);
    padding: 15px;
    box-shadow: var(--mbb-shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mbb-theme-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.mbb-theme-pill {
    padding: 5px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: #ffffff;
    color: #475569;
    transition: all 0.2s ease;
}

.mbb-theme-pill.active {
    background: var(--mbb-primary);
    color: #ffffff;
    border-color: var(--mbb-primary);
}

.mbb-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mbb-btn-group.full {
    grid-template-columns: 1fr;
}

.mbb-btn {
    padding: 11px 16px;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.mbb-btn-primary {
    background: var(--mbb-primary);
    color: #ffffff;
}
.mbb-btn-primary:hover {
    background: var(--mbb-primary-dark);
    box-shadow: 0 4px 12px rgba(8, 66, 152, 0.25);
}

.mbb-btn-success {
    background: #198754;
    color: #ffffff;
}
.mbb-btn-success:hover {
    background: #157347;
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.25);
}

.mbb-btn-whatsapp {
    background: #25d366;
    color: #ffffff;
}
.mbb-btn-whatsapp:hover {
    background: #1eb857;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.mbb-btn-outline {
    background: transparent;
    color: #475569;
    border: 1px solid #cbd5e1;
}
.mbb-btn-outline:hover {
    background: #f1f5f9;
    color: var(--mbb-dark);
}

/* Live Invoice Paper Preview Viewport */
.mbb-preview-viewport {
    background: #cbd5e1;
    padding: 15px;
    border-radius: var(--mbb-radius);
    max-height: 75vh;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   INVOICE TEMPLATES & THEMES (A4 & POS Receipt)
   ========================================================================== */
.mbb-invoice-sheet {
    background: #ffffff;
    width: 210mm;
    min-height: 297mm;
    padding: 10mm 11mm;
    box-sizing: border-box;
    border: 2px solid #084298; /* Official GST invoice outer frame border */
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    color: #1e293b;
    position: relative;
    font-size: 13px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mbb-theme-modern-blue {
    border: 2px solid #084298 !important;
}

.mbb-theme-classic-tally {
    border: 2.5px solid #000000 !important;
    border-radius: 0 !important;
}

.mbb-theme-emerald {
    border: 2px solid #0f766e !important;
}

.mbb-theme-compact-a5 {
    border: 2px solid #084298 !important;
}

.mbb-theme-thermal-pos {
    border: 1px dashed #000000 !important;
}

/* Theme 1: Modern Blue (myBillBook Signature) */
.mbb-theme-modern-blue .inv-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--mbb-primary);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.mbb-theme-modern-blue .inv-brand-name {
    font-size: 24px;
    font-weight: 800;
    color: var(--mbb-primary);
    margin: 0 0 4px 0;
}

.mbb-theme-modern-blue .inv-type-badge {
    background: var(--mbb-primary);
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    padding: 6px 16px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: right;
    display: inline-block;
}

.mbb-theme-modern-blue .inv-table th {
    background: var(--mbb-primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    padding: 8px 6px;
    border: 1px solid var(--mbb-primary);
}

.mbb-theme-modern-blue .inv-table td {
    padding: 8px 6px;
    border: 1px solid #e2e8f0;
    font-size: 12px;
}

.mbb-theme-modern-blue .inv-table tr:nth-child(even) {
    background: #f8fafc;
}

/* Theme 2: Classic Tally B&W */
.mbb-theme-classic-tally {
    font-family: Arial, Helvetica, sans-serif;
    color: #000;
}

.mbb-theme-classic-tally .inv-header-bar {
    display: flex;
    justify-content: space-between;
    border: 2px solid #000;
    padding: 10px;
    margin-bottom: -2px;
}

.mbb-theme-classic-tally .inv-brand-name {
    font-size: 22px;
    font-weight: 800;
    color: #000;
}

.mbb-theme-classic-tally .inv-type-badge {
    border: 1px solid #000;
    background: #fff;
    color: #000;
    font-size: 15px;
    font-weight: 800;
    padding: 4px 10px;
}

.mbb-theme-classic-tally .inv-table th {
    background: #f1f1f1;
    color: #000;
    border: 1px solid #000;
    padding: 6px;
}

.mbb-theme-classic-tally .inv-table td {
    border: 1px solid #000;
    color: #000;
    padding: 6px;
}

/* Theme 3: Emerald Business */
.mbb-theme-emerald .inv-header-bar {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #0f766e;
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.mbb-theme-emerald .inv-brand-name {
    font-size: 24px;
    font-weight: 800;
    color: #0f766e;
}

.mbb-theme-emerald .inv-type-badge {
    background: #0f766e;
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    padding: 6px 16px;
    border-radius: 4px;
}

.mbb-theme-emerald .inv-table th {
    background: #0f766e;
    color: #ffffff;
    padding: 8px 6px;
}

/* Theme 4: Compact A5 */
.mbb-theme-compact-a5 {
    width: 148mm;
    min-height: 210mm;
    padding: 10mm 10mm;
    font-size: 11px;
}

.mbb-theme-compact-a5 .inv-brand-name {
    font-size: 18px;
}

.mbb-theme-compact-a5 .inv-table th, .mbb-theme-compact-a5 .inv-table td {
    padding: 4px;
    font-size: 10px;
}

/* Theme 5: Thermal POS Receipt (80mm) */
.mbb-theme-thermal-pos {
    width: 76mm;
    min-height: auto;
    padding: 6mm 4mm;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    color: #000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.mbb-theme-thermal-pos .inv-header-bar {
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.mbb-theme-thermal-pos .inv-brand-name {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
}

.mbb-theme-thermal-pos .inv-type-badge {
    background: none;
    color: #000;
    font-size: 12px;
    padding: 0;
    margin-top: 4px;
    border: none;
}

.mbb-theme-thermal-pos .inv-table {
    border: none;
}

.mbb-theme-thermal-pos .inv-table th {
    background: none;
    color: #000;
    border-top: 1px dashed #000;
    border-bottom: 1px dashed #000;
    border-left: none;
    border-right: none;
    padding: 4px 2px;
    font-size: 10px;
}

.mbb-theme-thermal-pos .inv-table td {
    border: none;
    padding: 4px 2px;
    font-size: 10px;
}

/* Common Invoice Sub-Components */
.inv-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 12px;
}

.inv-box {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    background: #ffffff;
}

.inv-box-title {
    font-weight: 700;
    font-size: 12px;
    color: #475569;
    text-transform: uppercase;
    margin-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 4px;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.inv-summary-section {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 15px;
    margin-top: 10px;
}

.inv-payment-stamp {
    display: inline-block;
    padding: 4px 12px;
    border: 2px solid;
    border-radius: 4px;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    transform: rotate(-3deg);
    margin: 8px 0;
}

.inv-payment-stamp.paid {
    color: #166534;
    border-color: #166534;
    background: #dcfce7;
}

.inv-payment-stamp.unpaid {
    color: #991b1b;
    border-color: #991b1b;
    background: #fee2e2;
}

.inv-payment-stamp.partial {
    color: #c2410c;
    border-color: #c2410c;
    background: #ffedd5;
}

.inv-qr-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
}

.inv-qr-code {
    width: 80px;
    height: 80px;
    background: #fff;
    padding: 4px;
    border: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inv-sign-box {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    min-height: 80px;
}

.inv-sign-line {
    border-top: 1px solid #000;
    width: 160px;
    margin-top: 40px;
    padding-top: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
}

/* ==========================================================================
   METRICS & KPI CARDS (Sales Reports)
   ========================================================================== */
.mbb-metrics-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 25px;
}

@media (max-width: 900px) {
    .mbb-metrics-row {
        grid-template-columns: 1fr 1fr;
    }
}
@media (max-width: 500px) {
    .mbb-metrics-row {
        grid-template-columns: 1fr;
    }
}

.mbb-metric-card {
    background: #ffffff;
    border: 1px solid var(--mbb-border);
    border-radius: var(--mbb-radius);
    padding: 18px;
    box-shadow: var(--mbb-shadow);
    display: flex;
    align-items: center;
    gap: 15px;
}

.mbb-metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.mbb-metric-icon.sales {
    background: #e0f2fe;
    color: #0369a1;
}

.mbb-metric-icon.received {
    background: #dcfce7;
    color: #15803d;
}

.mbb-metric-icon.due {
    background: #fee2e2;
    color: #b91c1c;
}

.mbb-metric-icon.count {
    background: #f3e8ff;
    color: #7e22ce;
}

.mbb-metric-info {
    display: flex;
    flex-direction: column;
}

.mbb-metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--mbb-muted);
    text-transform: uppercase;
}

.mbb-metric-val {
    font-size: 20px;
    font-weight: 800;
    color: var(--mbb-dark);
    margin-top: 2px;
}

/* History / List Filter Bar */
.mbb-filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid var(--mbb-border);
    padding: 15px;
    border-radius: var(--mbb-radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mbb-filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Badges */
.mbb-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mbb-badge.paid {
    background: #dcfce7;
    color: #166534;
}

.mbb-badge.partial {
    background: #ffedd5;
    color: #9a3412;
}

.mbb-badge.unpaid {
    background: #fee2e2;
    color: #991b1b;
}

.mbb-badge.pending {
    background: #fef3c7;
    color: #92400e;
}

.mbb-badge.cancelled {
    background: #f1f5f9;
    color: #64748b;
    text-decoration: line-through;
}

/* Quick Date Range Preset Buttons */
.mbb-preset-btn {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 700;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.mbb-preset-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.mbb-preset-btn.active {
    background: #0f172a;
    color: #ffd400;
    border-color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

/* ==========================================================================
   PRINT MEDIA RULES (Pixel-Perfect Clean Output)
   ========================================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 0; /* Remove browser default headers (file url, date) and footers (page no) */
    }

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

    html, body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 210mm !important;
        height: 297mm !important;
        color: #0f172a !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Hide screen-only headers, navigation, toolbars, and modals */
    .print-top-toolbar,
    .mbb-topbar,
    .mbb-action-toolbar,
    .mbb-modal-overlay,
    .mbb-form-col,
    .mbb-theme-switcher,
    .mbb-preview-viewport > .mbb-action-toolbar,
    header.site-header,
    footer.site-footer,
    nav.site-nav {
        display: none !important;
    }

    /* On dashboard / billing pages, hide all UI siblings except the print container */
    body:not(.print-page):not(.print-frame) > *:not(#printInvoiceContainer):not(#printTicketArea) {
        display: none !important;
    }

    /* Ensure print containers are cleanly sized to full A4 page */
    #printInvoiceContainer,
    .invoice-paper-wrapper,
    #printInvoiceContent,
    body.print-page #printInvoiceContainer,
    body.print-page .invoice-paper-wrapper,
    body.print-page #printInvoiceContent,
    body.print-frame,
    body.print-frame > * {
        display: block !important;
        visibility: visible !important;
        position: static !important;
        width: 210mm !important;
        height: 297mm !important;
        max-width: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* Universal styling for the invoice sheet when printed: FULL A4 FRAME WITH BORDER */
    .mbb-invoice-sheet {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
        width: 198mm !important;
        min-height: 275mm !important;
        height: auto !important;
        max-height: none !important;
        margin: 5mm auto !important;
        padding: 7mm 9mm !important;
        border: 2px solid #084298 !important;
        border-radius: 6px !important;
        background: #ffffff !important;
        box-shadow: none !important;
        page-break-inside: avoid !important;
        page-break-after: avoid !important;
        overflow: visible !important;
        visibility: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mbb-invoice-sheet.mbb-theme-classic-tally,
    .mbb-invoice-sheet.mbb-theme-classic_tally {
        border: 2.5px solid #000000 !important;
        border-radius: 0 !important;
    }
    .mbb-invoice-sheet.mbb-theme-emerald {
        border: 2px solid #0f766e !important;
    }
    .mbb-invoice-sheet.mbb-theme-compact-a5,
    .mbb-invoice-sheet.mbb-theme-compact_a5 {
        border: 2px solid #084298 !important;
        width: 140mm !important;
        min-height: 200mm !important;
        height: 200mm !important;
        padding: 6mm 8mm !important;
    }
    .mbb-invoice-sheet.mbb-theme-thermal-pos,
    .mbb-invoice-sheet.mbb-theme-thermal_pos {
        border: 1px dashed #000000 !important;
        width: 76mm !important;
        min-height: auto !important;
        height: auto !important;
        padding: 4mm !important;
    }

    /* Print grids matching preview exactly */
    .mbb-invoice-sheet .inv-meta-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 15px !important;
        margin-bottom: 12px !important;
    }

    .mbb-invoice-sheet .inv-summary-section {
        display: grid !important;
        grid-template-columns: 1.1fr 0.9fr !important;
        gap: 15px !important;
        margin-top: 10px !important;
    }

    .mbb-invoice-sheet .inv-header-bar {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        border-bottom: 2px solid #084298 !important;
        padding-bottom: 10px !important;
        margin-bottom: 12px !important;
    }

    .mbb-invoice-sheet .inv-qr-container {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 8px 10px !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 6px !important;
        background: #f8fafc !important;
    }

    /* Print tables */
    .mbb-invoice-sheet table {
        display: table !important;
        width: 100% !important;
        border-collapse: collapse !important;
    }
    .mbb-invoice-sheet tr {
        display: table-row !important;
        page-break-inside: avoid !important;
    }
    .mbb-invoice-sheet th,
    .mbb-invoice-sheet td {
        display: table-cell !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .mbb-invoice-sheet thead {
        display: table-header-group !important;
    }
    .mbb-invoice-sheet tbody {
        display: table-row-group !important;
    }

    /* Exact box borders and badges */
    .inv-box {
        border: 1px solid #cbd5e1 !important;
        background: #ffffff !important;
        border-radius: 6px !important;
        padding: 10px !important;
    }
    .inv-payment-stamp.paid {
        color: #166534 !important;
        border: 2px solid #166534 !important;
        background: #dcfce7 !important;
    }
    .inv-payment-stamp.unpaid {
        color: #991b1b !important;
        border: 2px solid #991b1b !important;
        background: #fee2e2 !important;
    }
    .inv-payment-stamp.partial {
        color: #c2410c !important;
        border: 2px solid #c2410c !important;
        background: #ffedd5 !important;
    }
    .mbb-words-box {
        background: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 6px !important;
        padding: 8px 10px !important;
    }
}

/* ==========================================================================
   ITEM SELECT MODAL & SEARCH POPUP
   ========================================================================== */
.mbb-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 15px;
    box-sizing: border-box;
    animation: mbbModalFadeIn 0.2s ease-out;
}

@keyframes mbbModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mbb-modal-dialog {
    background: #ffffff;
    width: 100%;
    max-width: 820px;
    max-height: 90vh;
    border-radius: 14px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mbbModalSlideUp 0.25s ease-out;
}

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

.mbb-modal-header {
    background: #084298;
    color: #ffffff;
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mbb-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mbb-modal-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 26px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.mbb-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mbb-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mbb-modal-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.mbb-modal-search-box .search-icon {
    position: absolute;
    left: 14px;
    font-size: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.mbb-modal-search-input {
    width: 100%;
    padding: 13px 14px 13px 42px;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.mbb-modal-search-input:focus {
    border-color: #084298;
    box-shadow: 0 0 0 4px rgba(8, 66, 152, 0.12);
}

.mbb-modal-cat-filter {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.mbb-modal-cat-btn {
    padding: 6px 14px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.mbb-modal-cat-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.mbb-modal-cat-btn.active {
    background: #084298;
    color: #ffffff;
    border-color: #084298;
}

.mbb-modal-items-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    max-height: 48vh;
    overflow-y: auto;
    padding-right: 4px;
}

.mbb-modal-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.mbb-modal-item-row:hover {
    border-color: #084298;
    background: #f8fafc;
    box-shadow: 0 4px 10px rgba(8, 66, 152, 0.08);
    transform: translateY(-1px);
}

.mbb-modal-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mbb-modal-item-icon {
    width: 42px;
    height: 42px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.mbb-modal-item-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
}

.mbb-modal-item-meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mbb-modal-item-price-col {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mbb-modal-item-price {
    text-align: right;
}

.mbb-modal-item-price .amt {
    font-size: 16px;
    font-weight: 800;
    color: #084298;
}

.mbb-modal-item-price .tax {
    font-size: 11px;
    color: #64748b;
}

.mbb-btn-add-item {
    background: #198754;
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.mbb-btn-add-item:hover {
    background: #157347;
    box-shadow: 0 4px 10px rgba(25, 135, 84, 0.3);
    transform: translateY(-1px);
}

.mbb-btn-add-item.added {
    background: #084298 !important;
}

.mbb-modal-footer {
    padding: 14px 22px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Toast Notification */
.mbb-toast-notification {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: #1e293b;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    font-size: 14px;
    font-weight: 600;
    z-index: 11000;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
}

.mbb-toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

/* Document Type Selection Pills */
.mbb-doc-type-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.mbb-doc-pill {
    padding: 7px 15px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.mbb-doc-pill:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
    transform: translateY(-1px);
}

.mbb-doc-pill.active {
    background: var(--mbb-primary, #084298);
    color: #ffffff;
    border-color: var(--mbb-primary, #084298);
    box-shadow: 0 3px 10px rgba(8, 66, 152, 0.3);
}

.mbb-btn-success {
    background: #16a34a !important;
    color: #ffffff !important;
    border: none !important;
}

.mbb-btn-success:hover {
    background: #15803d !important;
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);
}

#mbbBtnOpenTrash:hover {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

/* Counter Services Responsive Layout */
@media (max-width: 992px) {
    #mbbTab_services > div[style*="grid-template-columns: 1fr 1.6fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Real-Time Live Sync Pulse Indicator */
@keyframes mbbLivePulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        transform: scale(1.15);
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.mbb-live-sync-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    color: #166534;
    user-select: none;
    box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
}

.mbb-live-sync-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: mbbLivePulse 1.8s infinite;
}




/* =========================================================================
   PRODUCT REQUIREMENTS & TO-BUY STYLES
   ========================================================================= */
.mbb-req-filter-btn {
    transition: all 0.2s ease;
    cursor: pointer;
}
.mbb-req-filter-btn:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
