/* Хавмач — стилі. Тепла палітра, томатний акцент, м’які тіні, темна тема. */
:root {
  --accent: #ff4d2e; --accent-2: #ff8a3d; --accent-ink: #fff;
  --bg: #faf6f2; --card: #ffffff; --ink: #231d19; --muted: #8b8179; --line: #eee6df; --field: #f6f0ea;
  --good: #12995a; --good-bg: #e3f6ec; --bad: #e0392b; --bad-bg: #fde9e6;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 8px 24px rgba(60, 30, 10, .06);
  --radius: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131010; --card: #1d1918; --ink: #f6efe9; --muted: #a0958c; --line: #2d2623; --field: #26201e;
    --good: #43d08a; --good-bg: #153326; --bad: #ff7466; --bad-bg: #3a1f1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- шапка ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px); padding-top: env(safe-area-inset-top); }
.top-inner { max-width: 560px; margin: 0 auto; height: 56px; padding: 0 12px; display: grid; grid-template-columns: minmax(48px, 1fr) auto minmax(48px, 1fr); align-items: center; }
.top h1 { font-size: 18px; font-weight: 700; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#top-actions { display: flex; justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--ink); }
.icon-btn:hover { background: var(--field); }
.icon-btn svg { width: 22px; height: 22px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: block; }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(120px + env(safe-area-inset-bottom)); animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main { animation: none; } * { transition: none !important; } }

/* ---------- картки й заголовки ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 6px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.section-title { margin: 22px 4px 10px; font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 56px; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 14px; }
.pos { color: var(--good); font-weight: 650; } .neg { color: var(--bad); font-weight: 650; } .zero { color: var(--muted); }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.pill.pos { background: var(--good-bg); } .pill.neg { background: var(--bad-bg); } .pill.zero { background: var(--field); font-weight: 500; }

.avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 16px; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.sq { border-radius: 14px; width: 46px; height: 46px; font-size: 19px; }
.avatar.receipt-ic { background: var(--field); color: var(--muted); }
.avatar.receipt-ic svg { width: 20px; height: 20px; }

/* ---------- велика картка балансу ---------- */
.hero { border-radius: 24px; padding: 22px 20px; margin: 8px 0 6px; color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(135deg, #8d847c, #6f6761); }
.hero.pos { background: linear-gradient(135deg, #17b26a, #0b8a52); }
.hero.neg { background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.hero .label { font-size: 14px; opacity: .9; }
.hero .big { font-size: 40px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.hero .hint { margin-top: 6px; font-size: 14px; opacity: .92; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 14px;
  font-weight: 650; background: var(--field); color: var(--ink); transition: transform .08s, filter .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(255, 77, 46, .28); }
.btn.primary:hover { filter: brightness(1.04); }
.btn.block { width: 100%; margin-top: 16px; min-height: 52px; font-size: 17px; }
.btn.sm { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-weight: 600; }
.fab { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  min-height: 54px; padding: 0 24px; border-radius: 999px; font-size: 17px; box-shadow: 0 10px 28px rgba(255, 77, 46, .38); }
.fab:active { transform: translateX(-50%) scale(.97); }

/* ---------- поля ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input, select { width: 100%; min-height: 48px; padding: 0 14px; font: inherit; color: var(--ink); background: var(--field);
  border: 2px solid transparent; border-radius: 14px; outline: none; transition: border-color .15s, background .15s; }
input:focus, select:focus { border-color: var(--accent); background: var(--card); }
input::placeholder { color: var(--muted); }
.amount-field { text-align: center; font-size: 34px; font-weight: 800; min-height: 68px; letter-spacing: -.01em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.err { color: var(--bad); font-size: 14px; margin: 12px 0 0; min-height: 1.2em; }

.seg { display: flex; gap: 4px; padding: 4px; background: var(--field); border-radius: 14px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button[aria-pressed="true"], .seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.part { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.part .name { flex: 1; margin: 0; color: var(--ink); font-size: 16px; font-weight: 500; }
.part input[type=text] { width: 110px; text-align: right; }
.part input[type=checkbox] { width: 24px; height: 24px; min-height: 0; accent-color: var(--accent); flex: none; }

/* ---------- чек ---------- */
.filebtn { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; padding: 16px; text-align: center;
  color: var(--ink); font-size: 15px; font-weight: 600; background: var(--field); border: 2px dashed var(--line); border-radius: 16px; cursor: pointer; }
.filebtn svg { width: 22px; height: 22px; color: var(--accent); }
.filebtn input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.filebtn:focus-within { border-color: var(--accent); }
.scan { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.thumb { height: 64px; width: 64px; object-fit: cover; border-radius: 12px; }
.status { font-size: 14px; color: var(--muted); margin: 8px 2px 0; min-height: 1.2em; }
.status.ok { color: var(--good); }

/* ---------- нижня панель (sheet) ---------- */
dialog { color: var(--ink); }
dialog::backdrop { background: rgba(20, 10, 5, .55); backdrop-filter: blur(2px); }
dialog.sheet { width: min(560px, 100%); max-width: 100%; max-height: 94vh; margin: auto auto 0; padding: 0; border: 0; background: var(--card);
  border-radius: 28px 28px 0 0; overflow: hidden; animation: slide .25s ease-out; }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 28px; } }
@keyframes slide { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.sheet-head h2 { font-size: 20px; }
.sheet-body { max-height: calc(94vh - 64px); overflow-y: auto; padding: 4px 20px calc(24px + env(safe-area-inset-bottom)); }
dialog.receipt-dialog { width: min(640px, 94vw); padding: 12px; border: 0; border-radius: 20px; background: var(--card); }
.receipt-dialog img { display: block; max-width: 100%; max-height: 74vh; margin: 0 auto; border-radius: 12px; }

/* ---------- екран входу ---------- */
.auth { padding-top: 28px; text-align: center; }
.auth .logo-big { width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 14px; box-shadow: 0 12px 30px rgba(255, 77, 46, .35); }
.auth h2 { font-size: 30px; font-weight: 800; }
.auth .tag { margin: 6px auto 24px; max-width: 300px; color: var(--muted); }
.auth form { text-align: left; }

/* ---------- інше ---------- */
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .emoji { font-size: 40px; display: block; margin-bottom: 6px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 2px; font-weight: 700; font-size: 17px; }
.arrow { width: 16px; height: 16px; color: var(--muted); flex: none; }
.who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: 90vw;
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: var(--shadow); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.transfer + .transfer { border-top: 1px solid var(--line); }
.transfer .row { border-top: 0; }
.cardline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 0 0 12px 0; }
.cardline .grow { flex: 1; min-width: 160px; }

.btn.ghost { background: transparent; color: var(--muted); padding: 0 10px; border: 1px solid var(--line); min-height: 30px; font-size: 13px; font-weight: 600; }
.btn.ghost svg { width: 15px; height: 15px; }
.row.start { align-items: flex-start; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dispute { margin-top: 6px; padding: 6px 10px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 13px; font-weight: 600; }
.integrity.ok { border-left: 5px solid var(--good); }
.integrity.bad { border-left: 5px solid var(--bad); background: var(--bad-bg); }
.integrity .code { font-size: 14px; letter-spacing: 1px; }
.btn.primary.sm { box-shadow: none; }

.invite-banner { display: flex; align-items: center; gap: 14px; text-align: left; margin: 0 0 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.invite-banner .title.big { font-size: 20px; font-weight: 800; }
.linkbox { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--field); font-size: 14px; word-break: break-all; user-select: all; }

.rcp { margin: 0 0 14px; }
.rcp img { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: var(--field); }
.rcp figcaption { margin-top: 6px; }
.rcp-list { max-height: 62vh; overflow-y: auto; }

.ocr-details { margin: 8px 2px 0; font-size: 14px; color: var(--muted); }
.ocr-details summary { cursor: pointer; padding: 4px 0; font-weight: 600; }
.ocr-text { margin: 6px 0; padding: 10px; max-height: 160px; overflow: auto; white-space: pre-wrap; word-break: break-word; border-radius: 10px; background: var(--field); color: var(--ink); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* сповіщення */
.bell { position: relative; }
.bell-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.bell-badge[hidden] { display: none; }
.row.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.row.unread + .row { border-top-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.note-text { overflow-wrap: anywhere; }
a.row { color: inherit; text-decoration: none; }

.btn.danger { color: var(--bad); background: var(--bad-bg); }
details.archive > summary { cursor: pointer; list-style: none; }
details.archive > summary::-webkit-details-marker { display: none; }
details.archive[open] > summary { opacity: .8; }
