:root {
    --primary: #10b981;
    --primary-dark: #059669;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --body-bg: radial-gradient(circle at top right, #1e293b, #0f172a);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --error: #ef4444;
    --success: #10b981;
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
    
    /* Dark theme tokens */
    --input-bg: rgba(0, 0, 0, 0.2);
    --header-bg: rgba(15, 23, 42, 0.8);
    --modal-bg: #1e293b;
    --balance-card-bg: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.7));
    --history-item-bg: rgba(255, 255, 255, 0.03);
    --history-section-bg: rgba(255, 255, 255, 0.01);
}

.light-theme {
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --body-bg: radial-gradient(circle at top right, #f8fafc, #cbd5e1);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(15, 23, 42, 0.08);
    --text-main: #0f172a;
    --text-muted: #475569;
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -2px rgba(15, 23, 42, 0.04);
    
    /* Light theme tokens */
    --input-bg: rgba(255, 255, 255, 0.95);
    --header-bg: rgba(255, 255, 255, 0.85);
    --modal-bg: #f8fafc;
    --balance-card-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.95));
    --history-item-bg: rgba(15, 23, 42, 0.04);
    --history-section-bg: rgba(15, 23, 42, 0.01);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--body-bg, var(--bg-gradient));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

/* Header */
header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: var(--header-bg, rgba(15, 23, 42, 0.8));
    backdrop-filter: blur(10px);
    transition: background 0.3s ease;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #34d399, #10b981);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-right: 3rem;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-bg, rgba(0, 0, 0, 0.2));
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

option {
    background: #1e293b;
    color: var(--text-main);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.auth-container {
    max-width: 400px;
    margin: 4rem auto;
}

/* Grid Layouts */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Cards */
.card-title {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.stat-box {
    background: rgba(0,0,0,0.2);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Toast Notification */
#toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

#toast.success { background: var(--success); }
#toast.error { background: var(--error); }

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 2rem;
    transition: all 0.2s ease;
    flex: 0 0 auto;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.tab-btn.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Stat Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Loaders */
.loader {
    border: 3px solid rgba(255,255,255,0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem 0.75rem;
    }
    
    .glass-panel {
        padding: 1.5rem 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 600px) {
    .flex-mobile-stack {
        flex-direction: column;
    }

    header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
        text-align: center;
    }
    
    .user-info {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .user-info span, .user-info button {
        width: 100%;
        text-align: center;
    }

    .btn {
        width: 100%;
    }
    
    #toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
        text-align: center;
    }

    .stat-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    .list-item.flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .list-item.flex button, .list-item.flex .btn {
        width: 100%;
        text-align: center;
    }
}

/* Pagination Styling */
.pagination-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.35rem 0.75rem;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}
.pagination-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary);
}
.pagination-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────────
   E12: Phone Simulator Styling (USSD & WhatsApp)
   ───────────────────────────────────────────────────────────────────────────── */
.self-service-fab {
    position: fixed;
    bottom: 2rem;
    left: 2rem; /* Keep right for toast, put on left */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.self-service-fab:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.6);
}

.phone-simulator-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.phone-container {
    width: min(375px, 90vw);
    height: min(720px, 85vh);
    background: #1e293b;
    border: 10px solid #0f172a;
    border-radius: 36px;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(255,255,255,0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
}

/* Phone Bezel/Notch */
.phone-notch {
    width: 150px;
    height: 25px;
    background: #0f172a;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    z-index: 1010;
    display: flex;
    align-items: center;
    justify-content: center;
}

.phone-notch::before {
    content: '';
    width: 50px;
    height: 4px;
    background: #334155;
    border-radius: 2px;
}

.phone-header {
    background: #0f172a;
    padding: 30px 15px 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: #94a3b8;
}

.phone-tabs {
    display: flex;
    background: #0f172a;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.phone-tab {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
}

.phone-tab.active {
    color: #10b981;
    border-bottom-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.phone-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0b141a;
    position: relative;
    height: calc(100% - 120px);
}

/* USSD Dialog Screen */
.ussd-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.9);
}

.ussd-box {
    width: 100%;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.ussd-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-line;
    margin-bottom: 1rem;
    font-weight: bold;
}

.ussd-input-wrapper {
    border-bottom: 2px solid #0f172a;
    margin-bottom: 1rem;
}

.ussd-input {
    width: 100%;
    border: none !important;
    background: transparent !important;
    color: #0f172a !important;
    font-size: 1rem !important;
    font-family: inherit;
    padding: 0.25rem 0 !important;
    box-shadow: none !important;
}

.ussd-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.ussd-btn {
    background: transparent;
    border: none;
    color: #10b981;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.ussd-btn:hover {
    opacity: 0.8;
}

/* WhatsApp Screen */
.wa-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-size: cover;
    height: 100%;
    overflow: hidden;
}

.wa-chat-header {
    background: #075e54;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.wa-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #128c7e;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.wa-status {
    display: flex;
    flex-direction: column;
}

.wa-status-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
}

.wa-status-text {
    color: rgba(255,255,255,0.7);
    font-size: 0.7rem;
}

.wa-chat-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.wa-msg {
    max-width: 80%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.3;
    position: relative;
    white-space: pre-wrap;
}

.wa-msg.incoming {
    background: #ffffff;
    color: #303030;
    align-self: flex-start;
    border-top-left-radius: 0;
}

.wa-msg.outgoing {
    background: #dcf8c6;
    color: #303030;
    align-self: flex-end;
    border-top-right-radius: 0;
}

.wa-msg-time {
    font-size: 0.65rem;
    color: #94a3b8;
    text-align: right;
    margin-top: 0.25rem;
    display: block;
}

.wa-input-area {
    background: #f0f0f0;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    border-top: 1px solid #ddd;
}

.wa-input-box {
    flex: 1;
    background: white !important;
    border: none !important;
    border-radius: 20px !important;
    padding: 0.5rem 1rem !important;
    color: #303030 !important;
    font-size: 0.9rem !important;
}

.wa-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #128c7e;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.wa-send-btn:hover {
    background: #075e54;
}

.phone-close {
    position: absolute;
    top: 2rem;
    right: 2rem;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    z-index: 1020;
    background: rgba(255, 255, 255, 0.1);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.phone-close:hover {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    transform: rotate(90deg);
}

/* Global modal styles for sharing dialogs */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}
.modal.hidden {
    display: none !important;
}
.modal-content {
    width: 90%;
    max-width: 420px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    background: var(--modal-bg, #1e293b);
    border-radius: 1rem;
    transition: background 0.3s ease;
}

/* Theme Toggle Button */
.theme-toggle-btn {
    position: fixed;
    top: 1.25rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    font-size: 1.1rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: var(--shadow-lg);
}
.theme-toggle-btn:hover {
    transform: scale(1.1) rotate(15deg);
    background: rgba(255, 255, 255, 0.15);
}
.light-theme .theme-toggle-btn:hover {
    background: rgba(15, 23, 42, 0.05);
}


