/* webui/static/webui/app.css
   Дизайн-язык «Радар»: рабочая панель (app-shell) + матовое стекло + blob-фон.
   Тёмная тема по умолчанию, светлая через [data-theme="light"].
   Легаси-классы и CSS-переменные (--primary/--success/.card/.btn ...) сохранены
   и переназначены на новый вид — JS страниц генерит разметку этими же именами. */

/* ─────────────────────────── Токены ─────────────────────────── */
:root {
    --bg: #0a0b0e;
    --glass: rgba(22,24,30,.55);
    --glass-2: rgba(30,32,40,.5);
    --raise: rgba(255,255,255,.06);
    --brd: rgba(255,255,255,.09);
    --brd-2: rgba(255,255,255,.14);
    --tx: #e9eaee;
    --tx-2: #9a9ca6;
    --tx-3: #696b76;
    --acc: #ff5a5f;
    --acc-dim: rgba(255,90,95,.16);
    --acc-hover: #ff6b70;
    --surface: #15171c;         /* непрозрачная поверхность (липкие шапки таблиц) */
    --good: #34cf74;
    --warn: #ecc04a;
    --crit: #ff5a5f;
    /* blob-градиенты */
    --b1a: #d98d7c; --b1b: #d69d86; --b1c: #cf998c; --b2a: #6fb9ab; --b2b: #7ba0cf;

    --font: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --blur: blur(26px) saturate(170%);
    --radius: 16px;
    --shadow: 0 8px 24px -12px rgba(0,0,0,.5);

    /* ── легаси-алиасы (используются в шаблонах/JS через var(...)) ── */
    --primary: var(--acc);
    --primary-hover: var(--acc-hover);
    --danger: var(--crit);
    --danger-hover: #ff7a7e;
    --success: var(--good);
    --warning: var(--warn);
    --info: #7ba0cf;
    --text: var(--tx);
    --text-secondary: var(--tx-2);
    --border: var(--brd);
    --bg-card: var(--raise);
    --status-queued: var(--tx-3);
    --status-running: var(--acc);
    --status-done: var(--good);
    --status-failed: var(--crit);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #eaedf3;
    --glass: rgba(255,255,255,.55);
    --glass-2: rgba(255,255,255,.62);
    --raise: rgba(20,22,30,.05);
    --brd: rgba(255,255,255,.6);
    --brd-2: rgba(20,22,30,.1);
    --tx: #1a1b1e;
    --tx-2: #5a5c64;
    --tx-3: #8d909a;
    --acc: #e5343b;
    --acc-dim: rgba(229,52,59,.1);
    --acc-hover: #cf2d34;
    --surface: #f4f6fb;         /* непрозрачная поверхность (липкие шапки таблиц) */
    --good: #1a9e52;
    --warn: #c08a12;
    --crit: #e5343b;
    --b1a: #ffc7b0; --b1b: #ffdcb0; --b1c: #f7ead0; --b2a: #bfe8dc; --b2b: #c2dcf7;
    --danger-hover: #cf2d34;
    --shadow: 0 8px 24px -14px rgba(20,30,60,.28);
    color-scheme: light;
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--tx);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    overflow-y: scroll;   /* жёлоб скролла всегда зарезервирован — разделы не «пляшут» по ширине */
    min-height: 100vh;
}
/* Полоса прокрутки в стиле сайта (тонкая, полупрозрачная, с ховером) */
* { scrollbar-width: thin; scrollbar-color: var(--brd-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brd-2); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--tx-3); }
/* Колокол уведомлений в шапке */
/* z-index выше .content (у него backdrop-filter создаёт слой) — иначе выпадашки
   из шапки (выбор канала, уведомления) прячутся под карточки контента. */
.bar { position: relative; z-index: 30; }
.notif-dot { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--acc); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.notif-pop { position: absolute; top: 56px; right: 12px; width: 320px; max-height: 60vh; overflow-y: auto; z-index: 80; display: none; border: 1px solid var(--brd-2); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.5); background: var(--surface); }
.notif-pop.show { display: block; }
.notif-h { font-size: 12px; font-weight: 600; color: var(--tx-3); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; }
.notif-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 9px; font-size: 13px; }
.notif-item:hover { background: var(--raise); }
.notif-item .nt { font-size: 12px; color: var(--tx-2); margin-top: 2px; }

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

