/* Шрифты вынесены в /css/fonts.css — его подключают и страницы, где main.css нет
   (например, вход). Оба файла грузятся параллельно по HTTP/2. */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  letter-spacing: -.011em;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-deep); }
.mono { font-family: var(--mono); letter-spacing: 0; }
.serif { font-family: var(--serif); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 28px; }
@media (max-width: 640px) { .container { padding: 0 18px; } }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.08; letter-spacing: -.02em; color: var(--ink); }
.muted { color: var(--stone-4); }
.hidden { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 14.5px; font-weight: 600; letter-spacing: -.005em;
  padding: 12px 22px; border-radius: var(--r-full); border: 1px solid var(--ink);
  background: var(--ink); color: #fff; cursor: pointer;
  transition: transform .16s cubic-bezier(.16,1,.3,1), box-shadow .16s, background .16s;
  box-shadow: var(--sh-sm); text-align: center; line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -10px rgba(28,26,22,.5); color: #fff; }
.btn:active { transform: translateY(0); }
.btn.accent { background: var(--accent); border-color: var(--accent); box-shadow: var(--sh-accent); }
.btn.accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); box-shadow: 0 16px 32px -10px rgba(224,81,46,.5); }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line-2); box-shadow: var(--sh-sm); }
.btn.secondary:hover { background: var(--paper); border-color: var(--stone-4); }
.btn.ghost { background: transparent; color: var(--ink); border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.small { padding: 9px 16px; font-size: 13px; }
/* Кастомный токен: цена — число внутри монеты (золотой кружок). Единый вид на любой кнопке. */
.tk-cost {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; margin-left: 8px; padding: 0 5px;
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
  color: #7a4a00;
  background: radial-gradient(circle at 35% 30%, #ffe38f, #f6b73c 58%, #e6930f);
  border: 1px solid rgba(150,90,0,.5);
  box-shadow: inset 0 1px 1px rgba(255,255,255,.7), inset 0 -1px 2px rgba(140,80,0,.35), 0 1px 2px rgba(0,0,0,.18);
  white-space: nowrap; vertical-align: middle;
}
.btn.large { padding: 15px 30px; font-size: 15.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Формы ---------- */
input, select, textarea {
  width: 100%; padding: 12px 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font-size: 15px; font-family: var(--sans); transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--stone-4); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-mist);
}
textarea { resize: vertical; }
label { display: block; margin: 14px 0 6px; color: var(--stone-6); font-size: 12.5px; font-weight: 600; }
/* Единый вид выпадающих списков вместо блёклого нативного: своя стрелка,
   текст не наезжает на неё, длинные варианты обрезаются с многоточием. */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 40px; cursor: pointer;
  background-color: var(--card);
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23726b60' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  text-overflow: ellipsis; white-space: nowrap;
}
select::-ms-expand { display: none; }

