@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #473472;
    --primary-hover: #53629E;
    --secondary: #53629E;
    --background: #D6F4ED;
    --surface: #FFFFFF;
    --text-main: #473472;
    --text-muted: #53629E;
    --border: #87BAC3;
    --success: #87BAC3;
    --danger: #EF4444;
    --warning: #F59E0B;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    overflow: hidden;
    /* Prevent body scroll, use content scroll */
}

/* --- Layout --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 30px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.nav-menu {
    list-style: none;
    flex: 1;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background-color: #EEF2FF;
    /* Light Indigo */
    color: var(--primary);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

/* --- Components --- */
.card {
    background-color: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-main);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card {
    background-color: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.stat-value.income {
    color: var(--success);
}

.stat-value.expense {
    color: var(--danger);
}

.stat-value.savings {
    color: var(--primary);
}

/* Forms */
input,
select,
button {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

button {
    cursor: pointer;
    font-weight: 600;
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--background);
}

.btn-danger {
    background-color: #FEF2F2;
    color: var(--danger);
}

.btn-danger:hover {
    background-color: #FEE2E2;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background-color: #F9FAFB;
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    margin-bottom: 16px;
}

tr:last-child td {
    border-bottom: none;
}

/* Auth Pages */
.auth-body {
    background-color: #F3F4F6;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 8px;
}

.link {
    text-align: center;
    font-size: 14px;
    margin-top: 20px;
}

.link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.link a:hover {
    text-decoration: underline;
}

.error-message {
    background-color: #FEF2F2;
    color: var(--danger);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 10px 20px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .nav-menu {
        display: none;
        /* Hide menu on mobile for now, or implement hamburger */
    }

    .sidebar-header {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .main-content {
        padding: 20px;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--surface);
    color: var(--text-main);
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    transform: scale(0.9);
    transition: all 0.3s ease;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-overlay.show .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
}

.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.goal-title {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-main);
}

.goal-amount {
    font-weight: 700;
    color: var(--primary);
    font-size: 18px;
}

.goal-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.goal-detail-item {
    display: flex;
    justify-content: space-between;
}

.goal-actions {
    display: flex;
    justify-content: flex-end;
}

/* Fixed Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    width: 90%;
    max-width: 400px;
    transform: scale(0.9);
    transition: all 0.3s ease;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal.show .modal-content {
    transform: scale(1);
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.quick-add-box {
    background-color: #F9FAFB;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.telegram-card {
    background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}