:root {
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --ink: #111418;
  --muted: #8B909A;
  --line: #ECEEF1;
  --green: #1E7A55;
  --green-soft: #E4F4EC;
  --red: #C0564F;
  --red-soft: #FBEDEA;
  --amber: #E0A458;
  --hero: #15251D;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { background: #E8EAEE; width: 100%; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  display: block;
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 92px;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px 20px 12px;
}
.top h1 { font-size: 27px; font-weight: 700; letter-spacing: -.4px; }
.top .sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.pill {
  font-size: 11.5px; font-weight: 600; color: var(--green);
  background: var(--green-soft); padding: 6px 10px; border-radius: 999px;
  white-space: nowrap;
}

main { padding: 0 20px; flex: 1; }

.hero {
  background: var(--hero); color: #fff; border-radius: 24px; padding: 20px 22px 18px;
}
.hero .label { font-size: 12.5px; color: #9FB8AA; font-weight: 500; }
.hero .big { font-size: 46px; font-weight: 700; letter-spacing: -1.5px; margin-top: 6px; }
.hero .big span { font-size: 17px; font-weight: 500; color: #B9CEC2; letter-spacing: 0; margin-left: 6px; }
.hero .note { font-size: 12.5px; color: #9FB8AA; margin-top: 6px; }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin-top: 16px; background: #26382F; }
.bar i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 11px; color: #9FB8AA; }
.legend b { color: #fff; font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: 1px; }

.grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; margin-top: 12px; }
.card {
  background: var(--card); border-radius: 18px; padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(17,20,24,.04);
}
.card .k { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.card .v { font-size: 18px; font-weight: 700; letter-spacing: -.3px; margin-top: 5px; }
.card .v small { font-size: 12px; font-weight: 500; color: var(--muted); }
.card .v.green { color: var(--green); }

.section { display: flex; align-items: center; justify-content: space-between; padding: 20px 2px 10px; }
.section h2 { font-size: 15px; font-weight: 650; letter-spacing: -.2px; }
.section .link { font-size: 12px; color: var(--muted); }

.row {
  background: var(--card); border-radius: 16px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; margin-bottom: 7px;
  box-shadow: 0 1px 2px rgba(17,20,24,.04);
  border: none; width: 100%; text-align: left; font: inherit; color: inherit;
}
.row:active { transform: scale(.995); }
.swatch { width: 32px; height: 32px; border-radius: 10px; flex: none; }
.row .name { font-size: 14px; font-weight: 600; }
.row .meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.row .right { margin-left: auto; text-align: right; }
.row .price { font-size: 13px; font-weight: 600; }
.row .profit { font-size: 11.5px; color: var(--green); font-weight: 600; margin-top: 2px; }
.row .profit.minus { color: var(--red); }

.model { margin-bottom: 7px; }
.model .row.main { margin-bottom: 0; }
.model.open .row.main { border-radius: 16px 16px 0 0; }
.chev { color: #B4B9C1; font-size: 13px; margin-left: 2px; width: 14px; text-align: center; flex: none; }
.model.open .chev { color: var(--ink); }
.subrows { background: var(--card); border-radius: 0 0 16px 16px; padding: 0 14px 8px 58px; box-shadow: 0 1px 2px rgba(17,20,24,.04); }
.subrow { font-size: 12.5px; color: #4C535C; padding: 7px 0; display: flex; align-items: center; gap: 8px; border-top: 1px solid #F0F1F3; }
.subrow .s { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.total { display: flex; justify-content: space-between; padding: 14px 4px 0; font-size: 12.5px; color: var(--muted); }
.total b { color: var(--ink); font-weight: 600; }

.op { display: flex; gap: 12px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.op:last-child { border-bottom: 0; }
.op .ico { width: 34px; height: 34px; border-radius: 11px; background: var(--green-soft); color: var(--green); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex: none; }
.op.out .ico, .op.expense .ico { background: var(--red-soft); color: var(--red); }
.op .t { font-size: 13px; font-weight: 550; }
.op .d { font-size: 11px; color: var(--muted); margin-top: 2px; }
.op .sum { margin-left: auto; text-align: right; font-size: 13px; font-weight: 600; white-space: nowrap; }
.op .sum small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }

.empty { background: var(--card); border-radius: 16px; padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; margin: 0 auto;
  width: 100%; max-width: 460px; height: 86px;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-around; padding-top: 10px;
  backdrop-filter: blur(12px); z-index: 20;
}
.tab { background: none; border: 0; text-align: center; font-size: 10px; color: #9AA0A9; width: 84px; font: inherit; font-size: 10px; padding: 0; }
.tab svg { display: block; margin: 0 auto 4px; }
.tab.active { color: var(--ink); font-weight: 600; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; background: var(--hero); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 300;
  margin-top: -16px; box-shadow: 0 8px 20px rgba(21,37,29,.28); border: 0; cursor: pointer;
}

/* модалка */
.modal {
  position: fixed; inset: 0; background: rgba(16,17,20,.42);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal.hidden { display: none; }
.sheet {
  width: 100%; max-width: 460px; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 20px 20px 28px;
  max-height: 92vh; overflow-y: auto;
}
.sheet h2 { font-size: 20px; font-weight: 700; margin-bottom: 14px; }
.seg { display: flex; background: #EDEFF2; border-radius: 14px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 0; border-radius: 11px; font: inherit; font-size: 13px; font-weight: 550; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(17,20,24,.08); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 12px; font: inherit; font-size: 14px; color: var(--ink);
}
.field input:focus, .field select:focus { outline: 2px solid rgba(30,122,85,.25); border-color: var(--green); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; margin: 4px 0 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.submit { width: 100%; border: 0; background: var(--hero); color: #fff; padding: 15px; border-radius: 14px; font: inherit; font-size: 15px; font-weight: 600; }
.cancel { width: 100%; border: 0; background: transparent; color: var(--muted); padding: 12px; font: inherit; font-size: 13px; margin-top: 4px; }
.err { color: var(--red); font-size: 12.5px; margin-bottom: 10px; min-height: 16px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }

.op-photo { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; margin-top: 7px; display: block; }
.photo-preview img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; margin: 6px 0 10px; display: block; }
.pay { border: 0; background: var(--green-soft); color: var(--green); font: inherit; font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 8px; margin-top: 4px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 340px; background: #fff; border-radius: 24px; padding: 28px 24px 24px; box-shadow: 0 12px 40px rgba(17,20,24,.08); text-align: center; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--hero); color: #fff; font-size: 34px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.login-card p { font-size: 12.5px; color: var(--muted); margin: 6px 0 18px; }
.login-card input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; font: inherit; font-size: 15px; margin-bottom: 10px; }
.login-card input:focus { outline: 2px solid rgba(30,122,85,.25); border-color: var(--green); }
.login-card button { width: 100%; border: 0; background: var(--hero); color: #fff; padding: 14px; border-radius: 13px; font: inherit; font-size: 15px; font-weight: 600; }
