/* ===== 暗号化家計簿アプリ - Premium Dark Theme ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Core palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255,255,255,0.03);
    --bg-glass: rgba(255,255,255,0.05);
    --bg-glass-hover: rgba(255,255,255,0.08);
    --border-glass: rgba(255,255,255,0.08);
    --border-focus: rgba(99,102,241,0.5);

    /* Text */
    --text-primary: #e8e8ed;
    --text-secondary: #8b8b9e;
    --text-muted: #5a5a6e;
    --text-accent: #a78bfa;

    /* Accent colors */
    --accent-primary: #6366f1;
    --accent-primary-glow: rgba(99,102,241,0.3);
    --accent-success: #10b981;
    --accent-success-glow: rgba(16,185,129,0.2);
    --accent-danger: #ef4444;
    --accent-danger-glow: rgba(239,68,68,0.2);
    --accent-warning: #f59e0b;
    --accent-info: #3b82f6;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a78bfa 100%);
    --gradient-income: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-expense: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
    --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
                   radial-gradient(ellipse at 50% 80%, rgba(16,185,129,0.04) 0%, transparent 50%);

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 30px var(--accent-primary-glow);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: var(--gradient-bg);
    pointer-events: none;
    z-index: 0;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===== Screen Sections ===== */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    animation: fadeIn 0.4s ease;
}
.screen.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ===== Auth Screen ===== */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
}

.auth-header {
    text-align: center;
    margin-bottom: 36px;
}

.auth-logo {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(99,102,241,0.1);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-accent);
    margin-top: 12px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 0.5px;
}

/* ===== Tabs ===== */
.auth-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 28px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-tab.active {
    background: var(--accent-primary);
    color: white;
    box-shadow: 0 2px 10px var(--accent-primary-glow);
}

.auth-tab:hover:not(.active) {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

/* ===== Forms ===== */
.auth-form { display: none; }
.auth-form.active { display: block; }

.form-group {
    margin-bottom: 18px;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
    background: rgba(255,255,255,0.06);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    width: 100%;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 15px var(--accent-primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--accent-primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-glass);
}

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.82rem;
    width: auto;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { opacity: 0.7; }

/* ===== Error/Success Messages ===== */
.message {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    margin-bottom: 16px;
    display: none;
    animation: slideUp 0.3s ease;
}

.message.show { display: block; }
.message.error {
    background: var(--accent-danger-glow);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}
.message.success {
    background: var(--accent-success-glow);
    border: 1px solid rgba(16,185,129,0.3);
    color: #6ee7b7;
}

/* ===== Backup Code Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 36px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.4s ease;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 12px;
    text-align: center;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 24px;
    line-height: 1.7;
}

.backup-code-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    padding: 20px;
    background: rgba(99,102,241,0.1);
    border: 2px dashed rgba(99,102,241,0.3);
    border-radius: var(--radius-lg);
    color: var(--text-accent);
    letter-spacing: 6px;
    margin-bottom: 16px;
    user-select: all;
}

.backup-warning {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: rgba(245,158,11,0.1);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.backup-warning-icon { font-size: 1.2rem; flex-shrink: 0; }
.backup-warning-text { font-size: 0.78rem; color: #fbbf24; line-height: 1.6; }

/* ===== Main App Layout ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 20px;
}

.sidebar-logo { font-size: 1.8rem; }
.sidebar-appname {
    font-size: 1.1rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-user {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.88rem;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99,102,241,0.12);
    color: var(--accent-primary);
}

.nav-item .nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border-glass);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    position: relative;
    z-index: 1;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-actions { display: flex; gap: 10px; }

/* ===== Dashboard Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(255,255,255,0.12);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.balance::before { background: var(--gradient-primary); }
.stat-card.income::before { background: var(--gradient-income); }
.stat-card.expense::before { background: var(--gradient-expense); }

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
}

.stat-card.income .stat-value { color: var(--accent-success); }
.stat-card.expense .stat-value { color: var(--accent-danger); }
.stat-card.balance .stat-value { color: var(--text-accent); }

.stat-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1.8rem;
    opacity: 0.15;
}

/* ===== Charts Section ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.chart-canvas-wrapper {
    position: relative;
    height: 250px;
}

.chart-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ===== Entry Form ===== */
.entry-form-card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.type-toggle {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-md);
    padding: 4px;
}

.type-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    color: var(--text-secondary);
}

