/* ============================================
   MOBILE-FIRST PROFESSIONAL STYLES
   Base styles = Mobile (320px+)
   Media queries scale UP with min-width
   ============================================ */

/* CSS Custom Properties for Theming */
:root {
    /* Colors */
    --primary-color: #007bff;
    --primary-dark: #0056b3;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    
    /* Light theme (default) */
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-color: #1a1a2e;
    --text-secondary: #6c757d;
    --border-color: #e0e0e0;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 15px;
    --font-size-lg: 17px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    
    /* Border radius */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 50%;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
    
    /* Touch targets */
    --touch-min: 44px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-color: #0d1117;
    --card-bg: #161b22;
    --text-color: #e6edf3;
    --text-secondary: #8b949e;
    --border-color: #30363d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ============================================
   BASE STYLES (Mobile First)
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color var(--transition-slow), color var(--transition-slow);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER CONTROLS
   ============================================ */

.header-controls {
    position: absolute;
    top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
    right: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    z-index: 160;
}

/* ============================================
   THEME TOGGLE (in header)
   ============================================ */

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle i {
    font-size: 18px;
}

/* ============================================
   COLOR PICKER BUTTON
   ============================================ */

.color-picker-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: var(--transition);
    padding: 0;
    flex-shrink: 0;
}

.color-picker-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.color-picker-btn:active {
    transform: scale(0.95);
}

.color-picker-btn i {
    font-size: 18px;
}

/* ============================================
   COLOR PICKER PANEL
   ============================================ */

.color-picker-panel {
    position: fixed;
    top: 70px;
    right: var(--space-lg);
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: var(--space-lg);
    z-index: 200;
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    pointer-events: none;
}

.color-picker-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.color-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.color-picker-header h3 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-color);
}

.color-picker-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

[data-theme="dark"] .color-picker-close {
    background: rgba(255, 255, 255, 0.1);
}

.color-picker-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

[data-theme="dark"] .color-picker-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.color-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.color-preset {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    padding: 3px;
    background: transparent;
    transition: var(--transition);
}

.color-preset:hover {
    transform: scale(1.1);
}

.color-preset.active {
    border-color: var(--text-color);
}

.color-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 4px;
}

.custom-color-section {
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.custom-color-section label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.custom-color-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.custom-color-wrapper input[type="color"] {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.custom-color-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.custom-color-wrapper input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.custom-color-value {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: var(--font-size-sm);
    color: var(--text-color);
    font-weight: 500;
    text-transform: uppercase;
}

/* ============================================
   APP HEADER
   ============================================ */

.app-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: var(--space-xl) var(--space-lg);
    padding-top: calc(var(--space-xl) + env(safe-area-inset-top, 0px));
    padding-right: calc(var(--space-lg) + 100px);
    text-align: center;
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 150;
}

.app-header h1 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ============================================
   PAGE CONTENT
   ============================================ */

.page-content {
    flex: 1;
    padding: var(--space-lg);
    padding-bottom: calc(var(--space-2xl) + 80px + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
    overflow: hidden;
    transition: var(--transition);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.03), rgba(0, 123, 255, 0.01));
}

.card-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.card-title {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-color);
}

.card-content {
    padding: var(--space-lg);
}

/* ============================================
   FORMS
   ============================================ */

.input-group {
    margin-bottom: var(--space-lg);
}

.input-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: var(--space-sm);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-prefix {
    position: absolute;
    left: var(--space-md);
    color: var(--text-secondary);
    font-weight: 500;
    pointer-events: none;
    z-index: 1;
}

.form-input {
    width: 100%;
    padding: var(--space-md);
    padding-left: var(--space-lg);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--text-color);
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
    min-height: var(--touch-min);
}

