:root {
  --bg: #F6F6F2; --card: #FFFFFF; --line: #E8E8E2; --line2: #D9D9D2; --soft: #ECECE6;
  --ink: #17201A; --muted: #5F6B63; --ink2: #3D4740;
  --green: #1F7A4D; --green-d: #175E3B; --green-t: #E6F2EB; --green-m: #2B8A5B;
  --red: #B93227; --red-t: #FBEBE9; --amber: #7A4706; --amber-t: #FBF1DF; --orange: #E8A04C;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: -apple-system, 'Segoe UI', system-ui, Roboto, sans-serif; font-size: 15px; }
button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
#app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 24px; padding-top: calc(18px + env(safe-area-inset-top)); }
.with-nav { padding-bottom: 104px; }
.with-cta { padding-bottom: 110px; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head h1 { font-size: 21px; font-weight: 700; }
.sub { font-size: 13px; color: var(--muted); }
.round { width: 44px; height: 44px; border-radius: 22px; background: var(--card); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.round.fill { background: var(--green); border-color: var(--green); color: #fff; }
.back { display: flex; align-items: center; gap: 10px; }

.hero { background: var(--green); color: #fff; border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hero .big { font-size: 31px; font-weight: 700; margin-top: 2px; }
.hero .row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pill { background: #fff; color: var(--green); font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 12px; white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hero .tile { background: var(--green-m); border-radius: 12px; padding: 10px 12px; }
.tile .t { font-size: 12px; } .tile .v { font-size: 16px; font-weight: 700; margin-top: 2px; }

.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick button { background: none; border: none; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
.ico { width: 52px; height: 52px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
.ico.s { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; }
.c-green { background: var(--green-t); color: var(--green); }
.c-amber { background: var(--amber-t); color: var(--amber); }
.c-red { background: var(--red-t); color: var(--red); }
.c-gray { background: var(--soft); color: var(--ink2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
button.card { text-align: left; width: 100%; }
.card h2, .sec { font-size: 15px; font-weight: 700; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.base { align-items: baseline; }
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.kpi { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.kpi .t { font-size: 11px; color: var(--muted); } .kpi .v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.pos { color: var(--green); } .neg { color: var(--red); } .warn { color: var(--amber); }
.badge { background: var(--green-t); color: var(--green-d); font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 10px; white-space: nowrap; }
.badge.amber { background: var(--amber-t); color: var(--amber); }
.link { background: none; border: none; color: var(--green); font-weight: 600; font-size: 13px; min-height: 44px; padding: 0 4px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: none; border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.item .mid { flex: 1; min-width: 0; }
.item .tt { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .ss { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .amt { font-size: 14px; font-weight: 700; white-space: nowrap; text-align: right; }
.item .amt small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 21px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.del { width: 44px; height: 44px; border: none; background: none; color: var(--muted); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: -8px; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 22px 12px; background: var(--card); border: 1px dashed var(--line2); border-radius: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 13px; color: var(--muted); }
.inp { height: 52px; width: 100%; background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 0 14px; font-size: 17px; font-weight: 600; }
.inp.txt { font-weight: 400; font-size: 16px; }
.inp:focus { outline: 2px solid var(--green); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line2); background: var(--card); font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: var(--soft); border-radius: 14px; padding: 4px; }
.seg button { height: 44px; border-radius: 10px; border: none; background: none; color: var(--ink2); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 700; }
.stepper { height: 52px; background: var(--card); border: 1px solid var(--line2); border-radius: 14px; display: flex; align-items: center; padding: 0 4px; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: none; background: var(--soft); font-size: 20px; flex-shrink: 0; }
.stepper input { flex: 1; min-width: 0; border: none; background: none; text-align: center; font-size: 18px; font-weight: 700; height: 44px; }
.hint { font-size: 12px; color: var(--muted); }
.line { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.line .k { color: var(--muted); }
.total { border-top: 1px solid var(--line); padding-top: 8px; display: flex; justify-content: space-between; align-items: baseline; }
.total b { font-size: 24px; }
.tip { background: var(--green-t); color: var(--green-d); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.tip .inp { width: 64px; height: 44px; text-align: center; padding: 0 6px; font-size: 16px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.amount { border: none; background: none; width: 100%; height: 56px; text-align: center; font-size: 40px; font-weight: 700; color: var(--red); }
.banner { background: var(--amber-t); color: var(--amber); border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; gap: 10px; }
.banner b { font-size: 16px; }

.cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.cta > div { max-width: 444px; margin: 0 auto; }
.btn { height: 54px; width: 100%; border-radius: 16px; border: none; background: var(--green); color: #fff; font-size: 16px; font-weight: 700; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line2); }
.btn.danger { background: var(--card); color: var(--red); border: 1px solid var(--line2); }
.btn.sm { height: 44px; font-size: 14px; border-radius: 12px; width: auto; padding: 0 14px; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav > div { max-width: 480px; margin: 0 auto; padding: 8px 12px 10px; display: flex; justify-content: space-between; align-items: center; }
.nav button { background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 60px; min-height: 48px; font-size: 11px; font-weight: 500; color: var(--muted); padding: 0; }
.nav button[aria-current="page"] { color: var(--green); font-weight: 700; }
.nav .plus { width: 52px; height: 52px; min-width: 52px; border-radius: 26px; background: var(--green); color: #fff; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 128px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 104px; width: 100%; justify-content: center; }
.bars .pair span { width: 40%; max-width: 18px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .l { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink2); }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.hbar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.hbar .n { width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .tr { flex: 1; height: 10px; background: var(--soft); border-radius: 5px; overflow: hidden; }
.hbar .tr span { display: block; height: 100%; background: var(--green); border-radius: 5px; }
.hbar .tr span.r { background: var(--red); }
.hbar .x { width: 84px; text-align: right; font-weight: 600; white-space: nowrap; }
.period { display: flex; align-items: center; justify-content: space-between; }
.period b { font-size: 15px; }

.overlay { position: fixed; inset: 0; background: rgba(23, 32, 26, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--bg); width: 100%; max-width: 480px; max-height: 90%; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet h2 { font-size: 18px; font-weight: 700; }
#toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; white-space: nowrap; }
#toast.on { opacity: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
