/* ==========================================================================
   1. CSS Variables (The White-Label Engine)
   ========================================================================== */
:root {
    --primary-color: #103f72;
    --secondary-color: #80c649;
    --accent-color: #1698a1;
    --accent-hover: #136189;
    --danger-color: #dc3545;
    --success-color: #198754;
    
    --bg-body: #f4f7f6;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #e2e8f0;
    
    --sidebar-width: 250px;
    --border-radius: 8px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px rgba(0,0,0,0.08);
}

/* ==========================================================================
   2. Reset & Base Typography
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    display: flex; 
    min-height: 100vh;
}

h2, h3, h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

a {
    text-decoration: none;
}

/* ==========================================================================
   3. Layout: Sidebar & Main Content
   ========================================================================== */
.mobile-top-bar { display: none; }
.sidebar-overlay { display: none; }

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: #ffffff;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000; 
}

.sidebar-header {
    padding: 5px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1.2em;
    font-weight: bold;
    color: var(--secondary-color);
    text-align: center;
}

.sidebar-footer {
    margin-top: auto; 
    padding: 20px; 
    border-top: 1px solid rgba(255,255,255,0.1); 
    display: flex; 
    flex-direction: column; 
    gap: 12px;
}

.sidebar-btn {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px; 
    width: 100%; 
    padding: 10px; 
    border-radius: var(--border-radius); 
    text-decoration: none; 
    font-weight: bold; 
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.05);
    color: #a0aec0;
    border: 1px solid transparent;
}

.sidebar-btn:hover, 
.sidebar-btn.active {
    background: var(--secondary-color);
    color: #ffffff;
}

.nav-links {
    list-style: none;
    margin-top: 20px;
}

.nav-links li a {
    display: block;
    padding: 15px 25px;
    color: #a0aec0;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-links li a:hover, 
.nav-links li a.active {
    background-color: rgba(255,255,255,0.05);
    color: #ffffff;
    border-left: 3px solid var(--secondary-color);
}

.print-only-header { display: none; }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: 100%;
}

.card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    overflow-wrap: break-word;
}

/* ==========================================================================
   4. UI Components (Buttons, Tables, Badges)
   ========================================================================== */
.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-group { 
    display: flex; 
    gap: 8px; 
    justify-content: flex-end; 
    white-space: nowrap; 
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: background 0.2s, transform 0.1s;
    text-align: center;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--accent-color); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--text-muted); color: #ffffff; }
