:root {
  --paper: #F6F3EC;
  --card: rgba(255, 253, 248, .92);
  --ink: #26304F;
  --muted: #7E86A3;
  --blue: #6F8FEA;
  --blue2: #A3BBF7;
  --soft: #E3EAFC;
  --line: rgba(147, 173, 242, .45);
  --green: #3E9B74;
  --red: #D0566F;
  --amber: #C99A2E;
  --font: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); }
body { min-height: 100vh; padding-bottom: calc(78px + var(--safe-b)); overflow-x: hidden;
  background-image: repeating-linear-gradient(transparent 0 33px, rgba(147, 173, 242, .18) 33px 34px); }
button, input, select { font: inherit; color: inherit; }

/* фон: акварельные пятна и пузыри */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg i { position: absolute; border-radius: 50%; }
.bg .b1 { width: 70vmax; height: 70vmax; left: -30vmax; top: -30vmax;
  background: radial-gradient(circle, rgba(147, 173, 242, .45), rgba(188, 205, 248, 0) 70%); }
.bg .b2 { width: 60vmax; height: 60vmax; right: -28vmax; bottom: -20vmax;
  background: radial-gradient(circle, rgba(147, 173, 242, .40), rgba(188, 205, 248, 0) 70%); }
.bg .b3, .bg .b4 { border: 1.5px solid rgba(255, 255, 255, .9); box-shadow: inset 0 0 18px rgba(157, 182, 244, .45);
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .9) 0 8%, rgba(220, 230, 255, .18) 9% 100%); }
.bg .b3 { width: 74px; height: 74px; right: 9%; top: 15%; }
.bg .b4 { width: 38px; height: 38px; left: 8%; top: 58%; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(14px + var(--safe-t)) 16px 12px; background: rgba(246, 243, 236, .88);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.top > div { flex: 1; min-width: 0; }
h1 { margin: 0; font-size: 28px; font-weight: 400; letter-spacing: .2px; }
h2 { margin: 0 0 6px; font-size: 18px; font-weight: 400; }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.sync { display: flex; align-items: center; gap: 6px; padding: 9px 14px; border: 0; border-radius: 999px;
  color: #fff; background: linear-gradient(90deg, var(--blue2), var(--blue)); font-size: 14px;
  box-shadow: 0 4px 14px rgba(111, 143, 234, .35); white-space: nowrap; }
.sync svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sync.busy svg { animation: spin 1s linear infinite; }
.sync .count { background: #fff; color: var(--blue); border-radius: 999px; padding: 0 7px; font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 14px 16px 24px; max-width: 640px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px;
  margin-bottom: 14px; box-shadow: 0 6px 24px rgba(111, 143, 234, .10); }
.card.soft { background: rgba(227, 234, 252, .75); }

/* форма */
.seg, .dest { display: flex; gap: 6px; background: var(--soft); padding: 4px; border-radius: 999px; }
.seg button, .dest button { flex: 1; border: 0; padding: 9px 8px; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button.on, .dest button.on { background: linear-gradient(90deg, var(--blue2), var(--blue)); color: #fff;
  box-shadow: 0 3px 10px rgba(111, 143, 234, .3); }
.dest { margin-top: 14px; }
.dest svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.amount { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 18px 0 10px; }
.amount input { width: 100%; max-width: 260px; border: 0; border-bottom: 2px solid var(--line); background: transparent;
  font-size: 46px; text-align: center; padding: 2px 0; outline: none; }
.amount input:focus { border-color: var(--blue); }
.amount span { font-size: 30px; color: var(--muted); }
.field { display: block; margin-top: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px 4px; }
.field input, .field select { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none; }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--blue) 50%), linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(111, 143, 234, .18); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 4px 0; line-height: 1.35; }
.center { text-align: center; }
.primary { width: 100%; margin-top: 16px; padding: 14px; border: 0; border-radius: 999px; color: #fff; font-size: 17px;
  background: linear-gradient(90deg, var(--blue2), var(--blue)); box-shadow: 0 6px 18px rgba(111, 143, 234, .35); }
.primary:active, .sync:active, .ghost:active { transform: scale(.98); }
.ghost { margin-top: 10px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  color: var(--blue); font-size: 15px; }
.ghost.danger { color: var(--red); }
.status { font-size: 14px; margin: 8px 4px 0; }
.status.ok { color: var(--green); }
.status.bad { color: var(--red); }
details { margin-top: 12px; }
summary { color: var(--blue); font-size: 14px; }

