:root {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #1d2433;
    background: #f4f6f9;
    font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: 5.5rem; }
a { color: #155eef; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    min-height: 3.5rem; padding: .75rem 1rem;
    background: rgba(255,255,255,.96); border-bottom: 1px solid #e2e7ef;
    backdrop-filter: blur(10px);
}
.user-name { display: block; color: #687287; font-size: .78rem; font-weight: 500; }
.link-muted { color: #596579; text-decoration: none; }
.container { width: min(100% - 1rem, 960px); margin: 1rem auto; }
h1 { font-size: 1.65rem; margin: .25rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }
.card {
    background: white; border: 1px solid #e1e6ee; border-radius: 1rem;
    padding: 1rem; margin-bottom: 1rem; box-shadow: 0 4px 18px rgba(30,42,60,.05);
}
.auth-card { max-width: 28rem; margin: 8vh auto 0; }
form { display: grid; gap: .9rem; }
label { display: grid; gap: .35rem; font-weight: 650; font-size: .92rem; }
input, select, button {
    width: 100%; min-height: 3rem; border-radius: .75rem; font: inherit;
}
input, select {
    border: 1px solid #bcc6d4; background: white; color: #18202e; padding: .7rem .8rem;
}
input:focus, select:focus { outline: 3px solid rgba(21,94,239,.18); border-color: #155eef; }
button {
    border: 0; background: #155eef; color: white; padding: .75rem 1rem;
    font-weight: 750; cursor: pointer;
}
button.secondary { background: #e9eef7; color: #1d2b45; }
.money-input { position: relative; }
.money-input input { padding-right: 3rem; font-size: 1.7rem; font-weight: 750; }
.money-input span { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-weight: 750; }
.muted { color: #687287; font-weight: 450; }
.flash { border-radius: .75rem; padding: .8rem 1rem; margin-bottom: 1rem; }
.flash-success { background: #eaf8ef; color: #17623a; }
.flash-error { background: #fff0f0; color: #922b2b; }
.empty { padding: 1rem; background: #f6f8fb; border-radius: .75rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.recent-list { display: grid; gap: .2rem; }
.recent-row { display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 0; border-top: 1px solid #edf0f5; }
.recent-row:first-child { border-top: 0; }
.recent-row small { display: block; margin-top: .15rem; color: #6b7485; }
.bottom-nav {
    position: fixed; left: 50%; bottom: max(.5rem, env(safe-area-inset-bottom)); transform: translateX(-50%);
    z-index: 20; width: min(calc(100% - 1rem), 34rem); display: grid; grid-template-columns: repeat(3, 1fr);
    background: #18243a; border-radius: 1rem; padding: .35rem; box-shadow: 0 8px 30px rgba(0,0,0,.22);
}
.bottom-nav a { color: #d6dce8; text-decoration: none; text-align: center; padding: .75rem .25rem; border-radius: .7rem; font-weight: 700; font-size: .86rem; }
.bottom-nav a.active { background: white; color: #14213a; }
.stat-grid { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
.stat { background: #f5f7fa; border-radius: .75rem; padding: .9rem; }
.stat span { display: block; color: #647084; font-size: .85rem; }
.stat strong { display: block; margin-top: .25rem; font-size: 1.15rem; }
.bar-chart { display: grid; gap: .8rem; }
.bar-row { display: grid; grid-template-columns: 5.5rem minmax(5rem, 1fr) auto; gap: .65rem; align-items: center; font-size: .85rem; }
.bar-progress { width: 100%; height: .8rem; border: 0; border-radius: 999px; overflow: hidden; appearance: none; background: #e7ebf1; }
.bar-progress::-webkit-progress-bar { background: #e7ebf1; border-radius: 999px; }
.bar-progress::-webkit-progress-value { background: #155eef; border-radius: 999px; }
.bar-progress::-moz-progress-bar { background: #155eef; border-radius: 999px; }
.inline-form { grid-template-columns: minmax(0,1fr) 5rem; }
.inline-form button { grid-column: 1 / -1; }
.account-list { display: grid; gap: 1rem; }
.account-row { border-top: 1px solid #e8ecf2; padding-top: 1rem; }
.account-row:first-child { border-top: 0; padding-top: 0; }
.checkbox { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .5rem; }
.checkbox input { width: 1.3rem; min-height: 1.3rem; }
code { display: block; overflow: auto; background: #121a28; color: #eef2f8; padding: .8rem; border-radius: .65rem; }
@media (min-width: 640px) {
    .container { margin-top: 1.5rem; }
    .card { padding: 1.4rem; }
    .entry-form { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .entry-form .amount-field, .entry-form button { grid-column: 1 / -1; }
    .entry-form label:last-of-type { grid-column: 1 / -1; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .inline-form { grid-template-columns: minmax(0,1fr) 7rem auto; }
    .inline-form button { grid-column: auto; }
    .account-row { grid-template-columns: minmax(0,1fr) 7rem 6rem auto; align-items: end; }
    .account-row small { grid-column: 1 / -1; }
}
@media (prefers-color-scheme: dark) {
    :root { color: #edf1f7; background: #0f1520; }
    .topbar, .card { background: #17202d; border-color: #2b3747; }
    input, select { background: #0f1723; color: #f0f4fa; border-color: #465368; }
    .link-muted, .muted, .user-name, .recent-row small { color: #a9b3c3; }
    .stat, .empty { background: #101925; }
    .bar-progress, .bar-progress::-webkit-progress-bar { background: #313d4e; }
    button.secondary { background: #354156; color: #fff; }
}
