/* ==================== PREMIUM UI (LIGHT & DARK MODE) ==================== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Noto+Sans+Devanagari:wght@400;500;600;700;800&display=swap');

:root {
    --brand-500: #4f46e5;
    --brand-600: #4338ca;
    --brand-glow: rgba(79, 70, 229, 0.4);
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ☀️ LIGHT MODE (Default) */
[data-theme="light"] {
    --bg-base: #f4f7f6; /* हल्का ग्रे/सफेद बैकग्राउंड */
    --bg-surface: #ffffff; /* सफेद कार्ड्स */
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-color: #e2e8f0;
    
    --text-primary: #0f172a; /* गहरा काला टेक्स्ट */
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;

    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05);
    --shadow-float: 0 10px 25px -5px rgba(0,0,0,0.1);
}

/* 🌙 DARK MODE */
[data-theme="dark"] {
    --bg-base: #0b1120; /* गहरा नीला/काला */
    --bg-surface: #151e31; /* डार्क कार्ड्स */
    --bg-glass: rgba(21, 30, 49, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;

    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-float: 0 20px 40px -10px rgba(0,0,0,0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Plus Jakarta Sans', 'Noto Sans Devanagari', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ==================== LAYOUT ==================== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 270px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column; z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.5rem; display: flex; align-items: center; gap: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--brand-500), #a855f7);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.25rem;
    box-shadow: 0 0 20px var(--brand-glow);
}

.sidebar-brand h3 { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.sidebar-brand span { font-size: 0.65rem; color: var(--brand-500); font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; }

.sidebar-menu { flex: 1; overflow-y: auto; padding: 1.5rem 1rem; }
.menu-section { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary); font-weight: 800; margin: 1.5rem 0 0.5rem 0.75rem; }

.sidebar-menu a {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.85rem 1rem; color: var(--text-secondary); border-radius: 12px;
    font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem;
    transition: var(--transition);
}

.sidebar-menu a i { font-size: 1.1rem; width: 20px; text-align: center; transition: var(--transition); }
.sidebar-menu a:hover { background: var(--bg-base); color: var(--brand-500); transform: translateX(4px); }
.sidebar-menu a.active { background: var(--brand-500); color: white; box-shadow: 0 4px 10px var(--brand-glow); }
.sidebar-menu a.active i { color: white; }

.sidebar-menu a .badge {
    background: var(--danger); color: white; font-size: 0.7rem; 
    padding: 0.15rem 0.5rem; border-radius: 50px; margin-left: auto; font-weight: 700;
}

.sidebar-footer { padding: 1.25rem; border-top: 1px solid var(--border-color); background: var(--bg-base); }
.user-profile { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.user-avatar { width: 44px; height: 44px; background: linear-gradient(135deg, #f59e0b, #f97316); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 800; font-size: 1.1rem; }
.user-details .name { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); }
.user-details .role { font-size: 0.7rem; font-weight: 800; color: var(--brand-500); text-transform: uppercase; }

.logout-btn { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 0.75rem; background: transparent; color: var(--danger); border-radius: 12px; font-size: 0.85rem; font-weight: 700; transition: var(--transition); border: 1px solid rgba(239, 68, 68, 0.2); }
.logout-btn:hover { background: var(--danger); color: white; }

/* ==================== TOPBAR ==================== */
.main-content { flex: 1; margin-left: 270px; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    background: var(--bg-glass); backdrop-filter: blur(20px);
    height: 75px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 900;
}

.page-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.5px; color: var(--text-primary); }
.menu-btn { display: none; background: none; font-size: 1.5rem; color: var(--text-primary); }

.content-body { padding: 2rem; flex: 1; max-width: 1600px; margin: 0 auto; width: 100%; }

/* ==================== CARDS ==================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }

.stat-card, .detail-card, .table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.stat-card:hover, .detail-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-float); border-color: var(--brand-500); }

.stat-card { padding: 1.5rem; display: flex; flex-direction: column; justify-content: center; }
.stat-card .label { font-size: 0.8rem; font-weight: 800; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 1px; }
.stat-card .value { font-size: 2.2rem; font-weight: 800; color: var(--text-primary); margin-top: 0.25rem; letter-spacing: -1px; }
.stat-card .icon { position: absolute; right: 1.5rem; bottom: 1.5rem; font-size: 3.5rem; opacity: 0.1; transition: var(--transition); }
.stat-card:hover .icon { transform: scale(1.2) rotate(10deg); opacity: 0.2; color: var(--brand-500); }

.stat-card.blue { border-top: 3px solid #3b82f6; }
.stat-card.red { border-top: 3px solid var(--danger); }
.stat-card.orange { border-top: 3px solid var(--warning); }
.stat-card.green { border-top: 3px solid var(--success); }

/* ==================== HERO ==================== */
.dash-hero {
    background: linear-gradient(135deg, #1e1b4b 0%, var(--brand-500) 100%);
    border-radius: var(--radius-lg); padding: 2rem; color: white;
    margin-bottom: 2rem; box-shadow: 0 10px 30px -10px var(--brand-glow);
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1.5rem;
}

.dash-hero h1 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem; }
.dash-hero p { font-size: 0.95rem; opacity: 0.9; }

/* ==================== TABLES ==================== */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; }
.data-table th { background: var(--bg-base); padding: 1rem 1.25rem; font-weight: 800; color: var(--text-tertiary); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.data-table td { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); vertical-align: middle; transition: var(--transition); font-size: 0.9rem; }
.data-table tbody tr:hover td { background: var(--bg-base); }

.data-table .acct { font-family: 'Courier New', monospace; font-weight: 800; color: var(--brand-500); background: rgba(99, 102, 241, 0.1); padding: 0.25rem 0.6rem; border-radius: 6px; font-size: 0.8rem; }
.data-table .amount { font-family: 'Courier New', monospace; font-weight: 800; font-size: 0.95rem; }
.data-table .amount.danger { color: var(--danger); }
.data-table .amount.ok { color: var(--success); }

/* ==================== BUTTONS & BADGES ==================== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.7rem 1.25rem; border-radius: 12px; font-weight: 700; font-size: 0.85rem; transition: var(--transition); }

.btn-primary { background: var(--brand-500); color: white; }
.btn-primary:hover { background: var(--brand-600); transform: translateY(-2px); box-shadow: 0 4px 12px var(--brand-glow); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; transform: translateY(-2px); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-2px); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--bg-base); color: var(--text-primary); }

.badge { display: inline-block; padding: 0.3rem 0.75rem; border-radius: 50px; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-active { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-defaulter { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* ==================== FORMS ==================== */
.form-control, .search-wrap input, select {
    width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border-color); 
    border-radius: 12px; font-family: inherit; font-size: 0.95rem; 
    outline: none; background: var(--bg-surface); color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus, .search-wrap input:focus, select:focus { 
    border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); 
}

.search-wrap { 
    display: flex; align-items: center; background: var(--bg-surface); 
    border: 1px solid var(--border-color); border-radius: 50px; 
    padding: 0.35rem 0.35rem 0.35rem 1.25rem; transition: var(--transition);
}
.search-wrap:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2); }
.search-wrap input { border: none; padding: 0.5rem; background: transparent; box-shadow: none; font-size: 1rem; }