/* Шапка страницы канала: аватар + название */
.channel-head { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.channel-ava { width: 60px; height: 60px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); flex-shrink: 0; }
.channel-posts td a { font-weight: 500; }
.channel-posts td:not(:first-child) { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Кастомный выпадающий список (заменяет нативный <select>, см. enhanceSelect) */
.csel { position: relative; width: 100%; }
.csel-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 15px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font-family: var(--sans); font-size: 15px;
  text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.csel-btn:hover { border-color: var(--stone-4); }
.csel[data-open="true"] .csel-btn { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-mist); }
.csel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csel-chev { width: 18px; height: 18px; flex-shrink: 0; color: var(--stone-5); transition: transform .2s; }
.csel[data-open="true"] .csel-chev { transform: rotate(180deg); }
.csel-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 45;
  background: var(--card); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: var(--sh-lg); max-height: 288px; overflow-y: auto; padding: 6px;
  display: none; -webkit-overflow-scrolling: touch;
}
.csel[data-open="true"] .csel-panel { display: block; animation: cselIn .15s ease; }
@keyframes cselIn { from { opacity: 0; transform: translateY(-4px); } }
.csel-opt {
  padding: 11px 12px; border-radius: 8px; font-size: 14.5px; line-height: 1.3; color: var(--ink-2);
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.csel-opt:hover { background: var(--paper-2); }
.csel-opt.sel { background: var(--accent-pale); color: var(--accent-deep); font-weight: 600; }

/* Строка «поле + список + кнопка» (подключение канала). Скрытый нативный select
   не занимает место, кастомный .csel растягивается. */
.connect-row { display: flex; flex-wrap: wrap; gap: 10px; }
.connect-row > input { flex: 1 1 100%; min-width: 0; }
.connect-row > .csel { flex: 1 1 200px; }
.connect-row > .btn { flex: 0 0 auto; }

/* Гибкое пополнение — ползунок */
.topup-card { padding: 26px 28px; }
.topup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.topup-amt { font-family: var(--serif); font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.topup-break { font-size: 14px; margin-top: 6px; }
.topup-total { text-align: right; margin-left: auto; }
.topup-total-num { font-family: var(--serif); font-size: 46px; font-weight: 700; line-height: 1; color: var(--accent); letter-spacing: -.03em; }
.topup-total-lbl { font-size: 12.5px; color: var(--stone-4); margin-top: 5px; }
.topup-bonus { display: inline-block; margin-top: 9px; padding: 3px 12px; border-radius: var(--r-full); background: var(--success-pale); color: var(--success); font-size: 12.5px; font-weight: 700; }
.topup-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px;
  background: transparent; outline: none; cursor: pointer; margin: 8px 0 2px;
}
/* WebKit: полоска через runnable-track, бегунок центрируем на ней через margin-top */
.topup-range::-webkit-slider-runnable-track {
  height: 10px; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), var(--accent-bright)) left/var(--fill,0%) 100% no-repeat, var(--paper-3);
  box-shadow: inset 0 1px 3px rgba(28,26,22,.09);
}
.topup-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -9px;  /* (10 - 28) / 2 — центр бегунка на полоске */
  width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 4px solid var(--accent);
  box-shadow: 0 3px 10px -2px rgba(224,81,46,.55), 0 1px 3px rgba(28,26,22,.18);
  cursor: grab; transition: transform .12s, box-shadow .12s;
}
.topup-range::-webkit-slider-thumb:hover { box-shadow: 0 5px 16px -2px rgba(224,81,46,.7), 0 1px 3px rgba(28,26,22,.18); }
.topup-range::-webkit-slider-thumb:active { transform: scale(1.14); cursor: grabbing; }
.topup-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-mist); }
.topup-range::-moz-range-track { height: 10px; border-radius: var(--r-full); background: var(--paper-3); box-shadow: inset 0 1px 3px rgba(28,26,22,.09); }
.topup-range::-moz-range-progress { height: 10px; border-radius: var(--r-full); background: linear-gradient(90deg, var(--accent), var(--accent-bright)); }
.topup-range::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); cursor: grab; box-shadow: 0 3px 10px -2px rgba(224,81,46,.55); }
.topup-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--stone-4); margin-top: 14px; }

