:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --bg2: var(--tg-theme-secondary-bg-color, #0e1621);
  --card: var(--tg-theme-section-bg-color, #232e3c);
  --field: #242f3d;
  --text: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8a9bb0);
  --link: var(--tg-theme-link-color, #6ab3f3);
  --accent: var(--tg-theme-button-color, #5288c1);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: #2f3c4c;
  --ok: #6fcf7a;
  --warn: #f0b75e;
  --bad: #f07d72;
  --info: #6ab3f3;
  --page: var(--bg);
  --field-border: transparent;
  --chip-text: #c3cfdc;
  --border2: #3a4a5c;
}
/* Тема «Авто»: цвета Telegram, data-scheme = светлая/тёмная у пользователя в Telegram */
:root[data-scheme="light"] {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #707579);
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-button-color, #2481cc);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --field: #ffffff; --field-border: #dfe3e8; --line: #e4e7ea; --chip-text: #4a5866; --border2: #c9d3dd;
  --ok: #2e9e45; --warn: #c98a1b; --bad: #d9534f; --info: #2481cc;
  --page: var(--bg2);
}
/* Темы, выбранные вручную, — свои цвета, независимо от Telegram */
:root[data-theme="dark"] {
  --bg: #17212b; --bg2: #0e1621; --card: #232e3c; --text: #f5f5f5; --hint: #8a9bb0; --link: #6ab3f3;
  --accent: #5288c1; --accent-text: #ffffff; --page: #17212b;
}
:root[data-theme="light"] {
  --bg: #ffffff; --bg2: #f1f2f6; --card: #ffffff; --text: #000000; --hint: #707579; --link: #2481cc;
  --accent: #2481cc; --accent-text: #ffffff; --page: #f1f2f6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text);
  font: 15px/1.4 -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
.screen { flex: 1; padding: 16px 16px 96px; display: grid; grid-gap: 14px; grid-template-columns: minmax(0, 1fr); align-content: start; max-width: 640px; width: 100%; margin: 0 auto; }
.center { margin: auto; text-align: center; padding: 40px 16px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
h1 { margin: 0; font-size: 22px; font-weight: 700; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }

.hello { display: flex; align-items: center; }
.hello > * + * { margin-left: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

.btn { min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  font-weight: 600; font-size: 16px; padding: 0 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 100%; }
.btn svg { margin-right: 8px; }
.btn.secondary { background: transparent; color: var(--link); border: 1px solid var(--border2); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.success { background: #3f9a52; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--link); padding: 8px 0; cursor: pointer; font-size: 15px; justify-self: start; min-height: 40px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 8px; }
.stat { background: var(--card); border-radius: 14px; padding: 12px 14px; display: grid; grid-gap: 4px; }
.stat b { font-size: 19px; }

.chips { display: flex; flex-wrap: wrap; margin-bottom: -8px; }
.chips .chip { margin: 0 8px 8px 0; }
.chip { min-height: 34px; padding: 0 12px; border-radius: 17px; border: 1px solid var(--field-border); background: var(--field); color: var(--chip-text); font-size: 13px; cursor: pointer; }
.chip.on { border-color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-text); }

.card { background: var(--card); border-radius: 14px; padding: 14px; display: block;
  border: 0; text-align: left; width: 100%; cursor: pointer; color: var(--text); }
.card > * { display: block; }
.card > * + * { margin-top: 8px; }
.card .top { display: flex; align-items: center; }
.card .top > * + * { margin-left: 8px; }
.card .top .muted { flex: 1; font-size: 13px; }
.card .mid { display: flex; align-items: baseline; }
.card .mid > * + * { margin-left: 12px; }
.card .mid span:first-child { flex: 1; }
.card .amount { font-weight: 700; font-size: 16px; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; white-space: nowrap; }
.pill.new { background: rgba(227,166,74,.16); color: var(--warn); }
.pill.approved { background: rgba(106,179,243,.16); color: var(--info); }
.pill.paid { background: rgba(95,191,106,.16); color: var(--ok); }
.pill.rejected { background: rgba(236,106,94,.16); color: var(--bad); }
.pill.urgent { background: rgba(227,166,74,.16); color: var(--warn); }

.field { display: grid; grid-gap: 6px; grid-template-columns: minmax(0, 1fr); }
.field label, .label { font-size: 13px; color: var(--hint); }
.input { min-height: 46px; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); padding: 10px 12px; font-size: 15px; width: 100%; }
.input:focus { outline: none; border-color: var(--accent); }
.input.bad { border-color: var(--bad); }
.input.good { border-color: var(--ok); }
textarea.input { resize: none; min-height: 80px; }
/* выпадающий список — со стрелкой, чтобы не путать с полем ввода */
select.input { -webkit-appearance: none; -moz-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a9bb0' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px 18px; }
select.input::-ms-expand { display: none; }
.hint-line { font-size: 13px; min-height: 18px; }
.hint-line.ok { color: var(--ok); }
.hint-line.bad { color: var(--bad); }
.hint-line.wait { color: var(--hint); }
.hint-line.warn { color: var(--warn); }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-gap: 4px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; padding: 4px; }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg button { min-height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--chip-text); font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.check { display: flex; align-items: center; min-height: 52px; padding: 0 14px; border-radius: 12px; background: var(--field); border: 1px solid var(--field-border); cursor: pointer; }
.icon-btn { width: 40px; height: 40px; border-radius: 20px; border: 0; background: var(--card); color: var(--hint); display: flex;
  align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; margin-left: auto; }
.icon-btn svg { width: 22px; height: 22px; }
.hello > div:nth-child(2) { flex: 1; min-width: 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.check span { flex: 1; display: flex; flex-direction: column; margin-right: 12px; }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-gap: 6px; }
.steps span { height: 4px; border-radius: 2px; background: var(--line); }
.steps span.on { background: var(--accent); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-gap: 10px; }
.tile { min-height: 84px; border-radius: 14px; background: var(--card); border: 1px solid var(--card); padding: 14px; color: var(--text);
  text-align: left; font-weight: 600; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; }
.tile.on { border-color: var(--accent); background: rgba(82,136,193,.22); }
.tile svg { width: 26px; height: 26px; stroke: var(--hint); }
.tile.on svg { stroke: var(--link); }

.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.rows div { display: flex; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rows div span:first-child { color: var(--hint); width: 120px; flex-shrink: 0; margin-right: 12px; }
.rows div span:last-child { word-break: break-all; }
.hist { display: grid; grid-gap: 6px; font-size: 13px; }
.hist div { display: flex; }
.hist div span:first-child { color: var(--hint); white-space: nowrap; margin-right: 8px; }
.hist div span:last-child { min-width: 0; overflow-wrap: anywhere; }
.card, .screen { min-width: 0; overflow-wrap: anywhere; }

.done { justify-items: center; text-align: center; padding-top: 40px; }
.done .ok { width: 88px; height: 88px; border-radius: 44px; background: rgba(95,191,106,.16); display: flex; align-items: center; justify-content: center; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--bg2);
  padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; min-height: 56px; border: 0; background: transparent; color: var(--hint); display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 12px; cursor: pointer; }
.tabs svg { margin-bottom: 4px; }
.tabs button.on { color: var(--link); font-weight: 600; }
.tabs svg { width: 24px; height: 24px; }

.person { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.person > div { flex: 1; display: flex; flex-direction: column; }
.person .chip { flex-shrink: 0; margin-left: 10px; }
.off { opacity: .5; }

#toast { position: fixed; left: 16px; right: 16px; bottom: 90px; background: #2b5278; color: #fff; padding: 12px 16px;
  border-radius: 12px; font-size: 14px; z-index: 10; max-width: 608px; margin: 0 auto; }
.error { color: var(--bad); font-size: 13px; }