/* ─────────────────────────── Blob-фон ─────────────────────────── */
.bg-blob { position: fixed; z-index: -1; filter: blur(64px); pointer-events: none; }
.bg-blob.a { width: 72vw; height: 72vw; top: -22vw; right: -15vw; opacity: .38; }
.bg-blob.b { width: 50vw; height: 50vw; bottom: -18vw; left: -13vw; opacity: .3; }
:root[data-theme="light"] .bg-blob.a { opacity: .82; }
:root[data-theme="light"] .bg-blob.b { opacity: .72; }

/* ─────────────────────────── Каркас ─────────────────────────── */
/* Всю рабочую область (сайдбар + контент) держим единым центрированным блоком
   с потолком ширины — иначе на больших мониторах либо всё растягивается, либо
   меню прижимается к краю и появляется разрыв до центрированного контента. */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; gap: 12px; padding: 12px; max-width: 1560px; margin-inline: auto; }
.glass {
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--brd);
    border-radius: var(--radius);
}

/* ── Сайдбар ── */
.side { display: flex; flex-direction: column; padding: 14px 12px; position: sticky; top: 12px; height: calc(100vh - 24px); }
.brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 16px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; color: var(--tx); }
.brand .pl { width: 22px; height: 16px; border-radius: 5px; background: var(--acc); display: grid; place-items: center; box-shadow: 0 3px 10px -2px var(--acc); }
.brand .pl::before { content: ""; border-style: solid; border-width: 4px 0 4px 7px; border-color: transparent transparent transparent #fff; margin-left: 1px; }
.nav-s { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--tx-3); padding: 14px 8px 6px; }
.side a {
    display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 9px;
    color: var(--tx-2); font-weight: 450; font-size: 13.5px; cursor: pointer;
    transition: background .16s, color .16s, transform .12s;
}
.side a .ic { width: 16px; height: 16px; flex: none; transition: transform .16s; }
.side a:hover { background: var(--raise); color: var(--tx); text-decoration: none; }
.side a:hover .ic { transform: scale(1.12); }
.side a:active { transform: scale(.97); }
.side a.active { background: var(--acc-dim); color: var(--acc); font-weight: 600; }
.side a .old { font-size: 11px; color: var(--tx-3); font-weight: 400; margin-left: auto; }
.side a.active .old { color: var(--tx-2); }
.side .sp { flex: 1; }
.side .me { border-top: 1px solid var(--brd); padding: 12px 8px 2px; display: flex; align-items: center; gap: 10px; }
.side .me .av { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg,#ff5a5f,#ff9a3c); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; text-transform: uppercase; }
.side .me .me-info { min-width: 0; }
.side .me .nm { font-size: 12.5px; font-weight: 500; color: var(--tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.side .me .pln { font-size: 11px; color: var(--tx-3); margin: 1px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.side .me .side-logout { background: none; border: none; color: var(--tx-3); font-size: 11.5px; cursor: pointer; padding: 2px 0; font-family: var(--font); transition: color .15s; }
.side .me .side-logout:hover { color: var(--acc); }

/* ── Основная колонка ── */
.main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; align-items: center; gap: 12px; padding: 11px 16px; }
.bar .crumb { font-weight: 600; font-size: 14px; color: var(--tx); display: inline-flex; align-items: center; }
.bar .crumb span { color: var(--tx-3); font-weight: 450; }
.bar .sp { flex: 1; }
.menu-btn { display: none !important; }   /* только на мобиле (см. медиазапрос) */
.crumb-av { width: 24px; height: 24px; border-radius: 7px; flex: none; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px; overflow: hidden; background-size: cover; background-position: center; text-transform: uppercase; vertical-align: -6px; margin-right: 8px; }
.crumb-av img { width: 100%; height: 100%; object-fit: cover; display: block; }

.content { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Заголовок страницы дублирует крошку в топбаре — прячем внутри контента,
   но оставляем на страницах вроде auth (там он вложен в .auth-wrap). */
.content > .page-title { display: none; }
.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 4px; color: var(--tx); }

/* ─────────────────────────── Кнопки ─────────────────────────── */
.btn {
    font-family: var(--font); font-weight: 500; font-size: 13px;
    border: 1px solid var(--brd-2); background: var(--raise); color: var(--tx);
    padding: 7px 13px; border-radius: 9px; cursor: pointer; min-height: var(--ctl-h);
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; line-height: 1.4;
    transition: transform .13s cubic-bezier(.34,1.56,.64,1), background .16s, box-shadow .2s, border-color .16s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--glass-2); transform: translateY(-1.5px); box-shadow: 0 6px 16px -6px rgba(0,0,0,.35); }
.btn:active:not(:disabled) { transform: translateY(0) scale(.96); transition-duration: .05s; }
.btn:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--acc); border-color: transparent; color: #fff; box-shadow: 0 2px 8px -4px var(--acc); }
.btn-primary:hover:not(:disabled) { background: var(--acc); box-shadow: 0 4px 12px -5px var(--acc); filter: brightness(1.05); }

.btn-secondary { background: var(--raise); color: var(--tx); border-color: var(--brd-2); }
.btn-secondary:hover:not(:disabled) { background: var(--glass-2); }

.btn-danger { background: transparent; color: var(--crit); border-color: var(--crit); box-shadow: none; }
.btn-danger:hover:not(:disabled) { background: var(--acc-dim); box-shadow: none; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; min-height: 32px; }
.btn.icon { padding: 7px; width: 32px; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ─────────────────────────── Карточки/панели ─────────────────────────── */
.card {
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--brd);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--tx); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 12px; }