/* Пресеты + поле «своя сумма» */
.topup-controls { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 20px; flex-wrap: wrap; margin-top: 18px; }
.topup-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.topup-custom label { display: block; font-family: var(--mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--stone-4); margin-bottom: 6px; }
.topup-custom-in { display: flex; align-items: center; gap: 4px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--card); transition: border-color .15s, box-shadow .15s; }
.topup-custom-in:focus-within { border-color: var(--accent); }
.topup-custom-in input { width: 68px; border: none; background: transparent; padding: 11px 0; font-family: var(--sans); font-size: 16px; font-weight: 700; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.topup-custom-in input:focus { outline: none; }
.topup-custom-in span { color: var(--stone-5); font-weight: 600; }
.topup-custom-in input::-webkit-outer-spin-button, .topup-custom-in input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.topup-custom-in input { -moz-appearance: textfield; appearance: textfield; }
.topup-preset { padding: 7px 14px; border-radius: var(--r-full); border: 1px solid var(--line-2); background: var(--card); color: var(--stone-6); font-size: 13px; font-weight: 600; font-family: var(--sans); cursor: pointer; transition: .15s; }
.topup-preset:hover { border-color: var(--accent); color: var(--accent-deep); }
.topup-preset.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Контент-план: список строк вместо таблицы (аккуратно на всех экранах) */
.plan-card { padding: 0; overflow: hidden; }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px 16px; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.plan-head b { font-family: var(--serif); font-size: 16px; }
.plan-list { display: flex; flex-direction: column; }
.plan-item { display: flex; align-items: flex-start; gap: 16px; padding: 15px 22px; border-bottom: 1px solid var(--line); transition: background .15s; }
.plan-item:last-child { border-bottom: none; }
.plan-item:hover { background: var(--paper); }
.plan-day {
  flex-shrink: 0; min-width: 84px; text-align: center;
  font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--accent-deep); background: var(--accent-pale); border-radius: 8px; padding: 7px 10px;
}
.plan-main { flex: 1 1 auto; min-width: 0; }
.plan-title { font-weight: 600; font-size: 15.5px; line-height: 1.35; letter-spacing: -.01em; }
.plan-desc { color: var(--stone-5); font-size: 13.5px; line-height: 1.5; margin-top: 4px; }
.plan-fmt { margin-top: 9px; }
.plan-write { flex-shrink: 0; align-self: center; white-space: nowrap; }
@media (max-width: 640px) {
  .plan-head { padding: 14px 16px; }
  .plan-item { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .plan-day { order: 1; min-width: 0; }
  .plan-main { order: 2; flex: 1 1 100%; }
  .plan-write { order: 3; flex: 1 1 100%; justify-content: center; }
}
@media (max-width: 480px) {
  .topup-card { padding: 22px 18px; }
  .topup-head { gap: 10px; }
  .topup-total { text-align: left; margin-left: 0; }
  .topup-total-num { font-size: 40px; }
  .topup-controls { gap: 14px; }
  .topup-custom { width: 100%; }
  .topup-custom-in input { width: auto; flex: 1; }
}

/* Форма подключения канала: поле + список + кнопка в ряд, на мобилке — стек */
.connect-row { display: grid; grid-template-columns: 1fr 220px auto; gap: 10px; align-items: center; }
@media (max-width: 640px) { .connect-row { grid-template-columns: 1fr; } }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 24px; box-shadow: var(--sh-sm);
  transition: box-shadow .2s, transform .2s, border-color .2s;
}
.grid { display: grid; gap: 18px; }
/* min(100%, N) — колонка не может стать шире контейнера: на узких экранах
   сжимается в один столбец без переполнения, на широких сохраняет N-раскладку. */
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }

/* Иконочный чип */
.ic {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 22px; margin-bottom: 16px;
  background: var(--paper-2); border: 1px solid var(--line);
}
.ic.accent { background: var(--accent-pale); border-color: transparent; }
.ic.green { background: var(--success-pale); border-color: transparent; }

/* Бейджи */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px;
  border-radius: var(--r-full); font-size: 12px; font-weight: 600;
  background: var(--paper-2); color: var(--stone-6); border: 1px solid var(--line);
}
.badge.primary, .badge.amber { color: var(--accent-deep); background: var(--accent-pale); border-color: transparent; }
.badge.green { color: var(--success); background: var(--success-pale); border-color: transparent; }
.badge.red { color: var(--danger); background: var(--danger-pale); border-color: transparent; }

/* Мета-метка (uppercase mono) */
.eyebrow-tag {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  color: var(--accent);
}
.eyebrow-tag::before { content: ''; width: 22px; height: 1px; background: var(--accent); }

