:root {
  --bg: #141416;
  --panel: #1c1c1f;
  --panel-2: #222226;
  --field: #18181b;
  --line: #2c2c31;
  --line-2: #38383e;
  --text: #f2f2f3;
  --muted: #9a9aa2;
  --dim: #6d6d75;

  --own: #ef5e9c;       /* наш контент */
  --ugc: #ff7a45;       /* UGC-креаторы / контент-завод */
  --bloggers: #6f7cff;  /* блогеры */
  --sales: #f1c64a;     /* продажи */
  --good: #45c986;
  --bad: #ff5d5d;

  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 14px;
  --display: 'Unbounded', 'Inter', system-ui, sans-serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 28px 36px 80px; }

/* ---------- шапка ---------- */
.topbar { display: flex; align-items: center; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.brand i { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, var(--own), var(--ugc)); display: inline-block; }
.tabs { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px; }
.tabs a { text-decoration: none; padding: 9px 18px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs a.on { background: var(--text); color: #111; }
.tabs a:not(.on):hover { color: var(--text); }
.topbar .spacer { flex: 1; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; font-size: 14px; }
.linkbtn:hover { color: var(--text); }

.kicker { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
h1.display { font-family: var(--display); font-weight: 800; font-size: 44px; letter-spacing: -.02em; margin: 0; line-height: 1.05; }
h2.display { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -.015em; margin: 0; }
h3 { margin: 0; font-size: 17px; font-weight: 700; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- карточки ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 28px 32px; }
.card + .card, .section { margin-top: 20px; }
.grid { display: grid; gap: 20px; }
.g5 { grid-template-columns: 1.55fr 1fr 1fr 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
.g2-wide { grid-template-columns: 1.05fr 0.95fr; align-items: start; }

.stat { border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--panel); padding: 26px 30px; min-height: 196px; position: relative; overflow: hidden; }
.stat .label { font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: #cfcfd4; font-weight: 600; line-height: 1.45; }
.stat .big { white-space: nowrap; font-family: var(--display); font-weight: 800; font-size: clamp(28px, 2.5vw, 42px); letter-spacing: -.02em; margin: 14px 0 12px; line-height: 1; }
.stat .sub { color: var(--muted); font-size: 14px; line-height: 1.45; }
.stat.hero { background: #0f0f11; padding-bottom: 60px; }
.stat.hero .big { font-size: clamp(40px, 4.2vw, 64px); position: relative; z-index: 1; }
.stat.hero .sub { position: relative; z-index: 1; }
.stat.hero .arrow { position: absolute; right: 30px; top: 62px; width: 110px; height: 110px; opacity: .9; }
.stat.hero .bar { position: absolute; left: 30px; right: 30px; bottom: 30px; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--own), #f07fb0); }
.stat.quality { background: linear-gradient(160deg, #1a3328, #182620); border-color: #24453a; }
.stat.quality .big { color: #6fe2a7; }
.stat.corr { background: linear-gradient(160deg, #2d2915, #221f13); border-color: #423b1c; }
.stat.corr .big { color: var(--sales); }
.dash { display: inline-block; width: 48px; height: 6px; border-radius: 4px; }
.stat.corr { padding-bottom: 60px; }
.corrbar { position: absolute; left: 30px; right: 30px; bottom: 30px; height: 6px; border-radius: 99px; background: linear-gradient(90deg, #d25a5a, #6b6b6b 50%, #45c986); }
.corrbar b { position: absolute; top: -7px; width: 5px; height: 20px; background: #fff; border-radius: 3px; transform: translateX(-50%); }

/* источники — переключатели */
.src { display: flex; align-items: center; gap: 18px; border-radius: var(--r-xl); padding: 26px 30px; border: 2px solid; cursor: pointer; user-select: none; transition: opacity .15s, filter .15s; }
.src.off { opacity: .45; filter: saturate(.4); }
.src .chk { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.src .chk svg { width: 24px; height: 24px; }
.src.off .chk svg { visibility: hidden; }
.src .name { font-weight: 700; font-size: 18px; white-space: nowrap; }
.src .meta { color: var(--muted); font-size: 14px; margin-top: 6px; }
.src .num { margin-left: auto; text-align: right; }
.src .num b { white-space: nowrap; font-size: clamp(22px, 2vw, 32px) !important; font-family: var(--display); font-weight: 800; font-size: 32px; display: block; line-height: 1; }
.src .num span { color: var(--muted); font-size: 14px; display: block; margin-top: 10px; }
.src.bloggers { background: #181c3a; border-color: #35408f; } .src.bloggers .chk { background: var(--bloggers); } .src.bloggers b { color: #8e99ff; }
.src.ugc { background: #2a1a12; border-color: #6e3a1e; } .src.ugc .chk { background: var(--ugc); } .src.ugc b { color: #ff8a55; }
.src.own { background: #2a1520; border-color: #6c2748; } .src.own .chk { background: var(--own); } .src.own b { color: #ff6fae; }

/* фильтр по оценке */
.filterbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 22px 32px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { border: 2px solid var(--line-2); background: transparent; border-radius: 999px; padding: 8px 16px; font-weight: 700; cursor: pointer; font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.chip.star { border-color: #f1c64a; color: #f1c64a; }
.chip.star.off { border-color: #4a4430; color: #7d7456; }
.chip.on { background: var(--text); color: #111; border-color: var(--text); }
.chip small { font-weight: 500; opacity: .7; }

/* ---------- формы ---------- */
label.f { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
.input, select.input, textarea.input {
  background: var(--field); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 13px 16px; outline: none; width: 100%; min-width: 0;
}
.input:focus { border-color: #5a5a63; }
.input::placeholder { color: var(--dim); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23aaa' stroke-width='1.8' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; cursor: pointer; }
textarea.input { min-height: 120px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.input.sm { padding: 9px 12px; border-radius: 11px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn { background: #ececee; color: #111; border: 0; border-radius: var(--r-md); padding: 13px 22px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 9px 14px; border-radius: 11px; font-size: 14px; }
.formgrid { display: grid; grid-template-columns: 1.1fr 1.1fr .8fr .8fr; gap: 14px; margin-top: 16px; }
details.more { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
details.more summary { cursor: pointer; font-weight: 700; list-style: none; }
details.more summary::before { content: '▸ '; }
details.more[open] summary::before { content: '▾ '; }
details.more > div { margin-top: 14px; display: grid; gap: 10px; }

/* ---------- таблицы ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.r, .table td.r { text-align: right; }
.table td { padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #202024; }
.tscroll { overflow-x: auto; margin: 0 -12px; }
.vlink { font-weight: 600; text-decoration: none; word-break: break-all; }
.vlink:hover { text-decoration: underline; }
.vsub { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #3a1d2b; color: #ff7fb4; text-transform: lowercase; }
.badge.manual { background: #2b2b30; color: var(--muted); }
.err { display: inline-block; margin-top: 6px; font-size: 13px; color: #ff7676; border: 1px solid #7a2c2c; border-radius: 9px; padding: 4px 10px; cursor: pointer; background: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.srcsel { display: flex; align-items: center; gap: 10px; }
.stars { color: var(--sales); letter-spacing: 1px; }
.up { color: var(--good); } .down { color: var(--bad); }
.plat { width: 18px; height: 18px; vertical-align: -3px; opacity: .8; }
.empty { color: var(--muted); padding: 26px 12px; text-align: center; }

/* ---------- график ---------- */
.chart { position: relative; margin-top: 18px; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: #0d0d0f; border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; font-size: 13px; min-width: 170px; box-shadow: 0 10px 30px rgba(0,0,0,.4); z-index: 5; }
.chart .tip div { display: flex; justify-content: space-between; gap: 14px; margin-top: 3px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; color: #cfcfd4; font-size: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend .pill { width: 28px; height: 8px; border-radius: 99px; }
.seg { display: inline-flex; background: var(--field); border: 1px solid var(--line-2); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: var(--text); color: #111; }

/* ---------- конкуренты ---------- */
.ava { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: #2a2a2f; flex: none; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-top: 18px; }
.post { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; text-decoration: none; }
.post:hover { border-color: #4a4a52; }
.post .th { aspect-ratio: 4 / 5; background: #29292e center / cover no-repeat; position: relative; }
.post .x { position: absolute; top: 10px; right: 10px; background: #fff; color: #111; font-weight: 800; border-radius: 999px; padding: 5px 11px; font-size: 14px; }
.post .x.hot { background: var(--own); color: #fff; }
.post .pl { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.55); border-radius: 999px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; }
.post .bd { padding: 14px 16px 16px; display: grid; gap: 8px; }
.post .cap { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 39px; }
.post .ms { display: flex; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.post .ms b { color: var(--text); font-weight: 600; }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; justify-content: flex-end; }
.drawer > div { width: min(980px, 100%); background: var(--bg); border-left: 1px solid var(--line); height: 100%; overflow-y: auto; padding: 30px 34px 60px; }

/* ---------- API ---------- */
.meter { height: 8px; background: #2a2a2f; border-radius: 99px; overflow: hidden; margin: 12px 0 8px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--good); }
.meter i.warn { background: var(--sales); } .meter i.crit { background: var(--bad); }
pre.raw { background: #0e0e10; border: 1px solid var(--line); border-radius: 14px; padding: 14px; overflow: auto; max-height: 360px; font-size: 12px; }
.ok { color: var(--good); } .no { color: var(--bad); }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(420px, 100%); }
.login h1 { font-family: var(--display); font-size: 30px; margin: 0 0 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #f2f2f3; color: #111; padding: 12px 20px; border-radius: 14px; font-weight: 600; z-index: 99; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 90vw; }
.toast.error { background: #ff6b6b; color: #fff; }

@media (max-width: 1200px) {
  .g5 { grid-template-columns: 1fr 1fr 1fr; }
  .g5 .hero { grid-column: span 3; }
  .g2-wide { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .wrap { padding: 18px 16px 60px; }
  h1.display { font-size: 32px; }
  .g5, .g3, .g4, .g2 { grid-template-columns: 1fr; }
  .g5 .hero { grid-column: auto; }
  .stat.hero .big { font-size: 48px; }
  .formgrid { grid-template-columns: 1fr 1fr; }
  .card { padding: 22px 18px; }
  .tabs { overflow-x: auto; max-width: 100%; }
}
.grid > .card, .grid > .card + .card { margin-top: 0; }
.srcsel select { min-width: 160px; }
.drawer .g4 { grid-template-columns: repeat(2, 1fr); }
.drawer .stat { min-height: 150px; }
@media (max-width: 860px) { .drawer .g4 { grid-template-columns: 1fr; } .drawer > div { padding: 22px 16px 60px; } }

/* ---------- топ роста ---------- */
.gtitle { margin: 0; font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.gtitle .trend { width: 24px; height: 24px; }
.ggroups { display: grid; gap: 16px; }
.ggroup { border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 14px 20px 16px; background: #18181b; }
.ghead { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px 0 8px; cursor: pointer; width: 100%; text-align: left; font-size: 15px; }
.ghead b { text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: #d7d7dc; }
.ghead .chev { display: inline-block; transform: rotate(90deg); transition: transform .15s; color: var(--muted); font-size: 20px; width: 14px; line-height: 1; }
.ggroup.collapsed .chev { transform: rotate(0deg); }
.ggroup.collapsed .gbody { display: none; }
.ghead .gsum { margin-left: auto; color: var(--muted); font-size: 13px; }
.grow { display: grid; grid-template-columns: 28px 38px 22px minmax(0, 1fr) auto minmax(150px, auto); align-items: center; gap: 12px; padding: 8px 0; font-size: 17px; }
.grow .gn { color: var(--muted); font-weight: 600; text-align: right; }
.grow .ava { width: 38px; height: 38px; }
.grow .gp { color: var(--muted); display: grid; place-items: center; }
.grow .gp .plat { width: 20px; height: 20px; }
.grow .gu { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow .gf { color: var(--muted); font-variant-numeric: tabular-nums; }
.grow .gd { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grow .gdelta { display: inline-flex; align-items: center; gap: 4px; }
.grow .gdelta .trend { width: 16px; height: 16px; }
.grow .gpct { color: #cfcfd4; }
.gmore { margin: 4px 0 0 40px; color: var(--text); font-size: 15px; }
@media (max-width: 860px) {
  .grow { grid-template-columns: 22px 32px minmax(0, 1fr) auto; font-size: 15px; }
  .grow .gp, .grow .gf { display: none; }
  .grow .ava { width: 32px; height: 32px; }
  .ghead .gsum { display: none; }
}

/* ---------- Ozon ---------- */
.mp { margin-top: 14px; border: 1px solid #2d3f8a; background: linear-gradient(160deg, #161c3a, #151827); border-radius: var(--r-lg); padding: 16px 18px; }
.mp.off { border-color: var(--line-2); background: #18181b; }
.mp code, .muted code { background: #2a2a30; padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.ozstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.ozstats div { background: rgba(255,255,255,.04); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.ozstats span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.ozstats b { font-family: var(--display); font-size: 20px; }
.ozstats small { color: var(--muted); font-size: 12.5px; }
.ozprod { display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.ozprod label { display: grid; grid-template-columns: 20px 1fr auto; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
@media (max-width: 860px) { .ozstats { grid-template-columns: 1fr; } }

/* ---------- ИИ-разбор ролика ---------- */
.post .th { display: block; text-decoration: none; }
.anbtn { margin-top: 4px; width: 100%; border: 0; border-radius: 12px; padding: 10px; font-weight: 700; cursor: pointer; background: #1f3a2a; color: #7ee2a8; }
.anbtn:hover { background: #26482f; }
.anbtn.done { background: #243049; color: #9fb0ff; }
.anbtn.busy { background: #2d2915; color: var(--sales); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 80; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.mbox { position: relative; background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-xl); width: min(1180px, 100%); max-height: calc(100vh - 48px); overflow-y: auto;
  display: grid; grid-template-columns: 300px 1fr; gap: 32px; padding: 30px; }
.mclose { position: absolute; top: 16px; right: 16px; width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 16px; }
.anthumb { aspect-ratio: 9 / 14; border-radius: var(--r-lg); background: #29292e center / cover no-repeat; }
.ancap { max-height: 90px; overflow: hidden; margin-bottom: 12px; line-height: 1.4; }
.anstat { display: flex; justify-content: space-between; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-top: 8px; }
.anstat span { color: var(--muted); }
.antopic { font-family: var(--display); font-size: 26px; line-height: 1.2; margin: 6px 40px 12px 0; }
.antags { margin-top: 12px; }
.tag { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 14px; font-size: 14px; }
.tag.t0 { background: #232a52; border-color: #35408f; color: #b4bdff; }
.tag.t1 { background: #1f3a2a; border-color: #2f6b47; color: #8fe6b3; }
.tag.t2 { background: #3a3218; border-color: #6b5a22; color: #f1d27a; }
.anblock { margin-top: 24px; }
.anblock h3 { margin-bottom: 10px; }
.anblock p { margin: 6px 0; line-height: 1.5; }
.antext { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; line-height: 1.6; white-space: pre-wrap; max-height: 320px; overflow-y: auto; color: #d8d8dc; }
.antext.script { max-height: none; }
.hook { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-top: 8px; font-size: 16px; line-height: 1.45; }
.copy { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; width: 36px; height: 36px; cursor: pointer; color: var(--text); flex: none; }
.anerr { background: #3a1c1c; border: 1px solid #7a2c2c; border-radius: 16px; padding: 16px 18px; margin-bottom: 18px; color: #ffb3b3; }
.anprog { display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 18px; line-height: 1.7; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid #3a3a40; border-top-color: var(--own); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 860px) {
  .modal { padding: 0; }
  .mbox { grid-template-columns: 1fr; border-radius: 0; max-height: 100vh; padding: 20px 16px; }
  .anthumb { max-width: 220px; }
}

/* ---------- продажи ---------- */
.periodbar { margin-bottom: 18px; gap: 12px; }
.dimrow td { opacity: .5; }
.grid > * { min-width: 0; }
#sbody .stat .big { font-size: clamp(24px, 2.3vw, 38px); }
#sbody .stat.hero .big { font-size: clamp(28px, 2.8vw, 44px); }
#sbody .stat { min-height: 170px; }

/* ---------- Telegram Mini App ---------- */
.tg body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overscroll-behavior-y: none; }
.tg .topbar { gap: 14px; margin-bottom: 18px; }
.tg .toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
@media (max-width: 860px) {
  /* вкладки — одной строкой с горизонтальной прокруткой */
  .topbar .tabs { flex-wrap: nowrap; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topbar .tabs::-webkit-scrollbar { display: none; }
  .tabs a { white-space: nowrap; padding: 9px 14px; }
  .topbar .spacer { display: none; }
  /* iOS увеличивает страницу при фокусе на поле со шрифтом меньше 16px */
  .input, select.input, textarea.input { font-size: 16px; }
  .tscroll { -webkit-overflow-scrolling: touch; }
}

/* ---------- нижняя панель вкладок в Telegram ---------- */
.botnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: space-around;
  background: rgba(28, 28, 31, .96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.botnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 6px 4px; text-decoration: none;
  color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: 14px; -webkit-tap-highlight-color: transparent; }
.botnav a svg { width: 26px; height: 26px; }
.botnav a.on { color: var(--text); }
.botnav a.on svg { color: var(--own); }
.tg .wrap { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.tg body { padding-bottom: 0; }
.tg .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---------- список разборов в Telegram ---------- */
.anitem { padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.anitem:last-child { border-bottom: 0; padding-bottom: 0; }
.anitem-t { font-weight: 600; line-height: 1.35; }
.anitem-m { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; color: var(--muted); font-size: 13.5px; }
.anitem-m span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* в Telegram окно разбора: сначала прогресс, хуки и сценарий, обложка и статистика — ниже */
@media (max-width: 860px) {
  .tg .mbox { padding-top: 64px; }
  .tg .mbox .anr { order: -1; }
  .tg .mbox .anthumb { max-width: 140px; }
}

/* ---------- «Анализ видео» в Telegram: поиск по ссылке и карточка ролика ---------- */
.vsearch { display: flex; gap: 10px; }
.vsearch .input { flex: 1; }
.vsearch .btn { padding: 13px 18px; }
.vcard-load { display: flex; align-items: center; gap: 12px; justify-content: center; padding: 40px 0; }
.vcard { width: min(300px, 100%); margin: 22px auto 0; }
.vthumb { position: relative; aspect-ratio: 9 / 14; border-radius: 22px; overflow: hidden; background: #29292e center / cover no-repeat; }
.vthumb::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35), transparent 28%, transparent 62%, rgba(0,0,0,.55)); pointer-events: none; }
.vbadge { position: absolute; z-index: 1; top: 14px; left: 14px; display: inline-flex; align-items: center; gap: 6px; color: #fff; font-weight: 700; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.vbadge svg { width: 20px; height: 20px; }
.vopen { position: absolute; z-index: 1; top: 10px; right: 10px; width: 38px; height: 38px; display: grid; place-items: center; color: #fff; border-radius: 12px; background: rgba(0,0,0,.25); }
.vopen svg { width: 20px; height: 20px; }
.vstats { position: absolute; z-index: 1; left: 12px; right: 12px; bottom: 12px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 10px 6px; border-radius: 16px;
  background: rgba(20,20,22,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); color: #fff; }
.vstats span { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vstats svg { width: 19px; height: 19px; }
.vstats b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.vauthor { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.vava { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--panel-2); flex: none; }
.vauthor b { color: #8e99ff; }
.vcap { margin: 10px 0 6px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vbtn { margin-top: 14px; width: 100%; border: 0; border-radius: 16px; padding: 15px; font-weight: 700; font-size: 16px; cursor: pointer; background: #1f3a2a; color: #7ee2a8; }
.vbtn.done { background: #243049; color: #9fb0ff; }
.vbtn.busy { background: #2d2915; color: var(--sales); }
.vbtn:disabled { opacity: .7; }

/* полноэкранный режим Telegram: не залезать под его кнопки «Закрыть» и «…» */
.tg body { padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.tg .modal { padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }

/* ---------- «Поиск видео»: сетка карточек ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 12px; margin-top: 12px; }
.vgrid .vcard { width: auto; margin: 0; }
.vcard.compact .vthumb { border-radius: 16px; }
.vcard.compact .vbadge { top: 10px; left: 10px; }
.vcard.compact .vopen { top: 6px; right: 6px; width: 32px; height: 32px; }
.vcard.compact .vstats { left: 8px; right: 8px; bottom: 8px; grid-template-columns: repeat(2, 1fr); padding: 7px 4px; border-radius: 12px; }
.vcard.compact .vstats svg { width: 16px; height: 16px; }
.vcard.compact .vstats b { font-size: 12px; }
.vcard.compact .vauthor { gap: 8px; margin-top: 10px; }
.vcard.compact .vava { width: 28px; height: 28px; }
.vcard.compact .vauthor b { font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.vcard.compact .vcap { font-size: 13px; margin: 6px 0 4px; }
.vcard.compact .vbtn { margin-top: 10px; padding: 11px 6px; font-size: 13.5px; border-radius: 12px; }

/* ---------- «Мой аккаунт» и баланс токенов ---------- */
.tokchip { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line-2); text-decoration: none; font-weight: 700; font-size: 14px; }
.acctok .acclabel { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.acctok .accnum { font-family: var(--display); font-size: 26px; }
.accbar { margin-top: 14px; height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.accbar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6f7cff, #9fa8ff); }
.acclist { margin-top: 10px; }
.accitem, .accsearch { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.accitem:last-child, .accsearch:last-child { border-bottom: 0; padding-bottom: 0; }
.accsearch { cursor: default; }
.accthumb { width: 46px; height: 64px; border-radius: 10px; background: #29292e center / cover no-repeat; flex: none; }
.accmain { flex: 1; min-width: 0; }
.acctitle { font-weight: 600; line-height: 1.35; margin-bottom: 4px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.accmeta { display: flex; gap: 14px; flex-wrap: wrap; }
.accgo { color: var(--dim); font-size: 22px; }
.tg .topbar { flex-wrap: nowrap; }
.tg .topbar .brand { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg .topbar .tokchip { flex: none; }
/* «Мой аккаунт»: кликабельные разделы и вложенные экраны */
.accnav { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; padding: 20px 20px; -webkit-tap-highlight-color: transparent; }
.accnav:active { background: var(--panel-2); }
.accnav .accmain { display: flex; flex-direction: column; gap: 4px; }
.accnav .accmain b { font-size: 16px; }
.accnav-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: #232a52; color: #9fa8ff; flex: none; }
.accnav-ic svg { width: 22px; height: 22px; }
.accback { color: var(--muted); text-decoration: none; font-size: 14px; display: inline-block; margin-bottom: 8px; }
h1.accsubtitle { font-size: 28px; }
/* знак SY: цвет = цвет текста (currentColor), форма — из картинки-маски */
.fire { display: inline-block; width: 18px; height: 18px; flex: none; vertical-align: middle; color: inherit; background-color: currentColor;
  -webkit-mask: url(/sy-mark.png) center / contain no-repeat; mask: url(/sy-mark.png) center / contain no-repeat; }
.tokchip .fire { width: 20px; height: 20px; }
.btn .fire, .vbtn .fire { width: 15px; height: 15px; vertical-align: -2px; }
.brand i { flex: none; }
