:root {
    /* Teal-Inspired Palette */
    --primary: #14B8A6;
    --primary-hover: #0D9488;
    --bg: #FAFAFA;
    --surface: #FFFFFF;
    --white: #FFFFFF;
    --text: #2E2E2E;
    --text-secondary: #6B6B6B;
    --border: #E9E0D8;
    --success: #5BA876;
    --error: #D64545;
    --warning: #E9B44C;

    /* Typography Scale */
    --fs-h1: 40px;
    --fs-h2: 32px;
    --fs-h3: 24px;
    --fs-large: 16px;
    --fs-body: 14px;

    /* Component Tokens */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 12px 24px -6px rgba(20, 184, 166, 0.15);
    --radius-card: 16px;
    --radius-btn: 12px;
    --radius-pill: 24px;
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Spacing Units */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 48px;

    --nav-height: 72px;
    --nav-mobile-height: 64px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    background-image: radial-gradient(at 0% 0%, rgba(20, 184, 166, 0.03) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(20, 184, 166, 0.03) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    font-size: var(--fs-body);
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

.container {
    max-width: 1140px;
    /* narrowed slightly for better proportion */
    margin: 0 auto;
    padding: 0 var(--space-3);
}

h1 {
    font-size: var(--fs-h1);
    font-weight: 700;
    margin-bottom: var(--space-2);
}

h2 {
    font-size: var(--fs-h2);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

h3 {
    font-size: var(--fs-h3);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

/* Navigation */
.navbar {
    height: var(--nav-height);
    background-color: var(--surface);
    box-shadow: 0 1px 0 var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-content {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.nav-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: var(--fs-body);
    transition: color var(--transition);
}

.nav-link:hover {
    color: var(--primary);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding-left: var(--space-3);
    border-left: 1px solid var(--border);
}

/* Base Components */
.card {
    background-color: var(--surface);
    padding: var(--space-3);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    border: 1px solid rgba(233, 224, 216, 0.5);
    /* softer border */
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Hero Cards */
.hero-card {
    background: linear-gradient(135deg, var(--surface) 0%, #FFFDFB 100%);
    border-radius: 24px;
    padding: var(--space-4);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: var(--space-4);
    position: relative;
    overflow: hidden;
}

/* Subtle decorative shape for hero */
.hero-card::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(20, 184, 166, 0.08) 0%, rgba(20, 184, 166, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-3);
    height: 40px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-btn);
    font-size: var(--fs-body);
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all var(--transition);
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .btn {
        height: 44px;
    }
}

.btn-secondary {
    background-color: #F0E9E3;
    color: var(--primary);
}

.btn-secondary:hover {
    background-color: var(--border);
}

.pill {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-2);
}

.form-group label {
    display: block;
    font-size: var(--fs-body);
    font-weight: 500;
    margin-bottom: var(--space-1);
}

.form-control {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    font-family: inherit;
    font-size: var(--fs-large);
    transition: all var(--transition);
    background-color: var(--surface);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}

/* Specific Layouts */
.dashboard-header {
    margin-bottom: var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
}

@media (max-width: 992px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
    }

    .dashboard-net-worth {
        width: 100%;
        text-align: left !important;
        padding-top: 1rem;
        border-top: 1px solid var(--border);
    }
}

.masonry-grid {
    columns: 1;
    column-gap: var(--space-3);
}

@media (min-width: 768px) {
    .masonry-grid {
        columns: 2;
    }
}

@media (min-width: 1024px) {
    .masonry-grid {
        columns: 3;
    }
}

.masonry-grid>* {
    break-inside: avoid;
    margin-bottom: var(--space-3);
}

/* Alerts */
.alert {
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-card);
    margin-bottom: var(--space-3);
    font-size: var(--fs-body);
    font-weight: 500;
    border: 1px solid transparent;
}

.alert-error {
    background-color: #FEF2F2;
    color: var(--error);
    border-color: #FEE2E2;
}

.alert-success {
    background-color: #F0FDF4;
    color: var(--success);
    border-color: #DCFCE7;
}

.alert-warning {
    background-color: #FFFBEB;
    color: var(--warning);
    border-color: #FEF3C7;
}

/* Mobile Nav Components (PWA) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-mobile-height);
    background: var(--surface);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    display: none;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }

    .desktop-nav {
        display: none;
    }

    main.container {
        padding-bottom: calc(var(--nav-mobile-height) + var(--space-3));
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    gap: 4px;
    flex: 1;
    transition: color var(--transition);
}

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

.mobile-nav-item.add-btn {
    position: relative;
    top: -15px;
}

.plus-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.4);
}

/* Drawer */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition);
    z-index: 1001;
}

.drawer-overlay.show {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100%;
    background: var(--surface);
    z-index: 1002;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(-280px);
}

.drawer-header {
    padding: var(--space-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2);
}

.drawer-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 12px var(--space-2);
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-card);
    transition: background var(--transition);
}

.drawer-link:hover {
    background: var(--bg);
}

/* Floating Action Button (Desktop Only) */
@media (min-width: 769px) {
    .fab {
        position: fixed;
        bottom: var(--space-4);
        right: var(--space-4);
        width: 60px;
        height: 60px;
        background-color: var(--primary);
        color: var(--white);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px rgba(20, 184, 166, 0.4);
        text-decoration: none;
        transition: transform var(--transition);
        z-index: 99;
    }

    .fab:hover {
        transform: scale(1.1);
    }
}

/* Progress Bars */
.progress-container {
    height: 8px;
    background-color: var(--border);
    border-radius: var(--radius-pill);
    margin: var(--space-2) 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* History */
.timeline-item {
    border-left: 4px solid var(--primary);
    margin-bottom: var(--space-3);
}

.source-chip {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg);
    color: var(--text-secondary);
}

.history-controls {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

/* Auth Pages */
.auth-wrapper {
    min-height: calc(100vh - var(--nav-height));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}