/* ---------- Кабинет ---------- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--card); border-right: 1px solid var(--line);
  padding: 24px 14px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { padding: 0 10px 20px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; }
.menu-toggle { display: none; }  /* бургер только на мобильном */
.sidebar a.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-radius: var(--r-sm);
  color: var(--stone-6); font-size: 14.5px; font-weight: 500; transition: background .15s, color .15s;
}
.sidebar a.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.sidebar a.nav-item.active { background: var(--ink); color: #fff; font-weight: 600; }
.balance-chip {
  margin-top: auto; padding: 16px; border-radius: var(--r);
  background: var(--ink); color: rgba(255,255,255,.75); font-size: 13px;
  position: relative; overflow: hidden;
}
.balance-chip::after {
  content: ''; position: absolute; top: -40%; right: -20%; width: 160px; height: 160px;
  border-radius: 50%; background: radial-gradient(circle, rgba(224,81,46,.35), transparent 70%);
  filter: blur(24px); pointer-events: none;
}
.balance-chip b { color: #fff; font-size: 26px; font-weight: 700; font-family: var(--serif); display: block; position: relative; }
.balance-chip .btn { margin-top: 12px; position: relative; }

.main { flex: 1; min-width: 0; padding: 34px 40px; max-width: 1400px; width: 100%; }
/* «Читательские» страницы держим узкими даже на широком экране (комфортная длина
   строки), остальное — таблицы/сетки/дашборд — используют всю ширину. */
.article-page { max-width: 880px; }
.topup-card { max-width: 720px; }
.page-title { font-size: 32px; margin-bottom: 8px; font-weight: 600; }
.page-sub { color: var(--stone-4); margin-bottom: 26px; font-size: 15px; }

/* Статистические плитки */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .label { color: var(--stone-4); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; font-family: var(--mono); }
.stat .val { font-size: 40px; font-weight: 600; font-family: var(--serif); color: var(--ink); line-height: 1.05; letter-spacing: -.03em; }
.stat .val.primary { color: var(--accent); }

.progress-wrap { background: var(--paper-3); border-radius: var(--r-full); height: 10px; overflow: hidden; margin: 18px 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: var(--r-full); transition: width .5s ease; }

.topic-card { cursor: pointer; }
a.topic-card, .topic-card { text-decoration: none; color: inherit; display: block; }
.topic-card:hover { border-color: var(--accent); box-shadow: var(--sh); transform: translateY(-2px); }
.topic-card b { font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }

/* Карточки выбора темы: ровная сетка — заголовок в 3 строки, описание в 3, кнопка у низа */
.topic-pick { display: flex; flex-direction: column; }
.topic-pick .tp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.topic-pick .tp-title {
  font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.32; letter-spacing: -.01em; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.topic-pick .tp-score { flex-shrink: 0; }
.topic-pick .tp-desc {
  color: var(--stone-5); font-size: 13.5px; line-height: 1.5; margin: 10px 0 16px;
  display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.topic-pick .btn { margin-top: auto; }

/* Галерея картинок статьи (управление: заменить/убрать) */
.inline-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 12px; }
.inline-img { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); }
.inline-img img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.inline-img-acts { display: flex; gap: 6px; padding: 8px; flex-wrap: wrap; }
.inline-img-acts .btn { flex: 1 1 auto; justify-content: center; padding: 7px 10px; }

/* Воронка продаж (админка) */
.funnel { display: flex; align-items: stretch; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.fn-step { flex: 1 1 150px; min-width: 128px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; }
.fn-num { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--ink); }
.fn-num.primary { color: var(--accent); }
.fn-lbl { font-size: 13px; font-weight: 600; color: var(--stone-6); margin-top: 6px; }
.fn-sub { font-size: 12px; color: var(--stone-4); margin-top: 3px; }
.fn-arrow { display: flex; align-items: center; color: var(--accent); font-size: 22px; flex: 0 0 auto; }
@media (max-width: 700px) { .fn-arrow { display: none; } .fn-step { flex: 1 1 44%; } }

/* Обложка статьи */
.cover { width: 100%; border-radius: var(--r); box-shadow: var(--sh); margin-bottom: 18px; display: block; }
.cover-placeholder {
  width: 100%; aspect-ratio: 16/9; border-radius: var(--r); margin-bottom: 18px;
  background: var(--paper-2); border: 1px dashed var(--line-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--stone-4); gap: 8px; text-align: center; padding: 20px;
}
.preview-thumbs { display: flex; gap: 12px; flex-wrap: wrap; }
.preview-thumbs img { width: 220px; max-width: 45%; border-radius: var(--r-sm); box-shadow: var(--sh-sm); }

.article-content {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 40px 44px; box-shadow: var(--sh-sm);
}
.article-content h2 { margin: 28px 0 12px; font-size: 25px; font-weight: 600; }
.article-content p { margin-bottom: 16px; color: var(--ink-2); font-size: 16.5px; line-height: 1.75; }
.article-content figure { margin: 22px 0; }
.article-content img { max-width: 100%; border-radius: var(--r-sm); box-shadow: var(--sh-sm); }
.article-content figcaption { color: var(--stone-4); font-size: 13px; margin-top: 8px; text-align: center; font-family: var(--mono); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }

/* Оценка */
.score-ring {
  font-family: var(--serif); font-size: 30px; font-weight: 600; color: #fff;
  width: 92px; height: 92px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink); box-shadow: var(--sh);
}
.score-row { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.criteria-bar { height: 8px; border-radius: var(--r-full); background: var(--paper-3); overflow: hidden; margin-top: 4px; }
.criteria-bar > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-full); }

/* Таблицы */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
/* Широкие таблицы админки скроллятся по горизонтали в своём боксе, а не распирают
   страницу (на мобилке ниже .admin-cards превращаются в карточки). */
.admin-cards { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--stone-4); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; font-family: var(--mono); }
tr:last-child td { border-bottom: none; }

