/* Team — минималистичный интерфейс. Только светлая тема. */
:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --text: #141414;
  --muted: #707070;
  --border: #e5e5e1;
  --accent: #141414;
  --accent-text: #ffffff;
  --pos: #1f8a4c;
  --neg: #c23a3a;
  --warn: #b7791f;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }
code, pre { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
pre { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); overflow: auto; }

/* каркас */
.app { display: flex; min-height: 100dvh; }
.side {
  width: 236px; flex: none; padding: 22px 14px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; font-size: 17px; padding: 0 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  text-decoration: none; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted);
  display: flex; align-items: center; gap: 10px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 8px; }
.side-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.side-link:hover { color: var(--text); }

.main { flex: 1; min-width: 0; padding: 36px 40px 60px; }
.page { max-width: 880px; margin: 0 auto; }
.page-wide { max-width: 980px; }

.topbar { display: none; }
.scrim { display: none; }
.burger {
  width: 40px; height: 40px; flex: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); display: grid; place-content: center; gap: 4px; cursor: pointer; padding: 0;
}
.burger span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--text); }

/* телефон: сверху полоска с ☰, меню — та же боковая панель, что на ПК, выезжает слева */
@media (max-width: 860px) {
  .app { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30;
    height: 60px; padding: 0 16px; padding-top: env(safe-area-inset-top);
    background: var(--bg); border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .side {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: min(280px, 84vw); height: 100dvh;
    background: var(--bg); overflow-y: auto; transform: translateX(-102%); transition: transform .22s ease;
    padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: calc(22px + env(safe-area-inset-bottom));
  }
  .menu-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .12); }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 20, .28);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  .menu-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-open { overflow: hidden; }
  .nav a { padding: 11px 10px; font-size: 16px; }
  .main { padding: 20px 16px calc(32px + env(safe-area-inset-bottom)); }
}
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .side, .scrim { transition: none; }
}

/* типографика */
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; font-weight: 680; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 640; }
.sub { color: var(--muted); margin: 0 0 26px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* блоки */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 24px; font-weight: 660; margin-top: 4px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.stat .v.sm { font-size: 17px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.chip.ok { color: var(--pos); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--neg); }

.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 13px; }
.item .amt { font-weight: 620; white-space: nowrap; }
/* строка с кнопками: на узком экране кнопки уходят под текст, а не сжимают его */
.item.wrap { flex-wrap: wrap; }
.item.wrap .grow { flex: 1 1 220px; }

.access { display: flex; flex-direction: column; gap: 8px; }
.access div { display: flex; gap: 10px; align-items: baseline; }
.access .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; transform: translateY(-1px); }
.access .on .dot { background: var(--pos); }
.access .off { color: var(--muted); }

/* формы */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input.in, textarea.in {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 12px; outline: none; width: 100%;
}
input.in:focus, textarea.in:focus, select.in:focus { border-color: var(--text); }
select.in { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; width: 100%; }
.btn {
  font: inherit; font-weight: 580; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-text); border-radius: var(--radius-sm); padding: 10px 16px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); opacity: 1; }
.btn.danger { background: transparent; color: var(--neg); border-color: var(--border); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.block { width: 100%; }
.err { color: var(--neg); font-size: 13px; }
.err:empty, .ok-text:empty { display: none; }
.ok-text { color: var(--pos); font-size: 13px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--border); }
.switch:first-of-type { border-top: 0; }
.toggle { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle:checked { background: var(--pos); }
.toggle:checked::after { transform: translateX(16px); }

/* вход */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { justify-content: center; margin-bottom: 26px; font-size: 20px; }
.auth-box h1 { text-align: center; font-size: 22px; }
.auth-box .sub { text-align: center; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.55; }
.hint b { color: var(--text); font-weight: 600; }
.sep { height: 1px; background: var(--border); margin: 6px 0; }

.code-big {
  font-family: var(--mono); font-size: 34px; letter-spacing: .12em; font-weight: 650;
  text-align: center; padding: 18px; border: 1px dashed var(--border); border-radius: var(--radius);
  user-select: all;
}

/* консоль бота */
.console { display: flex; flex-direction: column; height: calc(100dvh - 96px); max-width: 760px; margin: 0 auto; }
@media (max-width: 860px) { .console { height: calc(100dvh - 60px - 20px - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); } }
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.console-head h1 { margin: 0; font-size: 20px; }
.feed {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px;
  overscroll-behavior: contain;
}
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.bubble {
  padding: 10px 13px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border);
  white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow);
}
.msg.user .bubble { background: var(--accent); color: var(--accent-text); border-color: var(--accent); border-bottom-right-radius: 6px; }
.msg.bot .bubble, .msg.notify .bubble { border-bottom-left-radius: 6px; }
.msg.notify .bubble { border-left: 3px solid var(--pos); }
.msg .tagline { font-size: 11px; color: var(--muted); padding: 0 4px; }
.msg.user .bubble code { background: rgba(255,255,255,.15); }
.bubble a { text-underline-offset: 2px; }
.bubble blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--border); }
.tg-spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; }
.tg-spoiler.open { background: transparent; color: inherit; }
.bubble img.media, .bubble video.media { display: block; max-width: 100%; max-height: 340px; border-radius: 10px; margin: -2px -2px 8px; }
.kb { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.kb-row { display: flex; gap: 6px; }
.kb-btn {
  flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 9px 10px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
  text-decoration: none; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kb-btn:hover { background: var(--surface-2); }
.kb-btn:disabled { opacity: .5; cursor: default; }
.kb-btn.success { border-color: var(--pos); color: var(--pos); }
.kb-btn.danger { border-color: var(--neg); color: var(--neg); }
.kb-btn.primary { border-color: var(--text); }
.kb-btn.busy { opacity: .55; }
.chips-kb { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.composer { display: flex; gap: 8px; align-items: center; padding-top: 10px; border-top: 1px solid var(--border); }
.composer .in { flex: 1; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 18px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* всплывашки */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  max-width: min(92vw, 460px); box-shadow: 0 8px 30px rgba(0,0,0,.18); animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal-card { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 16px; border: 1px solid var(--border); }
.modal-text { white-space: pre-wrap; }

.skeleton { color: var(--muted); padding: 30px 0; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); white-space: nowrap; color: var(--muted); }
.status.sold { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 40%, var(--border)); }
.status.listed { color: var(--text); }
.status.bad { color: var(--neg); }
.copy-row { display: flex; gap: 8px; }
.acc-price { font-size: 20px; font-weight: 660; white-space: nowrap; }
.copy-row .in { font-family: var(--mono); font-size: 13px; }

/* профиль: пары «название — значение» */
.kvs { display: flex; flex-direction: column; }
.kv { display: flex; gap: 16px; justify-content: space-between; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--border); }
.kv:first-child { border-top: 0; }
.kv .k { color: var(--muted); font-size: 14px; flex: none; }
.kv .v { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }
.notice { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: color-mix(in srgb, var(--warn) 7%, var(--surface)); }
@media (max-width: 520px) {
  .kv { flex-direction: column; gap: 2px; align-items: flex-start; }
  .kv .v { text-align: left; }
}