/* сегодня / сводка */
.big { font-size: 26px; }
.big b { font-weight: 400; }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.line:last-child { border-bottom: 0; }
.line .r { white-space: nowrap; }
.muted { color: var(--muted); }
.green { color: var(--green); }
.red { color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--amber); } .dot.red { background: var(--red); }
.bar { height: 8px; border-radius: 4px; background: rgba(147, 173, 242, .25); overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #B4C8F9, var(--blue)); }
.sec { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: #6F8BE0; margin: 18px 4px 8px; }

/* список записей */
.filters { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 7px 12px;
  font-size: 14px; white-space: nowrap; }
.chip.on { background: linear-gradient(90deg, var(--blue2), var(--blue)); color: #fff; border-color: transparent; }
.entry { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.entry + .entry { border-top: 1px dashed var(--line); }
.entry .ic { width: 36px; height: 36px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; flex: none; }
.entry .ic svg { width: 19px; height: 19px; fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.entry .mid { flex: 1; min-width: 0; }
.entry .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.entry .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.entry .sum { white-space: nowrap; font-size: 16px; }
.badge { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; margin-left: 4px; }
.badge.pending { background: #FFF1CF; color: #8A6A10; }
.badge.sent { background: var(--soft); color: #4D66B8; }
.badge.done { background: #DDF3E8; color: #2F7A5A; }
.badge.local { background: #F1E8FB; color: #7651A8; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; padding: 6px 8px calc(6px + var(--safe-b));
  background: rgba(255, 253, 248, .92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 14px; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--blue); background: rgba(188, 205, 248, .35); }

/* лист действий над записью */
.sheet-bg { position: fixed; inset: 0; background: rgba(38, 48, 79, .28); z-index: 20; display: flex; align-items: flex-end; }
.sheet { width: 100%; background: var(--paper); border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  animation: up .2s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin-bottom: 4px; }
.sheet button { display: block; width: 100%; margin-top: 8px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(86px + var(--safe-b)); z-index: 30; padding: 12px 16px;
  border-radius: 16px; background: rgba(38, 48, 79, .92); color: #fff; font-size: 15px; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.hint a { color: var(--blue); }
.gear { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; display: grid;
  place-items: center; flex: none; }
.gear svg { width: 21px; height: 21px; fill: none; stroke: var(--blue); stroke-width: 1.7; stroke-linecap: round; }
.dot.yellow { background: var(--amber); }
.line > span:first-child { min-width: 0; }
.sync { padding: 9px 12px; }
h1 { font-size: 25px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top { gap: 8px; padding-left: 14px; padding-right: 12px; }
.sync { font-size: 13px; padding: 9px 11px; gap: 5px; }
@media (max-width: 380px) { #syncText { display: none; } }
.line.tap { cursor: pointer; }
.line.tap:active { background: rgba(188, 205, 248, .25); }
.tabs button { position: relative; }
.tabs button.has-dot::after { content: ""; position: absolute; top: 5px; right: calc(50% - 16px); width: 8px; height: 8px;
  border-radius: 50%; background: var(--red); }
.edit-banner { background: #FFF1CF; color: #8A6A10; border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; }
.edit-banner a { color: var(--blue); }
.lock { position: fixed; inset: 0; z-index: 50; background: var(--paper); display: flex; align-items: center; justify-content: center;
  background-image: radial-gradient(circle at 10% 0%, rgba(147, 173, 242, .45), transparent 55%),
    radial-gradient(circle at 100% 100%, rgba(147, 173, 242, .40), transparent 55%); }
.lock-in { width: 100%; max-width: 340px; padding: 20px; text-align: center; }
.lock-ic { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue2), var(--blue)); box-shadow: 0 8px 22px rgba(111, 143, 234, .35); }
.lock-ic svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; }
.lock h2 { font-size: 24px; margin: 6px 0 0; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 6px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--blue); }
.pin-dots i.on { background: var(--blue); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 14px 10px 10px; }
.keys button { height: 66px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 253, 248, .9);
  font-size: 26px; color: var(--ink); box-shadow: 0 3px 10px rgba(111, 143, 234, .12); }
.keys button:active { background: var(--soft); }
.center { text-align: center; }
[hidden] { display: none !important; }
.keys button { width: 74px; height: 74px; justify-self: center; }

/* ---- обновлённая навигация: компактная кнопка синхронизации, «+» по центру */
#syncText { display: none !important; }
.sync { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; position: relative; flex: none; }
.sync svg { width: 21px; height: 21px; }
.sync .count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; line-height: 18px;
  padding: 0 4px; font-size: 11px; text-align: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.gear { width: 44px; height: 44px; }
h1 { font-size: 27px; }
.tabs { align-items: flex-end; }
.tabs .plus { color: var(--blue); }
.tabs .plus span { width: 52px; height: 52px; margin-top: -26px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--blue2), var(--blue)); box-shadow: 0 6px 18px rgba(111, 143, 234, .45);
  border: 3px solid var(--paper); }
.tabs .plus span svg { width: 26px; height: 26px; stroke: #fff; stroke-width: 2.2; }
.tabs .plus.on { background: transparent; }
/* ---- операции */
.search { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 0 12px; margin-bottom: 10px; }
.search svg { width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.search input { flex: 1; border: 0; outline: none; background: transparent; padding: 11px 0; font-size: 16px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 4px 8px; }
.day-head .sec { margin: 0; }
.day-head .tot { font-size: 13px; color: var(--muted); }
.totals { display: flex; gap: 10px; margin-bottom: 4px; }
.totals .card { flex: 1; margin-bottom: 10px; padding: 12px 14px; }
.totals .k { font-size: 12px; color: var(--muted); }
.totals .v { font-size: 20px; margin-top: 2px; }
.entry.tap:active { background: rgba(188, 205, 248, .25); }
.spend-list { margin: 10px 0 4px; border-top: 1px dashed var(--line); }
.spend-list .line { font-size: 14px; }

/* данные с ноутбука устарели */
.card.warn { background: #FFF4E0; border-color: #F2C77B; }
.card.warn b { color: #8A5A00; }