/* Постраничная навигация под таблицей */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.pager:empty { display: none; }
.pager .muted { font-size: 13px; }
.pager button[disabled] { opacity: .45; cursor: default; }

/* Табы */
.tabs { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.tabs .tab {
  padding: 9px 18px; border-radius: var(--r-full); cursor: pointer;
  background: var(--card); border: 1px solid var(--line-2); font-size: 13.5px; font-weight: 600; color: var(--stone-5);
  transition: .15s;
}
.tabs .tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Модалка */
.modal-bg {
  position: fixed; inset: 0; background: rgba(28,26,22,.45); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal { max-width: 540px; width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--sh-lg); }
.modal h3 { margin-bottom: 6px; font-size: 22px; }

/* Тосты (стопкой в правом нижнем углу) */
#toast-root {
  position: fixed; bottom: 26px; right: 26px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; pointer-events: auto;
  padding: 13px 18px; border-radius: var(--r-sm); max-width: 380px; box-shadow: var(--sh-lg);
  border-left: 3px solid var(--success); animation: slidein .25s; font-size: 14px;
  display: flex; align-items: center; gap: 11px;
}
.toast.error { border-left-color: var(--accent-bright); }
.toast .ti {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: var(--success); color: #fff;
}
.toast.error .ti { background: var(--accent-bright); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* Скелетоны загрузки */
.skel {
  background: linear-gradient(90deg, var(--paper-2) 25%, var(--paper-3) 37%, var(--paper-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.skel-line { height: 14px; margin-bottom: 10px; }
.skel-title { height: 34px; width: 42%; margin-bottom: 22px; }

/* Онбординг новичка */
.onboard { background: linear-gradient(135deg, var(--accent-pale), var(--card) 70%); border: 1px solid var(--accent-pale); position: relative; margin-bottom: 20px; }
.onboard-x { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--stone-4); cursor: pointer; }
.onboard-steps { display: grid; gap: 12px; margin: 16px 0 18px; }
.onboard-steps > div { display: flex; align-items: flex-start; gap: 12px; }
.onboard-num { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }

/* Пустые состояния */
.empty { text-align: center; padding: 48px 28px; }
.empty-ic {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--accent-pale); display: flex; align-items: center; justify-content: center; font-size: 30px;
}
.empty-title { font-family: var(--serif); font-size: 21px; font-weight: 600; margin-bottom: 6px; }
.empty-text { color: var(--stone-5); font-size: 14.5px; max-width: 400px; margin: 0 auto 18px; line-height: 1.55; }

/* Карточки пополнения (кабинет) */
.price-card { position: relative; display: flex; flex-direction: column; }
.price-card .pk-title { font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--stone-4); margin-bottom: 12px; }
.price-card .tokens { font-family: var(--serif); font-size: 44px; font-weight: 600; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.price-card .tk-label { font-size: 13px; color: var(--stone-4); margin: 4px 0 14px; }
.price-card .rub { font-size: 20px; font-weight: 700; margin-bottom: 18px; color: var(--accent); }
.price-card .btn { margin-top: auto; }
.price-card:hover { box-shadow: var(--sh); transform: translateY(-2px); }
.price-card.popular { background: var(--ink); border-color: var(--ink); box-shadow: var(--sh-lg); }
.price-card.popular .pk-title, .price-card.popular .tk-label { color: rgba(255,255,255,.5); }
.price-card.popular .tokens { color: #fff; }
.price-card.popular .rub { color: var(--accent-bright); }
.popular-tag {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  padding: 5px 14px; background: var(--accent); color: #fff; border-radius: var(--r-full);
  font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; white-space: nowrap; box-shadow: var(--sh-accent);
}

/* Прогресс-оверлей фоновых операций */
.job-overlay {
  position: fixed; inset: 0; background: rgba(28,26,22,.5); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 150; padding: 20px; animation: fade .2s;
}
.job-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 36px 34px; max-width: 440px; width: 100%; box-shadow: var(--sh-lg); text-align: center;
}
.job-spin {
  width: 50px; height: 50px; margin: 0 auto 20px; border-radius: 50%;
  border: 3px solid var(--paper-3); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.job-title { font-family: var(--serif); font-size: 21px; font-weight: 600; margin-bottom: 6px; }
.job-step { color: var(--stone-5); font-size: 14px; min-height: 20px; margin-bottom: 18px; }
.job-bar { height: 8px; background: var(--paper-3); border-radius: var(--r-full); overflow: hidden; }
.job-bar > span { display: block; height: 100%; width: 5%; background: var(--accent); border-radius: var(--r-full); transition: width .45s ease; }
.job-bar.indet { position: relative; }
.job-bar.indet > span { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-115%); } 100% { transform: translateX(330%); } }
.job-hint { margin-top: 14px; font-size: 12.5px; color: var(--stone-4); }

/* Индикатор навигации сверху */
#navbar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 300;
  background: var(--accent); box-shadow: 0 0 8px rgba(224,81,46,.6);
  transition: width .4s ease, opacity .35s ease; opacity: 0;
}

