/* ===== Тема ===== */
:root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --border: #262c35;
    --text: #e7ecf3;
    --muted: #8a94a3;
    --accent: #5b8cff;
    --good: #2fd07a;
    --bad: #ff5c6c;
    --transfer: #f5a623;
    --shadow: 0 8px 30px rgba(0,0,0,.35);
    --radius: 16px;
}
:root[data-theme="light"] {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-2: #f4f6fa;
    --border: #e3e8ef;
    --text: #101828;
    --muted: #667085;
    --accent: #3b6fe0;
    --good: #10a15a;
    --bad: #e23b4e;
    --transfer: #d9891a;
    --shadow: 0 8px 30px rgba(16,24,40,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding-bottom: env(safe-area-inset-bottom);
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }

/* ===== Вид / прокрутка ===== */
.view { padding: 16px 14px 96px; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); margin: 22px 4px 10px; font-weight: 600; }

/* ===== Карточка капитала ===== */
.capital {
    background: linear-gradient(150deg, var(--accent), #7b5bff);
    color: #fff; border-radius: 22px; padding: 20px; box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.capital .label { opacity: .85; font-size: 13px; }
.capital .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 2px; }
.capital .sub { opacity: .9; font-size: 15px; font-weight: 600; }
.capital .rate { position: absolute; top: 16px; right: 16px; font-size: 12px;
    background: rgba(255,255,255,.18); padding: 4px 9px; border-radius: 20px; }

/* спарклайн */
.spark { display: block; width: 100%; height: 54px; margin-top: 14px; }

/* ===== Разбивка ===== */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 13px 14px; }
.stat .t { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 4px; }
.stat .v.good { color: var(--good); }
.stat .v.bad { color: var(--bad); }

/* ===== Списки ===== */
.card { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 14px;
    border-top: 1px solid var(--border); }
.row:first-child { border-top: none; }
.row .emoji { width: 38px; height: 38px; flex: none; border-radius: 11px;
    background: var(--surface-2); display: grid; place-items: center; font-size: 19px; }
.row .main { flex: 1; min-width: 0; }
.row .main .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .main .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 700; text-align: right; white-space: nowrap; }
.row .amt .sub { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.amt.good { color: var(--good); } .amt.bad { color: var(--bad); } .amt.tr { color: var(--transfer); }
.row.tappable:active { background: var(--surface-2); }

.day-head { font-size: 12px; color: var(--muted); margin: 18px 6px 8px; font-weight: 600;
    display: flex; justify-content: space-between; }

/* ===== Кнопки ===== */
.btn { border: none; border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600;
    background: var(--surface-2); color: var(--text); cursor: pointer; }
.btn:active { opacity: .8; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.quick { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ===== FAB ===== */
.fab { position: fixed; right: calc(50% - 280px + 18px); bottom: 84px; z-index: 40;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
    box-shadow: var(--shadow); }
@media (max-width: 596px) { .fab { right: 18px; } }
.fab:active { transform: scale(.94); }

/* ===== Нижняя навигация ===== */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4,1fr);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom); }
.tab { border: none; background: none; color: var(--muted); cursor: pointer;
    padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 600; }
.tab .ic { font-size: 19px; filter: grayscale(.3); }
.tab.is-active { color: var(--accent); }
.tab.is-active .ic { filter: none; }

/* ===== Шторка (bottom sheet) ===== */
.sheet-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; background: var(--surface);
    border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 92vh; overflow-y: auto; animation: up .22s cubic-bezier(.2,.8,.2,1); }
.sheet .grab { width: 40px; height: 4px; border-radius: 3px; background: var(--border);
    margin: 6px auto 12px; }
.sheet h3 { margin: 4px 2px 14px; font-size: 19px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ===== Формы ===== */
label.fld { display: block; margin: 12px 0 0; }
label.fld > span { font-size: 12.5px; color: var(--muted); display: block; margin-bottom: 6px; }
input, select, textarea { width: 100%; background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; font-size: 16px;
    font-family: inherit; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.amount-input { font-size: 30px; font-weight: 800; text-align: center; padding: 16px 12px; letter-spacing: -.01em; }

/* чипы выбора */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    padding: 9px 13px; border-radius: 30px; font-size: 14px; cursor: pointer; font-weight: 500;
    display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on.good { background: var(--good); border-color: var(--good); }
.chip.on.bad { background: var(--bad); border-color: var(--bad); }
.chip.on.tr { background: var(--transfer); border-color: var(--transfer); }

/* сегмент-переключатель */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: none; background: none; color: var(--muted); padding: 10px;
    border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.seg.good button.on { color: var(--good); } .seg.bad button.on { color: var(--bad); }
.seg.tr button.on { color: var(--transfer); }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-actions .btn { flex: 1; }

/* ===== Пусто ===== */
.empty { text-align: center; color: var(--muted); padding: 34px 20px; }
.empty .em { font-size: 40px; display: block; margin-bottom: 10px; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2);
    color: var(--muted); font-weight: 600; }
.badge.warn { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }

/* ===== Тост ===== */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
    background: #000; color: #fff; padding: 11px 18px; border-radius: 30px; font-size: 14px;
    font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 200;
    max-width: 90%; }
.toast.show { opacity: .95; transform: translateX(-50%) translateY(0); }

.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 4px 0; line-height: 1.4; }
.link { color: var(--accent); cursor: pointer; font-weight: 600; }
.right { text-align: right; } .center { text-align: center; }
.spacer { height: 8px; }
