
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Roboto:wght@400;500;700&family=Poppins:wght@400;500;600;700&family=Open+Sans:wght@400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root[data-theme="dark"], :root {
    --bg-primary: #0a0e27;
    --bg-secondary: #131829;
    --bg-tertiary: #1a1f3a;
    --text-primary: #e4e7eb;
    --text-secondary: #9ca3af;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #2d3548;
}

:root[data-theme="light"] {
    --bg-primary: #f9fafb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --border: #e5e7eb;
}

:root[data-accent="cyan"], :root {
    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-light: rgba(6, 182, 212, 0.1);
}

:root[data-accent="purple"] {
    --accent: #a855f7;
    --accent-hover: #9333ea;
    --accent-light: rgba(168, 85, 247, 0.1);
}

:root[data-accent="blue"] {
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.1);
}

:root[data-accent="green"] {
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: rgba(16, 185, 129, 0.1);
}

:root[data-accent="orange"] {
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: rgba(245, 158, 11, 0.1);
}

:root[data-accent="pink"] {
    --accent: #ec4899;
    --accent-hover: #db2777;
    --accent-light: rgba(236, 72, 153, 0.1);
}

:root[data-font="inter"], :root {
    --font-primary: 'Inter', sans-serif;
}

:root[data-font="roboto"] {
    --font-primary: 'Roboto', sans-serif;
}

:root[data-font="poppins"] {
    --font-primary: 'Poppins', sans-serif;
}

:root[data-font="opensans"] {
    --font-primary: 'Open Sans', sans-serif;
}

:root[data-density="compact"] {
    --day-cell-min-height: 90px;
    --day-cell-padding: 0.25rem;
    --day-number-size: 0.85rem;
    --day-event-size: 0.7rem;
    --day-event-padding: 0.15rem 0.3rem;
    --day-event-margin: 0.15rem;
    --day-summary-size: 0.7rem;
}

:root[data-density="comfortable"], :root {
    --day-cell-min-height: 120px;
    --day-cell-padding: 0.5rem;
    --day-number-size: 0.9rem;
    --day-event-size: 0.75rem;
    --day-event-padding: 0.25rem 0.4rem;
    --day-event-margin: 0.25rem;
    --day-summary-size: 0.75rem;
}

:root[data-density="spacious"] {
    --day-cell-min-height: 140px;
    --day-cell-padding: 0.75rem;
    --day-number-size: 1rem;
    --day-event-size: 0.8rem;
    --day-event-padding: 0.35rem 0.5rem;
    --day-event-margin: 0.35rem;
    --day-summary-size: 0.8rem;
}

:root[data-compact="true"] {
    --spacing-sm: 0.25rem;
    --spacing-md: 0.5rem;
    --spacing-lg: 0.75rem;
}

:root {
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-link {
    color: var(--accent);
    cursor: pointer;
    margin-left: 0.25rem;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-primary);
}

.form-input-error {
    border-color: var(--danger) !important;
}

.form-error {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

textarea.form-input {
    min-height: 80px;
    resize: vertical;
    font-family: var(--font-primary);
}

.select-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.select-input:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: var(--font-primary);
}

.btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
    color: var(--accent);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-edit {
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: var(--accent);
    color: white;
}