/* Кнопка в состоянии загрузки */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn.secondary.loading::after { border-color: rgba(28,26,22,.25); border-top-color: var(--ink); }

/* Логин */
.auth-wrap { max-width: 430px; margin: 0 auto; padding-top: 64px; }
.auth-logo { text-align: center; margin-bottom: 24px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--stone-4); font-size: 12.5px; font-family: var(--mono); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Логотип (общий) */
.logo { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: -.02em; color: var(--ink); display: inline-flex; align-items: center; gap: 2px; }
.logo .dot { color: var(--accent); }
.logo-mark { height: 1.3em; width: auto; margin-right: 6px; vertical-align: middle; }

/* Строка «поле + кнопка» (копирование реф-кода/ссылки). min-width:0 позволяет
   полю сжиматься, а не выпирать; на узких экранах кнопка переносится под поле. */
.copy-row { display: flex; gap: 10px; align-items: stretch; }
.copy-row input { flex: 1 1 auto; min-width: 0; }
#ref-code { font-family: var(--mono, monospace); font-weight: 700; text-align: center; font-size: 22px; letter-spacing: 3px; }

@keyframes menuDrop { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 820px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 100;
    padding: 10px 16px; gap: 0; box-shadow: var(--sh-sm);
  }
  .sidebar .logo { padding: 0; font-size: 20px; }
  /* бургер-кнопка */
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 40px; border: 1px solid var(--line-2); border-radius: 10px;
    background: var(--paper-2); color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer;
  }
  /* меню: скрыто; раскрывается по клику (.open) вертикальным списком с мягкой анимацией */
  .sidebar-nav { display: none; }
  .sidebar.open .sidebar-nav { display: flex; margin-top: 10px; animation: menuDrop .18s ease; }
  .sidebar a.nav-item { padding: 12px 14px; font-size: 15px; }
  .balance-chip { margin: 10px 0 0; }
  .main { padding: 22px 16px; }
  .article-content { padding: 24px 20px; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .page-title { font-size: 25px; }
  /* Широкие таблицы скроллятся горизонтально, а не ломают вёрстку */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Таблицы с классом .admin-cards на мобильном превращаются в карточки с подписями */
  .admin-cards { overflow-x: visible; }
  .admin-cards tr { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; }
  .admin-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: none; padding: 7px 0; text-align: right; }
  .admin-cards td::before { content: attr(data-label); color: var(--stone-5); font-weight: 600; font-size: 12.5px; text-align: left; }
  .admin-cards td[data-label="Действия"] { flex-wrap: wrap; justify-content: flex-end; }
  .admin-cards td[data-label="Действия"]::before { display: none; }
  .article-content { padding: 22px 18px; }
  .article-content h2 { font-size: 20px; }
  .article-content p { font-size: 15.5px; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }
  /* реф-код и ссылка: поле на всю ширину, кнопка отдельной строкой — код виден целиком */
  .copy-row { flex-wrap: wrap; }
  .copy-row input { flex: 1 1 100%; }
  .copy-row .btn { flex: 1 1 auto; justify-content: center; }
  #ref-code { font-size: 19px; letter-spacing: 2px; }
  .preview-thumbs img { max-width: 47%; }
  .job-card { padding: 28px 22px; }
  .score-ring { width: 76px; height: 76px; font-size: 26px; }
  /* Тосты во всю ширину экрана снизу */
  #toast-root { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .toast { max-width: none; }
  .modal h3 { font-size: 20px; }
  /* 16px — чтобы iOS не зумил страницу при фокусе на поле/списке */
  input, select, textarea { font-size: 16px; }
  /* Селект в форме подключения канала — на всю ширину строки */
  #ch-niche { max-width: 100% !important; }
  /* В карточных таблицах строка-заголовок не нужна — метки берутся из data-label */
  .admin-cards thead { display: none; }
  /* Шапка канала: аватар поменьше, перенос при нехватке места */
  .channel-head { gap: 12px; flex-wrap: wrap; }
  .channel-ava { width: 48px; height: 48px; border-radius: 13px; }
}


