:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111114);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --accent: var(--tg-theme-button-color, #2f7cf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(127, 127, 127, 0.18);
  --green: #1f9d55;
  --red: #e5484d;
  --amber: #c27c0e;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }

.top { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px 6px; }
.top-title { font-size: 22px; font-weight: 700; }
.top-role { color: var(--hint); font-size: 13px; }

main { padding: 0 16px 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); font-weight: 600; margin: 20px 4px 8px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card.flat { padding: 0; overflow: hidden; }

.kpis { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.kpi { background: var(--card); border-radius: var(--radius); padding: 12px; min-width: 0; }
.kpi .l { color: var(--hint); font-size: 12px; }
.kpi .v { font-size: 16px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--hint); font-size: 13px; margin-top: 2px; }
.row .amt { font-weight: 600; white-space: nowrap; text-align: right; }
.row.tap { cursor: pointer; }
.total-row { font-weight: 700; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--hint); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: var(--line); color: var(--hint); white-space: nowrap; }
.badge.red { background: rgba(229,72,77,.14); color: var(--red); }
.badge.amber { background: rgba(194,124,14,.14); color: var(--amber); }
.badge.green { background: rgba(31,157,85,.14); color: var(--green); }

.decision { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.decision:last-child { border-bottom: 0; }
.decision .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: var(--accent-text); font-weight: 600; cursor: pointer; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: var(--line); color: var(--text); }
.btn.danger { background: rgba(229,72,77,.14); color: var(--red); }
.btn.block { width: 100%; padding: 13px; margin-top: 8px; }
.btn:disabled { opacity: .5; }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 2px; overflow-x: auto; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 8px; border-radius: 8px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin: 0 2px 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 11px 12px; outline: none; }
.field textarea { min-height: 64px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; min-width: 0; }

.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%;
  border: 0; background: var(--accent); color: var(--accent-text); font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.2); cursor: pointer; z-index: 5; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 6; }
.tabs button { flex: 1; border: 0; background: none; font-size: 11px; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; cursor: pointer; }
.tabs button span { font-size: 18px; line-height: 1; }
.tabs button.active { color: var(--accent); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); transform: translateY(105%); transition: transform .25s; z-index: 11; }
.sheet.open { transform: none; }
.sheet-bg.open { opacity: 1; pointer-events: auto; }
.sheet .grip { width: 38px; height: 5px; background: var(--line); border-radius: 3px; margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
.sheet img.doc { width: 100%; border-radius: 10px; margin-top: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--hint); }
.kv .v { text-align: right; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); background: rgba(20,20,22,.92); color: #fff;
  padding: 12px 14px; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; z-index: 20; text-align: center; }
.toast.show { opacity: 1; transform: none; }

.empty { color: var(--hint); text-align: center; padding: 28px 12px; }
.report-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.report-item:last-child { border-bottom: 0; }
.report-item .n { display: inline-block; width: 22px; height: 22px; border-radius: 50%; background: var(--line); text-align: center; font-size: 12px; line-height: 22px; font-weight: 700; margin-right: 6px; }
.report-item .h { font-weight: 600; margin-bottom: 4px; }
.report-item .line { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 2px 0; }
.report-item .line span:first-child { color: var(--hint); }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar input, .toolbar select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px 10px; }
.toolbar .grow { flex: 1; }
