/* Общий стиль всех Mini App: графит + один янтарный акцент. */
:root {
  --bg: #0f0f10;
  --surface: #17171a;
  --surface-2: #1e1e22;
  --hover: #232328;
  --line: #2a2a30;
  --line-soft: #222226;
  --text: #ececee;
  --text-2: #a3a3ab;
  --text-3: #6e6e78;
  --accent: #f0b44c;
  --accent-ink: #1f1505;
  --accent-soft: rgba(240, 180, 76, .12);
  --ok: #6cc18f;
  --ok-soft: rgba(108, 193, 143, .12);
  --bad: #e66a5f;
  --bad-soft: rgba(230, 106, 95, .12);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 10px;
  --r-sm: 8px;
  --pad: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 var(--sans); min-height: 100vh; padding-bottom: 96px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 var(--pad); }

/* ---------- шапка ---------- */
.head { position: sticky; top: 0; z-index: 20; background: rgba(15, 15, 16, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft); }
.head .bar { display: flex; align-items: flex-end; gap: 12px; padding: 18px 0 14px; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.head h1 { margin: 0; font-size: 22px; line-height: 1.15; font-weight: 600; letter-spacing: -.015em; }
.head .side { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status { font: 500 12px/1 var(--mono); color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.status.dirty { color: var(--accent); }
.status.dirty::before { background: var(--accent); }

.tabs { display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none; margin-bottom: -1px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 0; background: none; padding: 0 0 11px; color: var(--text-3); font-weight: 500; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { font: 500 11px/1 var(--mono); background: var(--surface-2); color: var(--text-2); padding: 3px 6px; border-radius: 99px; }
.tabs button.on .count { background: var(--accent); color: var(--accent-ink); }

main { padding-top: 18px; }

/* ---------- текст ---------- */
.label { font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.label:first-child { margin-top: 4px; }
.label .grow { flex: 1; }
.lead { color: var(--text-2); font-size: 14px; margin: 0 0 16px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------- списки (основной блок интерфейса) ---------- */
.list { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--line-soft); min-height: 52px; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.item:first-child { border-top: 0; }
button.item, .item.tap { cursor: pointer; }
button.item:active, .item.tap:active { background: var(--hover); }
.item > svg.i { color: var(--text-3); }
.item .t { font-weight: 500; }
.item .s { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.item .meta { font: 12px var(--mono); color: var(--text-3); white-space: nowrap; }
.item .chev { color: var(--text-3); }
.item.block { display: block; }

/* ---------- показатели ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.kpis > div { padding: 14px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.kpis > div:nth-child(2n) { border-right: 0; }
.kpis > div:nth-last-child(-n+2) { border-bottom: 0; }
@media (min-width: 560px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpis > div { border-bottom: 0; border-right: 1px solid var(--line-soft); }
  .kpis > div:nth-child(2n) { border-right: 1px solid var(--line-soft); }
  .kpis > div:last-child { border-right: 0; }
}
.kpis .n { font: 500 26px/1.1 var(--mono); letter-spacing: -.02em; }
.kpis .l { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }

/* ---------- метки ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font: 500 11.5px/1 var(--mono); padding: 5px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.accent { background: var(--accent); }
.dot.ok { background: var(--ok); }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .12s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #f4bf62; }
.btn.quiet { background: none; border-color: transparent; color: var(--text-2); }
.btn.danger { background: none; color: var(--bad); border-color: rgba(230, 106, 95, .35); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.icon { padding: 0; width: 34px; height: 34px; }
.btn.block { width: 100%; }

/* ---------- поля ---------- */
.field-label { display: block; font-size: 12.5px; color: var(--text-3); margin: 16px 0 6px; }
.field { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; outline: none; transition: border-color .12s; }
.field:focus { border-color: var(--accent); }
textarea.field { min-height: 100px; resize: vertical; line-height: 1.5; }
select.field { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.search { position: relative; }
.search svg.i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .field { padding-left: 40px; }
.search.big .field { padding-top: 14px; padding-bottom: 14px; font-size: 16px; border-radius: var(--r); background: var(--surface); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--line-soft); padding: 5px 5px 5px 10px; border-radius: 6px; font-size: 13.5px; }
.chip button { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 2px; display: flex; }
.chip button:hover { color: var(--bad); }
.chip.plain { padding-right: 10px; }

.toolbar { display: flex; gap: 2px; margin-bottom: 6px; }
.toolbar button { border: 0; background: none; color: var(--text-3); border-radius: 6px; min-width: 30px; height: 28px; cursor: pointer; font-size: 13px; }
.toolbar button:hover { background: var(--surface-2); color: var(--text); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; color: var(--text-3); font: 500 13px var(--mono); border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button.on { background: var(--surface-2); color: var(--text); }

/* ---------- текст ответа ---------- */
.prose { font-size: 15px; line-height: 1.55; word-wrap: break-word; }
.prose b, .prose strong { font-weight: 600; }
.prose code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.prose blockquote { margin: 6px 0; padding-left: 10px; border-left: 2px solid var(--accent); color: var(--text-2); }
.prose tg-spoiler { background: var(--line); color: transparent; border-radius: 3px; }

/* ---------- предпросмотр Telegram ---------- */
.tg { background: #0e1621; border-radius: var(--r); padding: 12px; }
.tg .bubble { background: #182533; border-radius: 12px 12px 12px 4px; padding: 8px 11px; max-width: 94%; font-size: 14px; line-height: 1.45; word-wrap: break-word; }
.tg .bubble b, .tg .bubble strong { font-weight: 600; }
.tg .kb { display: grid; gap: 4px; margin-top: 4px; max-width: 94%; }
.tg .kb div { background: rgba(43, 82, 120, .55); border-radius: 7px; padding: 7px 6px; text-align: center; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- чат ---------- */
.chat { display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 84%; padding: 8px 12px; border-radius: 12px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.in { background: var(--surface-2); border-bottom-left-radius: 4px; align-self: flex-start; }
.msg.out { background: var(--accent-soft); color: #f6dfb3; border-bottom-right-radius: 4px; align-self: flex-end; }
.msg .who { display: block; font: 500 11px var(--mono); color: var(--text-3); margin-bottom: 2px; }
.sys { align-self: center; font: 12px var(--mono); color: var(--text-3); padding: 4px 0; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(15, 15, 16, .96); border-top: 1px solid var(--line-soft); padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom)); }
.composer .wrap { display: flex; gap: 8px; align-items: flex-end; padding: 0; }
.composer textarea { min-height: 42px; max-height: 140px; resize: none; }

/* ---------- шторка ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .18s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow: auto; background: var(--surface); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; transform: translateY(100%); transition: transform .22s ease; padding: 0 var(--pad) 110px; max-width: 720px; margin: 0 auto; }
.sheet.open { transform: none; }
.sheet .grab { width: 36px; height: 4px; border-radius: 4px; background: var(--line); margin: 8px auto 14px; }
.sheet h2 { font-size: 19px; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.sheet .list { background: var(--bg); }

/* ---------- нижняя панель сохранения ---------- */
.savebar { position: fixed; left: var(--pad); right: var(--pad); bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30; max-width: 688px; margin: 0 auto; display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 8px 8px 14px; transform: translateY(160%); transition: transform .22s ease; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); }
.savebar.show { transform: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 200%); z-index: 60; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 500; font-size: 14px; transition: transform .22s ease; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--bad); color: #fff; }

.empty { text-align: center; color: var(--text-3); padding: 34px 16px; }
.empty svg.i { width: 28px; height: 28px; margin-bottom: 8px; stroke-width: 1.4; }
.empty .t { color: var(--text-2); font-weight: 500; }
.loading { padding: 80px 0; text-align: center; color: var(--text-3); font: 13px var(--mono); }

.meter { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.low i { background: var(--text-3); }

.stars { display: flex; gap: 6px; }
.stars button { border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-sm); width: 44px; height: 40px; cursor: pointer; color: var(--text-3); display: grid; place-items: center; }
.stars button svg.i { width: 20px; height: 20px; }
.stars button.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.stars button.on svg.i { fill: currentColor; }

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
