:root {
    --primary: #0f172a; /* Midnight Blue */
    --accent: #f59e0b;  /* Amber Gold */
    --bg: #f1f5f9;      /* Light Gray Blue */
    --white: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
}

body { font-family: 'Inter', 'Segoe UI', sans-serif; background: var(--bg); margin: 0; color: #333; }

/* Navigation */
nav { background: var(--white); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.logo { font-size: 1.5rem; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.btn-logout { text-decoration: none; color: #64748b; font-size: 0.9rem; font-weight: 500; transition: 0.3s; }
.btn-logout:hover { color: var(--danger); }

.container { max-width: 900px; margin: 2rem auto; padding: 0 1rem; }

/* Cards */
.card { background: var(--white); padding: 2rem; border-radius: 16px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); margin-bottom: 1.5rem; position: relative; }

/* Wallet Section */
.wallet-card { text-align: center; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); color: white; }
.wallet-balance-label { color: #94a3b8; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }
.balance { font-size: 3.5rem; font-weight: 700; margin: 10px 0; color: var(--accent); }
.btn-deposit { background: var(--accent); color: #000; border: none; padding: 12px 30px; border-radius: 50px; font-weight: bold; cursor: pointer; transition: transform 0.2s; margin-top: 10px; }
.btn-deposit:hover { transform: scale(1.05); }

/* Quick Action Grid (Manager) */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.action-card { background: white; padding: 1.5rem; border-radius: 12px; text-align: center; cursor: pointer; transition: all 0.3s; border: 1px solid #e2e8f0; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.action-card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }
.action-icon { font-size: 2rem; margin-bottom: 0.5rem; display: block; }
.action-title { font-weight: 600; color: var(--primary); font-size: 0.9rem; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; padding: 15px; color: #64748b; font-size: 0.85rem; text-transform: uppercase; border-bottom: 2px solid #f1f5f9; }
td { padding: 15px; border-bottom: 1px solid #f1f5f9; color: #334155; }
tr:last-child td { border-bottom: none; }

/* MODALS (The New Professional Look) */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px); z-index: 1000; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.show { display: flex; opacity: 1; }
.modal-box { background: white; width: 90%; max-width: 500px; padding: 2rem; border-radius: 16px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); position: relative; transform: scale(0.95); transition: transform 0.3s ease; }
.modal-overlay.show .modal-box { transform: scale(1); }

.close-modal { position: absolute; top: 15px; right: 20px; font-size: 1.5rem; cursor: pointer; color: #94a3b8; }
.modal-title { margin-top: 0; color: var(--primary); font-size: 1.25rem; margin-bottom: 1.5rem; }

/* Forms in Modals */
.form-group { margin-bottom: 1rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.5rem; color: #475569; font-size: 0.9rem; font-weight: 500; }
.form-group input, .form-group select { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; box-sizing: border-box; transition: 0.3s; }
.form-group input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(30, 41, 59, 0.1); }
.btn-submit { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 1rem; }
.btn-submit:hover { background: #334155; }

/* --- Fix for the "Split Among" Checkbox Area --- */

.rider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Auto-columns */
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    padding: 15px;
    border-radius: 8px;
    background: #f8fafc;
    margin-top: 5px;
}

/* This class controls the individual box for "Checkbox + Name" */
.rider-option {
    display: flex;            /* Key fix: Forces side-by-side alignment */
    align-items: center;      /* Vertically centers them */
    justify-content: flex-start;
    gap: 12px;                /* Perfect space between box and text */
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    cursor: pointer;
    font-size: 0.95rem;
    color: #334155;
    font-weight: 500;
    transition: all 0.2s ease;
    user-select: none;
}

/* Hover Effect for Professional Feel */
.rider-option:hover {
    border-color: #0f172a;    /* Dark border on hover */
    background: #e2e8f0;      /* Light gray background on hover */
    transform: translateY(-1px);
}

/* Style the actual Checkbox input */
.rider-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;                /* Resets default browser margin */
    accent-color: #0f172a;    /* Makes the checkmark color match your theme */
    cursor: pointer;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    /* Adjust Container */
    .container {
        padding: 10px;
        margin: 1rem auto;
    }

    /* Navigation Stack */
    nav {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 1rem;
    }

    /* Cards */
    .card {
        padding: 1.5rem;
    }

    /* Wallet Font Size */
    .balance {
        font-size: 2.5rem; /* Smaller font for mobile */
    }

    /* Tables: Scroll horizontally on small screens */
    .card table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    /* Action Grid: 2 columns on mobile instead of auto */
    .action-grid {
        grid-template-columns: 1fr 1fr; 
    }

    /* Modals: Full width */
    .modal-box {
        width: 95%;
        padding: 1.5rem;
    }
}

/* --- LOGIN PAGE RESTORATION --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); /* Midnight Blue Gradient */
    margin: 0;
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-card h1 {
    color: #0f172a; /* Dark Blue */
    margin-bottom: 0.5rem;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.login-card p {
    color: #64748b; /* Slate Gray */
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin-bottom: 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box; /* Ensures padding doesn't break width */
    transition: 0.3s;
}

.login-card input:focus {
    border-color: #0f172a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.login-card button {
    width: 100%;
    padding: 14px;
    background: #f59e0b; /* Amber Gold */
    color: #0f172a;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s;
    margin-top: 10px;
}

.login-card button:hover {
    transform: translateY(-2px);
    background: #d97706; /* Darker Gold */
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.4);
}

/* Custom Split Inputs */
.custom-amount-input {
    width: 80px;
    padding: 5px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-left: auto; /* Pushes input to the right */
    display: none; /* Hidden by default (Equal Split Mode) */
    background: #fff;
}

.rider-option.custom-mode {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.rider-option.custom-mode .custom-amount-input {
    display: block; /* Show inputs in Custom Mode */
}

.preset-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.preset-select {
    flex: 1;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.btn-save-preset {
    background: #3b82f6; /* Blue */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* 1. Make 'Total Amount' Input look just like the Description Input */
#expense_total, #total_input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    color: #334155;
    background: #fff;
    transition: all 0.2s ease;
    box-sizing: border-box; /* Ensures padding doesn't make it wider */
    margin-top: 5px;
}

/* When Disabled (in Custom Mode), make it look nice */
#expense_total[readonly], #total_input[readonly] {
    background-color: #f1f5f9;
    color: #94a3b8;
    border-color: #e2e8f0;
    cursor: not-allowed;
}

/* 2. MODERN TOGGLE SWITCH (Replaces the old checkbox) */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    margin-right: 8px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1; /* Gray when off */
    transition: .4s;
    border-radius: 34px;
}

.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: #10b981; /* Green when on */
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Align the label text with the switch */
.toggle-label-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #475569;
    font-weight: 600;
}

/* --- SPLIT TYPE SELECTOR --- */
.split-type-container {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #cbd5e1;
}

.split-radio {
    display: none; /* Hide actual radio buttons */
}

.split-label {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

/* When checked, make it look active */
.split-radio:checked + .split-label {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Floating "Remaining" Badge for Custom Mode */
.remaining-badge {
    background: #fffbeb;
    color: #b45309;
    font-size: 0.8rem;
    padding: 5px 10px;
    border-radius: 20px;
    margin-left: auto;
    border: 1px solid #fcd34d;
    display: none; /* Hidden in Equal Mode */
}

/* --- PROFESSIONAL TOGGLE SWITCHES --- */
.switch-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}
.switch-label {
    font-weight: 500;
    color: #334155;
    font-size: 0.95rem;
}
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(22px); }