/* ====== Блог: список и страница статьи ====== */
.post-nav { position: sticky; top: 0; z-index: 50; background: rgba(251,249,244,.9);
  backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.post-nav-inner { height: 62px; display: flex; align-items: center; justify-content: space-between; }
.post-nav .logo { display: flex; align-items: center; gap: 8px; font-family: var(--serif);
  font-size: 21px; font-weight: 600; color: var(--ink); }
.post-nav .logo-mark { width: 26px; height: 26px; }
.post-nav .dot { color: var(--accent); }

.post-wrap { max-width: 760px; margin: 0 auto; padding: 42px 20px 64px; }
.post-crumbs { font-size: 13px; color: var(--stone-4); margin-bottom: 20px; }
.post-crumbs a { color: var(--stone-5); }
.post-crumbs a:hover { color: var(--accent); }

.post h1, .blog-title { font-family: var(--serif); font-weight: 600;
  font-size: clamp(29px, 4.6vw, 43px); line-height: 1.13; letter-spacing: -.02em;
  color: var(--ink); margin-bottom: 14px; }
.post-meta { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--stone-4); margin-bottom: 26px; }
.post-lead { font-size: 19px; line-height: 1.6; color: var(--stone-6); margin-bottom: 30px; }

.post-body { font-size: 17px; line-height: 1.72; color: var(--ink-2); }
.post-body h2 { font-family: var(--serif); font-weight: 600; font-size: 27px;
  line-height: 1.22; color: var(--ink); margin: 40px 0 14px; }
.post-body h3 { font-size: 19.5px; font-weight: 650; color: var(--ink); margin: 28px 0 10px; }
.post-body p { margin-bottom: 16px; }
.post-body ul, .post-body ol { margin: 0 0 18px 22px; }
.post-body li { margin-bottom: 8px; }
.post-body a { color: var(--accent-deep); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-thickness: 1px; }
.post-body a:hover { color: var(--accent); }
.post-body b { font-weight: 650; color: var(--ink); }
.post-body table { width: 100%; border-collapse: collapse; margin: 22px 0; font-size: 15.5px; }
.post-body th, .post-body td { padding: 10px 12px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top; }
.post-body th { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--stone-5); font-weight: 600; }
.post-body tbody tr:last-child td { border-bottom: 0; }

.post-note { background: var(--accent-mist); border: 1px solid var(--accent-pale);
  border-radius: var(--r); padding: 16px 18px; margin: 24px 0; font-size: 16px;
  line-height: 1.6; color: var(--ink-2); }

.post-cta { margin: 44px 0 8px; padding: 26px 24px; border-radius: var(--r-lg);
  background: var(--ink); color: var(--paper); }
.post-cta b { display: block; font-family: var(--serif); font-size: 22px; margin-bottom: 8px; }
.post-cta p { font-size: 15.5px; line-height: 1.6; color: rgba(251,249,244,.78);
  margin-bottom: 18px; }

.post-more { max-width: 760px; margin: 48px auto 0; padding-top: 24px;
  border-top: 1px solid var(--line); }
.post-more b { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--stone-4); }
.post-more ul { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.post-more a { color: var(--ink); font-size: 16.5px; }
.post-more a:hover { color: var(--accent); }

.blog-list { display: grid; gap: 14px; margin-top: 28px; }
.blog-card { display: block; padding: 22px 24px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); transition: .16s; }
.blog-card:hover { border-color: var(--line-2); box-shadow: var(--sh); transform: translateY(-2px); }
.blog-card-date { font-family: var(--mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--stone-4); }
.blog-card b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600;
  line-height: 1.24; color: var(--ink); margin: 8px 0 8px; }
.blog-card p { font-size: 15px; line-height: 1.55; color: var(--stone-5); margin-bottom: 10px; }
.blog-card-more { font-size: 14px; font-weight: 600; color: var(--accent-deep); }

@media (max-width: 600px) {
  .post-wrap { padding: 28px 16px 48px; }
  .post-body { font-size: 16.5px; }
  .post-body table { font-size: 14.5px; }
  .post-body th, .post-body td { padding: 8px 8px; }
  .post-cta { padding: 22px 18px; }
}