.type-btn.active.income-btn {
    background: rgba(16,185,129,0.15);
    color: var(--accent-success);
    box-shadow: 0 2px 10px var(--accent-success-glow);
}

.type-btn.active.expense-btn {
    background: rgba(239,68,68,0.15);
    color: var(--accent-danger);
    box-shadow: 0 2px 10px var(--accent-danger-glow);
}

/* ===== Entries List ===== */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entry-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.entry-item:hover {
    background: var(--bg-glass-hover);
    border-color: rgba(255,255,255,0.1);
}

.entry-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.entry-icon.income {
    background: rgba(16,185,129,0.12);
}

.entry-icon.expense {
    background: rgba(239,68,68,0.12);
}

.entry-details {
    flex: 1;
    min-width: 0;
}

.entry-category {
    font-size: 0.88rem;
    font-weight: 600;
}

.entry-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    margin-top: 2px;
}

.entry-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.entry-amount.income { color: var(--accent-success); }
.entry-amount.expense { color: var(--accent-danger); }

.entry-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.entry-item:hover .entry-actions {
    opacity: 1;
}

.entry-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.entry-action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

.entry-action-btn.delete:hover {
    background: var(--accent-danger-glow);
    color: var(--accent-danger);
}

/* ===== Settings ===== */
.settings-section {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 16px;
}

.settings-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Month Picker ===== */
.month-picker {
    display: flex;
    align-items: center;
    gap: 16px;
}

.month-picker-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1rem;
}

.month-picker-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.month-display {
    font-size: 1rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10,10,15,0.9);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

.loading-overlay.show { display: flex; }

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(99,102,241,0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Toasts ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    animation: slideUp 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
}

.toast.success { border-left: 3px solid var(--accent-success); }
.toast.error { border-left: 3px solid var(--accent-danger); }
.toast.info { border-left: 3px solid var(--accent-info); }

/* ===== Select ===== */
.form-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
    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='%238b8b9e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.form-select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ===== Recent Entries Table ===== */
