:root {
  --bg: #ffffff;
  --bg-2: #f2f3f7;
  --card: #f2f3f7;
  --line: #e4e7ee;
  --gold: #0032e8;
  --gold-2: #0027b5; /* нажатие / тёмный синий логотипа */
  --gold-soft: #e8edfe;
  --ink: #111111;
  --muted: #6d7380;
  --danger: #d4532b;
  --ok: #1f8a4c;
  --rb: #c46a12;
  --rf: #0032e8;
  --pad: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: Futura, "Futura PT", "Trebuchet MS", "Segoe UI", sans-serif;
  padding-bottom: 88px;
}

.top {
  position: sticky; top: 0; z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: calc(12px + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right)) 10px calc(var(--pad) + env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.brand b { font-size: 16px; letter-spacing: .04em; text-transform: none; color: var(--gold); font-weight: 700; }
.brand .logo { margin: 0; line-height: 0; }
.brand .logo img { display: block; width: 166px; max-width: 100%; height: auto; }
@media (max-width: 380px) { .brand .logo img { width: 140px; } }
.brand span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 6px 10px; font-size: 12px;
  flex: 0 1 auto; text-align: center;
}

.screen { display: none; padding: 14px var(--pad) 24px; }
.screen.on { display: block; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  background: #fff; border-top: 1px solid var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.nav button {
  background: none; border: 0; color: var(--muted); padding: 10px 6px;
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
}
.nav button.on { color: var(--gold); }

h2 { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-bottom: 10px;
}
.row { display: grid; gap: 8px; margin-bottom: 8px; }
.row.2 { grid-template-columns: 1fr 1fr; }
.row.3 { grid-template-columns: 1fr 1fr 1fr; }
label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .06em; }
input, select, textarea {
  width: 100%; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 10px;
  font-size: 16px;
}
.filebtn {
  display: block; margin: 6px 0 10px; border: 1px dashed #0032e8; border-radius: 16px;
  padding: 12px; text-align: center; color: #0032e8; font-size: 14px; background: #fff;
}
.filebtn input { display: none; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button, .toggle {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 8px 12px; font-size: 13px;
}
.seg button.on, .toggle.on { border-color: var(--gold); color: #fff; background: var(--gold); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.warn { color: var(--danger); font-size: 13px; }
.ok { color: var(--ok); }

.btn {
  width: 100%; border: 0; border-radius: 12px; padding: 14px 12px;
  background: var(--gold); color: #fff; font-weight: 700; font-size: 15px; border-radius: 30px;
}
.btn:active { background: var(--gold-2); }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 500; }
.btn.ghost:active { background: var(--gold-soft); }
.btn + .btn { margin-top: 8px; }
.actions { display: grid; gap: 8px; margin-top: 12px; }

.total {
  padding: 16px; border-radius: 16px;
  background: var(--gold); color: #fff;
  border: 0;
}
.total .k { font-size: 12px; color: rgba(255,255,255,.8); letter-spacing: .08em; text-transform: uppercase; }
.total .v { font-size: 34px; font-variant-numeric: tabular-nums; margin: 6px 0 2px; }
.total .s { color: rgba(255,255,255,.75); font-size: 13px; }

.line { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.line span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.line.em { color: var(--gold); font-weight: 700; border-bottom: 0; padding-top: 12px; }
.small { font-size: 12px; color: var(--muted); margin-top: 6px; }

.history { display: grid; gap: 8px; }
.item {
  text-align: left; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; color: inherit;
}
.item b { display: block; font-size: 15px; }
.item .meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.preview {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  background: #fff; border: 1px dashed var(--line); font-size: 13px;
}
.preview.rb { border-color: var(--rb); color: #8a4b08; }
.preview.rf { border-color: var(--rf); color: #0032e8; }

.empty { color: var(--muted); padding: 24px 8px; text-align: center; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom));
  background: #0032e8; color: #fff; border: 0;
  border-radius: 12px; padding: 12px 14px; display: none; z-index: 30;
}
.toast.on { display: block; }

@media (min-width: 720px) {
  .wrap { max-width: 720px; margin: 0 auto; }
}