/* metric-плитка (легаси .card-stat) */
.card-stat { text-align: left; padding: 15px 17px; }
.card-stat .stat-value { font-size: 25px; font-weight: 700; letter-spacing: -.02em; color: var(--tx); font-variant-numeric: tabular-nums; line-height: 1.1; }
.card-stat .stat-label { font-size: 12px; color: var(--tx-2); margin-top: 6px; }

/* ─────────────────────────── Таблицы ─────────────────────────── */
.table-wrap { overflow-x: auto; margin-bottom: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--tx-3); text-transform: uppercase; letter-spacing: .03em; padding: 0 14px 10px; }
td { padding: 11px 14px; border-top: 1px solid var(--brd); color: var(--tx); vertical-align: middle; }
tbody tr:hover td { background: var(--raise); }

/* ─────────────────────────── Формы ─────────────────────────── */
:root { --ctl-h: 40px; }  /* единая высота полей/кнопок/списков по всему сайту */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="file"], input[type="search"], textarea, select {
    width: 100%; padding: 9px 12px; min-height: var(--ctl-h);
    background: var(--raise); border: 1px solid var(--brd-2); border-radius: 9px;
    font-size: 14px; font-family: var(--font); color: var(--tx);
    transition: border-color .15s, box-shadow .15s;
}
select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    padding-right: 34px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='12'%20height='12'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%238a9099'%20stroke-width='2.5'%20stroke-linecap='round'%20stroke-linejoin='round'%3E%3Cpath%20d='M6%209l6%206%206-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
}
input::placeholder, textarea::placeholder { color: var(--tx-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-dim); }
input[type="file"] { padding: 8px 12px; }
textarea { resize: vertical; min-height: 68px; }
select option { background: var(--bg); color: var(--tx); }

