/* ============================================================
   PARSER — Design system: «Marker» (поиск-центрик: бумага + чернила + маркер)
   Палитра: тёплая бумага + чернильный акцент + жёлтый маркер; тёмная зелёная (AA).
   Шрифт: Golos Text (интерфейс) + PT Mono (данные/метки). Чёрные кнопки, жёлтый hover.
   ============================================================ */
:root {
  --bg:      #fbfaf7;   /* тёплая бумага */
  --bg2:     #f3f1e9;   /* поля ввода / приглушённые поверхности */
  --card:    #ffffff;
  --card2:   #f8f6f0;
  --elev:    #ffffff;
  --border:  #e8e4d8;   /* хайрлайн карточек (+ мягкая тень несёт структуру) */
  --border2: #c9c3b1;   /* видимые границы инпутов/разделителей (WCAG) */
  --text:    #141414;   /* чернила, ~15:1 на бумаге */
  --muted:   #5f5b4c;   /* вторичный текст — AA ≥4.5 */
  --dim:     #6d6857;   /* де-эмфаза — AA на мелком */

  --brand:   #141414;   /* акцент = чернила (актив/фокус/кольца) */
  --brand2:  #141414;   /* заливка кнопок (белый текст AA) */
  --brand-wash: #fbf2c8;/* жёлтая «размывка» — активные пункты, подсветки */
  --mark:    #ffe14d;   /* фирменный маркер (подсветка, hover) */
  --glow:    rgba(255,225,77,.55);
  --lime:    #0d7a43;   /* «живые»/успех/зелёная CTA — под белый текст AA */
  --green:   #0d7a43;
  --red:     #d92d3a;
  --amber:   #ffe14d;   /* тёплый акцент (фон тегов, тёмный текст) = маркер */
  --peach:   #8a8471;   /* «скоро»/де-эмфаза бейджей — тёплый серый */
  --sky:     #f5c211;   /* вторая точка градиента прогресса (тёмный жёлтый) */

  --radius:  12px;
  --f-head:  "Golos Text", system-ui, sans-serif;
  --f-body:  "Golos Text", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --f-mono:  "PT Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color-scheme: light;
  font-family: var(--f-body);
  font-weight: 400;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(900px 480px at 84% -10%, rgba(255,225,77,.10), transparent 60%);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--mark); color: var(--text); }

/* Голые ссылки в тексте/таблицах — чернила + жёлтое подчёркивание-маркер */
a { color: var(--text); text-decoration: underline; text-decoration-color: #e3c94e; text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { color: var(--text); text-decoration-color: var(--text); }
/* Компонентные ссылки рисуют себя сами — без подчёркивания */
a.btn, a.logo, .nav a, a.link, a.side-link, a.parser-card, a.hist-item, a.hist-all,
a.back-link, a.lp-tile, .nav-dd-menu a, footer a, a.badge, a.chip { text-decoration: none; }
/* Видимый фокус клавиатуры на всех интерактивных (WCAG 2.4.7) */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
.side-link:focus-visible, .parser-card:focus-visible, .hist-item:focus-visible,
.chip:focus-visible, .csel-btn:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand2); outline-offset: 2px; border-radius: 8px;
}
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
/* Шапка совпадает по ширине с контентом страницы (иначе «висит» уже контента) */
body:has(main.app-main) header.nav .container { max-width: 1800px; padding: 0 22px; }
body:has(main.app-main .admin-shell) header.nav .container { max-width: 1500px; }
body:has(main.lp-main) header.nav .container { max-width: min(1320px, 94vw); }

/* ---------- Nav ---------- */
header.nav { border-bottom: 1px solid var(--border); background: rgba(251,250,247,.88); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 50; }
.nav-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 9px; font-family: var(--f-head); font-weight: 800; font-size: 20px; letter-spacing: -.3px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark { display: block; flex: none; }
.logo span { color: var(--text); background: var(--mark); padding: 1px 7px 2px; border-radius: 7px; margin-left: 2px; }
.nav a.link { color: var(--muted); font-weight: 700; font-size: 14px; transition: color .15s; white-space: nowrap; }
.nav a.link:hover { color: var(--text); text-decoration: none; }
.nav .spacer { flex: 1; }
.lang-switch { display: inline-flex; gap: 2px; align-items: center; }
.lang-switch a { color: var(--dim); font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 7px; letter-spacing: .4px; }
.lang-switch a:hover { color: var(--text); text-decoration: none; }
.lang-switch a.on { color: var(--brand2); background: var(--brand-wash); }
.nav-dd { position: relative; display: flex; align-items: center; height: 60px; flex: 0 0 auto; }
.nav-dd-toggle { cursor: pointer; color: var(--brand2); font-size: 14px; font-weight: 700; user-select: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; line-height: 1; }
.nav-dd-menu { display: none; position: absolute; top: 100%; left: 0; background: var(--card); border: 1px solid var(--border2); border-radius: 12px; padding: 6px; min-width: 186px; z-index: 60; box-shadow: 0 14px 34px -14px rgba(60,54,30,.3); }
.nav-dd:hover .nav-dd-menu, .nav-dd:focus-within .nav-dd-menu { display: block; }
.nav-dd-menu a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--muted); font-size: 14px; }
.nav-dd-menu a:hover { background: var(--brand-wash); color: var(--text); text-decoration: none; }

