:root {
    --bg: #f3f7f6;
    --bg-deep: #e7f0ee;
    --ink: #102 intermediate;
    --muted: #5b6f6c;
    --card: rgba(255, 255, 255, 0.86);
    --line: rgba(16, 42, 40, 0.08);
    --brand: #0f766e;
    --brand-dark: #0b3d3a;
    --accent: #d97706;
    --danger: #be123c;
    --success: #15803d;
    --shadow: 0 12px 40px rgba(11, 61, 58, 0.12);
    --radius: 22px;
    --nav-h: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Manrope", system-ui, sans-serif;
    --display: "Sora", "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(15, 118, 110, 0.18), transparent 55%),
        radial-gradient(900px 500px at 100% 0%, rgba(217, 119, 6, 0.12), transparent 50%),
        linear-gradient(180deg, #f7fbfa 0%, var(--bg) 40%, var(--bg-deep) 100%);
    min-height: 100vh;
    line-height: 1.45;
}

a { color: var(--brand-dark); text-decoration: none; }
button, input, select { font: inherit; }
svg { width: 22px; height: 22px; display: block; }

.app-shell {
    width: min(480px, 100%);
    margin: 0 auto;
    min-height: 100vh;
    padding: 0 16px calc(var(--nav-h) + var(--safe-bottom) + 18px);
    position: relative;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0 8px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(12px);
    background: linear-gradient(180deg, rgba(243, 247, 246, 0.95), rgba(243, 247, 246, 0.7));
}

.topbar-brand {
    font-family: var(--display);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--brand-dark);
}
.topbar-sep { opacity: 0.35; margin: 0 6px; }
.topbar-page { color: var(--muted); font-size: 0.92rem; }

.icon-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--brand-dark);
}

.page { animation: rise 0.45s ease both; }
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.hero-total {
    margin-top: 8px;
    padding: 28px 22px;
    border-radius: 28px;
    color: #f8fffe;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.08), transparent 40%),
        linear-gradient(160deg, #0b3d3a 0%, #0f766e 55%, #136f63 100%);
    box-shadow: var(--shadow);
    text-align: center;
}
.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    opacity: 0.8;
    font-weight: 700;
}
.total-amount {
    margin: 10px 0 6px;
    font-family: var(--display);
    font-size: clamp(2.4rem, 10vw, 3.2rem);
    letter-spacing: -0.04em;
    font-weight: 800;
}
.total-delta { margin: 0; opacity: 0.9; font-size: 0.95rem; }
.total-delta.is-up { color: #bbf7d0; }
.total-delta.is-down { color: #fecdd3; }

.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 18px 0;
}
.quick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 84px;
    padding: 12px 8px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 0.78rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(11, 61, 58, 0.05);
    transition: transform 0.15s ease, background 0.15s ease;
}
.quick-btn:active { transform: scale(0.97); }
.quick-btn svg { color: var(--brand); }

.section { margin: 22px 0; }
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.section-head h3, .section > h3 {
    margin: 0 0 12px;
    font-family: var(--display);
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}
.section-head h3 { margin: 0; }
.section-head a { font-size: 0.9rem; font-weight: 600; }