/* Кастомный дропдаун (нативный список Windows не стилизуется) — заменяет select */
.sel-wrap { position: relative; width: 100%; }
select.sel-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; opacity: 0; pointer-events: none; overflow: hidden; clip: rect(0 0 0 0); }
.sel-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: var(--ctl-h); padding: 9px 12px; background: var(--raise); border: 1px solid var(--brd-2); border-radius: 9px; font-size: 14px; font-family: var(--font); color: var(--tx); cursor: pointer; user-select: none; transition: border-color .15s, box-shadow .15s; }
.sel-wrap.open .sel-btn, .sel-btn:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-dim); }
.sel-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-caret { flex: none; width: 12px; height: 12px; color: #8a9099; transition: transform .15s; }
.sel-wrap.open .sel-caret { transform: rotate(180deg); }
.sel-pop { position: absolute; z-index: 70; top: calc(100% + 6px); left: 0; right: 0; max-height: 264px; overflow: auto; background: var(--surface); border: 1px solid var(--brd-2); border-radius: 10px; box-shadow: 0 14px 34px -14px rgba(0,0,0,.55); padding: 5px; }
.sel-opt { padding: 8px 10px; border-radius: 7px; font-size: 14px; color: var(--tx); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sel-opt:hover { background: var(--acc-dim); }
.sel-opt.active { background: var(--acc); color: #fff; }
label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 7px; color: var(--tx-2); }
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }

/* ── поле с проверкой пароля (auth) ── */
.pw-field { position: relative; }
.pw-field.invalid input { border-color: var(--crit); box-shadow: 0 0 0 3px var(--acc-dim); }
.pw-hints { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.pw-hints li { display: flex; align-items: center; gap: 7px; color: var(--tx-3); padding: 2px 0; transition: color .15s; }
.pw-hints li::before { content: "○"; font-size: 11px; color: var(--tx-3); width: 12px; text-align: center; }
.pw-hints li.ok { color: var(--good); }
.pw-hints li.ok::before { content: "✓"; color: var(--good); }
.pw-hints li.bad { color: var(--crit); }
.pw-hints li.bad::before { content: "✕"; color: var(--crit); }

/* всплывашка сбоку от поля пароля */
.pw-pop {
    position: absolute; left: calc(100% + 14px); top: 0; width: 230px; z-index: 20;
    background: var(--glass-2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--brd-2); border-radius: 11px; padding: 12px 14px;
    box-shadow: var(--shadow);
    opacity: 0; visibility: hidden; transform: translateX(-6px); transition: opacity .16s, transform .16s, visibility .16s;
}
.pw-field.invalid .pw-pop { opacity: 1; visibility: visible; transform: none; }
.pw-pop::before {
    content: ""; position: absolute; left: -6px; top: 14px; width: 12px; height: 12px;
    background: var(--glass-2); border-left: 1px solid var(--brd-2); border-bottom: 1px solid var(--brd-2);
    transform: rotate(45deg);
}
.pw-pop .pw-pop-title { font-size: 12px; font-weight: 600; color: var(--crit); margin-bottom: 8px; }
.pw-pop ul { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.pw-pop li { display: flex; align-items: center; gap: 7px; color: var(--tx-2); padding: 2px 0; }
.pw-pop li::before { content: "○"; color: var(--tx-3); width: 12px; text-align: center; }
.pw-pop li.ok { color: var(--good); }
.pw-pop li.ok::before { content: "✓"; color: var(--good); }
.pw-pop li.bad { color: var(--crit); }
.pw-pop li.bad::before { content: "✕"; color: var(--crit); }
@media (max-width: 560px) {
    .pw-pop { position: static; width: auto; margin-top: 10px; opacity: 1; visibility: visible; transform: none; transition: none; }
    .pw-pop::before { display: none; }
    .pw-field:not(.invalid) .pw-pop { display: none; }
}

/* ─────────────────────────── Табы / сегмент-контрол ─────────────────────────── */
.tabs { display: inline-flex; background: var(--raise); border-radius: 10px; padding: 3px; gap: 2px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
    border: none; background: none; font-family: var(--font); font-size: 12.5px; font-weight: 500;
    color: var(--tx-2); padding: 6px 13px; border-radius: 7px; cursor: pointer; transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--tx); }
.tab-btn.active { background: var(--glass-2); color: var(--tx); box-shadow: 0 1px 4px -1px rgba(0,0,0,.25); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─────────────────────────── Тост ─────────────────────────── */
#toast-container { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    padding: 12px 18px; border-radius: 11px; font-size: 13.5px; font-weight: 500; color: #fff;
    background: var(--glass-2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--brd-2); box-shadow: var(--shadow); max-width: 380px; pointer-events: auto;
    opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { color: var(--tx); border-left: 3px solid var(--good); }
.toast-error { color: var(--tx); border-left: 3px solid var(--crit); }

/* ─────────────────────────── Бейджи / чипы ─────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.badge-queued { background: var(--raise); color: var(--tx-2); }
.badge-running { background: var(--acc-dim); color: var(--acc); }
.badge-done { background: rgba(52,207,116,.15); color: var(--good); }
.badge-failed { background: var(--acc-dim); color: var(--crit); }
.badge-vein { background: var(--acc-dim); color: var(--acc); text-transform: none; }
.badge-format { background: rgba(236,192,74,.15); color: var(--warn); text-transform: none; }

/* ─────────────────────────── Auth ─────────────────────────── */
.auth-wrap { max-width: 420px; margin: 0 auto; padding: 0 16px; width: 100%; }
.auth-wrap .card { padding: 30px 26px; margin-bottom: 0; }
.auth-wrap .page-title { display: block; text-align: center; margin-bottom: 22px; font-size: 1.7rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-brand-pl { width: 26px; height: 19px; border-radius: 6px; background: var(--acc); display: inline-grid; place-items: center; box-shadow: 0 3px 10px -2px var(--acc); }
.auth-brand-pl::before { content: ""; border-style: solid; border-width: 5px 0 5px 8px; border-color: transparent transparent transparent #fff; margin-left: 1px; }

/* bare-режим (страница входа): без сайдбара/топбара, контент по центру */
body.bare .app { display: grid; grid-template-columns: 1fr; place-items: center; }
body.bare .side, body.bare .bar { display: none; }
body.bare .main { width: 100%; justify-content: center; }
body.bare .content { min-height: calc(100vh - 24px); justify-content: center; }

/* ─────────────────────────── Таргетинг split ─────────────────────────── */
.split-layout { display: grid; grid-template-columns: 280px 1fr; gap: 12px; align-items: start; }
@media (max-width: 768px) { .split-layout { grid-template-columns: 1fr; } }
/* дети grid-контейнеров должны уметь сжиматься (иначе таблицы распирают верстку) */
.split-layout > *, .split2 > * { min-width: 0; }
.sidebar-list { list-style: none; }
.sidebar-list li {
    padding: 9px 11px; border-radius: 9px; cursor: pointer; font-size: 13.5px; margin-bottom: 2px;
    transition: background .15s, color .15s; display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--tx);
}
.sidebar-list li:hover { background: var(--raise); }
.sidebar-list li.active { background: var(--acc-dim); color: var(--acc); font-weight: 600; }
.sidebar-list li.active .btn { color: var(--acc); border-color: var(--brd-2); }

/* ─────────────────────────── Жилы / идеи ─────────────────────────── */
.vein-card { border-left: 3px solid var(--acc); }
.vein-card .hooks { list-style: disc; padding-left: 20px; font-size: 13px; color: var(--tx-2); }
.vein-card .hooks li { margin: 3px 0; }
.vein-card .patterns { font-size: 12px; color: var(--tx-3); margin-top: 6px; }
.idea-card { position: relative; }
.idea-card .idea-title { font-weight: 600; margin-bottom: 4px; color: var(--tx); }
.idea-card .idea-hook { font-style: italic; color: var(--tx-2); font-size: 13px; margin-bottom: 8px; }
.idea-card .idea-outline { list-style: decimal; padding-left: 20px; font-size: 13px; margin-bottom: 4px; color: var(--tx-2); }

/* ─────────────────────────── Диагностика ─────────────────────────── */
.diag-verdict { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; color: var(--tx); }
.diag-recs { list-style: disc; padding-left: 20px; font-size: 13.5px; color: var(--tx-2); }
.diag-recs li { margin: 3px 0; }
.diag-medians { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--tx-2); margin-top: 8px; }

/* ─────────────────────────── Флаги тарифа ─────────────────────────── */
.flag-list { list-style: none; }
.flag-list li { padding: 4px 0; color: var(--tx); }
.flag-list li::before { content: "✓ "; color: var(--good); font-weight: 700; }
.flag-list li.off { color: var(--tx-3); }
.flag-list li.off::before { content: "✕ "; color: var(--tx-3); }

/* ─────────────────────────── Прочее ─────────────────────────── */
.empty { text-align: center; padding: 36px 20px; color: var(--tx-2); font-size: 14px; }
.empty a { color: var(--acc); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--tx-2); }
.text-danger { color: var(--crit); }
code { background: var(--raise); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
details summary { color: var(--acc); }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

.spinner {
    display: inline-block; width: 15px; height: 15px; vertical-align: -2px;
    border: 2px solid var(--brd-2); border-top-color: var(--acc); border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-btn.spinning svg { animation: spin .7s linear infinite; }

/* ── График удержания по длине ролика (SVG-кривая) ── */
svg.ret-ch { display: block; width: 100%; height: auto; overflow: visible; }
.ret-dot { cursor: pointer; transition: r .1s; }
.ret-dot:hover { r: 6.5; }
.ret-tip {
    position: absolute; pointer-events: none; opacity: 0; transform: translate(-50%,-125%);
    background: var(--glass-2); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--brd-2); border-radius: 9px; padding: 6px 10px; font-size: 12px;
    transition: opacity .1s; white-space: nowrap; z-index: 9; color: var(--tx);
}
.ret-tip b { font-weight: 700; }

/* ── Строка ролика с обложкой (топ/аутлайеры) ── */
.vrow { display: flex; align-items: center; gap: 11px; min-width: 0; }
.vth { width: 64px; height: 36px; border-radius: 6px; flex: none; position: relative; overflow: hidden; background-size: cover; background-position: center; background-color: var(--raise); }
.vth-ph { background: linear-gradient(135deg, var(--acc), #ff9a3c); }
.vth img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vnm { font-weight: 500; color: var(--tx); overflow: hidden; text-overflow: ellipsis; }
.vnm:hover { color: var(--acc); }
.vsub { font-size: 12px; color: var(--tx-2); }
.tnum { font-variant-numeric: tabular-nums; }
.mx { font-weight: 700; color: var(--good); font-variant-numeric: tabular-nums; }
.mx.a { color: var(--acc); }

/* ── Метрика-пилюля (скруглённый выделенный прямоугольник) ── */
.mpill { display: inline-block; padding: 3px 10px; border-radius: 8px; font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; background: var(--raise); color: var(--tx); white-space: nowrap; }
.mpill.acc { background: var(--acc-dim); color: var(--acc); }
.mpill.good { background: rgba(52,207,116,.15); color: var(--good); }
.mpill .mp-l { font-weight: 500; color: var(--tx-2); margin-right: 4px; }

/* ── Строка канала: аватар (буква/фото) + имя-ссылка ── */
.chan-row { display: flex; align-items: center; gap: 11px; min-width: 0; }
.chan-av { position: relative; width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; overflow: hidden; background-size: cover; background-position: center; text-transform: uppercase; }
/* фото поверх буквы — абсолютом, чтобы grid не делил на 2 строки и не резал картинку */
.chan-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.chan-link { color: var(--tx); font-weight: 500; }
.chan-link:hover { color: var(--acc); }

/* ── «Мой канал»: 2 колонки (показатели слева / график справа) ── */
.split2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .split2 { grid-template-columns: 1fr; } }
.stat-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: var(--raise); border: 1px solid var(--brd); border-radius: 12px; padding: 12px 14px; }
.stat-box .sv { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--tx); line-height: 1.1; }
.stat-box .sl { font-size: 11.5px; color: var(--tx-2); margin-top: 3px; }
.kpi-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.kpi { background: var(--raise); border-radius: 9px; padding: 8px 12px; }
.kpi .kl { font-size: 11px; color: var(--tx-2); }
.kpi .kv { font-size: 15px; font-weight: 700; color: var(--tx); font-variant-numeric: tabular-nums; }
.chart-col { min-width: 0; }
.chart-col .chart-head { font-size: 13.5px; }
#ret-chart-slot { max-width: 560px; }
/* ИИ-диагностика: график и «Что делать» рядом, когда хватает ширины, и
   переносятся друг под друга на узких контейнерах (flex-wrap, без завязки
   на ширину окна — корректно и во вложенной колонке дашборда). */
/* Контент диагностики держим в читаемой ширине — иначе на больших экранах
   плитки и текст растягиваются в пустые простыни. */
.diag-body { max-width: 1180px; }
/* KPI: адаптивно 4-в-ряд на широком, 2 — на узком (не жёсткие 2 колонки). */
.diag-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.diag-split { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; margin-top: 16px; }
.diag-split .chart-box { flex: 1 1 190px; max-width: 380px; margin-top: 0; }
.diag-actions { flex: 1 1 210px; background: var(--raise); border: 1px solid var(--brd); border-radius: 11px; padding: 13px 15px; }
.diag-actions .ai-recs { margin-top: 4px; }
/* прокручиваемая таблица «Все ролики» */
.vscroll { max-height: 520px; overflow-y: auto; position: relative; }
.vscroll thead th {
    position: sticky; top: 0; z-index: 3;
    background: var(--surface);          /* НЕпрозрачно — строки не просвечивают */
    height: 36px; padding-top: 12px;
}
/* строки «уходят» под шапку через градиент-затухание (липкая полоса под шапкой) */
.vscroll-fade {
    position: sticky; top: 36px; z-index: 2; height: 8px; margin-bottom: -8px;
    background: linear-gradient(to bottom, var(--surface), transparent);
    pointer-events: none;
}

/* ── Сортируемые шапки таблиц ── */
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; transition: color .15s; }
th.th-sort:hover { color: var(--tx-2); }
th.th-active { color: var(--acc); }
/* колонка действий в таблицах — кнопки к правому краю */
td.actions, th.actions { text-align: right !important; white-space: nowrap; }
/* пагинация таблиц */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 2px 2px; font-size: 13px; color: var(--tx-2); }
.pager .pg-info { font-variant-numeric: tabular-nums; }
/* крупное поле поиска — оформление как у блока stat-box (фон/бордюр/радиус) */
.big-search { width: 100%; padding: 11px 14px; border-radius: 12px; font-size: 14px; background: var(--raise); border: 1px solid var(--brd); }
.th-arr { display: inline-block; min-width: 10px; font-size: 10px; color: var(--acc); margin-left: 2px; }