.btn-secondary:hover { background: #5c636a; }

.btn-success { background: var(--success-color); color: #ffffff; }

.btn-danger { background: var(--danger-color); color: #ffffff; }
.btn-danger:hover { background: #851823; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.95em;
    min-width: 600px;
}

table.data-table th, 
table.data-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

table.data-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

table.data-table tr:hover { background-color: #f8fafc; }

.table-responsive { width: 100%; }

/* Status Badges */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
    white-space: nowrap;
}

.badge-draft { background: #e2e8f0; color: #4a5568; }
.badge-sent { background: #e0f2fe; color: #0284c7; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-viewed { background: #f3e8ff; color: #7e22ce; } 
.badge-accepted { background: #d1e7dd; color: #0f5132; }
.badge-credited { background: #e2e3e5; color: #383d41; }
.badge-neutral { background: #eeeeee; color: #333333; }
.badge-success { background: var(--success-color); color: #ffffff; }

/* Accordion UI Styles */
.accordion-item { background: #fff; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 15px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.accordion-header { background: #f8fafc; padding: 15px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 16px; color: #103f72; transition: background 0.2s; }
.accordion-header:hover { background: #f1f5f9; }
.accordion-header.active { border-bottom: 1px solid #ddd; }
.toggle-icon { font-size: 18px; transition: transform 0.3s ease; }
.accordion-header.active .toggle-icon { transform: rotate(180deg); }
.accordion-content { padding: 20px; display: none; }

/* Toggle Switch UI */
.switch { position: relative; display: inline-block; width: 50px; height: 24px; flex-shrink: 0; /* Prevents the switch from squishing on mobile */ }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #198754; }
input:checked + .slider:before { transform: translateX(26px); }

/* Module Row Layout */
.module-row { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid #eee; gap: 15px; /* Adds safe breathing room between text and switch */ }
.module-row:last-child { border-bottom: none; }
.module-info { flex-grow: 1; /* Allows text to take up remaining space safely */ }
.module-info h4 { margin: 0 0 5px 0; color: #333; font-size: 15px; }
.module-info p { margin: 0; font-size: 13px; color: #666; }


/* ==========================================================================
   5. Forms & Inputs
   ========================================================================== */
.form-row { 
    display: flex; 
    gap: 20px; 
    margin-bottom: 15px; 
    flex-wrap: wrap;
}

.form-group { 
    flex: 1; 
    margin-bottom: 15px; 
    min-width: 200px; 
}

.flex-2 { flex: 2; }
.flex-1 { flex: 1; }

label { 
    display: block; 
    font-weight: bold; 
    margin-bottom: 8px; 
    color: var(--text-main); 
    font-size: 0.9em; 
}

.index-form label { 
    position: relative; 
    text-align: left; 
    margin-bottom: 15px; 
}

input[type="text"], 
input[type="email"], 
input[type="tel"], 
input[type="number"], 
input[type="date"], 
input[type="password"], 
select { 
    width: 100%; 
    padding: 10px 15px; 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    box-sizing: border-box; 
    font-family: inherit; 
    font-size: 14px;
}

input:focus, 
select:focus { 
    outline: none; 
    border-color: var(--secondary-color); 
}

.input-transparent { 
    width: 100px; 
    border: none; 
    background: transparent; 
    text-align: right; 
    padding: 0; 
    font-family: inherit; 
    font-size: inherit; 
}

input[type="color"] { 
    width: 100%; 
    height: 45px; 
    border: 1px solid var(--border-color); 
    border-radius: var(--border-radius); 
    cursor: pointer; 
    padding: 2px; 
}

input[type="file"] { 
    width: 100%; 
    padding: 10px; 
    border: 1px dashed var(--border-color); 
    border-radius: var(--border-radius); 
    background: #f8fafc; 
    cursor: pointer; 
}

/* ==========================================================================
   6. Autocomplete & Dropdowns
   ========================================================================== */
.autocomplete-items {
    position: absolute;
    border: 1px solid #ddd;
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border-radius: 0 0 4px 4px;
    overflow: hidden;
}
.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}
.autocomplete-items div:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
    font-weight: bold;
}

/* ==========================================================================
   7. Page Headers & Layout Helpers
   ========================================================================== */
.page-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 30px; 
}

.section-header { 
    margin-top: 40px; 
    color: var(--primary-color); 
    border-bottom: 2px solid var(--border-color); 
    padding-bottom: 10px; 
    font-size: 1.2em; 
}

.form-actions { 
    clear: both; 
    padding-top: 40px; 
    text-align: right; 
    border-top: 1px solid var(--border-color); 
    margin-top: 40px; 
}

.clearfix::after { content: ""; clear: both; display: table; }
.mw-500 { max-width: 500px; }
.mw-600 { max-width: 600px; }
.mw-900 { max-width: 900px; }
.p-20 { padding: 20px !important; }
.mb-25 { margin-bottom: 25px !important; }
.mt-0 { margin-top: 0 !important; }
.mt-5 { margin-top: 5px !important; }
.mt-15 { margin-top: 15px; }
.gap-20 { gap: 20px; }
.d-inline-block { display: inline-block !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.fw-bold { font-weight: bold; }
.fs-sm { font-size: 0.9em !important; }

.text-primary { color: var(--primary-color) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-accent { color: var(--accent-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-warning { color: #d97706 !important; }

.optional-text { 
    font-size: 0.85em; 
    color: var(--text-muted); 
    font-weight: normal; 
}

.btn-lg { font-size: 1.1em; padding: 12px 30px; }
.btn-sm { padding: 6px 12px; font-size: 0.85em; border-radius: 4px; }

.flex-center-between { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-wrap: wrap; 
    gap: 10px;
}

.search-form { display: flex; gap: 10px; align-items: center; }
.search-input { flex: 1; }
.search-meta { color: var(--primary-color); font-size: 0.9em; margin-top: -10px; margin-bottom: 20px; }

/* ==========================================================================
   8. Alerts & Messaging
   ========================================================================== */
.alert { 
    padding: 15px; 
    border-radius: var(--border-radius); 
    margin-bottom: 25px; 
    color: #ffffff; 
}
.alert-success { background-color: var(--success-color); }
.alert-danger { background-color: var(--danger-color); }

/* ==========================================================================
   9. Document Creation & Totals Box
   ========================================================================== */
.totals-box { 
    float: right; 
    width: 320px; 
    margin-top: 30px;
    margin-right: -30px;
    background: #f8fafc; 
    padding: 20px; 
    border-radius: var(--border-radius); 
    border: 1px solid var(--border-color); 
}

.totals-row { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 12px; 
    font-size: 15px; 
}

.totals-row.grand { 
    font-size: 1.2em; 
    font-weight: bold; 
    color: var(--accent-color); 
    border-top: 2px solid var(--border-color); 
    padding-top: 15px; 
    margin-top: 5px; 
}

/* ==========================================================================
   10. App Specific Modules
   ========================================================================== */
.btn-whatsapp { 
    background-color: #25D366; 
    color: #ffffff !important; 
    padding: 8px 16px; 
    border-radius: 6px; 
    text-decoration: none; 
    font-weight: bold; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    gap: 8px; 
    font-size: 0.9em; 
    transition: 0.2s;
}
.btn-whatsapp:hover { background-color: #128C7E; transform: translateY(-1px); }

.stat-card {
    background: var(--bg-card); 
    padding: 20px; 
    border-radius: var(--border-radius); 
    box-shadow: var(--shadow-sm); 
    border-left: 5px solid var(--secondary-color); 
    margin-bottom: 25px;
}

/* ==========================================================================
   11. Login Screen
   ========================================================================== */
body.login-body { 
    justify-content: center; 
    align-items: center; 
    background-color: var(--primary-color); 
    padding: 15px; 
}

.login-card { 
    background: var(--bg-card); 
    padding: 40px; 
    border-radius: var(--border-radius); 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    width: 100%; 
    max-width: 400px; 
    text-align: center; 
    border-top: 5px solid var(--secondary-color); 
    box-sizing: border-box;
}

.login-logo { max-width: 60%; margin-bottom: 10px; }
.brand-title { color: var(--primary-color); margin: 0 0 5px 0; font-size: 1.8em; }
.brand-subtitle { color: var(--text-muted); font-size: 0.9em; margin-bottom: 30px; }

.password-wrapper { position: relative; text-align: left; margin-bottom: 15px; }
.password-input { width: 100%; padding-right: 40px; box-sizing: border-box; }
.password-toggle { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; font-size: 1.2em; }
.password-toggle-profile, .password-toggle-index { position: absolute; right: 15px; top: 70%; transform: translateY(-50%); cursor: pointer; font-size: 1.2em; }

.btn-login { width: 100%; padding: 12px; font-size: 1.1em; margin-top: 10px; }
.login-footer-text { margin-top: 25px; font-size: 0.8em; color: #a0aec0; }

/* ==========================================================================
   12. Catalog & Product Management
   ========================================================================== */
.radio-group { display: flex; gap: 15px; padding: 10px 0; flex-wrap: wrap; }
.radio-group label { cursor: pointer; display: flex; align-items: center; gap: 5px; font-weight: normal; }

.product-form { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.product-form > div { flex: 1; }
.product-form .name-field { flex: 2; min-width: 200px; }
.product-form label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 0.9em; color: var(--text-main); }
.product-form input[type="text"], .product-form input[type="number"], .product-form select { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 4px; box-sizing: border-box; }

/* ==========================================================================
   13. Grids (Profile, Statement, Wallet)
   ========================================================================== */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px; align-items: start; }
.statement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; max-width: 900px; }
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.empty-grid-msg { grid-column: 1 / -1; }

/* ==========================================================================
   14. Tabs & Reports
   ========================================================================== */
.tabs { 
    display: flex; 
    border-bottom: 2px solid var(--border-color); 
    margin-bottom: 25px; 
    gap: 10px; 
    overflow-x: auto; 
    padding-bottom: 10px; 
    -webkit-overflow-scrolling: touch;
}

.tab-btn { 
    background: none; border: none; padding: 12px 20px; cursor: pointer; 
    font-size: 15px; font-weight: bold; color: var(--text-muted); 
    border-radius: var(--border-radius) var(--border-radius) 0 0; transition: 0.3s; white-space: nowrap; 
}
.tab-btn:hover { background: #f8fafc; color: var(--primary-color); }
.tab-btn.active { background: var(--primary-color); color: #ffffff; }

.tab-content { display: none; animation: fadeIn 0.4s; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.report-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.print-btn { background: #ffffff; border: 1px solid var(--border-color); padding: 8px 15px; border-radius: 4px; cursor: pointer; color: var(--text-main); font-weight: bold; }
.print-btn:hover { border-color: var(--secondary-color); color: var(--secondary-color); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-top: 20px; }
.summary-card { background: #f8fafc; border-top: 4px solid var(--primary-color); padding: 20px; border-radius: var(--border-radius); }
.summary-card.border-secondary { border-top-color: var(--secondary-color); }
.summary-card.border-success { border-top-color: var(--success-color); }
.summary-card.border-danger { border-top-color: var(--danger-color); }
.summary-card h2 { margin: 10px 0 0 0; }
.summary-card p { margin: 0; font-size: 0.9em; color: var(--text-muted); }

.mrr-card { margin-top: 30px; background: var(--primary-color); color: #ffffff; padding: 30px; border-radius: var(--border-radius); }
.mrr-card h3 { color: var(--secondary-color); margin-top: 0; }
.mrr-card h1 { font-size: 3em; margin: 10px 0; }
.mrr-card p.disclaimer { opacity: 0.8; font-size: 0.9em; margin: 0; }

/* ==========================================================================
   15. Statement & Bulk Mailing
   ========================================================================== */
.bulk-report { background: var(--primary-color); color: #ffffff; padding: 20px; border-radius: var(--border-radius); margin-bottom: 25px; border-left: 5px solid var(--secondary-color); }
.bulk-report h3 { color: #ffffff; margin-top: 0; }
.bulk-report ul { list-style: none; padding: 0; margin: 0; font-size: 1.1em; }
.bulk-report li { margin-bottom: 5px; }

.card-bulk { border: 2px solid var(--secondary-color); background-color: #f8fafc; }
.helper-text { font-size: 0.9em; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; }
.w-100 { width: 100% !important; }

/* ==========================================================================
   16. System Settings & User Management
   ========================================================================== */
.current-logo { max-height: 60px; margin-top: 10px; border-radius: 4px; border: 1px solid var(--border-color); padding: 5px; background: #ffffff; }

.role-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.85em; font-weight: bold; }
.role-admin { background-color: #d1e7dd; color: #0f5132; }
.role-staff { background-color: #e2e3e5; color: #383d41; }

.add-user-box { background: #f8fafc; padding: 20px; border-radius: var(--border-radius); margin-top: 20px; border: 1px solid var(--border-color); }
.flex-row-mobile-col { display: flex; gap: 10px; width: 100%; align-items: center; }

/* ==========================================================================
   17. Prepaid Wallet POS
   ========================================================================== */
.wallet-card { background: var(--bg-card); padding: 25px 20px; border-radius: var(--border-radius); box-shadow: var(--shadow-sm); border-top: 4px solid var(--secondary-color); text-align: center; }
.wallet-card h3 { margin: 0; color: var(--text-main); font-size: 1.2em; }
.wallet-balance { font-size: 2.2em; font-weight: bold; color: var(--primary-color); margin: 15px 0; display: flex; align-items: center; justify-content: center; gap: 5px; }
.currency-symbol { font-size: 0.5em; color: var(--text-muted); align-self: flex-start; margin-top: 5px; }

.redeem-form { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.redeem-input { width: 100px; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--border-radius); text-align: center; font-size: 1.1em; }
.redeem-input:focus { outline: none; border-color: var(--secondary-color); }

/* ==========================================================================
   18. Payment Gateway Management
   ========================================================================== */
.gateway-card { background: #f8fafc; padding: 20px; border-radius: var(--border-radius); border: 1px solid var(--border-color); margin-bottom: 20px; transition: border-color 0.3s ease, box-shadow 0.3s ease; }
.gateway-card:hover { border-color: var(--secondary-color); box-shadow: var(--shadow-sm); }
.gateway-header { display: flex; gap: 10px; align-items: center; margin-bottom: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
.gateway-header h3 { margin: 0; font-size: 1.2em; color: var(--primary-color); }
.gateway-body { margin-top: 15px; border-top: 1px solid var(--border-color); padding-top: 15px; }


/* ==========================================================================
   19. serialised product dispatch module
   ========================================================================== */
/* Smart Dropdown UI */
        .serial-selector-wrapper {
            position: relative;
            margin-bottom: 10px;
        }
        .scan-input {
            width: 100%;
            padding: 12px;
            font-size: 15px;
            border: 1px solid #cbd5e1;
            border-radius: 6px;
            background: #f8fafc;
            transition: all 0.2s;
        }
        .scan-input:focus {
            border-color: #3b82f6;
            background: white;
            outline: none;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }
        .serial-dropdown {
            position: absolute;
            top: 100%;
            left: 0;
            right: 0;
            background: white;
            border: 1px solid #cbd5e1;
            border-top: none;
            border-radius: 0 0 6px 6px;
            max-height: 200px;
            overflow-y: auto;
            z-index: 10;
            display: none;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .serial-option {
            padding: 10px 12px;
            cursor: pointer;
            border-bottom: 1px solid #f1f5f9;
            font-family: monospace;
            font-size: 14px;
        }
        .serial-option:last-child { border-bottom: none; }
        .serial-option:hover { background-color: #f0f9ff; color: #0284c7; }
        
        /* Selected Tags (Pills) */
        .selected-tags-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-top: 10px;
            min-height: 34px;
        }
        .serial-tag {
            background-color: #e0f2fe;
            color: #0369a1;
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 13px;
            font-family: monospace;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            border: 1px solid #bae6fd;
        }
        .remove-tag {
            cursor: pointer;
            color: #0284c7;
            font-weight: bold;
            font-size: 16px;
            line-height: 1;
        }
        .remove-tag:hover { color: #dc2626; }


/* ==========================================================================
   21. Media Queries (Mobile, Tablet, Print)
   ========================================================================== */

/* --------- TABLETS & MOBILES (Max 768px) --------- */
@media screen and (max-width: 768px) {
    body { flex-direction: column; }

    /* --- Top Bar & Nav --- */
    .mobile-top-bar {
        display: flex;
        justify-content: center; 
        align-items: center;
        background: #ffffff;
        padding: 15px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        position: fixed;
        top: 0; 
        left: 0; 
        width: 100%;
        z-index: 999;
    }
    .burger-menu { background: none; border: none; cursor: pointer; padding: 5px; outline: none; }
    .sidebar { left: -280px; width: 260px; transition: left 0.3s ease-in-out; z-index: 1001; box-shadow: 5px 0 15px rgba(0,0,0,0.2); }
    .sidebar.active { left: 0; }
    .sidebar-footer { margin-bottom: 40px; }
    
    .sidebar-overlay {
        display: block; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
        background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(2px); z-index: 1000;
        opacity: 0; transition: opacity 0.3s ease-in-out; pointer-events: none; 
    }
    .sidebar-overlay.active { opacity: 1; pointer-events: auto; }

    /* --- Main Layout & Cards --- */
    .main-content { margin-left: 0; padding: 15px; padding-top: 80px !important; width: 100%; overflow-x: hidden; }
    .card { padding: 15px; }
    h2 { font-size: 1.3em; }
    h3 { font-size: 1.1em; }
    .page-header { flex-direction: column; align-items: flex-start !important; gap: 10px; }

    /* --- Buttons & Groups --- */
    .btn { padding: 8px 12px; font-size: 0.85em; }
    .btn-lg { padding: 10px 15px; font-size: 0.95em; width: 100%; }
    .btn-group { flex-direction: column; width: 100%; gap: 8px; }
    .btn-group .btn { width: 100%; justify-content: center; }
    .action-group { flex-wrap: wrap; justify-content: flex-start; }
    
    /* --- Forms, Inputs & Security --- */
    input[type="text"], input[type="email"], input[type="tel"], input[type="number"], 
    input[type="date"], input[type="password"], select { font-size: 16px !important; padding: 8px 12px; }
    .form-row { flex-direction: column; gap: 0; margin-bottom: 0; }
    .search-form { flex-direction: column; width: 100%; align-items: stretch; }
    .search-form .btn { width: 100%; }
    .password-toggle-profile, .password-toggle-index { margin-top: 0; }
    
    /* --- Tables --- */
    table.data-table th, table.data-table td { padding: 8px 5px; font-size: 0.8em; }
    .table-responsive {
        overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 15px;
        padding-bottom: 10px; border: 1px solid var(--border-color); border-radius: var(--border-radius);
    }
    .table-responsive table.data-table { min-width: 500px; margin-top: 0; }
    .totals-box { width: 100% !important; float: none !important; margin-top: 20px; padding: 15px; }

    /* --- Grids (Collapse to 1 column) --- */
    .profile-grid, .wallet-grid, .summary-grid, .statement-grid { grid-template-columns: 1fr !important; gap: 15px; }
    
    /* --- Specific Components --- */
    .flex-row-mobile-col { flex-direction: column; align-items: stretch; gap: 15px; }
    .flex-row-mobile-col > * { flex: 1 1 100% !important; width: 100% !important; margin: 0; }
    
    .product-form { flex-direction: column; align-items: stretch; gap: 15px; }
    .product-form > div { min-width: 100% !important; margin: 0; }
    .product-form button { width: 100%; padding: 12px !important; font-size: 1em; }
    
    .gateway-card { padding: 15px; }
    .gateway-header h3 { font-size: 1.1em; }
    .gateway-body { margin-top: 10px; padding-top: 10px; }

    .stat-card.flex-center-between { flex-direction: column; align-items: flex-start !important; gap: 15px; }
    .stat-card form { width: 100%; align-items: stretch !important; }
    .stat-card form > div { flex-direction: column !important; width: 100% !important; }
    .stat-card select, .stat-card input, .stat-card button { width: 100% !important; margin-left: 0 !important; }
    
    #status-tender-container { text-align: left !important; }
    .header-actions, .footer-actions { flex-direction: column; width: 100%; align-items: stretch !important; }
    .header-actions .btn, .header-actions form, .header-actions button { width: 100%; margin-bottom: 5px; }
    .footer-actions .btn, .footer-actions .btn-whatsapp { width: 100%; text-align: center; justify-content: center; }
}

@media (max-width: 600px) {
    .accordion-header { padding: 12px 15px; font-size: 15px; }
    .accordion-content { padding: 15px; }
    
    .module-row { 
        align-items: flex-start; /* If the description text wraps to multiple lines, this keeps the switch at the top rather than centering awkwardly */
    }
    
    .switch {
        margin-top: 2px; /* Minor visual alignment tweak when aligned to top */
    }
}

/* --------- SMALL PHONES (Max 480px) --------- */
@media screen and (max-width: 480px) {
    .login-card { padding: 25px; }
    .mrr-card { padding: 20px; }
    .mrr-card h1 { font-size: 2.2em; }
}

/* --------- PRINT MEDIA --------- */
@media print {
    .print-only-header { 
        display: block !important; text-align: center; margin-bottom: 30px; 
        padding-bottom: 20px; border-bottom: 3px solid var(--primary-color); 
    }
    .print-only-header img { max-height: 70px; }
    .sidebar, .tabs, .print-btn, .mobile-top-bar { display: none !important; }
    
    .main-content { margin-left: 0 !important; width: 100% !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: none !important; margin-bottom: 20px; padding: 0 !important; }
    
    .tab-content { display: none !important; } 
    .tab-content.active { display: block !important; } 
    body { background: #ffffff; }
}