:root {
    --primary-color: #1e3a8a;
    --primary-light: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    padding-bottom: 70px; /* Space for bottom nav */
    padding-top: 60px; /* Space for top header */
    overflow-x: hidden;
}

/* Header */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.top-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

/* App Container */
#app-container {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    min-height: calc(100vh - 130px);
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background-color: var(--card-bg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 40;
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: 'Cairo', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    width: 25%;
    padding: 8px 0;
    transition: color 0.2s;
}

.nav-btn .icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.nav-btn.active {
    color: var(--primary-color);
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Typography */
.text-center { text-align: center; }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-muted { color: var(--text-muted); font-size: 0.9rem; }
.font-bold { font-weight: 700; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.2s, transform 0.1s;
}
.btn:active {
    transform: scale(0.98);
}
.btn-primary {
    background-color: var(--primary-color);
    color: white;
}
.btn-success {
    background-color: var(--success-color);
    color: white;
}
.btn-danger {
    background-color: var(--danger-color);
    color: white;
}
.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}
.btn-sm {
    padding: 8px 12px;
    font-size: 0.9rem;
    width: auto;
    display: inline-block;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.95rem;
}
.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    transition: border-color 0.2s;
    background-color: #fafafa;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: white;
}
.row {
    display: flex;
    gap: 12px;
}
.col {
    flex: 1;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.stat-box {
    background: var(--bg-color);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
    padding: 16px;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

/* Utilities */
.hidden { display: none !important; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }

/* Toasts */
#toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    max-width: 400px;
}
.toast {
    background-color: var(--text-main);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease-out;
    text-align: center;
}
.toast.success { background-color: var(--success-color); }
.toast.error { background-color: var(--danger-color); }

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* History List */
.history-item {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 0;
    cursor: pointer;
}
.history-item:last-child {
    border-bottom: none;
}
.history-date {
    font-weight: 700;
    color: var(--primary-color);
}
.history-summary {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.9rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
}
.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Expenses List */
.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.expense-item:last-child {
    border-bottom: none;
}
.expense-desc { font-weight: 600; }
.expense-amount { color: var(--danger-color); font-weight: 700; }
.expense-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 4px;
    cursor: pointer;
}

/* Simple Bar Chart */
.chart-container {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 20px;
    margin-top: 10px;
    border-bottom: 1px solid var(--border-color);
}
.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
}
.chart-bar {
    width: 100%;
    background-color: var(--primary-light);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.5s ease;
}
.chart-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}