.input-wrapper .form-input {
    padding-left: calc(var(--space-xl) + var(--space-sm));
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

/* Select styling */
select.form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* Textarea */
textarea.form-input {
    min-height: 80px;
    resize: vertical;
}

.notes-input {
    min-height: 70px;
}

/* ============================================
   BUTTONS
   ============================================ */

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.btn-full {
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--space-md) var(--space-lg);
    font-size: var(--font-size-base);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-primary:active {
    filter: brightness(0.95);
    transform: scale(0.98);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #1e7e34);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #bd2130);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), #545b62);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, var(--info-color), #117a8b);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d39e00);
    color: #212529;
}

.btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    border-radius: var(--radius-full);
    padding: 0;
    font-size: 16px;
}

/* Settings page toggle switch already using standard .toggle-switch/.toggle-slider styles below */

/* ============================================
   INLINE COLOR PICKER
   ============================================ */

.color-picker-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: flex-start;
}

.color-presets-inline {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.color-preset-inline {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.color-preset-inline:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

.color-preset-inline.active {
    border-color: var(--text-color);
    transform: scale(1.15);
}

.custom-color-inline {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

#settings-custom-color {
    width: 50px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition);
}

#settings-custom-color:hover {
    border-color: var(--primary-color);
}

.custom-color-value-inline {
    font-family: monospace;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    min-width: 70px;
}

/* ============================================
   SUMMARY GRID
   ============================================ */

.summary-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

/* ============================================
   SUMMARY ITEMS
   ============================================ */

.summary-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: rgba(0, 123, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 123, 255, 0.08);
    gap: var(--space-sm);
}

.summary-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.summary-value {
    font-size: var(--font-size-base);
    font-weight: 700;
    text-align: right;
    word-break: break-word;
}

/* ============================================
   INSIGHTS CARD
   ============================================ */

.insights-card {
    border-left: 4px solid var(--warning-color);
}

.insights-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.insight-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .insight-item {
    background: rgba(255, 255, 255, 0.03);
}

.insight-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.insight-warning .insight-icon {
    background: rgba(255, 193, 7, 0.15);
    color: var(--warning-color);
}

.insight-danger .insight-icon {
    background: rgba(220, 53, 69, 0.15);
    color: var(--danger-color);
}

.insight-success .insight-icon {
    background: rgba(40, 167, 69, 0.15);
    color: var(--success-color);
}

.insight-info .insight-icon {
    background: rgba(23, 162, 184, 0.15);
    color: var(--info-color);
}

.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 2px;
}