.account-list { display: grid; gap: 12px; margin-bottom: 14px; }
.account-card {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 16px;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px solid var(--line);
    box-shadow: 0 10px 28px rgba(11, 61, 58, 0.06);
    color: inherit;
    position: relative;
    overflow: hidden;
}
.account-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 5px;
    background: var(--accent, var(--brand));
}
.account-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--accent, var(--brand)) 16%, white);
    color: var(--accent, var(--brand));
}
.account-meta { min-width: 0; }
.account-meta strong, .account-balance strong {
    display: block;
    font-size: 1rem;
}
.account-meta span, .account-balance span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.account-balance { text-align: right; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 16px;
    border: 0;
    font-weight: 700;
    cursor: pointer;
}
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 0.88rem; border-radius: 12px; }
.btn-primary { background: var(--brand-dark); color: #fff; }
.btn-secondary { background: #dcece9; color: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-danger { background: #fff1f2; color: var(--danger); border: 1px solid #fecdd3; }

.form-stack { display: grid; gap: 14px; }
.form-stack label, .filter-bar label { display: grid; gap: 6px; }
.form-stack label > span { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.form-stack input, .form-stack select, .filter-bar select {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    padding: 0 14px;
}
.form-stack input:focus, .form-stack select:focus, .filter-bar select:focus {
    outline: 2px solid rgba(15, 118, 110, 0.25);
    border-color: var(--brand);
}

.choice-grid {
    border: 0;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.choice-grid legend {
    margin-bottom: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted);
}
.choice-item {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 52px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
}
.choice-item input { position: absolute; opacity: 0; }
.choice-item:has(input:checked) {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.color-item span {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--swatch);
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 6px;
    background: #e7efed;
    border-radius: 16px;
}
.segmented label {
    display: grid;
    place-items: center;
    min-height: 44px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
}
.segmented input { display: none; }
.segmented label:has(input:checked) {
    background: #fff;
    color: var(--brand-dark);
    box-shadow: 0 4px 14px rgba(11, 61, 58, 0.08);
}

.tx-list { display: grid; gap: 10px; }
.tx-item {
    display: grid;
    grid-template-columns: 42px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--line);
}
.tx-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
}
.tx-icon.is-income { background: #dcfce7; color: var(--success); }
.tx-icon.is-expense { background: #ffe4e6; color: var(--danger); }
.tx-meta strong { display: block; }
.tx-meta span { color: var(--muted); font-size: 0.82rem; }
.tx-amount.is-income { color: var(--success); }
.tx-amount.is-expense { color: var(--danger); }
.tx-side { text-align: right; display: grid; gap: 4px; justify-items: end; }
.link-danger {
    background: none;
    border: 0;
    color: var(--danger);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.detail-hero {
    text-align: center;
    padding: 24px 16px;
    border-radius: 28px;
    background: color-mix(in srgb, var(--accent) 12%, white);
    border: 1px solid color-mix(in srgb, var(--accent) 25%, white);
    margin-top: 8px;
}
.detail-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 10px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
}
.detail-hero h2 { margin: 0; font-family: var(--display); }
.detail-balance {
    margin: 12px 0 4px;
    font-family: var(--display);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}
.muted { color: var(--muted); }
.danger-zone { margin-top: 28px; }

.empty-state {
    text-align: center;
    padding: 28px 18px;
    border-radius: var(--radius);
    background: var(--card);
    border: 1px dashed rgba(15, 118, 110, 0.25);
}
.empty-state.compact { padding: 18px; }
.empty-state p { margin-top: 0; color: var(--muted); }

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(480px, 100%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: rgba(255, 255, 255, 0.92);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
    z-index: 30;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 8px 4px;
    border-radius: 14px;
}
.nav-item.is-active {
    color: var(--brand-dark);
    background: rgba(15, 118, 110, 0.1);
}

.flash-stack { display: grid; gap: 8px; margin: 10px 0; }
.flash {
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 0.92rem;
    font-weight: 600;
}
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #ffe4e6; color: #9f1239; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}
.auth-shell { width: min(420px, 100%); }
.auth-brand {
    text-align: center;
    margin-bottom: 18px;
    animation: rise 0.5s ease both;
}
.brand-mark {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(145deg, #0b3d3a, #0f766e);
    box-shadow: var(--shadow);
}
.auth-brand h1 {
    margin: 0;
    font-family: var(--display);
    font-size: 2rem;
    letter-spacing: -0.04em;
    color: var(--brand-dark);
}
.auth-brand p { margin: 8px 0 0; color: var(--muted); }
.auth-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 22px;
    box-shadow: var(--shadow);
    animation: rise 0.55s ease both;
}
.auth-panel h2 {
    margin: 0 0 6px;
    font-family: var(--display);
}
.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin: 18px 0 0;
    font-size: 0.9rem;
    font-weight: 600;
}
.info-box {
    margin-top: 14px;
    padding: 12px;
    border-radius: 14px;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    word-break: break-all;
    font-size: 0.88rem;
}

.toggle-row, .reminder-row, .reminder-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--line);
}
.reminder-list { display: grid; gap: 10px; }
.reminder-actions { display: flex; align-items: center; gap: 10px; }
.help-text { color: var(--muted); font-size: 0.88rem; }

.ios-install-box {
    margin: 0 0 14px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(160deg, #ecfdf5, #f0fdfa);
    border: 1px solid rgba(15, 118, 110, 0.22);
}
.ios-install-box h4 {
    margin: 0 0 10px;
    font-family: var(--display);
    font-size: 1rem;
    color: var(--brand-dark);
}
.ios-install-box ol {
    margin: 0 0 10px;
    padding-left: 1.2rem;
    color: var(--ink);
    font-size: 0.92rem;
}
.ios-install-box li { margin: 0.35rem 0; }
.ios-install-box .muted { margin: 0; font-size: 0.82rem; }

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    inset: 0;
    background: #c9d6d3;
    border-radius: 999px;
    transition: 0.2s;
    cursor: pointer;
}
.slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.switch input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

@media (min-width: 768px) {
    .app-shell { padding-top: 12px; }
    .quick-btn:hover, .account-card:hover, .nav-item:hover {
        transform: translateY(-1px);
    }
}

@media (max-width: 380px) {
    .quick-actions { gap: 8px; }
    .quick-btn { min-height: 78px; font-size: 0.72rem; }
    .total-amount { font-size: 2.2rem; }
}