.recent-entries {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.recent-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== Mobile Hamburger ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .mobile-toggle { display: flex; }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: 60px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .auth-card {
        padding: 32px 24px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* ===== Crypto Info Badge ===== */
.crypto-info {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.crypto-chip {
    padding: 4px 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    font-size: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
}

/* ===== Filter Bar ===== */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 14px;
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-chip.active {
    background: rgba(99,102,241,0.12);
    border-color: rgba(99,102,241,0.3);
    color: var(--accent-primary);
}

.filter-chip:hover:not(.active) {
    border-color: rgba(255,255,255,0.15);
    color: var(--text-primary);
}

/* ===== Confirm dialog ===== */
.confirm-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}
.confirm-actions .btn { flex: 1; }

/* ===== Stat Sub Text ===== */
.stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

/* ===== Insight Cards ===== */
.insight-item {
    flex: 1;
    min-width: 200px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.insight-item .insight-icon {
    font-size: 1.1rem;
    margin-right: 6px;
}

.insight-item .insight-value {
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* ===== Top Category Ranking ===== */
.top-cat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

.top-cat-item:last-child { border-bottom: none; }

.top-cat-rank {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.top-cat-rank.r1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #000; }
.top-cat-rank.r2 { background: linear-gradient(135deg, #94a3b8, #cbd5e1); color: #000; }
.top-cat-rank.r3 { background: linear-gradient(135deg, #b45309, #d97706); color: #fff; }
.top-cat-rank.r4, .top-cat-rank.r5 { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.top-cat-info { flex: 1; min-width: 0; }
.top-cat-name { font-size: 0.82rem; font-weight: 600; }
.top-cat-bar-wrap {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}
.top-cat-bar {
    height: 100%;
    border-radius: 2px;
    background: var(--gradient-primary);
    transition: width 0.6s ease;
}

.top-cat-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-danger);
    flex-shrink: 0;
}

.top-cat-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ===== LIGHT MODE THEME ===== */
[data-theme="light"] {
    --bg-primary: #f5f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(0,0,0,0.02);
    --bg-glass: rgba(255,255,255,0.8);
    --bg-glass-hover: rgba(0,0,0,0.04);
    --border-glass: rgba(0,0,0,0.08);
    --text-primary: #1a1a2e;
    --text-secondary: #64648a;
    --text-muted: #9999b0;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
    --gradient-bg: radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.04) 0%, transparent 50%),
                   radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.03) 0%, transparent 50%);
}

[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); }
[data-theme="light"] .form-input,
[data-theme="light"] .form-select { background: rgba(0,0,0,0.03); color: var(--text-primary); }
[data-theme="light"] .backup-code-display { color: var(--accent-primary); }
[data-theme="light"] .message.error { color: #dc2626; background: rgba(239,68,68,0.08); }
[data-theme="light"] .message.success { color: #059669; background: rgba(16,185,129,0.08); }

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border-glass);
    border-radius: 50%;
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.3s;
    color: var(--text-primary);
}
.theme-toggle:hover { transform: scale(1.1); }

/* ===== Search Bar ===== */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.search-input {
    flex: 1;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: all 0.3s;
}
.search-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}
.search-input::placeholder { color: var(--text-muted); }

/* ===== Calendar View ===== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 12px;
}
.calendar-header-cell {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 0;
    text-transform: uppercase;
}
.calendar-cell {
    aspect-ratio: 1;
    padding: 6px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: all 0.2s;
    min-height: 60px;
}
.calendar-cell:hover {
    border-color: var(--border-glass);
    background: var(--bg-glass-hover);
}
.calendar-cell.today {
    border-color: var(--accent-primary);
    background: rgba(99,102,241,0.08);
}
.calendar-cell.other-month { opacity: 0.3; }
.calendar-day {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.calendar-amount {
    font-size: 0.6rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}
.calendar-amount.has-expense { color: var(--accent-danger); }
.calendar-amount.has-income { color: var(--accent-success); }
.calendar-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
}
.calendar-dot.expense { background: var(--accent-danger); }
.calendar-dot.income { background: var(--accent-success); }

/* ===== Budget Bars ===== */
.budget-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.budget-item {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 16px;
}
.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.budget-category { font-size: 0.85rem; font-weight: 600; }
.budget-amounts {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.budget-bar-wrap {
    height: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}
.budget-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
    background: var(--accent-primary);
}
.budget-bar.warning { background: var(--accent-warning); }
.budget-bar.danger { background: var(--accent-danger); }
.budget-pct {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}
.budget-alert {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 600;
}
.budget-alert.over {
    background: var(--accent-danger-glow);
    color: var(--accent-danger);
}

/* ===== Receipt Camera ===== */
.camera-preview {
    width: 100%;
    max-height: 400px;
    border-radius: var(--radius-lg);
    background: #000;
    object-fit: cover;
}
.camera-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}
.ocr-progress {
    margin-top: 12px;
    text-align: center;
}
.ocr-progress-bar {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}
.ocr-progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s;
}
.ocr-result {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}
.ocr-result-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.ocr-result-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

/* ===== Split Bill ===== */
.split-members-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}
.split-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}
.split-member-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.88rem;
}
.split-member-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: var(--accent-primary);
}
.split-result-card {
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    margin-top: 16px;
}
.split-per-person {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-primary);
}

/* ===== Recurring Transactions ===== */
.recurring-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}
.recurring-info { flex: 1; }
.recurring-name { font-weight: 600; font-size: 0.88rem; }
.recurring-schedule {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.recurring-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
}

/* ===== Sidebar overflow for more items ===== */
.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
}
.nav-separator {
    height: 1px;
    background: var(--border-glass);
    margin: 8px 0;
}

/* ===== Currency Converter ===== */
.currency-result {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-primary);
    text-align: center;
    padding: 20px;
    margin-top: 16px;
}
.currency-rate {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== Custom Category ===== */
.category-list-edit {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.category-edit-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
}
.category-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}
.category-edit-name { flex: 1; font-size: 0.85rem; }
.category-delete-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.category-delete-btn:hover { background: var(--accent-danger-glow); color: var(--accent-danger); }

/* ===== Analysis Page ===== */
.analysis-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.analysis-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
}
.analysis-card.full-width { grid-column: 1 / -1; }
.analysis-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.comparison-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-glass);
}
.comparison-row:last-child { border-bottom: none; }
.comparison-label { font-size: 0.82rem; }
.comparison-value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    font-size: 0.85rem;
}
.comparison-change {
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.comparison-change.up { background: var(--accent-danger-glow); color: var(--accent-danger); }
.comparison-change.down { background: var(--accent-success-glow); color: var(--accent-success); }

.form-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 4px 0;
    transition: color 0.3s;
}

@media (max-width: 768px) {
    .analysis-grid { grid-template-columns: 1fr; }
    .calendar-cell { min-height: 44px; }
    .calendar-amount { font-size: 0.52rem; }
}