.insight-message {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ============================================
   UPCOMING DEDUCTIONS
   ============================================ */

.upcoming-deductions-card {
    border-left: 4px solid var(--info-color);
}

.upcoming-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.upcoming-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

[data-theme="dark"] .upcoming-item {
    background: rgba(255, 255, 255, 0.03);
}

.upcoming-item.urgent {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.upcoming-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.upcoming-details {
    flex: 1;
    min-width: 0;
}

.upcoming-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 2px;
}

.upcoming-meta {
    display: flex;
    gap: var(--space-sm);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.upcoming-amount {
    font-weight: 600;
    color: var(--danger-color);
}

.upcoming-frequency {
    text-transform: capitalize;
}

.upcoming-due {
    text-align: right;
    flex-shrink: 0;
}

.days-until {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--primary-color);
}

.days-until.urgent-text {
    color: var(--danger-color);
}

.due-date {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* ============================================
   STATISTICS CARD
   ============================================ */

.stats-card {
    border-left: 4px solid var(--success-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.stat-box {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .stat-box {
    background: rgba(255, 255, 255, 0.03);
}

.stat-box .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    flex-shrink: 0;
}

.stat-box .stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-box .stat-value {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-color);
    word-break: break-word;
}

.stat-box .stat-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.extreme-expenses {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.extreme-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    gap: var(--space-sm);
}

.extreme-item.highest {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.15);
}

.extreme-item.lowest {
    background: rgba(40, 167, 69, 0.08);
    border: 1px solid rgba(40, 167, 69, 0.15);
}

.extreme-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-weight: 500;
}

.extreme-item.highest .extreme-label {
    color: var(--danger-color);
}

.extreme-item.lowest .extreme-label {
    color: var(--success-color);
}

.extreme-value {
    font-weight: 600;
    color: var(--text-color);
    text-align: right;
}

/* ============================================
   CATEGORY BREAKDOWN LIST
   ============================================ */

.category-breakdown-list {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.category-breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

.category-breakdown-item:last-child {
    border-bottom: none;
}

.category-breakdown-item .category-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.category-breakdown-item .category-name {
    font-size: var(--font-size-sm);
    color: var(--text-color);
    font-weight: 500;
}

.category-breakdown-item .category-stats {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.category-breakdown-item .category-amount {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
}

.category-breakdown-item .category-percentage {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* ============================================
   FREQUENCY LEGEND
   ============================================ */

.frequency-legend {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.legend-note {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* ============================================
   TREND CHART
   ============================================ */

.trend-card {
    border-left: 4px solid var(--info-color);
}

.trend-chart-wrapper {
    height: 200px;
}

.trend-summary {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.trend-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.trend-increasing {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-color);
}

.trend-decreasing {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success-color);
}

.trend-stable {
    background: rgba(23, 162, 184, 0.1);
    color: var(--info-color);
}

/* ============================================
   CATEGORY BUDGETS
   ============================================ */

.category-budgets-card {
    border-left: 4px solid var(--secondary-color);
}

.category-budgets-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.category-budget-item {
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .category-budget-item {
    background: rgba(255, 255, 255, 0.03);
}

.category-budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    gap: var(--space-sm);
}

.category-budget-header .category-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.category-budget-header .category-name {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
}

.category-budget-amounts {
    font-size: var(--font-size-sm);
}

.category-budget-amounts .spent {
    font-weight: 600;
    color: var(--danger-color);
}

.category-budget-amounts .separator {
    color: var(--text-secondary);
    margin: 0 var(--space-xs);
}

.category-budget-amounts .budget {
    font-weight: 600;
    color: var(--success-color);
}

.category-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--space-xs);
}

.category-progress-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.category-budget-footer {
    display: flex;
    justify-content: flex-end;
}

.category-budget-footer .utilization {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 500;
}

.category-budget-footer .utilization.over-budget {
    color: var(--danger-color);
}

/* ============================================
   DEDUCTION BREAKDOWN
   ============================================ */

.deduction-breakdown {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.breakdown-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin: 0 0 var(--space-md);
    color: var(--text-color);
}

.breakdown-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    padding: var(--space-xs) 0;
    gap: var(--space-sm);
}

.breakdown-item span:last-child {
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
}

/* ============================================
   MONTHLY EQUIVALENT SECTION
   ============================================ */

.monthly-equivalent-section {
    margin-top: var(--space-lg);
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.06), rgba(0, 123, 255, 0.02));
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 123, 255, 0.1);
}

.equivalent-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--primary-color);
    margin: 0 0 var(--space-xs);
}

.equivalent-explanation {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-md);
}

.equivalent-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.equivalent-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-sm);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}

[data-theme="dark"] .equivalent-item {
    background: rgba(0, 0, 0, 0.2);
}

.equivalent-item span:first-child {
    color: var(--text-secondary);
    font-weight: 500;
}

.equivalent-item span:last-child {
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: var(--font-size-xs);
    color: var(--text-color);
}

.equivalent-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    gap: var(--space-sm);
}

.equivalent-total .total-value {
    font-size: var(--font-size-base);
    font-weight: 700;
}

/* ============================================
   NEXT DEDUCTION
   ============================================ */

.next-deduction-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.deduction-detail {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: rgba(0, 123, 255, 0.04);
    border-radius: var(--radius-sm);
    gap: var(--space-sm);
}

.detail-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-align: right;
}

.next-due-highlight {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: linear-gradient(135deg, var(--info-color), #117a8b);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-size-base);
    margin-top: var(--space-sm);
}

/* ============================================
   FORM GRID
   ============================================ */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* ============================================
   BUDGET MODE TOGGLE
   ============================================ */

.budget-mode-toggle {
    margin-bottom: var(--space-lg);
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 123, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 123, 255, 0.1);
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.toggle-label {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-color);
}

.toggle-description {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.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-color);
    transition: var(--transition);
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-switch input:focus + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

