:root {
    --bg: #F5F4F0;
    --surface: #FFFFFF;
    --ink: #111111;
    --ink-light: #666666;
    --accent: #2B4C3B;
    --danger: #A63D2F;
    --gold: #D99A5A;
    --border: #E2E0D8;
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    max-width: 600px;
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) 20px max(100px, env(safe-area-inset-bottom));
}

h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
}

h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-light);
    margin-bottom: 16px;
    margin-top: 32px;
}

button,
select,
input {
    font: inherit;
}

button {
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

.page-title {
    margin-bottom: 4px;
}

.subtitle {
    font-size: 15px;
    color: var(--ink-light);
    margin-bottom: 32px;
    font-weight: 500;
}

.small-muted,
.muted {
    color: var(--ink-light);
    font-size: 14px;
    line-height: 1.5;
}

.muted-label {
    color: var(--ink-light);
}

.danger-text {
    color: var(--danger) !important;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 24px;
    gap: 16px;
}

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

.nav-links {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link,
.back-btn {
    color: var(--ink-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid var(--ink-light);
    padding-bottom: 2px;
    cursor: pointer;
}

.nav-button {
    background: transparent;
    border: none;
}

.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.login-title {
    font-size: 48px;
    margin-bottom: 8px;
}

.login-subtitle {
    margin-bottom: 20px;
}

.login-btn {
    width: auto;
    padding-left: 32px;
    padding-right: 32px;
}

.filter-row {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

.filter-select {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
    -webkit-appearance: none;
    text-align: center;
}

.dashboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    width: 100%;
}

.donut-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    margin-bottom: 24px;
}

.donut-chart {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(#E2E0D8 0%);
    transition: background 0.4s ease-out;
    box-shadow: inset 0 0 0 4px var(--bg);
}

.donut-hole {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.donut-hole span {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.donut-hole strong {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
    color: var(--ink);
    margin: 4px 0;
}

.correlation-box {
    width: 100%;
    background: var(--surface);
    padding: 16px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.corr-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}

.corr-track {
    background: var(--bg);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    width: 100%;
}

.corr-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.3s;
}

.mini-totals {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--ink-light);
}

.mini-totals strong {
    display: block;
    color: var(--ink);
    font-size: 14px;
    margin-top: 2px;
}

.type-toggle {
    display: flex;
    background: #EAE8E1;
    border-radius: 100px;
    padding: 4px;
    margin-bottom: 20px;
    width: 100%;
}

.toggle-btn {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}

.toggle-btn.active {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.setup-toggle .toggle-btn {
    font-size: 12px;
}

.form-area {
    margin-bottom: 32px;
}

.input-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1.5px solid var(--border);
    padding: 16px 0;
}

.input-line label {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink-light);
    flex-shrink: 0;
}

.input-line input,
.input-line select {
    flex: 1;
    text-align: right;
    margin-left: 16px;
    border: none;
    background: transparent;
    font-size: 18px;
    color: var(--ink);
    outline: none;
    -webkit-appearance: none;
    min-width: 0;
}

.input-line input[type="number"] {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.btn-primary {
    display: block;
    width: 100%;
    background: var(--ink);
    color: var(--surface);
    text-align: center;
    padding: 18px;
    border-radius: 100px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    margin-top: 24px;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--ink);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wide-outline {
    width: 100%;
    border-style: dashed;
    padding: 18px;
    font-size: 15px;
    margin-bottom: 32px;
}

.no-margin {
    margin-top: 0;
}

.button-row {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.button-row .btn-primary {
    flex: 2;
}

.button-row .btn-outline {
    flex: 1;
}

.tags-container {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tags-container::-webkit-scrollbar {
    display: none;
}

.tag {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.section-heading-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.list-wrap {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0 20px;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

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

.list-main {
    flex: 1;
    min-width: 0;
}

.env-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    word-break: break-word;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.env-track,
.progress-track {
    background: var(--bg);
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}

.progress-track {
    height: 8px;
    border-radius: 4px;
    margin-bottom: 24px;
}

.env-fill,
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--ink);
}

.env-stats {
    text-align: right;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-light);
    min-width: 95px;
}

.tx-desc {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    word-break: break-word;
}

.tx-meta {
    font-size: 12px;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.5;
}

.tx-amt {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.tx-amt.income,
.tx-amt.savings {
    color: var(--accent);
}

.pill {
    background: #EAE8E1;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
    font-weight: 600;
}

.action-btns {
    display: flex;
    align-items: center;
    gap: 16px;
}

.edit-btn,
.del-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.edit-btn {
    color: var(--ink-light);
    font-size: 16px;
}

.del-btn {
    color: var(--danger);
    font-size: 20px;
}

.activity-list {
    margin-top: 16px;
}

.modal {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 100;
    padding: max(20px, env(safe-area-inset-top)) 20px max(100px, env(safe-area-inset-bottom));
    overflow-y: auto;
}

.modal-content {
    max-width: 600px;
    margin: 0 auto;
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    color: var(--ink);
}

.modal-list {
    margin-bottom: 60px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(245, 244, 240, 0.97);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-align: center;
    padding: 24px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 24px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.goal-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--ink-light);
    word-break: break-word;
}

.goal-amount {
    font-size: 46px;
    font-weight: 800;
    letter-spacing: -2px;
    color: var(--ink);
    margin-bottom: 10px;
    text-align: left;
}

.saved-line {
    font-size: 14px;
    color: var(--ink-light);
    font-weight: 600;
    margin-bottom: 18px;
}

.projection {
    background: var(--bg);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 32px;
    text-align: center;
}

.proj-date {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-top: 4px;
}

.proj-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-light);
}

.slider-container {
    text-align: left;
    margin-bottom: 8px;
}

.slider-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 15px;
    gap: 16px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: var(--ink);
    cursor: pointer;
    margin-top: -10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: var(--border);
    border-radius: 4px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.metric {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
}

.metric span {
    display: block;
    color: var(--ink-light);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 6px;
}

.metric strong {
    font-size: 20px;
    font-weight: 800;
}

.insight-card {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.insight-card h3 {
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 8px;
}

.insight-card p {
    font-size: 14px;
    color: var(--ink-light);
    line-height: 1.5;
}

.insight-card.good h3 {
    color: var(--accent);
}

@media (max-width: 420px) {
    .header-top {
        align-items: flex-start;
    }

    .mini-totals {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .goal-amount {
        font-size: 38px;
    }
}