/* ==================== RESPONSIVE ==================== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; backdrop-filter: blur(4px); }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .menu-btn { display: block; }
    .content-body { padding: 1.25rem; }
    .topbar { padding: 0 1.25rem; height: 65px; }
    .desktop-show { display: none !important; }
    .desktop-hide { display: flex !important; flex-direction: column; gap: 1rem; }
}

@media (min-width: 1025px) {
    .desktop-show { display: block; }
    .desktop-hide { display: none; }
}

@media (max-width: 640px) {
    .dash-hero { padding: 1.5rem; }
    .dash-hero h1 { font-size: 1.4rem; }
    .stats-grid { grid-template-columns: 1fr; gap: 1rem; }
    .search-wrap { flex-direction: column; padding: 1rem; gap: 0.75rem; border-radius: var(--radius-lg); }
    .search-wrap button { width: 100%; }
}

/* Mobile Cards */
.consumer-card { 
    background: var(--bg-surface); border-radius: var(--radius-lg); padding: 1.25rem; 
    border: 1px solid var(--border-color); border-left: 4px solid var(--brand-500); 
    display: block; box-shadow: var(--shadow-md); transition: var(--transition); margin-bottom: 1rem;
}
.consumer-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-float); }
.consumer-card.defaulter { border-left-color: var(--danger); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.card-name { font-weight: 800; font-size: 1.1rem; color: var(--text-primary); }
.card-acct { font-family: monospace; font-size: 0.85rem; color: var(--brand-500); font-weight: 700; margin-top: 0.25rem;}
.card-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; font-size: 0.9rem; margin-bottom: 1.25rem; }
.card-field .k { font-size: 0.7rem; color: var(--text-tertiary); text-transform: uppercase; display: block; font-weight: 800; letter-spacing: 0.5px;}
.card-field .v { font-weight: 700; color: var(--text-primary); display: block; margin-top: 0.15rem; }
.card-outstanding { display: flex; justify-content: space-between; align-items: center; padding-top: 1.25rem; border-top: 1px dashed var(--border-color); }