/* Budget Actions */
.budget-actions {
    display: flex;
    gap: var(--space-sm);
}

.budget-actions button {
    flex: 1;
    min-height: var(--touch-min);
}

/* Expense-only Info */
.expense-only-info {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.08), rgba(23, 162, 184, 0.02));
    border-radius: var(--radius-sm);
    border: 1px solid rgba(23, 162, 184, 0.2);
}

.expense-only-info .info-icon {
    color: var(--info-color);
    font-size: var(--font-size-xl);
    flex-shrink: 0;
}

.expense-only-info p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ============================================
   SETTINGS SECTION
   ============================================ */

.settings-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) 0;
}

.settings-label {
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.settings-value select {
    min-width: 100px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
}

/* ============================================
   FILTERS SECTION
   ============================================ */

.filters-section {
    background: rgba(0, 123, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

/* Search Section */
.search-section {
    margin-bottom: var(--space-lg);
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: var(--space-md);
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 1;
}

.search-input {
    padding-left: calc(var(--space-xl) + var(--space-sm));
    padding-right: calc(var(--space-xl) + var(--space-sm));
    min-height: var(--touch-min);
}

.search-clear-btn {
    position: absolute;
    right: var(--space-sm);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

[data-theme="dark"] .search-clear-btn {
    background: rgba(255, 255, 255, 0.1);
}

.search-clear-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

[data-theme="dark"] .search-clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.filter-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.filter-grid .input-group {
    margin-bottom: 0;
}

.filter-grid .input-label {
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-xs);
}

.filter-grid .form-input {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    min-height: 40px;
}

.date-filter-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.filter-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
    align-items: stretch;
}

.filter-footer button {
    width: 100%;
    min-height: var(--touch-min);
    font-size: var(--font-size-sm);
}

.filter-count {
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ============================================
   EXPENSES LIST
   ============================================ */

.expenses-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.expense-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--space-lg);
    transition: var(--transition);
}

.expense-card:active {
    transform: scale(0.99);
}

.expense-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.expense-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.expense-main {
    flex: 1;
    min-width: 0;
}

.expense-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 var(--space-xs);
    word-break: break-word;
}

.expense-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}

.category-tag,
.frequency-tag,
.day-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--space-sm);
    border-radius: 4px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    text-transform: capitalize;
}

.category-tag {
    color: white;
}

.frequency-tag,
.day-tag {
    background: rgba(0, 123, 255, 0.1);
    color: var(--primary-color);
}

.expense-amount {
    flex-shrink: 0;
    margin-left: auto;
}

.amount-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--success-color);
}

.expense-footer {
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-md);
}

.start-date {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.expense-notes {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: var(--space-sm) 0 0;
    font-style: italic;
}

.expense-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.expense-actions .btn-icon {
    flex: 1;
    min-height: var(--touch-min);
    border-radius: var(--radius-sm);
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.action-buttons button,
.action-buttons label {
    min-height: var(--touch-min);
    font-size: var(--font-size-sm);
    width: 100%;
}

/* ============================================
   EMPTY STATES
   ============================================ */

.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
}

.empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-lg);
    border-radius: var(--radius-full);
    background: rgba(0, 123, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    font-size: var(--font-size-xl);
}

.empty-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 var(--space-sm);
}

.empty-text {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--space-lg);
    line-height: 1.6;
}

/* ============================================
   CHARTS
   ============================================ */

.charts-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-wrapper canvas {
    max-width: 100%;
    max-height: 100%;
}

/* ============================================
   BUDGET PROGRESS
   ============================================ */

.budget-progress {
    margin-bottom: var(--space-lg);
}

.progress-bar {
    width: 100%;
    height: 24px;
    background: var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-md);
}

