/* Сметный бот — Mini App. Цвета — из темы Telegram (--tg-theme-*), запасные — свои, светлые и тёмные. */
:root {
  --f-bg: #f1f2f5; --f-card: #ffffff; --f-text: #15171a; --f-hint: #6c737c; --f-accent: #2481cc; --f-accent-text: #ffffff; --f-line: rgba(20, 24, 30, .09); --f-soft: #eef3f8;
}
:root[data-theme="dark"] {
  --f-bg: #0f1419; --f-card: #1a2129; --f-text: #eef1f4; --f-hint: #8f9aa6; --f-accent: #4ea4f0; --f-accent-text: #ffffff; --f-line: rgba(255, 255, 255, .08); --f-soft: #1f2a36;
}
:root {
  --bg: var(--tg-theme-secondary-bg-color, var(--f-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--f-card)));
  --text: var(--tg-theme-text-color, var(--f-text));
  --hint: var(--tg-theme-hint-color, var(--f-hint));
  --accent: var(--tg-theme-button-color, var(--f-accent));
  --accent-text: var(--tg-theme-button-text-color, var(--f-accent-text));
  --link: var(--tg-theme-link-color, var(--f-accent));
  --danger: var(--tg-theme-destructive-text-color, #d7443e);
  --line: var(--f-line);
  --soft: var(--f-soft);
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; overflow-x: hidden; }
body.has-main { padding-bottom: 84px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--link); }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 6px 16px; background: var(--bg); }
.bar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.2px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { border: 0; background: none; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; color: var(--link); cursor: pointer; }
main { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }

.card { background: var(--card); border-radius: var(--r); padding: 14px 16px; }
.card.flat { padding: 0; overflow: hidden; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
h2 { margin: 6px 2px 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--hint); }
p { margin: 0; }

.access { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.access b { font-size: 17px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; padding: 7px 12px; background: var(--soft); color: var(--link); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 92px; padding: 10px 4px; border: 0; border-radius: var(--r); background: var(--card); cursor: pointer; text-align: center; font-size: 13px; font-weight: 600; line-height: 1.2; }
.tile svg { width: 28px; height: 28px; color: var(--accent); }
.tile:active { transform: scale(.98); }

.list { background: var(--card); border-radius: var(--r); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px; border: 0; background: none; text-align: left; cursor: pointer; }
.row + .row { border-top: 1px solid var(--line); }
.row .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); color: var(--accent); flex: none; }
.row .ic svg { width: 18px; height: 18px; }
.row .t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .t b { font-weight: 600; }
.row .t span { color: var(--hint); font-size: 13px; }
.row .go { color: var(--hint); font-size: 20px; }
.row .sum { font-weight: 700; white-space: nowrap; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 14px; }
.field > label, .field > .lbl { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--hint); }
.input { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); padding: 10px 12px; font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
.input.bad { border-color: var(--danger); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 6px 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.err { color: var(--danger); font-size: 14px; }
.err:empty { display: none; }

.total { display: flex; flex-direction: column; gap: 2px; }
.total .big { font-size: 32px; font-weight: 800; letter-spacing: -.5px; }
.split { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--hint); font-size: 14px; }
.split b { color: var(--text); white-space: nowrap; }
details { border-top: 1px solid var(--line); }
details:first-child { border-top: 0; }
summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary span::before { content: "›"; display: inline-block; width: 14px; color: var(--hint); transition: transform .15s; }
details[open] summary span::before { transform: rotate(90deg); }
summary b { white-space: nowrap; }
.lines { margin: 0; padding: 0 16px 12px 30px; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lines li { display: flex; justify-content: space-between; gap: 10px; }
.lines li b { font-weight: 600; white-space: nowrap; }

.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; }
.btn.secondary { background: var(--soft); color: var(--link); }
.btn:disabled { opacity: .55; }
.btns { display: flex; gap: 8px; }
.btns .btn { min-height: 42px; font-size: 14px; }
.main-btn { position: fixed; left: 16px; right: 16px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 6; min-height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 16px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); cursor: pointer; max-width: 608px; margin: 0 auto; }
.main-btn.busy { opacity: .7; }

.kp-head { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; text-align: center; background: var(--bg); }
.kp-head b { display: block; font-size: 18px; letter-spacing: .3px; }
.kp-head .tl { font-size: 11px; letter-spacing: .6px; color: var(--hint); margin-top: 4px; }
.kp-head .ft { font-size: 12px; color: var(--hint); margin-top: 8px; }

.plan { display: flex; align-items: center; gap: 12px; }
.plan .t { flex: 1; }
.plan .t b { display: block; font-size: 16px; }
.plan .price { text-align: right; }
.plan .price b { display: block; font-size: 17px; white-space: nowrap; }
.plan .btn { width: auto; padding: 0 16px; min-height: 40px; font-size: 14px; }

.done { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 26px 16px; }
.done .mark { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--accent); font-size: 32px; font-weight: 700; }
.done h3 { margin: 4px 0 0; font-size: 20px; }
.docs { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.doc { display: flex; align-items: center; gap: 10px; }
.doc .ext { width: 38px; height: 44px; border-radius: 8px; background: var(--accent); color: var(--accent-text); font-size: 10px; font-weight: 800; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; flex: none; }

.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 12px; color: var(--hint); }
.skeleton { height: 90px; border-radius: var(--r); background: var(--card); opacity: .6; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px)); z-index: 10; max-width: calc(100% - 32px); background: rgba(20, 22, 26, .92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; }
.empty { text-align: center; padding: 20px 10px; color: var(--hint); }
ul.plain { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
[hidden] { display: none !important; }
