:root {
    --primary: #1e293b; --secondary: #2563eb; --success: #16a34a; --danger: #dc2626;
    --light: #f1f5f9; --white: #ffffff; --border: #e2e8f0; --text-dark: #0f172a;
}

/* --- GLOBAL RESET --- */
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

body {
    background-color: var(--light);
    color: var(--text-dark);
    /* CRITICAL FIX: height: 100vh ensures body fills screen */
    height: 100vh;
    width: 100%;
    overflow: hidden; /* Prevents body scroll */
    margin: 0;
}

/* --- LOGIN SCREEN --- */
#loginScreen {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--secondary), #0f172a);
    display: flex;
    justify-content: center; align-items: center;
    z-index: 9999;
}

.login-card {
    background: white; padding: 2.5rem; border-radius: 16px; width: 90%; max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); text-align: center; z-index: 10000;
}
.login-header .logo-icon { width: 50px; height: 50px; background: var(--secondary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; font-size: 1.5rem; font-weight: bold; }
.input-group { margin-bottom: 1rem; text-align: left; }
.input-group label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.9rem; }
.input-group input { width: 100%; padding: 0.8rem; border: 1px solid var(--border); border-radius: 8px; }
.btn-login { width: 100%; padding: 0.8rem; background: var(--primary); color: white; border: none; border-radius: 8px; font-weight: bold; font-size: 1rem; cursor: pointer; }

/* --- APP CONTAINER --- */
.app-container {
    display: none; /* Hidden initially */
    height: 100vh; /* Fills the body height */
    width: 100%;
    flex-direction: column;
}

/* News */
.news-marquee {
    background: #1e293b; color: #fbbf24; padding: 10px; overflow: hidden; white-space: nowrap;
    font-size: 0.9rem; font-weight: 500; animation: marquee 20s linear infinite;
}
@keyframes marquee { 0% { transform: translateX(100vw); } 100% { transform: translateX(-100%); } }

/* Dashboard Layout */
.dashboard-wrapper { display: flex; flex: 1; overflow: hidden; } /* Flex layout for sidebar + content */

/* Sidebar */
.sidebar { width: 260px; background: var(--primary); color: #cbd5e1; display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; overflow-y: auto; }
.brand { height: 64px; display: flex; align-items: center; padding: 0 1.5rem; color: white; font-weight: bold; font-size: 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.nav-menu { list-style: none; padding: 1rem; flex: 1; }
.nav-item { padding: 0.75rem 1rem; margin-bottom: 0.5rem; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: 0.2s; white-space: nowrap; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); color: white; }

/* Main Content */
.main-content { flex: 1; overflow-y: auto; padding: 2rem; background-color: var(--light); }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 10px; }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.5rem; color: var(--primary); cursor: pointer; }

/* Components */
.card { background: white; padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.stat-value { font-size: 2rem; font-weight: 700; margin-top: 0.5rem; }
.text-primary { color: var(--secondary); } .text-success { color: var(--success); } .text-danger { color: var(--danger); }
.btn { padding: 0.6rem 1.2rem; border: none; border-radius: 8px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary { background: var(--secondary); color: white; } .btn-danger { background: var(--danger); color: white; } .btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem; border-bottom: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
th { background: #f8fafc; font-weight: 600; color: #64748b; text-transform: uppercase; }
.table-container { overflow-x: auto; width: 100%; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; justify-content: center; align-items: center; z-index: 2000; }
.modal { background: white; padding: 2rem; width: 90%; max-width: 500px; border-radius: 12px; max-height: 90vh; overflow-y: auto; }
.modal input, .modal select { width: 100%; padding: 0.6rem; margin-bottom: 0; border: 1px solid var(--border); border-radius: 6px; }
.type-toggle { display: flex; background: #e2e8f0; padding: 4px; border-radius: 8px; margin-bottom: 10px; }
.type-opt { flex: 1; text-align: center; padding: 8px; cursor: pointer; font-weight: bold; }
.type-opt.active[data-val="credit"] { background: var(--success); color: white; }
.type-opt.active[data-val="debit"] { background: var(--danger); color: white; }

/* Filters */
.filter-bar { display: flex; gap: 10px; background: white; padding: 1rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; min-width: 140px; }
.filter-group label { font-size: 0.8rem; font-weight: bold; margin-bottom: 4px; color: #64748b; }

#denomInputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.denom-row { display: flex; align-items: center; background: #f8fafc; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); }
.denom-label { font-weight: bold; width: 60px; }
.denom-input { flex: 1; padding: 5px; border: 1px solid var(--border); border-radius: 4px; }

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: 1rem; }
.avatar { width: 80px; height: 80px; background: var(--secondary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; font-size: 2rem; font-weight: bold; }

/* Mobile */
@media (max-width: 768px) {
    .sidebar { position: fixed; top: 0; left: 0; height: 100%; z-index: 1000; transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.show { transform: translateX(0); }
    .mobile-menu-btn { display: block; }
    .header { align-items: flex-start; }
    .card { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr; }
    #denomInputs { grid-template-columns: 1fr; }
}