.progress-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.budget-fill {
    background: linear-gradient(90deg, var(--success-color), #28a745);
}

.progress-labels {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.progress-label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.label-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
}

.budget-dot {
    background: var(--success-color);
}

.actual-dot {
    background: var(--danger-color);
}

.budget-stats {
    display: flex;
    gap: var(--space-md);
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: var(--space-md);
    background: rgba(0, 123, 255, 0.04);
    border-radius: var(--radius-sm);
}

.stat-label {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: var(--space-sm) 0;
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    color: var(--text-secondary);
    background: transparent;
    min-width: 64px;
    min-height: var(--touch-min);
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
}

.nav-item i {
    font-size: 20px;
    margin-bottom: 2px;
}

.nav-item span {
    font-size: var(--font-size-xs);
    font-weight: 500;
}

/* ============================================
   PWA INSTALL BANNER
   ============================================ */

.pwa-install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    padding-top: env(safe-area-inset-top, 0px);
}

.install-banner-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-lg);
    text-align: center;
    gap: var(--space-md);
}

.install-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-lg);
}

.install-text h3 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: 600;
}

.install-text p {
    margin: var(--space-xs) 0 0;
    font-size: var(--font-size-sm);
    opacity: 0.9;
}

.install-actions {
    display: flex;
    gap: var(--space-sm);
    width: 100%;
}

.install-actions button {
    flex: 1;
    min-height: var(--touch-min);
    font-size: var(--font-size-sm);
}

/* ============================================
   CONFIRMATION MODAL
   ============================================ */

.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: var(--space-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.confirm-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.confirm-modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-xl);
    max-width: 320px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.confirm-modal h3 {
    margin: 0 0 var(--space-md);
    font-size: var(--font-size-lg);
    color: var(--text-color);
}

.confirm-modal p {
    margin: 0 0 var(--space-lg);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.confirm-modal-actions {
    display: flex;
    gap: var(--space-sm);
}

.confirm-modal-actions button {
    flex: 1;
    min-height: var(--touch-min);
    font-size: var(--font-size-sm);
}

/* ============================================
   BUDGET WARNING BADGE
   ============================================ */

.budget-warning-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: 4px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-left: var(--space-xs);
}

.budget-warning-badge.warning {
    background: rgba(255, 193, 7, 0.2);
    color: var(--warning-color);
}

.budget-warning-badge.danger {
    background: rgba(220, 53, 69, 0.2);
    color: var(--danger-color);
}

/* ============================================
   CURRENCY CONVERTER
   ============================================ */

.currency-converter-card {
    border-left: 4px solid var(--primary-color);
}

.converter-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.converter-controls .input-group {
    margin-bottom: 0;
}

.converter-controls .btn-primary {
    min-height: var(--touch-min);
}

.converter-error {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.2);
    border-radius: var(--radius-sm);
    color: var(--danger-color);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

.rates-updated {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(23, 162, 184, 0.08);
    border-radius: var(--radius-sm);
    color: var(--info-color);
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-md);
}

.converter-results {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.converter-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: rgba(0, 123, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 123, 255, 0.08);
    gap: var(--space-sm);
}

.converter-result-item .result-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.converter-result-item .result-value {
    font-size: var(--font-size-base);
    font-weight: 700;
    color: var(--text-color);
    text-align: right;
}

.converter-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    line-height: 1.5;
}