/* ── Модальное подтверждение (Да/Нет) ── */
.modal-ov { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .15s; }
.modal-ov.show { opacity: 1; }
.modal { max-width: 380px; width: 100%; padding: 20px 22px; border-radius: 16px; box-shadow: var(--shadow); transform: translateY(8px) scale(.98); transition: transform .15s; }
.modal-ov.show .modal { transform: none; }
.modal-title { font-size: 15px; font-weight: 600; color: var(--tx); }
.modal-msg { font-size: 13.5px; color: var(--tx-2); margin-top: 8px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
/* широкая модалка (карточка канала) */
.modal-wide { max-width: 900px; max-height: 88vh; overflow-y: auto; }

/* ─────────────────────────── ИИ-блоки (жилы / план / диагностика) ─────────────────────────── */
.chart-box { background: var(--raise); border: 1px solid var(--brd); border-radius: 11px; padding: 11px 12px 8px; }
.ai-verdict { font-size: 15px; line-height: 1.55; color: var(--tx); }
.ai-verdict .lead { color: var(--acc); font-weight: 700; }
.ai-eyebrow { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tx-3); margin-bottom: 6px; }
.ai-recs { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.ai-recs li { display: flex; gap: 10px; font-size: 14px; color: var(--tx); }
.ai-recs .ic { flex: none; width: 18px; height: 18px; border-radius: 50%; background: rgba(52,207,116,.15); color: var(--good); display: grid; place-items: center; font-size: 11px; margin-top: 1px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; background: var(--acc-dim); color: var(--acc); }
.ai-hooks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ai-hooks li { font-size: 13.5px; padding-left: 16px; position: relative; color: var(--tx); }
.ai-hooks li::before { content: "“"; position: absolute; left: 0; top: -1px; color: var(--acc); font-weight: 700; font-size: 16px; }
/* жила V1 */
.vein-v1 { padding: 16px 18px; margin-bottom: 12px; }
.vein-v1 .vn { font-size: 16px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.vein-v1 .vn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--acc); flex: none; }
.vein-v1 .vn .str { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--good); background: rgba(52,207,116,.15); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.vein-blk + .vein-blk { margin-top: 11px; }
.vein-ev { font-size: 13.5px; color: var(--tx-2); line-height: 1.5; }
.ai-evlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ai-evlist li { font-size: 12.5px; color: var(--tx-2); line-height: 1.45; padding-left: 14px; position: relative; }
.ai-evlist li::before { content: "•"; position: absolute; left: 3px; top: -1px; color: var(--tx-3); }
/* идея V1 (сетка) */
.idea-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .idea-grid { grid-template-columns: 1fr; } }
.idea-v1 { padding: 14px 15px; display: flex; flex-direction: column; gap: 9px; }
.idea-v1 .it { font-size: 14.5px; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; }
.idea-v1 .ih { font-size: 13px; color: var(--tx-2); background: var(--acc-dim); border-radius: 9px; padding: 8px 10px; }
.idea-v1 .ih b { color: var(--acc); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 2px; }
.idea-v1 ol { margin: 0; padding-left: 17px; font-size: 12.5px; color: var(--tx-2); display: flex; flex-direction: column; gap: 3px; }
.idea-v1 .if { margin-top: auto; display: flex; align-items: center; gap: 8px; padding-top: 2px; }
/* сила жил (бар) */
.strbars { display: flex; flex-direction: column; gap: 10px; }
.strbar { display: grid; grid-template-columns: 170px 1fr auto; gap: 12px; align-items: center; }
.strbar .snm { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strbar .strack { height: 11px; border-radius: 6px; background: var(--raise); border: 1px solid var(--brd); overflow: hidden; }
.strbar .sfill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--acc), var(--acc-hover)); }
.strbar .sval { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--acc); font-size: 13px; }
@media (max-width: 560px) { .strbar { grid-template-columns: 108px 1fr auto; gap: 8px; } }
.ch-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.ch-modal-head .modal-cancel { font-size: 15px; }
.ch-stats { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .ch-stats { grid-template-columns: 1fr 1fr; } }

