:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #10b981;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --nav-width: 260px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Navbar Styling */
.navbar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--nav-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1.5rem;
    z-index: 1000;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3rem;
    padding-left: 0.5rem;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 0.75rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: var(--radius);
}

.nav-links a:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-links a.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-links i {
    width: 20px;
    height: 20px;
}

/* New Features Styles */
.stat-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Fixed Section Summary */
.fixed-summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card-small {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.2rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.summary-card-small .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card-small .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-card-small.highlight .value {
    color: var(--accent);
}

/* Checkbox styling */
.checkbox-cell {
    width: 40px;
    text-align: center;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.custom-checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
}

.custom-checkbox i {
    color: white;
    width: 14px;
    height: 14px;
    display: none;
}

.custom-checkbox.checked i {
    display: block;
}

tr.paid td {
    color: var(--text-secondary);
    opacity: 0.6;
}

tr.paid td:first-child {
    text-decoration: line-through;
}

/* Table Footer */
.table-footer {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 700;
}

.table-footer td {
    border-top: 2px solid var(--border) !important;
}

/* Print Styles */
@media print {

    .navbar,
    .finance-form,
    .btn-delete,
    .actions,
    .month-selector,
    .year-selector,
    .salary-settings {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        box-shadow: none;
        border: 1px solid #eee;
    }

    .page {
        display: block !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Main Content Area */
.content {
    margin-left: var(--nav-width);
    padding: 2rem 3rem;
    min-height: 100vh;
    max-width: 1200px;
}

.page {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header Styling */
.section-header {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
}

.salary-settings {
    display: flex;
    gap: 1.5rem;
}

.variance-summary {
    text-align: right;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.variance-summary p {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.variance-summary span {
    font-size: 1.25rem;
    font-weight: 700;
}

.current-period {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-weight: 600;
}

.current-period select {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    outline: none;
    padding: 2px 4px;
    border-radius: 4px;
}

.current-period select:hover {
    background: rgba(99, 102, 241, 0.05);
}

.sub-section {
    margin-bottom: 3rem;
}

.sub-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.sub-title i {
    color: var(--primary);
}

.section-header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.section-header p {
    color: var(--text-muted);
}

.budget-input label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-with-icon {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-sm);
}

.input-with-icon span {
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

.input-with-icon input {
    border: none;
    outline: none;
    font-size: 1.125rem;
    font-weight: 600;
    width: 120px;
    background: transparent;
}

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

.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid var(--border);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.total-spent .stat-icon {
    background: #fee2e2;
    color: #ef4444;
}

.claimable .stat-icon {
    background: #dcfce7;
    color: #10b981;
}

.remaining .stat-icon {
    background: #e0e7ff;
    color: #6366f1;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Card Styling */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

/* Forms */
.finance-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
}

.input-group {
    flex: 1;
    min-width: 200px;
}

.input-group.full-width {
    flex-basis: 100%;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.input-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
    height: 46px;
}

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

.btn-primary.full-width {
    justify-content: center;
    width: 100%;
}

/* Table */
.list-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 1rem;
    border-bottom: 2px solid var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

.data-table .actions {
    text-align: right;
    width: 80px;
}

.table-input {
    width: 100px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    outline: none;
    transition: all 0.2s;
}

.table-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
}

/* Chart Placeholder / Summary List */
.charts-placeholder {
    display: none;
}

#dashboard.active .charts-placeholder {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-top: 2rem;
}

.chart-card {
    flex: 1;
    min-width: 300px;
}

.expense-summary-list {
    margin-top: 1rem;
}

body>.charts-placeholder,
main>.charts-placeholder {
    display: none !important;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.summary-value {
    font-weight: 700;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .navbar {
        width: 100%;
        height: auto;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid var(--border);
        padding: 6px 10px;
        background: rgba(255, 255, 255, 0.9);
        backdrop-filter: blur(10px);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    }

    .nav-container {
        max-width: 600px;
        margin: 0 auto;
    }

    .logo {
        display: none;
    }

    .nav-links {
        display: flex;
        justify-content: space-around;
        gap: 0;
    }

    .nav-links li {
        margin-bottom: 0;
        flex: 1;
    }

    .nav-links a {
        flex-direction: column;
        gap: 4px;
        font-size: 0.65rem;
        padding: 8px 4px;
        text-align: center;
        border-radius: 8px;
        color: var(--text-muted);
    }

    .nav-links a.active {
        background: transparent;
        color: var(--primary);
        box-shadow: none;
    }

    .nav-links i {
        width: 20px;
        height: 20px;
    }

    .content {
        margin-left: 0;
        padding: 1rem;
        padding-bottom: 80px;
        /* Space for bottom nav */
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        text-align: center;
        margin-bottom: 2rem;
    }

    .section-header h1 {
        font-size: 1.75rem;
    }

    .salary-settings {
        width: 100%;
        flex-direction: column;
        gap: 1rem;
    }

    .budget-input {
        width: 100%;
    }

    .input-with-icon {
        justify-content: center;
        padding: 0.75rem;
    }

    .finance-form {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group {
        width: 100%;
        min-width: unset;
    }

    /* Make buttons bigger for touch */
    .btn-primary,
    .btn-secondary {
        height: 52px;
        font-size: 1rem;
    }

    /* Fixed Section Summary Bar for Mobile */
    .fixed-summary-bar {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }

    .summary-card-small {
        padding: 0.8rem;
    }

    .summary-card-small .value {
        font-size: 1.1rem;
    }
}

/* Specific iOS Bottom Safe Area */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .navbar {
        padding-bottom: calc(6px + env(safe-area-inset-bottom));
    }
}