.btn-delete {
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.username {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.profile-picture {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}

.profile-icon {
    font-size: 1.5rem;
}

.btn-logout {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-icon {
    font-size: 1.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.view-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.view-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    margin-bottom: -1px;
}

.view-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.view-tab:hover {
    color: var(--text-primary);
}

.calendar-section {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.calendar-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.controls-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-nav {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-nav:hover {
    background: var(--bg-primary);
    border-color: var(--accent);
}

.btn-add {
    padding: 0.5rem 1.5rem;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-add:hover {
    background: var(--accent-hover);
}

.view-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 6px;
    padding: 0.25rem;
}

.view-toggle button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.view-toggle button.active {
    background: var(--accent);
    color: white;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.day-header {
    background: var(--bg-tertiary);
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--accent);
}

.day-cell {
    background: var(--bg-secondary);
    padding: var(--day-cell-padding);
    min-height: var(--day-cell-min-height);
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid transparent;
}

.day-cell:hover {
    background: var(--bg-tertiary);
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.day-cell.other-month {
    opacity: 0.4;
}

.day-cell.today {
    background: var(--accent-light);
    border: 2px solid var(--accent);
    box-shadow: 0 0 12px var(--accent-light);
}

.day-number {
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-size: var(--day-number-size);
    color: var(--text-primary);
    flex-shrink: 0;
}

.day-cell.today .day-number {
    color: var(--accent);
}

.day-summary {
    font-size: var(--day-summary-size);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 0.25rem;
    padding: 0.15rem 0.25rem;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.day-summary.positive {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.day-summary.negative {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.day-events {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

[data-compact="true"] .calendar-grid .day-cell {
    min-height: 100px;
    max-height: 100px;
    overflow: hidden;
}

[data-compact="true"] .calendar-grid .day-cell .day-events {
    overflow: hidden;
    flex: 1;
}

[data-compact="true"] .calendar-grid .day-cell .day-event {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    margin-bottom: 0.15rem;
}

[data-compact="true"] .calendar-grid .day-cell .day-summary {
    font-size: 0.7rem;
    padding: 0.15rem 0.25rem;
}

[data-compact="true"] .day-number {
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.day-event {
    padding: var(--day-event-padding);
    margin-bottom: var(--day-event-margin);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.event-indicator {
    width: 3px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 3px 0 0 3px;
}

.event-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding-left: 0.5rem;
}

.event-title-cal {
    font-weight: 600;
    font-size: var(--day-event-size);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.event-amount-cal {
    font-family: 'JetBrains Mono', monospace;
    font-size: calc(var(--day-event-size) - 0.05rem);
    font-weight: 600;
    color: var(--text-secondary);
}

.event-icon {
    display: inline-block;
    margin-right: 0.25rem;
    font-size: 0.9em;
}

.day-event.income {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.day-event.income .event-indicator {
    background: var(--success);
}

.day-event.income:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.1));
    transform: translateX(2px);
}

.day-event.income .event-amount-cal {
    color: var(--success);
}

/* Expense Events */
.day-event.expense {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.day-event.expense .event-indicator {
    background: var(--danger);
}

.day-event.expense:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(239, 68, 68, 0.1));
    transform: translateX(2px);
}

.day-event.expense .event-amount-cal {
    color: var(--danger);
}

.day-event.general {
    background: linear-gradient(135deg, var(--accent-light), transparent);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.day-event.general .event-indicator {
    background: var(--accent);
}

.day-event.general:hover {
    background: linear-gradient(135deg, var(--accent-light), var(--accent-light));
    transform: translateX(2px);
}

.day-event.recurring,
.week-event.recurring {
    border-style: dashed !important;
    opacity: 0.9;
}

.more-events {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    background: var(--accent-light);
    border-radius: 4px;
    text-align: center;
    margin-top: 0.25rem;
}

.week-view {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.week-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.week-day-header {
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    border-right: 1px solid var(--border);
}

.week-day-header:last-child {
    border-right: none;
}

.week-day-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--bg-secondary);
}

.week-day {
    padding: 1rem;
    min-height: 400px;
    border-right: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.week-day:last-child {
    border-right: none;
}

.week-day:hover {
    background: var(--bg-tertiary);
}

.week-day.today {
    background: var(--accent-light);
}

.week-event {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    border-left: 3px solid;
    background: var(--bg-tertiary);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.week-event:hover {
    transform: translateX(2px);
}

.week-event.expense { 
    border-left-color: var(--danger);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), transparent);
}

.week-event.income { 
    border-left-color: var(--success);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), transparent);
}

.week-event.general { 
    border-left-color: var(--accent);
    background: linear-gradient(135deg, var(--accent-light), transparent);
}

.week-event-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.week-event-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.week-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    font-weight: 600;
}

.week-total.positive { color: var(--success); }
.week-total.negative { color: var(--danger); }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-large {
    max-width: 800px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.modal-actions .btn {
    flex: 1;
}

/* Day Events Modal */
.day-summary-modal {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.income-badge,
.expense-badge,
.net-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.income-badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.expense-badge {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.net-badge {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--accent);
}

.net-badge.positive {
    color: var(--success);
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.net-badge.negative {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.event-card {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.event-card.expense { border-left-color: var(--danger); }
.event-card.income { border-left-color: var(--success); }
.event-card.general { border-left-color: var(--accent); }

.event-info h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.event-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.event-category {
    text-transform: capitalize;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.event-amount-display {
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.event-notes-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

.event-actions {
    display: flex;
    gap: 0.5rem;
}

.budgets-section {
    max-width: 1200px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.budget-grid {
    display: grid;
    gap: 1rem;
}

.budget-card {
    background: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.budget-name {
    font-weight: 600;
    font-size: 1.05rem;
}

.budget-amounts {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.budget-spent {
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.budget-progress {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.budget-progress-bar {
    height: 100%;
    background: var(--success);
    transition: all 0.3s;
}

.budget-progress-bar.over { background: var(--danger); }

.budget-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.budget-status {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.budget-actions {
    display: flex;
    gap: 0.5rem;
}

.analytics-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.category-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.category-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-name {
    font-weight: 600;
    color: var(--text-primary);
}

.category-amount {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.category-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.category-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    transition: width 0.3s;
}

.category-percentage {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

.trend-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.trend-item {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.trend-month {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.trend-amounts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trend-income,
.trend-expenses,
.trend-balance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.trend-label {
    color: var(--text-secondary);
}

.trend-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.settings-section {
    max-width: 1200px;
    margin: 0 auto;
}

.settings-section h2 {
    margin-bottom: 2rem;
    font-size: 1.75rem;
    font-weight: 700;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.settings-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.settings-card-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Theme Selector */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.theme-option {
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid var(--border);
}

.theme-option:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.theme-option.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.theme-preview {
    width: 100%;
    aspect-ratio: 16/10;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    overflow: hidden;
    position: relative;
}

.dark-preview {
    background: #0a0e27;
}

.dark-preview .preview-bar {
    height: 20%;
    background: #131829;
}

.dark-preview .preview-content {
    height: 80%;
    background: #1a1f3a;
    margin: 4px;
    border-radius: 4px;
}

.light-preview {
    background: #f9fafb;
}

.light-preview .preview-bar {
    height: 20%;
    background: #ffffff;
}

.light-preview .preview-content {
    height: 80%;
    background: #f3f4f6;
    margin: 4px;
    border-radius: 4px;
}

.auto-preview {
    background: linear-gradient(90deg, #0a0e27 0%, #0a0e27 50%, #f9fafb 50%, #f9fafb 100%);
}

.auto-preview .preview-bar {
    height: 20%;
    background: linear-gradient(90deg, #131829 0%, #131829 50%, #ffffff 50%, #ffffff 100%);
}

.auto-preview .preview-content {
    height: 80%;
    background: linear-gradient(90deg, #1a1f3a 0%, #1a1f3a 50%, #f3f4f6 50%, #f3f4f6 100%);
    margin: 4px;
    border-radius: 4px;
}

.theme-option span {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.color-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.color-option.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.color-option span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Toggle Switch */
.toggle-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-radius: 8px;
    background: var(--bg-tertiary);
    margin-bottom: 0.75rem;
}

.toggle-info strong {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.toggle-info p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--accent);
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Image Upload */
.image-preview-container {
    width: 100%;
    aspect-ratio: 1;
    max-width: 200px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.background-preview-container {
    aspect-ratio: 16/9;
    max-width: 100%;
}

.profile-preview,
.background-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-placeholder,
.background-placeholder {
    text-align: center;
    color: var(--text-secondary);
}

.placeholder-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.image-upload-controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.file-upload-btn {
    cursor: pointer;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.settings-save-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.settings-save-bar p {
    color: var(--text-secondary);
}

.info-box {
    background: var(--accent-light);
    border: 1px solid rgba(6, 182, 212, 0.3);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.info-box strong {
    color: var(--accent);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Loading States */
.loading-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.toast-hiding {
    animation: slideOut 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    color: var(--text-primary);
    font-size: 0.9rem;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.toast-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--accent); }

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 999;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    /* Header */
    .header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .user-section {
        gap: 0.5rem;
    }
    
    .username {
        display: none;
    }
    
    .profile-picture {
        width: 32px;
        height: 32px;
    }
    
    .main {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .view-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .view-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .view-tab {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.65rem 1rem;
    }
    
    .calendar-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .calendar-title {
        font-size: 1.25rem;
        text-align: center;
    }
    
    .controls-group {
        justify-content: space-between;
    }
    
    .btn-nav {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }
    
    .btn-add {
        display: none;
    }
    
    .fab {
        display: flex;
    }
    
    .calendar-grid {
        gap: 2px;
    }
    
    .day-header {
        padding: 0.5rem 0.25rem;
        font-size: 0.8rem;
    }
    
    .day-cell {
        min-height: 85px;
        padding: 0.3rem;
    }
    
    .day-number {
        font-size: 0.8rem;
        margin-bottom: 0.2rem;
    }
    
    .day-summary {
        font-size: 0.65rem;
        padding: 0.15rem 0.25rem;
        margin-bottom: 0.15rem;
    }
    
    .day-event {
        font-size: 0.65rem;
        padding: 0.15rem 0.25rem;
        margin-bottom: 0.15rem;
    }
    
    .event-title-cal {
        font-size: 0.7rem;
    }
    
    .event-amount-cal {
        font-size: 0.6rem;
    }
    
    .more-events {
        font-size: 0.6rem;
        padding: 0.1rem 0.2rem;
    }
    
    [data-compact="true"] .calendar-grid .day-cell {
        min-height: 70px;
        max-height: 70px;
    }
    
    [data-density="compact"] .calendar-grid .day-cell {
        min-height: 70px;
        padding: 0.2rem;
    }
    
    [data-density="comfortable"] .calendar-grid .day-cell {
        min-height: 85px;
        padding: 0.3rem;
    }
    
    [data-density="spacious"] .calendar-grid .day-cell {
        min-height: 100px;
        padding: 0.4rem;
    }
    
    .week-view {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .week-header,
    .week-grid {
        min-width: 600px;
    }
    
    .week-day-header {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }
    
    .week-day-date {
        font-size: 0.65rem;
    }
    
    .week-event {
        font-size: 0.7rem;
        padding: 0.3rem 0.4rem;
        margin-bottom: 0.3rem;
    }
    
    .week-total {
        font-size: 0.7rem;
        padding: 0.3rem;
    }
    
    /* Modals */
    .modal {
        margin: 0;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .modal-large {
        max-width: 100%;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-title {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-actions {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    .form-input,
    .select-input {
        font-size: 16px;
        padding: 0.75rem;
    }
    
    .event-list {
        gap: 0.5rem;
    }
    
    .event-card {
        padding: 0.75rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .event-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .budget-grid {
        gap: 0.75rem;
    }
    
    .budget-card {
        padding: 1rem;
    }
    
    .budget-footer {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .budget-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-card {
        padding: 1rem;
    }
    
    .theme-selector {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .color-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    
    .image-preview-container {
        max-width: 150px;
    }
    
    .settings-save-bar {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .settings-save-bar p {
        text-align: center;
    }
    
    .day-summary-modal {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .main {
        padding: 0.75rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .day-cell {
        min-height: 75px;
        padding: 0.25rem;
    }
    
    .day-number {
        font-size: 0.75rem;
    }
    
    .day-summary {
        font-size: 0.6rem;
        padding: 0.1rem 0.2rem;
    }
    
    .day-event {
        font-size: 0.6rem;
        padding: 0.1rem 0.2rem;
        margin-bottom: 0.1rem;
    }
    
    .event-icon {
        display: none; 
    }
    
    .more-events {
        font-size: 0.55rem;
    }
    
    [data-compact="true"] .calendar-grid .day-cell {
        min-height: 60px;
        max-height: 60px;
    }
    
    [data-compact="true"] .day-event:nth-child(n+2) {
        display: none;
    }
    
    [data-compact="true"] .event-amount-cal {
        display: none;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .calendar-grid .day-cell {
        min-height: 70px;
    }
    
    [data-compact="true"] .calendar-grid .day-cell {
        min-height: 60px;
        max-height: 60px;
    }
    
    .day-event {
        font-size: 0.6rem;
        padding: 0.1rem 0.2rem;
    }
}

@media (hover: none) and (pointer: coarse) {
    .btn,
    .btn-nav,
    .btn-add,
    .btn-edit,
    .btn-delete {
        min-height: 44px;
    }
    
    .day-cell {
        min-height: 80px;
    }
    
    .day-event {
        padding: 0.3rem 0.4rem;
        margin-bottom: 0.2rem;
    }
    
    .view-tab {
        min-height: 44px;
    }
    
    .day-cell:active {
        background: var(--bg-tertiary);
        transform: scale(0.98);
    }
    
    .day-event:active {
        opacity: 0.8;
    }
    
    .btn:active {
        transform: scale(0.95);
    }
}

@supports (padding: max(0px)) {
    .header {
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(2rem, env(safe-area-inset-left));
        padding-right: max(2rem, env(safe-area-inset-right));
    }
    
    .main {
        padding-left: max(2rem, env(safe-area-inset-left));
        padding-right: max(2rem, env(safe-area-inset-right));
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
    
    .fab {
        bottom: max(24px, env(safe-area-inset-bottom));
        right: max(24px, env(safe-area-inset-right));
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .day-event {
        border-width: 2px;
    }
    
    .btn {
        border-width: 2px;
    }
}

*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

[data-theme="light"] .modal {
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .toast {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .stat-card {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .day-cell {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .day-cell:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] body {
    background-image: none;
}

* {
    transition-property: background-color, border-color, color;
    transition-duration: 0.2s;
    transition-timing-function: ease-in-out;
}

.day-cell,
.btn,
.modal,
.toast,
input,
select,
textarea {
    transition-property: background-color, border-color, color, transform, box-shadow;
}

[data-compact] .calendar-grid .day-cell {
    transition: min-height 0.3s ease, max-height 0.3s ease, padding 0.3s ease;
}

@media print {
    [data-theme="light"] {
        --bg-primary: #ffffff;
        --bg-secondary: #ffffff;
        --text-primary: #000000;
    }
    
    .header,
    .view-tabs,
    .btn,
    .settings-save-bar,
    .fab {
        display: none !important;
    }
    
    .calendar-grid .day-cell {
        min-height: 100px;
        max-height: none;
        page-break-inside: avoid;
    }
    
    [data-compact="true"] .calendar-grid .day-cell {
        max-height: none;
    }
    
    .day-event {
        font-size: 8pt;
    }
}

[data-compact="true"] .calendar-section::before {
    content: "📌 Compact Mode Active";
    display: block;
    padding: 0.5rem;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 0.75rem;
    text-align: center;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    [data-compact="true"] .calendar-section::before {
        font-size: 0.7rem;
        padding: 0.4rem;
    }
}