/* ─────────────────────────── Мобильный сайдбар ─────────────────────────── */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
@media (max-width: 820px) {
    .app { grid-template-columns: 1fr; }
    .menu-btn { display: inline-flex !important; }
    .side {
        position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; width: 250px; z-index: 50;
        border-radius: 0 16px 16px 0; transform: translateX(-108%); transition: transform .25s ease;
    }
    .side.open { transform: none; }
    .scrim.show { display: block; }
}

@media (max-width: 680px) {
    .card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ─── Нативный документ-разбор (полный разбор ниши/канала) ─── */
.doc-overlay { position: fixed; inset: 0; z-index: 200; background: var(--bg); overflow-y: auto; padding: 24px 16px 60px; }
.doc-overlay .doc { max-width: 820px; margin: 0 auto; }
.doc-overlay .doc-h { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.doc-overlay .doc-h h1 { font-size: 22px; font-weight: 700; margin: 0 0 2px; }
.doc-overlay .doc-h .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.doc-overlay .doc-meta { font-size: 13px; color: var(--tx-2); margin-bottom: 20px; }
.doc-overlay .sec-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--tx-3); margin: 24px 0 10px; }
.doc-overlay .verdict { background: var(--acc-dim); border: 1px solid var(--acc); border-radius: 13px; padding: 15px 18px; margin-bottom: 16px; }
.doc-overlay .verdict .e { font-size: 12px; color: var(--acc); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.doc-overlay .verdict p { font-size: 14px; line-height: 1.5; margin: 6px 0 0; }
.doc-overlay .verdict ul { margin: 10px 0 0; padding-left: 18px; font-size: 13.5px; line-height: 1.6; }
.doc-overlay .tiles { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
.doc-overlay .tile { background: var(--raise); border-radius: 12px; padding: 14px 16px; }
.doc-overlay .tile .lbl { font-size: 12px; color: var(--tx-2); }
.doc-overlay .tile .val { font-size: 23px; font-weight: 700; margin-top: 4px; }
.doc-overlay .grid3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.doc-overlay .hit { background: var(--raise); border: 1px solid var(--brd); border-radius: 13px; overflow: hidden; text-decoration: none; color: inherit; display: block; }
.doc-overlay .hit .ht { height: 96px; background-size: cover; background-position: center; display: flex; align-items: flex-start; padding: 9px; }
.doc-overlay .hit .hb { padding: 12px 14px; }
.doc-overlay .hit h4 { font-size: 14px; font-weight: 600; margin: 0 0 6px; line-height: 1.3; }
.doc-overlay .hit p { font-size: 12.5px; color: var(--tx-2); line-height: 1.45; margin: 0; }
.doc-overlay .vein { background: var(--raise); border: 1px solid var(--brd); border-radius: 13px; padding: 15px; }
.doc-overlay .vein h4 { font-size: 14.5px; font-weight: 600; margin: 0 0 7px; }
.doc-overlay .vein .ev { font-size: 12.5px; color: var(--tx-2); line-height: 1.5; }
.doc-overlay .vein .vbar { height: 5px; border-radius: 99px; background: var(--raise); margin-top: 11px; overflow: hidden; border: 1px solid var(--brd); }
.doc-overlay .vein .vbar i { display: block; height: 100%; background: var(--acc); border-radius: 99px; }
@media (max-width: 720px) { .doc-overlay .tiles, .doc-overlay .grid3 { grid-template-columns: 1fr; } }
@media print {
    body > *:not(.doc-overlay) { display: none !important; }
    .doc-overlay { position: static; padding: 0; overflow: visible; background: #fff; }
    .doc-overlay .acts { display: none !important; }
}

/* Круглая иконка пустого состояния (напр. «Мой канал» без подключения). */
.empty .ei { width: 64px; height: 64px; border-radius: 18px; background: var(--acc-dim); color: var(--acc); display: grid; place-items: center; margin: 0 auto 18px; }

/* ─── Копирайтер (инлайн-панель заголовков/описания в карточке идеи) ─── */
.cw-panel { display: none; padding: 10px 8px 6px 30px; }
.cw-panel.show { display: block; }
.cw-topic { padding: 0 0 10px; border-bottom: 1px solid var(--brd); margin-bottom: 12px; }
.cw-sec-t { font-size: 12px; font-weight: 600; color: var(--tx-2); text-transform: uppercase; letter-spacing: .03em; }
.cw-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cw-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--raise); border: 1px solid var(--brd); border-radius: 10px; }
.cw-t { flex: 1; min-width: 0; font-size: 14px; }
.cw-row .cw-copy { flex: 0 0 auto; }
.cw-desc { margin-top: 8px; padding: 12px 14px; background: var(--raise); border: 1px solid var(--brd); border-radius: 10px; font-size: 13.5px; line-height: 1.5; }