[data-theme="dark"] .converter-note {
    background: rgba(255, 255, 255, 0.03);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-primary { color: var(--primary-color); }
.text-danger { color: var(--danger-color); }
.text-success { color: var(--success-color); }
.text-secondary { color: var(--text-secondary); }
.text-info { color: var(--info-color); }
.text-muted { color: var(--text-secondary); font-size: var(--font-size-xs); }

/* ============================================
   NOTIFICATIONS
   ============================================ */

.notification {
    position: fixed;
    top: 70px;
    left: var(--space-lg);
    right: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 150;
    max-width: 400px;
    margin: 0 auto;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-notification {
    background: linear-gradient(135deg, var(--danger-color), #bd2130);
    color: white;
}

.success-notification {
    background: linear-gradient(135deg, var(--success-color), #1e7e34);
    color: white;
}

.info-notification {
    background: linear-gradient(135deg, var(--info-color), #117a8b);
    color: white;
}

/* ============================================
   OFFLINE INDICATOR
   ============================================ */

.offline-indicator {
    position: fixed;
    top: calc(70px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger-color);
    color: white;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.offline-indicator.show {
    opacity: 1;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.card {
    animation: fadeInUp 0.3s ease;
}

/* Page transition animations */
.page-content {
    animation: fadeIn 0.3s ease;
}

/* Staggered card animations */
.card:nth-child(1) { animation-delay: 0ms; }
.card:nth-child(2) { animation-delay: 50ms; }
.card:nth-child(3) { animation-delay: 100ms; }
.card:nth-child(4) { animation-delay: 150ms; }
.card:nth-child(5) { animation-delay: 200ms; }

/* ============================================
   SKELETON LOADING STATES
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--border-color) 25%,
        rgba(0, 123, 255, 0.1) 50%,
        var(--border-color) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-sm);
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 100%; }

.skeleton-title {
    height: 24px;
    width: 50%;
    margin-bottom: var(--space-md);
}

.skeleton-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
}

.skeleton-card {
    padding: var(--space-lg);
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: var(--space-lg);
}

.skeleton-card .skeleton-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.skeleton-card .skeleton-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Button press effect */
.btn-primary:active,
.btn-secondary:active,
.btn-success:active,
.btn-danger:active,
.btn-info:active,
.btn-warning:active {
    transform: scale(0.97);
}

/* Ripple effect for buttons */
button {
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

button:active::after {
    width: 200%;
    height: 200%;
}

/* Card hover lift effect */
@media (hover: hover) {
    .card {
        transition: transform var(--transition), box-shadow var(--transition);
    }
    
    .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
    }
    
    .expense-card {
        transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    }
    
    .expense-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow);
        border-color: var(--primary-color);
    }
}

/* Icon button hover */
.btn-icon:hover {
    transform: scale(1.1);
}

.btn-icon:active {
    transform: scale(0.9);
}

/* Nav item interaction */
.nav-item {
    transition: transform var(--transition), background-color var(--transition), color var(--transition);
}

.nav-item:active {
    transform: scale(0.92);
}

/* Input focus glow */
.form-input:focus {
    animation: pulse 0.3s ease;
}

/* Toggle switch animation */
.toggle-slider {
    transition: background-color var(--transition), transform var(--transition);
}

/* Progress bar animation */
.progress-fill,
.category-progress-fill {
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Insight item hover */
.insight-item {
    transition: transform var(--transition), background-color var(--transition);
}

.insight-item:hover {
    transform: translateX(4px);
}

/* Upcoming item hover */
.upcoming-item {
    transition: transform var(--transition), background-color var(--transition);
}

.upcoming-item:hover {
    transform: translateX(4px);
}

/* Category breakdown item hover */
.category-breakdown-item {
    transition: background-color var(--transition);
}

.category-breakdown-item:hover {
    background: rgba(0, 123, 255, 0.04);
}

/* ============================================
   ENHANCED MOBILE EXPERIENCE
   ============================================ */

/* Touch feedback for mobile */
@media (hover: none) {
    .card:active {
        transform: scale(0.99);
        transition: transform 0.1s ease;
    }
    
    .expense-card:active {
        transform: scale(0.98);
        background: rgba(0, 123, 255, 0.02);
    }
    
    .btn-primary:active,
    .btn-secondary:active,
    .btn-success:active,
    .btn-danger:active {
        transform: scale(0.95);
    }
    
    .nav-item:active {
        transform: scale(0.9);
    }
}

/* Pull to refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 50;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Safe area handling for notched devices */
@supports (padding: max(0px)) {
    .app-header {
        padding-top: max(var(--space-xl), env(safe-area-inset-top));
        padding-right: max(var(--space-lg), env(safe-area-inset-right));
        padding-left: max(var(--space-lg), env(safe-area-inset-left));
    }
    
    .page-content {
        padding-left: max(var(--space-lg), env(safe-area-inset-left));
        padding-right: max(var(--space-lg), env(safe-area-inset-right));
        padding-bottom: max(var(--space-2xl) + 80px, calc(var(--space-2xl) + 80px + env(safe-area-inset-bottom)));
    }
    
    .bottom-nav {
        padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.loading-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.loading-content {
    background: var(--card-bg);
    padding: var(--space-xl);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.loading-content .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Button loading state */
button.loading {
    pointer-events: none;
    opacity: 0.8;
}

button.loading .btn-text {
    visibility: hidden;
}

button.loading::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================
   SPIN ANIMATION
   ============================================ */

.spin-animation {
    animation: spin 1s linear infinite;
}

/* ============================================
   TOOLTIP STYLES
   ============================================ */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: var(--space-xs) var(--space-sm);
    background: var(--text-color);
    color: var(--card-bg);
    font-size: var(--font-size-xs);
    font-weight: 500;
    white-space: nowrap;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition);
    z-index: 100;
}

[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ============================================
   EMPTY STATE ANIMATIONS
   ============================================ */

.empty-icon {
    animation: bounce 2s ease-in-out infinite;
}

.empty-state .btn-primary {
    animation: fadeInUp 0.5s ease 0.3s both;
}

/* ============================================
   SUCCESS ANIMATIONS
   ============================================ */

@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto;
}

.success-checkmark circle {
    fill: none;
    stroke: var(--success-color);
    stroke-width: 2;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: checkmark 0.6s ease-in-out forwards;
}

.success-checkmark path {
    fill: none;
    stroke: var(--success-color);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: checkmark 0.3s 0.4s ease-in-out forwards;
}

/* ============================================
   MEDIA QUERIES - TABLET (640px+)
   ============================================ */

@media (min-width: 640px) {
    :root {
        --font-size-base: 16px;
        --font-size-lg: 18px;
        --font-size-xl: 22px;
    }
    
    .page-content {
        padding: var(--space-xl);
        padding-bottom: calc(var(--space-2xl) + 80px);
        max-width: 800px;
        margin: 0 auto;
    }
    
    .summary-grid {
        flex-direction: row;
    }
    
    .summary-grid > .card {
        flex: 1;
    }
    
    .form-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .form-grid .input-group {
        flex: 1 1 calc(50% - var(--space-md));
        min-width: 200px;
    }
    
    .filter-grid {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .filter-grid .input-group {
        flex: 1 1 calc(50% - var(--space-md));
        min-width: 150px;
    }
    
    .date-filter-row {
        flex-direction: row;
    }
    
    .date-filter-row .input-group {
        flex: 1;
    }
    
    .filter-footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
    
    .filter-footer button {
        width: auto;
        min-width: 120px;
    }
    
    .charts-grid {
        flex-direction: row;
    }
    
    .charts-grid > .card {
        flex: 1;
    }
    
    .chart-wrapper {
        height: 280px;
    }
    
    .progress-labels {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .action-buttons button,
    .action-buttons label {
        flex: 1 1 calc(50% - var(--space-sm));
        min-width: 140px;
        width: auto;
    }
    
    .install-banner-content {
        flex-direction: row;
        text-align: left;
    }
    
    .install-actions {
        width: auto;
    }
}

/* ============================================
   MEDIA QUERIES - DESKTOP (1024px+)
   ============================================ */

@media (min-width: 1024px) {
    :root {
        --font-size-xl: 24px;
        --font-size-2xl: 28px;
    }
    
    .app-header h1 {
        font-size: var(--font-size-2xl);
    }
    
    .page-content {
        max-width: 1000px;
        padding: var(--space-2xl);
    }
    
    .card:hover {
        box-shadow: var(--shadow);
    }
    
    .card-header {
        padding: var(--space-xl);
    }
    
    .card-content {
        padding: var(--space-xl);
    }
    
    .card-icon {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .form-grid .input-group {
        flex: 1 1 calc(33.333% - var(--space-md));
    }
    
    .filter-grid .input-group {
        flex: 1 1 calc(25% - var(--space-md));
    }
    
    .action-buttons button,
    .action-buttons label {
        flex: 1 1 calc(16.666% - var(--space-sm));
        min-width: 120px;
    }
    
    .chart-wrapper {
        height: 300px;
    }
    
    /* Bottom nav becomes top nav on desktop */
    .bottom-nav {
        position: static;
        border-top: none;
        border-bottom: 1px solid var(--border-color);
        padding: var(--space-md) 0;
        justify-content: center;
        gap: var(--space-xl);
        box-shadow: none;
    }
    
    .nav-item {
        flex-direction: row;
        gap: var(--space-sm);
        min-width: auto;
        padding: var(--space-sm) var(--space-lg);
    }
    
    .nav-item i {
        margin-bottom: 0;
    }
    
    .page-content {
        padding-bottom: var(--space-2xl);
    }
}

/* ============================================
   PWA STANDALONE MODE
   ============================================ */

@media all and (display-mode: standalone) {
    .pwa-install-banner {
        display: none !important;
    }
    
    .app-header {
        padding-top: calc(var(--space-xl) + env(safe-area-inset-top, 0px));
    }
    
    .theme-toggle {
        top: calc(var(--space-lg) + env(safe-area-inset-top, 0px));
    }
}

/* ============================================
   iOS PWA ENHANCEMENTS
   ============================================ */

@supports (-webkit-touch-callout: none) {
    .page-content {
        padding-bottom: calc(var(--space-2xl) + 80px + env(safe-area-inset-bottom, 0px));
    }
    
    .bottom-nav {
        padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
.form-input:focus,
button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--border-color);
    }
    
    .btn-primary {
        background: var(--primary-color);
    }
}

/* Print styles */
@media print {
    .bottom-nav,
    .theme-toggle,
    .pwa-install-banner {
        display: none !important;
    }
    
    .page-content {
        padding-bottom: 0;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* ============================================
   SETTINGS PAGE STYLES
   ============================================ */

.settings-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
}

[data-theme="dark"] .settings-item {
    background: rgba(255, 255, 255, 0.03);
}

.settings-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 150px;
}

.settings-item-label {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-color);
}

.settings-item-desc {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.settings-item.danger-zone {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

/* Categories List */
.categories-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.category-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .category-item {
    background: rgba(255, 255, 255, 0.03);
}

.category-preview {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    flex-shrink: 0;
}

.category-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-details .category-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-color);
}

.category-details .category-id {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    text-transform: capitalize;
}

.category-actions {
    display: flex;
    gap: var(--space-xs);
}

/* Templates List */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.template-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .template-item {
    background: rgba(255, 255, 255, 0.03);
}

.template-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.template-name {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--text-color);
}

.template-meta {
    display: flex;
    gap: var(--space-sm);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.template-amount {
    font-weight: 600;
    color: var(--success-color);
}

.template-frequency {
    text-transform: capitalize;
}

.template-actions {
    display: flex;
    gap: var(--space-xs);
}

/* Info List */
.info-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.info-value {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-color);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: var(--space-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    color: var(--text-color);
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

[data-theme="dark"] .modal-close {
    background: rgba(255, 255, 255, 0.1);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

[data-theme="dark"] .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.modal-footer button {
    flex: 1;
    min-height: var(--touch-min);
}

/* Color Options */
.color-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-color);
}

/* Icon Options */
.icon-options {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.icon-option {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
    font-size: 16px;
}

.icon-option:hover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.05);
}

.icon-option.active {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
    color: var(--primary-color);
}

/* ============================================ */
/* ACCESSIBILITY ENHANCEMENTS */
/* ============================================ */

/* Skip Link for Accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s ease;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-weight: 500;
}

.skip-link:focus {
    top: 0;
}

/* Screen Reader Only - Visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible styles for better keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* High visibility focus for interactive elements */
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-success:focus-visible,
.btn-danger:focus-visible,
.btn-info:focus-visible,
.btn-warning:focus-visible {
    outline: 3px solid white;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px var(--primary-color);
}

/* Nav item focus */
.nav-item:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background: rgba(0, 123, 255, 0.15);
}

/* Card focus for keyboard navigation */
.card:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Expense card keyboard focus */
.expense-card:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}