/* ---------- Buttons (плоские, профессиональные) ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--f-head); font-weight: 600; font-size: 14px;
  background: var(--brand2); color: #fff; border: 1px solid transparent;
  padding: 11px 18px; border-radius: 10px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(20,18,40,.12); transition: background .15s, box-shadow .15s, border-color .15s;
}
.btn:hover { background: var(--mark); color: var(--text); box-shadow: 0 3px 10px -2px rgba(140,115,0,.35); text-decoration: none; }
.btn:active { background: #ecca38; color: var(--text); }
.btn.ghost { background: var(--card); border-color: var(--border2); color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: var(--brand-wash); border-color: var(--brand); color: var(--text); box-shadow: none; }
.btn.danger { background: #fff; border-color: #edbcc1; color: var(--red); box-shadow: none; }
.btn.danger:hover { background: #fff5f5; border-color: var(--red); }
.btn.green { background: var(--green); color: #fff; box-shadow: 0 1px 2px rgba(20,18,40,.12); }
.btn.green:hover { background: #0a6438; box-shadow: 0 3px 8px -2px rgba(13,122,67,.4); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
/* фикс: при нажатии/фокусе фон и текст кнопки остаются читаемыми */
.btn:focus:not(:hover):not(:active) { color: #fff; }
.btn.ghost:active, .btn.ghost:focus { background: var(--card); color: var(--text); }
.btn.danger:active, .btn.danger:focus { background: #fff; color: var(--red); }
.btn.tg { background: #229ED9; color: #fff; box-shadow: 0 1px 2px rgba(20,18,40,.12); }
.btn.tg:hover { background: #1b87ba; }
details > summary { list-style: none; } details > summary::-webkit-details-marker { display: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  position: relative; box-shadow: 0 10px 30px -22px rgba(60,54,30,.35);
}
.card:hover { border-color: var(--border2); }
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid.cols-3, .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; letter-spacing: .3px; text-transform: uppercase; font-weight: 700; }
input, select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--border2);
  color: var(--text); padding: 11px 13px; border-radius: 11px; font-size: 14px;
  font-family: var(--f-body); font-weight: 600; transition: border-color .15s, box-shadow .15s;
  color-scheme: light;
}
select { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23141414' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--glow);
}
input[type=file] { padding: 7px 12px; cursor: pointer; color: var(--muted); }
input[type=file]::file-selector-button,
input[type=file]::-webkit-file-upload-button {
  margin-right: 12px; padding: 8px 14px; border-radius: 10px;
  background: var(--brand-wash); border: 1px solid var(--border2); color: var(--brand2);
  font-family: var(--f-body); font-weight: 800; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
input[type=file]:hover::file-selector-button,
input[type=file]:hover::-webkit-file-upload-button { border-color: var(--brand); }
/* Кастомный дропдаун (замена нативного <select>) */
.csel { position: relative; width: 100%; }
.csel-btn { width: 100%; text-align: left; background: #fff; border: 1px solid var(--border2);
  color: var(--text); padding: 11px 36px 11px 13px; border-radius: 11px; font-size: 14px; font-weight: 600;
  font-family: var(--f-body); cursor: pointer; position: relative; transition: border-color .15s, box-shadow .15s; }
.csel-btn::after { content: ''; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px;
  border-right: 1.8px solid var(--brand2); border-bottom: 1.8px solid var(--brand2);
  transform: translateY(-70%) rotate(45deg); transition: transform .15s; }
.csel.open .csel-btn { border-color: var(--brand); box-shadow: 0 0 0 3px var(--glow); }
.csel.open .csel-btn::after { transform: translateY(-30%) rotate(225deg); }
.csel-menu { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; border: 1px solid var(--border2); border-radius: 14px; padding: 6px;
  max-height: 320px; overflow-y: auto; box-shadow: 0 18px 44px -18px rgba(60,54,30,.35); }
.csel.open .csel-menu { display: block; }
.csel-group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); padding: 9px 10px 4px; font-weight: 700; }
.csel-opt { padding: 9px 11px; border-radius: 9px; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.csel-opt:hover { background: var(--brand-wash); }
.csel-opt.sel { background: var(--brand-wash); color: var(--brand2); }
.hint { font-size: 12px; color: var(--dim); margin-top: 4px; font-weight: 600; }
code { font-family: var(--f-mono); background: var(--bg2); padding: 1px 6px; border-radius: 6px; color: var(--brand2); font-size: 13px; font-weight: 700; }

/* ---------- Typography ---------- */
h1 { font-family: var(--f-head); font-size: 32px; letter-spacing: -.8px; margin: 24px 0 8px; font-weight: 800; }
h2 { font-family: var(--f-head); font-size: 22px; margin: 0 0 14px; font-weight: 800; letter-spacing: -.3px; }
h3 { font-family: var(--f-head); font-weight: 800; }
.lead { color: var(--muted); font-size: 17px; max-width: 640px; }
.muted { color: var(--muted); }

/* ---------- Tariffs ---------- */
.plan { text-align: center; position: relative; }
.plan .price { font-family: var(--f-head); font-size: 38px; font-weight: 800; margin: 8px 0; color: var(--text); font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 15px; color: var(--muted); font-weight: 600; }
.plan.featured { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset, 0 18px 40px -20px var(--glow); }

/* ---------- Badges / pills ---------- */
.badge { display: inline-block; font-family: var(--f-head); font-size: 11px; padding: 3px 10px;
  border-radius: 999px; background: var(--bg2); color: var(--muted);
  border: 1px solid var(--border); letter-spacing: .4px; font-weight: 700; }
.badge.brand { background: var(--brand-wash); color: var(--text); border-color: #ecd98a; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--dim); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
td { font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f5f4ef; }

/* ---------- Status pills ---------- */
.pill { font-family: var(--f-head); font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 800; letter-spacing: .3px; }
.pill.pending   { background: #eeebe0; color: #6d6857; }
.pill.running   { background: var(--brand-wash); color: #4d4000; }
.pill.done      { background: #d8f5ec; color: #14755c; }
.pill.error     { background: #fde3e6; color: #c62f40; }
.pill.cancelled { background: #eeebe0; color: var(--dim); }

/* ---------- Progress ---------- */
.progress { height: 9px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), var(--mark)); transition: width .4s; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; border: 1px solid; font-weight: 600; }
.alert.ok  { background: #e6f7f1; border-color: #b6e7d8; color: #157a60; }
.alert.err { background: #fdeaec; border-color: #f4c4ca; color: #c62f40; }
.alert.warn { background: #fef3e0; border-color: #f7ddb0; color: #a8710f; }

/* ---------- 3D Hero ---------- */
.hero { position: relative; padding: 56px 0 40px; text-align: center; overflow: hidden; }
.hero-canvas { position: absolute; inset: -10% 0 auto 0; width: 100%; height: 560px; z-index: 0; opacity: .9; pointer-events: none; }
.hero-inner { position: relative; z-index: 1; }
@media (max-width: 760px) { .hero-canvas { height: 420px; } }

/* ---------- Utils ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
footer { color: var(--dim); font-size: 13px; padding: 32px 0; text-align: center; border-top: 1px solid var(--border); margin-top: 40px; font-weight: 600; }
ul.features { list-style: none; padding: 0; }
ul.features li { padding: 6px 0 6px 26px; position: relative; }
ul.features li:before { content: "✓"; position: absolute; left: 0; color: var(--lime); font-weight: 800; }

/* ============================================================
   RESPONSIVE / TELEGRAM MINI APP
   ============================================================ */
.nav-burger { display: none; margin-left: auto; padding: 8px; cursor: pointer; background: none; border: 0; flex-direction: column; gap: 4px; }
.nav-burger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-links { display: flex; flex: 1; align-items: center; gap: 16px; }
.nav-page-links { display: none; }

/* ⚠️ Левое меню выключается на 1180px, а бургер включался только на 820px — между
   ними навигации не было ВООБЩЕ: ни меню, ни бургера, ни страничных ссылок
   (проверено на 1000px: остались логотип, язык, «Безопасность», «Выйти»). Это
   планшет в альбоме и окно браузера в половину экрана. Включаем бургер там же,
   где пропадает меню. */
@media (max-width: 1180px) {
  .nav-burger { display: flex; }
  .nav-page-links { display: contents; }
  .nav-inner { gap: 10px; }
  .nav-links {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--card); border-bottom: 1px solid var(--border2);
    padding: 10px 12px 16px; box-shadow: 0 18px 40px -18px rgba(60,54,30,.25);
    max-height: calc(100vh - 60px); overflow-y: auto;
  }
  .nav-inner.open .nav-links { display: flex; }
  .nav-inner.open .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-inner.open .nav-burger span:nth-child(2) { opacity: 0; }
  .nav-inner.open .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .nav-links .link { padding: 11px 8px; font-size: 15px; border-radius: 8px; }
  .nav-links .link:hover { background: var(--brand-wash); color: var(--text); }
  .nav-links .spacer { display: none; }
  .nav-links > .muted { order: -1; padding: 6px 8px; font-size: 12px !important; opacity: .85; }
  .nav-links .btn { margin-top: 6px; justify-content: center; }
  .nav-dd { display: block; height: auto; }
  .nav-dd-toggle { display: block; padding: 11px 8px; }
  .nav-dd-menu { display: block; position: static; background: transparent; border: none; box-shadow: none; padding: 2px 0 4px; min-width: 0; margin-left: 8px; border-left: 2px solid var(--border2); padding-left: 10px; }
  .nav-dd-menu a { padding: 9px 8px; }
}

@media (max-width: 820px) {
  .container { padding: 0 14px; }
  h1 { font-size: 25px; margin: 16px 0 6px; }
  h2 { font-size: 18px; }
  .lead { font-size: 15px; }
  .card { padding: 16px; border-radius: 14px; margin-bottom: 14px; }

  table thead { display: none; }
  table, table tbody { display: block; width: 100%; }
  table tr { display: block; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 4px 13px; margin-bottom: 10px; }
  tbody tr:hover td { background: transparent; }
  table td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; text-align: right; font-size: 14px; border-bottom: 1px solid var(--border); }
  table tr td:last-child { border-bottom: none; }
  table td::before { content: attr(data-label); flex: none; text-align: left; padding-top: 1px; color: var(--dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
  table td > * { min-width: 0; }
  table td:not([data-label])::before, table td[data-label=""]::before { content: ""; }
  .row { gap: 8px; }
  .btn { padding: 10px 15px; }
}

/* ---------- Сетка парсеров (хаб после входа) ---------- */
.parser-grid { display: grid; gap: 14px; margin-top: 18px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.parser-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 18px 20px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  box-shadow: 0 8px 24px -18px rgba(50,46,26,.4); transition: border-color .15s, box-shadow .15s, transform .12s;
}
.parser-card:not(.off):hover { border-color: var(--brand); text-decoration: none; box-shadow: 0 12px 28px -16px rgba(140,115,0,.28); transform: translateY(-2px); }
.parser-ico { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.parser-ico svg, .parser-ico img { display: block; }
.parser-name { font-family: var(--f-head); font-weight: 800; font-size: 18px; color: var(--text); }
.parser-tag { font-size: 13px; color: var(--muted); }
.parser-card.off { opacity: .55; cursor: default; box-shadow: none; }
.parser-card.off .parser-tag { color: var(--dim); }

.back-link { display: inline-block; font-size: 14px; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
.back-link:hover { color: var(--brand2); }

.container.narrow { max-width: 640px; }
.container.narrow .card { max-width: none !important; }
.container.narrow > h1:first-child { margin-top: 4px; }

/* ---------- Telegram Mini App ---------- */
.tg-miniapp footer { padding: 18px 0; margin-top: 28px; }
.tg-miniapp .footer-tagline { display: none; }
.tg-miniapp main.container { padding-top: 16px; }

/* ---------- App-shell ---------- */
main.app-main { position: fixed; top: 60px; left: 0; right: 0; bottom: 0; max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important; overflow: hidden; }
main.app-main ~ footer { display: none; }
.app-shell { height: 100%; max-width: 1800px; margin: 0 auto; display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; gap: 16px; padding: 16px 22px; box-sizing: border-box; }
.app-shell.admin-shell { grid-template-columns: 240px minmax(0, 1fr); max-width: 1500px; }
.app-shell.admin-shell .app-work-inner { max-width: 1100px; }
@media (max-width: 1180px) { .app-shell.admin-shell { grid-template-columns: minmax(0, 1fr); } }
/* «Широкий» режим для страниц-списков (слежения, аудитории): без правой панели истории. */
.app-shell.wide { grid-template-columns: 240px minmax(0, 1fr); max-width: 1500px; }
.app-shell.wide .app-work-inner { max-width: 1200px; }
@media (max-width: 1180px) { .app-shell.wide { grid-template-columns: minmax(0, 1fr); } }
/* Защита таблиц от «поехавших» колонок: горизонтальный скролл вместо сжатия/переносов.
   На мобиле (≤820px) таблицы и так превращаются в карточки — там min-width не нужен. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 2px -2px; }
@media (min-width: 821px) {
  .table-wrap > table { min-width: max-content; }
  /* Колонка действий закреплена справа: кнопки (Удалить и т.п.) не обрезаются при скролле.
     Класс .sticky-actions вешает JS в base.html, только если в последней колонке есть кнопки/формы. */
  .table-wrap > table.sticky-actions tr > :last-child {
    position: sticky; right: 0; z-index: 1; background: var(--card);
  }
  .table-wrap > table.sticky-actions tbody tr:hover > :last-child { background: var(--card); }
  .table-wrap > table.sticky-actions tr > :last-child::after {
    content: ""; position: absolute; left: -12px; top: 0; bottom: 0; width: 12px;
    background: linear-gradient(to right, transparent, rgba(20,20,20,.07)); pointer-events: none;
  }
}
.app-side, .app-work, .app-hist { min-height: 0; }
.app-side, .app-work, .hist-list { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
.app-side::-webkit-scrollbar, .app-work::-webkit-scrollbar, .hist-list::-webkit-scrollbar { width: 9px; }
.app-side::-webkit-scrollbar-thumb, .app-work::-webkit-scrollbar-thumb, .hist-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }

.app-side { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; overflow-y: auto; overflow-x: hidden; box-shadow: 0 10px 30px -24px rgba(60,54,30,.3); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-home { font-weight: 800; margin-bottom: 4px; }
.side-grp { padding: 0; }
.side-grp + .side-grp { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.side-grp > summary { list-style: none; cursor: pointer; user-select: none; font-family: var(--f-head); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); padding: 7px 8px 5px; display: flex; align-items: center; justify-content: space-between; font-weight: 800; }
.side-grp > summary::-webkit-details-marker { display: none; }
.side-grp > summary::after { content: "▾"; font-size: 9px; opacity: .55; transition: transform .15s; }
.side-grp:not([open]) > summary::after { transform: rotate(-90deg); }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-size: 13.5px; color: var(--text); font-weight: 700; transition: background .12s, color .12s; }
.side-link:hover { background: var(--bg2); text-decoration: none; }
.side-link.on { background: var(--brand-wash); color: var(--brand2); box-shadow: inset 2px 0 0 var(--brand); }
.side-link.off { color: var(--dim); cursor: default; }
.side-ico { width: 20px; text-align: center; flex: none; font-size: 14px; }
.side-ico svg, .side-ico img { display: block; border-radius: 6px; }
.side-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-soon { font-size: 9.5px; color: var(--dim); border: 1px solid var(--border2); border-radius: 6px; padding: 1px 5px; letter-spacing: .03em; flex: none; }
.unread-badge { flex: none; background: #e5484d; color: #fff; font-size: 10.5px; font-weight: 800; line-height: 1; min-width: 16px; text-align: center; border-radius: 9px; padding: 3px 6px; }

/* Поддержка — инбокс-хелпдеск */
.sup-tabs { display: flex; gap: 2px; flex-wrap: wrap; margin: 16px 0 12px; border-bottom: 1px solid var(--border); }
.sup-tab { padding: 8px 14px; font-weight: 700; font-size: 13.5px; color: var(--dim); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sup-tab:hover { color: var(--text); text-decoration: none; }
.sup-tab.on { color: var(--text); border-bottom-color: var(--brand); }
.sup-cnt { display: inline-block; background: var(--bg2); color: var(--dim); border-radius: 9px; font-size: 11px; font-weight: 800; padding: 2px 7px; margin-left: 2px; }
.sup-cnt.hot { background: #e5484d; color: #fff; }
.sup-search { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.sup-search input[type=search] { flex: 1; max-width: 340px; }
.sup-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.sup-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.sup-row:last-child { border-bottom: none; }
.sup-row:hover { background: var(--bg2); text-decoration: none; }
.sup-row.wait { background: var(--brand-wash); }
.sup-ch { flex: none; width: 38px; text-align: center; font-size: 10px; font-weight: 800; padding: 4px 0; border-radius: 6px; letter-spacing: .03em; }
.sup-ch.tg { background: #229ed2; color: #fff; }
.sup-ch.web { background: var(--bg2); color: var(--dim); border: 1px solid var(--border2); }
.sup-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sup-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-snip { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-time { flex: none; font-size: 11.5px; color: var(--dim); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.sup-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e5484d; }
.sup-tag { display: inline-block; font-size: 10px; color: var(--dim); border: 1px solid var(--border2); border-radius: 6px; padding: 1px 5px; font-weight: 600; vertical-align: middle; }

.app-work { overflow: auto; }
.app-work-inner { max-width: 920px; margin: 0 auto; padding: 20px 18px 32px; }
.app-work-inner > h1:first-child, .app-work-inner > .row:first-child, .app-work-inner > .alert:first-child { margin-top: 0; }

.app-hist { overflow: hidden; }
.hist { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; height: 100%; box-sizing: border-box; box-shadow: 0 10px 30px -24px rgba(60,54,30,.3); }
.hist-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 11px; border-bottom: 1px solid var(--border); }
.hist-title { font-family: var(--f-head); font-size: 13px; font-weight: 800; }
.hist-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.hist-item { display: block; padding: 9px 10px; border: 1px solid var(--border); border-radius: 11px; color: var(--text); transition: border-color .12s, background .12s; }
.hist-item:hover { background: var(--bg2); border-color: var(--border2); text-decoration: none; }
.hist-item.on { border-color: var(--brand); background: var(--brand-wash); }
.hist-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hist-kind { font-size: 12px; font-weight: 800; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.hist-top .pill { flex: none; max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-target { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-meta { display: flex; gap: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--dim); margin-top: 5px; font-weight: 700; }
.hist-all { flex: none; display: block; text-align: center; font-size: 12px; color: var(--muted); padding: 10px; border-top: 1px solid var(--border); font-weight: 700; }
.hist-all:hover { color: var(--brand2); text-decoration: none; }
.hist-empty { font-size: 13px; line-height: 1.6; padding: 16px 12px; }

@media (max-width: 1180px) { .app-shell { grid-template-columns: minmax(0,1fr) 300px; } .app-side { display: none; } }
@media (max-width: 820px) {
  main.app-main { position: static; height: auto; overflow: visible; }
  main.app-main ~ footer { display: block; }
  .app-shell { display: block; height: auto; padding: 14px; max-width: none; }
  .app-side { display: none; }
  .app-work { overflow: visible; }
  .app-work-inner { padding: 0; max-width: none; }
  .app-hist { overflow: visible; margin-top: 16px; }
  .hist { height: auto; }
  .hist-list { max-height: 60vh; }
}
.tg-miniapp main.app-main { position: static; height: auto; overflow: visible; }
.tg-miniapp main.app-main ~ footer { display: block; }
.tg-miniapp .app-shell { display: block; height: auto; padding: 12px; max-width: none; }
.tg-miniapp .app-side { display: none; }
.tg-miniapp .app-work { overflow: visible; }
.tg-miniapp .app-work-inner { padding: 0; max-width: none; }
.tg-miniapp .app-hist { overflow: visible; margin-top: 14px; }
.tg-miniapp .hist { height: auto; }
.tg-miniapp .hist-list { max-height: 50vh; }

/* ---------- «?»-пояснения ---------- */
.help-q { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border2); color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; user-select: none; vertical-align: middle; line-height: 1; }
.help-q:hover { color: var(--brand2); border-color: var(--brand); }
.help-box { margin-top: 6px; padding: 9px 11px; background: var(--brand-wash); border: 1px solid var(--border); border-left: 2px solid var(--brand); border-radius: 10px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---------- Автоподсказка городов / чипы ---------- */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--border2); border-radius: 11px; margin-top: 4px; max-height: 240px; overflow-y: auto; box-shadow: 0 14px 34px -14px rgba(60,54,30,.3); }
.ac-item { padding: 9px 12px; font-size: 14px; cursor: pointer; color: var(--text); }
.ac-item:hover { background: var(--brand-wash); color: var(--brand2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--brand-wash); border: 1px solid #ecd98a; border-radius: 999px; font-size: 13px; color: var(--text); font-weight: 700; }
.chip-x { cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 50%; }
.chip-x:hover { color: var(--red); }
