/* Mental Bank — modern design system */
:root {
    --bg: #f4f6f9;
    --bg-elevated: #ffffff;
    --bg-subtle: #eef1f6;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-foreground: #ffffff;
    --primary-soft: #eef2ff;
    --primary-muted: rgba(79, 70, 229, 0.12);
    --accent: #0d9488;
    --accent-soft: #ccfbf1;
    --success: #059669;
    --success-soft: #d1fae5;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --happiness: #db2777;
    --happiness-soft: #fce7f3;
    --success-bucket: #2563eb;
    --success-bucket-soft: #dbeafe;
    --prosperity: #b45309;
    --prosperity-soft: #fef3c7;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 4.5rem;
    --header-height: 56px;
    --bottom-nav-bar-height: calc(4rem * var(--ui-scale, 1));
    --bottom-nav-height: calc(var(--bottom-nav-bar-height) + env(safe-area-inset-bottom, 0px));
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --transition: 0.18s ease;
    --ui-scale: 1;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    font-size: calc(15px * var(--ui-scale, 1));
    overflow-x: clip;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    line-height: 1.5;
    font-size: 1rem;
    overflow-x: clip;
    max-width: 100%;
}

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Icons */
.icon,
.nav-link svg,
.bottom-nav svg,
.brand-mark svg {
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    max-width: 1.25rem;
    max-height: 1.25rem;
    flex-shrink: 0;
    overflow: hidden;
}

.icon-sm { width: 1rem; height: 1rem; max-width: 1rem; max-height: 1rem; }
.icon-md { width: 1.25rem; height: 1.25rem; max-width: 1.25rem; max-height: 1.25rem; }
.icon-lg { width: 1.5rem; height: 1.5rem; max-width: 1.5rem; max-height: 1.5rem; }
.icon-xl { width: 2rem; height: 2rem; max-width: 2rem; max-height: 2rem; }

.icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    flex-shrink: 0;
    overflow: hidden;
}

.icon-wrap svg {
    width: 1.5rem;
    height: 1.5rem;
    max-width: 1.5rem;
    max-height: 1.5rem;
}

.icon-wrap-sm { width: 36px; height: 36px; }
.icon-wrap-md { width: 44px; height: 44px; }
.icon-wrap-lg { width: 52px; height: 52px; border-radius: var(--radius-lg); }

.icon-wrap-happiness { background: var(--happiness-soft); color: var(--happiness); }
.icon-wrap-success { background: var(--success-bucket-soft); color: var(--success-bucket); }
.icon-wrap-prosperity { background: var(--prosperity-soft); color: var(--prosperity); }
.icon-wrap-primary { background: var(--primary-soft); color: var(--primary); }

/* App layout */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    display: none;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    box-shadow: var(--shadow-lg);
    transition: width var(--transition), padding var(--transition);
    overflow-x: hidden;
}

.sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
    min-width: 0;
}

.sidebar-top .brand {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.sidebar-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.sidebar-toggle:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary-muted);
}

.sidebar-toggle svg {
    width: 1rem;
    height: 1rem;
    transition: transform var(--transition);
}

html.sidebar-collapsed .sidebar {
    width: var(--sidebar-width-collapsed);
    padding: 1.25rem 0.625rem;
}

html.sidebar-collapsed .sidebar-top {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

html.sidebar-collapsed .sidebar-top .brand {
    justify-content: center;
    padding: 0;
    width: 100%;
}

html.sidebar-collapsed .sidebar-toggle {
    justify-self: center;
}

html.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

html.sidebar-collapsed .brand-copy,
html.sidebar-collapsed .nav-link-label,
html.sidebar-collapsed .user-menu-name {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
}

html.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.625rem;
    gap: 0;
}

html.sidebar-collapsed .user-menu a {
    justify-content: center;
    width: 100%;
    padding: 0.375rem;
}

html.sidebar-collapsed .sidebar-top .brand-copy {
    display: none;
}

@media (min-width: 768px) {
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within {
        width: var(--sidebar-width);
        padding: 1.25rem 1rem;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .brand-copy,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .brand-copy {
        display: block;
        opacity: 1;
        width: auto;
        pointer-events: auto;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .nav-link-label,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .nav-link-label,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .user-menu-name,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .user-menu-name {
        opacity: 1;
        width: auto;
        pointer-events: auto;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .nav-link,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .nav-link {
        justify-content: flex-start;
        gap: 0.75rem;
        padding: 0.625rem 0.875rem;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .sidebar-top,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .sidebar-top {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .sidebar-top .brand,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .sidebar-top .brand {
        justify-content: flex-start;
        width: auto;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .sidebar-toggle,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .sidebar-toggle {
        justify-self: auto;
    }

    html.sidebar-hover-expand.sidebar-collapsed .sidebar:hover .sidebar-toggle svg,
    html.sidebar-hover-expand.sidebar-collapsed .sidebar:focus-within .sidebar-toggle svg {
        transform: rotate(0deg);
    }
}

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-shrink: 0;
    height: var(--header-height);
    padding: 0 max(1rem, env(safe-area-inset-right, 0px)) 0 max(1rem, env(safe-area-inset-left, 0px));
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.mobile-header-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 1rem max(1rem, env(safe-area-inset-right, 0px)) calc(var(--bottom-nav-height) + 1.5rem) max(1rem, env(safe-area-inset-left, 0px));
    overflow-x: clip;
}

@media (min-width: 768px) {
    .sidebar { display: flex; }
    .mobile-header { display: none; }
    .main-content {
        padding: 2rem 2rem 3rem;
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (min-width: 1024px) {
    .main-content { padding: 2.5rem 3rem 3rem; }
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
    padding: 0.25rem 0.5rem;
    min-width: 0;
}

.brand-mark {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    flex-shrink: 0;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-mark svg {
    width: 22px;
    height: 22px;
    max-width: 22px;
    max-height: 22px;
    color: white;
}

.brand-mark-sm {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    max-width: 36px;
    max-height: 36px;
    border-radius: 8px;
}

.brand-mark-sm svg {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
}

.brand-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.brand-sub {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Navigation */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 0.125rem;
    min-width: 0;
}

.nav-link-label {
    min-width: 0;
    transition: opacity var(--transition);
}

.nav-link svg {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
}

.nav-link:hover {
    background: var(--bg-subtle);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    min-height: var(--bottom-nav-height);
    height: var(--bottom-nav-height);
    padding-top: 0.25rem;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

@media (min-width: 768px) {
    .bottom-nav { display: none; }
}

.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    max-height: var(--bottom-nav-bar-height);
    gap: 0.125rem;
    padding: 0.25rem 0.25rem 0.375rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.1;
    border-radius: 8px;
    transition: color var(--transition);
    overflow: hidden;
}

.bottom-nav a.active { color: var(--primary); }
.bottom-nav a .icon,
.bottom-nav a svg {
    width: calc(22px * var(--ui-scale, 1));
    height: calc(22px * var(--ui-scale, 1));
    max-width: calc(22px * var(--ui-scale, 1));
    max-height: calc(22px * var(--ui-scale, 1));
    flex-shrink: 0;
}

/* Cards */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
    .card { padding: 1.5rem; }
}

.card-hero {
    background: var(--hero-gradient, linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%));
    border: none;
    color: white;
    box-shadow: var(--shadow-lg);
}

.card-hero .text-muted { color: rgba(255, 255, 255, 0.65); }
.card-hero .amount-positive { color: #a7f3d0; }
.card-hero .amount-negative { color: #fecaca; }
.card-hero .amount-with-currency { font-weight: 600; }
.card-hero .currency-brain-icon { color: inherit; }
.card-hero .balance-display {
    font-size: clamp(1.875rem, 4.75vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: white;
}

.card-hero.goal-reached {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.2), 0 0 24px rgba(167, 243, 208, 0.15);
}

.hero-main {
    flex: 1 1 12rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-hero .hero-label {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.2;
}

.hero-metrics {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 0.625rem;
    row-gap: 0.125rem;
}

.hero-metrics .balance-display {
    margin: 0;
}

.card-hero .hero-target {
    margin: 0;
    font-size: 0.6875rem;
    line-height: 1.2;
}

.card-hero .hero-goal-status {
    min-height: 2.5rem;
    margin: 0;
}

.hero-goal-reached-msg {
    font-size: 0.75rem;
    line-height: 1.35;
    font-weight: 500;
    color: #a7f3d0;
    margin: 0;
}

.card-hero .hero-goal-surplus {
    color: rgba(255, 255, 255, 0.75);
    margin: 0.125rem 0 0;
    font-size: 0.6875rem;
    line-height: 1.3;
}

.card-hero.goal-reached .progress-ring-text-reached .percent {
    font-size: 0.8125rem;
    color: #a7f3d0;
    letter-spacing: -0.01em;
    max-width: 4.75rem;
    text-align: center;
    line-height: 1.15;
    word-break: break-word;
}

.card-hero.goal-reached .progress-ring-text-reached .label {
    font-size: 0.5625rem;
    margin-top: 0.2rem;
    line-height: 1.2;
    max-width: 4.75rem;
    text-align: center;
}

.goal-confetti-canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.card-flat {
    background: var(--bg-subtle);
    border-color: transparent;
    box-shadow: none;
}

/* Forms */
.form-input,
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="date"],
textarea,
select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

textarea {
    resize: vertical;
    max-width: 100%;
    min-width: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.form-field-header {
    margin-bottom: 0.375rem;
}

.form-field-header .form-label {
    margin-bottom: 0.125rem;
}

.form-hint {
    font-size: 0.6875rem;
    line-height: 1.4;
    font-weight: 400;
    color: var(--text-muted);
    margin: 0;
}

.form-group { margin-bottom: 1rem; }

.form-checkbox {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    border-radius: 4px;
}

.form-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 1px 2px var(--primary-muted);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: var(--primary-foreground);
    box-shadow: 0 4px 12px var(--primary-muted);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: var(--bg-subtle);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    padding: 0.5rem 0.75rem;
}

.btn-ghost:hover { background: var(--primary-soft); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid transparent;
}

.btn-danger:hover { background: #fecaca; }

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

/* Messages */
.messages {
    margin-bottom: 1rem;
}

.messages.messages-toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    margin: 0;
    max-width: min(22rem, calc(100vw - 2rem));
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.messages.messages-toast .message {
    margin-bottom: 0;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    pointer-events: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.messages.messages-toast .message.message-dismiss {
    opacity: 0;
    transform: translateX(1rem);
}

.message {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.message-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #a7f3d0;
}

.message-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.message-info {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid #c7d2fe;
}

/* Progress ring */
.progress-ring-wrap {
    position: relative;
    width: 100px;
    height: 100px;
    flex-shrink: 0;
}

@media (min-width: 640px) {
    .progress-ring-wrap { width: 120px; height: 120px; }
}

.progress-ring { transform: rotate(-90deg); width: 100%; height: 100%; }

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}

.progress-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.progress-ring-text .percent {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    line-height: 1;
}

.progress-ring-text .label {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 0.15rem;
}

/* Stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 0.75rem;
    text-align: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Bucket badges */
.bucket-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.bucket-happiness { background: var(--happiness-soft); color: var(--happiness); }
.bucket-success { background: var(--success-bucket-soft); color: var(--success-bucket); }
.bucket-prosperity { background: var(--prosperity-soft); color: var(--prosperity); }

.today-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--primary-soft);
    color: var(--primary);
    vertical-align: middle;
}

.day-card-today {
    border-color: #c7d2fe;
    box-shadow: 0 0 0 1px var(--primary-soft);
}

/* Event chips */
.event-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.event-chip {
    padding: 0.45rem 0.85rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.event-chip:hover {
    background: var(--primary-soft);
    border-color: #c7d2fe;
    color: var(--primary);
}

/* Day cards */
.day-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    overflow: hidden;
    background: var(--bg-elevated);
}

.day-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    user-select: none;
}

.day-card-header:hover { background: var(--bg-subtle); }

.day-card-body {
    padding: 0 1rem 0.75rem;
    display: none;
    border-top: 1px solid var(--border);
}

.day-card.open .day-card-body { display: block; padding-top: 0.5rem; }

.day-card .chevron {
    color: var(--text-muted);
    transition: transform var(--transition);
}

.day-card.open .chevron { transform: rotate(180deg); }

.history-toolbar .form-group:last-child {
    margin-bottom: 0;
}

.history-sentinel {
    height: 1px;
}

.deposit-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.deposit-row:last-child { border-bottom: none; }

.deposit-row-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.deposit-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
    min-width: 0;
    flex: 1;
}

/* Landing */
.landing {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

.landing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    max-width: 1100px;
    margin: 0 auto;
}

.landing-nav .brand { margin-bottom: 0; }

.landing-hero {
    text-align: center;
    padding: 2rem 1.25rem 3rem;
    max-width: 640px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .landing-hero { padding: 4rem 2rem 3.5rem; }
}

.landing-hero h1 {
    font-size: clamp(2rem, 5vw, 2.75rem);
    margin-bottom: 1rem;
    letter-spacing: -0.03em;
}

.landing-hero .lead {
    font-size: 1.0625rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 2rem;
}

.landing-buckets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    max-width: 960px;
    margin: 0 auto 3rem;
    padding: 0 1.25rem;
}

@media (min-width: 640px) {
    .landing-buckets { grid-template-columns: repeat(3, 1fr); }
}

.bucket-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    text-align: left;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.bucket-card h3 {
    font-size: 1.0625rem;
    margin: 0.75rem 0 0.35rem;
}

.bucket-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}

.landing-footer {
    text-align: center;
    padding: 0 1.25rem 3rem;
    max-width: 560px;
    margin: 0 auto;
}

/* Auth / onboarding */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: var(--bg);
}

.auth-card,
.onboarding-wrap {
    width: 100%;
    max-width: 440px;
}

.onboarding-wide { max-width: 640px; }

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header .brand-mark {
    margin: 0 auto 1rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.hidden,
[hidden] {
    display: none !important;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

/* User menu */
.user-menu {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.user-menu-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.user-menu a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
}

.user-menu a:hover { color: var(--primary); }

/* Utilities */
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.ml-2 { margin-left: 0.5rem; }
.flex { display: flex; }
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.text-center { text-align: center; }
.w-full { width: 100%; }
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.section-title {
    font-size: clamp(1.35rem, 3vw, 1.625rem);
    margin-bottom: 0.35rem;
}

.section-subtitle {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.amount-positive {
    color: var(--success);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.amount-negative {
    color: var(--danger);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.balance-display.negative {
    color: var(--danger);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

.onboarding-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
}

.step-dot.active {
    background: var(--primary);
    width: 24px;
    border-radius: 4px;
}

.calc-preview {
    background: var(--bg-subtle);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.35rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.calc-row .value {
    color: var(--text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.goal-tracker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.goal-tracker-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.goal-tracker-pill:hover {
    color: var(--text);
    border-color: var(--primary-light, #a5b4fc);
}

.goal-tracker-pill.active {
    color: var(--primary-foreground);
    background: var(--primary);
    border-color: var(--primary);
}

.form-input-currency {
    max-width: 4rem;
    text-align: center;
    font-weight: 600;
}

.input-with-currency {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.input-with-currency:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-with-currency-prefix {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.input-with-currency-select {
    appearance: none;
    border: none;
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.625rem 1.75rem 0.625rem 0.625rem;
    min-width: 4.75rem;
    max-width: 5.5rem;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
}

.input-with-currency-select:focus {
    outline: none;
}

.input-with-currency-prefix.is-brain .input-with-currency-select {
    color: transparent;
    width: 2.75rem;
    min-width: 2.75rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    background-image: none;
}

.input-with-currency-brain-icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-with-currency-amount {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    color: var(--text);
}

.input-with-currency-amount:focus {
    outline: none;
}

.currency-brain-icon {
    vertical-align: -0.15em;
    display: inline-block;
}

.amount-with-currency {
    display: inline-flex;
    align-items: baseline;
    gap: 0.125rem;
}

.calc-row .value.amount-with-currency {
    align-items: center;
}

.self-contract-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.self-contract-item:last-of-type {
    border-bottom: none;
}

.self-contract-item-body {
    flex: 1;
    min-width: 0;
}

.self-contract-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.625rem;
}

.self-contract-item-title {
    font-size: 0.9375rem;
}

.self-contract-item-meta {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.self-contract-item-desc {
    margin: 0.375rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.self-contract-item-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.5rem;
}

.affirmation-box {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    padding: 1rem 1.25rem;
    border-radius: 0 10px 10px 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.9375rem;
}

.affirmation-display-group .form-label {
    margin-bottom: 0.5rem;
}

/* Quill reflection editor */
.reflection-prompt-box {
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    padding: 1rem 1.25rem;
    border-radius: 0 10px 10px 0;
}

.reflection-prompt-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
    margin: 0;
}

.reflection-prompt-text-sm {
    font-size: 0.8125rem;
    font-style: italic;
}

.reflection-quill-wrap {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-elevated);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.reflection-quill-wrap .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    padding: 0.375rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.125rem;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    border-radius: 0;
}

.reflection-quill-wrap .ql-toolbar.ql-snow .ql-formats {
    margin-right: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.0625rem;
}

.reflection-quill-wrap .ql-toolbar.ql-snow button {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.reflection-quill-wrap .ql-toolbar.ql-snow button svg {
    float: none;
    width: 1rem;
    height: 1rem;
}

.reflection-quill-wrap .ql-toolbar.ql-snow button:hover,
.reflection-quill-wrap .ql-toolbar.ql-snow button.ql-active {
    background: var(--primary-soft);
    color: var(--primary);
}

.reflection-quill-wrap .ql-snow .ql-stroke {
    stroke: var(--text-secondary) !important;
}

.reflection-quill-wrap .ql-snow .ql-fill {
    fill: var(--text-secondary) !important;
}

.reflection-quill-wrap .ql-snow .ql-picker {
    color: var(--text-secondary);
}

.reflection-quill-wrap .ql-snow button:hover .ql-stroke,
.reflection-quill-wrap .ql-snow button.ql-active .ql-stroke {
    stroke: var(--primary) !important;
}

.reflection-quill-wrap .ql-snow button:hover .ql-fill,
.reflection-quill-wrap .ql-snow button.ql-active .ql-fill {
    fill: var(--primary) !important;
}

.reflection-quill-wrap .ql-container.ql-snow {
    border: none;
    border-radius: 0;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 0.9375rem;
}

.reflection-quill-wrap .ql-editor {
    min-height: 10rem;
    max-height: 24rem;
    overflow-y: auto;
    padding: 1rem 1.125rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg-elevated);
    border-radius: 0;
}

.reflection-quill-wrap .ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
    left: 1.125rem;
    right: 1.125rem;
}

.reflection-body {
    color: var(--text-secondary);
    line-height: 1.65;
    font-size: 0.9375rem;
}

.reflection-body p {
    margin: 0 0 0.75rem;
}

.reflection-body p:last-child {
    margin-bottom: 0;
}

.reflection-body ul,
.reflection-body ol {
    margin: 0 0 0.75rem;
    padding-left: 1.5rem;
}

.reflection-body blockquote {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0 0.5rem 1rem;
    border-left: 3px solid var(--primary);
    color: var(--text-secondary);
}

.reflection-body a {
    color: var(--primary);
}

@media (max-width: 480px) {
    .reflection-quill-wrap .ql-toolbar.ql-snow {
        padding: 0.5rem;
    }

    .reflection-quill-wrap .ql-toolbar.ql-snow button {
        width: 2.25rem;
        height: 2.25rem;
    }

    .reflection-quill-wrap .ql-toolbar.ql-snow button svg {
        width: 1.125rem;
        height: 1.125rem;
    }

    .reflection-quill-wrap .ql-editor {
        min-height: 8.5rem;
        padding: 0.875rem 1rem;
    }
}

.hero-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-header { margin-bottom: 1.25rem; }

.page-header.flex-between {
    align-items: flex-start;
}

.page-header.flex-between > :first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.page-header-action {
    flex-shrink: 0;
}

@media (max-width: 639px) {
    .deposit-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .deposit-row-actions {
        width: 100%;
        justify-content: space-between;
    }

    .stat-grid .stat-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

@media (min-width: 768px) {
    .page-header { margin-bottom: 1.75rem; }
}

/* Settings / appearance */
.appearance-save-status {
    color: var(--primary);
    font-weight: 500;
}

.appearance-save-status.is-error {
    color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: 0.8125rem;
    margin-top: 0.375rem;
}

.theme-picker {
    border: none;
    padding: 0;
    margin: 0;
}

.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

@media (max-width: 639px) {
    .theme-picker-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.theme-picker-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.theme-picker-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-picker-card:has(.theme-picker-input:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.theme-picker-swatch {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow-sm);
}

.theme-swatch-indigo { background: linear-gradient(135deg, #4338ca, #6366f1); }
.theme-swatch-ocean { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.theme-swatch-forest { background: linear-gradient(135deg, #059669, #34d399); }
.theme-swatch-rose { background: linear-gradient(135deg, #e11d48, #fb7185); }
.theme-swatch-midnight { background: linear-gradient(135deg, #0f172a, #475569); }
.theme-swatch-ember { background: linear-gradient(135deg, #78350f, #f59e0b); }
.theme-swatch-obsidian { background: linear-gradient(135deg, #0a0a0a, #737373); }
.theme-swatch-twilight { background: linear-gradient(135deg, #312e81, #a78bfa); }

.theme-picker-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: center;
}

.ui-scale-group {
    margin-bottom: 1rem;
}

.ui-scale-control {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0.625rem 0;
}

.ui-scale-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 0.375rem;
    border-radius: 999px;
    background: var(--border);
    pointer-events: none;
}

.ui-scale-track-fill {
    height: 100%;
    width: 50%;
    border-radius: 999px;
    background: var(--primary);
    pointer-events: none;
}

.form-range {
    position: relative;
    z-index: 1;
    width: 100%;
    margin: 0;
    height: 2.5rem;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.form-range:focus {
    outline: none;
}

.form-range:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow);
}

.form-range:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow);
}

.form-range::-webkit-slider-runnable-track {
    height: 0.375rem;
    border-radius: 999px;
    background: transparent;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 1.5rem;
    height: 1.5rem;
    margin-top: -0.5625rem;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-elevated);
    box-shadow: var(--shadow);
}

.form-range::-moz-range-track {
    height: 0.375rem;
    border-radius: 999px;
    background: transparent;
}

.form-range::-moz-range-progress {
    height: 0.375rem;
    border-radius: 999px;
    background: transparent;
}

.form-range::-moz-range-thumb {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-elevated);
    box-shadow: var(--shadow);
}

@media (max-width: 639px) {
    .ui-scale-control {
        padding: 0.875rem 0;
    }

    .form-range {
        height: 2.75rem;
    }

    .form-range::-webkit-slider-thumb {
        width: 1.625rem;
        height: 1.625rem;
        margin-top: -0.625rem;
    }

    .form-range::-moz-range-thumb {
        width: 1.625rem;
        height: 1.625rem;
    }
}

.ui-scale-value {
    float: right;
    font-weight: 600;
    color: var(--primary);
}

.ui-scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}
