/* ============================================================
   Админка «Клерк.Консультант» — единый стиль.
   Тон задан по образцу bisness-bot: синяя активная «пилюля»,
   мягкие скругления, типографическая шкала, живые карточки.
   ============================================================ */

:root {
    --red: #EF3124; --red-dark: #d42b1f;
    --blue: #306FEE; --blue-dark: #1a5ad9;
    --gray-50: #F7F7F8; --gray-100: #eeeef0; --gray-200: #dddde0;
    --gray-300: #c4c4c8; --gray-400: #9999a0; --gray-500: #666670;
    --gray-600: #444450; --gray-700: #222230; --gray-800: #1b1b24; --gray-900: #111119;
    --bg: #F7F7F8; --white: #fff;
    --ok-bg: #f0fdf4; --ok-fg: #16a34a; --ok-br: #bbf7d0;
    --err-bg: #fef2f2; --err-fg: #dc2626; --err-br: #fecaca;
    --amber: #f59e0b; --amber-dark: #d97706;
    --radius: 14px; --radius-md: 12px; --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.05);
    --shadow-hover: 0 6px 20px rgba(16,24,40,.08);
    --font: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html { font-size: 16px; }
body {
    font-family: var(--font); background: var(--bg); color: var(--gray-900);
    line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }
h1, h2, h3 { letter-spacing: -0.01em; }

/* Поля ввода */
input, textarea, select {
    font-family: inherit; font-size: 0.9rem; line-height: 1.4; padding: 9px 12px;
    border: 1px solid var(--gray-200); border-radius: var(--radius-sm); background: var(--white);
    color: var(--gray-900); outline: none; width: 100%; transition: border .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--gray-400); }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(48,111,238,.13); }
select:disabled { background: var(--gray-100); color: var(--gray-400); cursor: not-allowed; }
label { display: block; font-size: 0.9rem; color: var(--gray-700); font-weight: 500; }
label input, label textarea, label select { margin-top: 6px; font-weight: 400; }

/* Кнопки */
button, .btn-sm {
    font-family: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; line-height: 1.2;
    text-decoration: none;
}
button:active, .btn-sm:active { transform: translateY(1px); }
.btn-red { background: var(--red); color: #fff; } .btn-red:hover { background: var(--red-dark); }
.btn-blue { background: var(--blue); color: #fff; } .btn-blue:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--white); color: var(--gray-600); border-color: var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }
.btn-gray { background: var(--gray-300); color: var(--gray-900); } .btn-gray:hover { background: var(--gray-400); }
.btn-danger { background: var(--err-bg); color: var(--err-fg); border-color: var(--err-br); }
.btn-danger:hover { background: #fee2e2; }

/* Утилиты */
.muted { color: var(--gray-500); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- Логин */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-form {
    background: var(--white); padding: 40px; border-radius: var(--radius); border: 1px solid var(--gray-200);
    box-shadow: 0 8px 32px rgba(16,24,40,.08); width: 100%; max-width: 380px;
    display: flex; flex-direction: column; gap: 16px;
}
.login-form .logo-block { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-form .logo-sq { width: 44px; height: 44px; border-radius: 12px; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.4rem; flex-shrink: 0; }
.login-form h1 { font-size: 1.25rem; font-weight: 700; }
.login-form button { width: 100%; padding: 11px; font-size: 0.95rem; }
.login-form .field { display: flex; flex-direction: column; gap: 5px; }
.field-error { color: var(--red); font-size: .82rem; min-height: 1.1em; line-height: 1.2; }
input.input-invalid { border-color: var(--red); }
input.input-invalid:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(239,49,36,.15); }
.error { color: var(--red); font-size: .9rem; min-height: 1.25rem; text-align: center; }

/* ---------------------------------------------------------- Каркас */
.admin-layout { display: flex; min-height: 100vh; background: var(--bg); }
.admin-nav {
    width: 250px; min-height: 100vh; background: var(--white); border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column; gap: 3px; padding: 20px 14px 16px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.nav-logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; border-bottom: 1px solid var(--gray-100); margin-bottom: 10px; }
.nav-logo .sq { width: 34px; height: 34px; border-radius: 9px; background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.05rem; flex-shrink: 0; }
.nav-logo span { font-weight: 700; font-size: 1rem; color: var(--gray-900); line-height: 1.2; letter-spacing: -0.01em; }
.admin-nav a { display: block; padding: 9px 12px; color: var(--gray-600); font-size: 0.89rem; font-weight: 500; border-radius: var(--radius-sm); transition: background .12s, color .12s, box-shadow .12s; line-height: 1.2; }
.admin-nav a:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.admin-nav a.active { background: var(--blue); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(48,111,238,.3); }
.admin-nav a.active:hover { background: var(--blue-dark); color: #fff; }
.nav-sep { height: 1px; background: var(--gray-200); margin: 8px 4px; }
.nav-group-label { padding: 4px 12px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-400); }
.nav-user { padding: 6px 12px; font-size: 0.74rem; color: var(--gray-400); }
.spacer { flex: 1; }
.admin-nav a.nav-logout { color: var(--red); }
.admin-nav a.nav-logout:hover { background: var(--err-bg); color: var(--red); }

.admin-main { flex: 1; min-width: 0; padding: 36px 44px; display: flex; justify-content: center; }
.admin-main-inner { width: 100%; max-width: 1180px; }
.admin-main > a.back-link { color: var(--blue); font-size: 0.85rem; font-weight: 500; }

/* ---------------------------------------------------------- Шапка страницы */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin-bottom: 4px; }
.page-head h2 { font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.page-head .sub { color: var(--gray-500); font-size: 0.85rem; margin-top: 2px; max-width: 60ch; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------- Статистика */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s, border-color .15s; }
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.stat-card-link { text-decoration: none; color: inherit; cursor: pointer; }
.stat-card-link:hover { border-color: var(--gray-300); text-decoration: none; }
.stat-card.accent-blue { border-left: 3px solid var(--blue); }
.stat-card.accent-amber { border-left: 3px solid var(--amber); }
.stat-card.accent-red { border-left: 3px solid var(--red); }
.stat-value { font-size: 2.1rem; font-weight: 700; color: var(--gray-900); line-height: 1.1; letter-spacing: -0.02em; }
.stat-value.blue { color: var(--blue); }
.stat-value.amber { color: var(--amber-dark); }
.stat-value.red { color: var(--red); }
.stat-label { font-size: 0.82rem; color: var(--gray-500); font-weight: 500; }
.stat-label .delta { color: var(--gray-400); }

/* ---------------------------------------------------------- Таблица */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--gray-200); box-shadow: var(--shadow); background: var(--white); }
.table-wrap .chats-table { border: none; border-radius: 0; box-shadow: none; }
.chats-table { width: 100%; border-collapse: collapse; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow); }
.chats-table th { text-align: left; padding: 11px 16px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); background: var(--gray-50); white-space: nowrap; }
.chats-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: top; font-size: 0.88rem; }
.chats-table tr:last-child td { border-bottom: none; }
.chats-table tbody tr:hover td { background: var(--gray-50); }
.cell-meta { font-size: 0.8rem; color: var(--gray-500); white-space: nowrap; }
.cell-empty { text-align: center; color: var(--gray-400); padding: 32px; }
.row-actions a { font-size: 0.82rem; color: var(--gray-500); }
.row-actions a:hover { color: var(--gray-900); }
.link-danger { color: var(--err-fg) !important; }

/* ---------------------------------------------------------- Карточка */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 20px 24px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.card-tight { padding: 16px 18px; }
.card-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; font-size: 0.9rem; }

/* ---------------------------------------------------------- Поиск / тулбар */
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { flex: 1; }
.search-form a { color: var(--gray-500); align-self: center; font-size: 0.85rem; }
.search-form a:hover { color: var(--red); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input { max-width: 340px; }
.toolbar select { width: auto; }

/* ---------------------------------------------------------- Промпт */
.prompt-editor { width: 100%; min-height: 480px; font-family: var(--mono); font-size: 0.84rem; line-height: 1.6; resize: vertical; border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 16px; background: var(--gray-50); color: var(--gray-700); }
.prompt-editor:focus { border-color: var(--blue); background: var(--white); }
.hint { font-size: 0.82rem; color: var(--gray-600); background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 16px; line-height: 1.5; }
.hint code { background: var(--gray-200); padding: 1px 6px; border-radius: 4px; font-size: 0.8rem; }
.note-ok { background: var(--ok-bg); border: 1px solid var(--ok-br); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; color: var(--ok-fg); font-size: 0.9rem; }

/* ---------------------------------------------------------- Статус-тост */
.status-msg { position: fixed; top: 20px; right: 20px; z-index: 1000; max-width: 380px; padding: 12px 18px; border-radius: var(--radius-sm); font-size: 0.9rem; box-shadow: 0 8px 24px rgba(16,24,40,.14); display: none; }
.status-msg.ok { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-br); display: block; }
.status-msg.error { background: var(--err-bg); color: var(--err-fg); border: 1px solid var(--err-br); display: block; }

/* ---------------------------------------------------------- Бейджи */
.badge { display: inline-block; font-size: 0.7rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; background: var(--gray-100); color: var(--gray-600); }
.badge.on { background: var(--ok-bg); color: var(--ok-fg); }
.badge.off { background: var(--err-bg); color: var(--err-fg); }
.badge.info { background: #eef2ff; color: #3730a3; }
.badge.warn { background: #fff7ed; color: #9a3412; }
.badge.hidden { background: #fde8e8; color: var(--red-dark); }
.sub-badge { font-size: 0.7rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; }
.sub-badge.yes { background: var(--ok-bg); color: var(--ok-fg); }
.sub-badge.no { background: var(--err-bg); color: var(--err-fg); }
.badge-test { background: var(--err-bg); color: var(--red); font-size: 0.66rem; padding: 2px 8px; border-radius: 20px; margin-left: 8px; vertical-align: middle; }

/* ---------------------------------------------------------- Иконки-кнопки */
.icon-btn { background: none; border: 1px solid var(--gray-200); border-radius: 7px; padding: 5px 10px; cursor: pointer; font-size: 0.76rem; font-weight: 500; color: var(--gray-600); transition: all .15s; }
.icon-btn:hover { background: var(--gray-100); color: var(--gray-900); }
.icon-btn.danger { color: var(--red); }
.icon-btn.danger:hover { background: var(--err-bg); }

/* ---------------------------------------------------------- Чат-лог */
.chat-log { display: flex; flex-direction: column; gap: 14px; max-width: 880px; margin-top: 20px; }
.log-message { border-radius: var(--radius-md); padding: 16px 18px; border: 1px solid var(--gray-200); background: var(--white); }
.log-message.user { border-left: 3px solid var(--blue); }
.log-message.assistant { border-left: 3px solid var(--red); }
.log-role { font-size: 0.85rem; font-weight: 700; color: var(--gray-600); margin-bottom: 2px; }
.log-time { font-size: 0.75rem; color: var(--gray-400); margin-bottom: 8px; }
.log-content { font-size: 0.9rem; line-height: 1.6; word-break: break-word; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.log-text { white-space: pre-wrap; }
.tool-badge { display: inline-flex; align-items: center; gap: 5px; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 6px; padding: 2px 9px; font-size: 0.8rem; color: var(--gray-600); font-family: var(--mono); }

/* Карточка рекомендованного трека в логе */
.log-track { width: 100%; max-width: 520px; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; }
.log-track-head { padding: 9px 14px; background: var(--blue); color: #fff; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.log-track-summary { padding: 11px 14px 2px; font-size: .92rem; line-height: 1.5; color: var(--gray-700); }
.log-track-course { padding: 11px 14px; border-top: 1px solid var(--gray-200); display: flex; flex-direction: column; gap: 4px; }
.log-track-tag { font-size: .66rem; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .05em; }
.log-track-title { font-size: .95rem; font-weight: 600; line-height: 1.3; }
.log-track-title a { color: var(--blue); }
.log-track-why { font-size: .85rem; color: var(--gray-600); line-height: 1.5; }
.log-track-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .8rem; color: var(--gray-400); margin-top: 2px; }
.log-pill { display: inline-block; font-size: .72rem; padding: 2px 9px; border-radius: 100px; background: #eff6ff; color: var(--blue); font-weight: 600; }
.log-track-link { color: var(--blue); font-weight: 600; }
.log-track-notes { margin: 0; padding: 6px 14px 12px 30px; }
.log-track-notes li { font-size: .8rem; color: var(--gray-600); line-height: 1.5; }

/* ---------------------------------------------------------- Формы (настройки/пользователи) */
.settings-card { margin-bottom: 24px; max-width: 760px; }
.settings-card h2 { font-size: 1.05rem; margin: 0 0 14px; }
.field-label { display: block; font-size: 0.78rem; color: var(--gray-500); margin: 14px 0 6px; font-weight: 600; }
.switch-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; cursor: pointer; }
.switch-row > span:nth-child(2) { font-weight: 600; }
.switch-hint { flex-basis: 100%; font-size: 0.78rem; color: var(--gray-400); margin-left: 28px; }
.kv-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 0.9rem; }
.kv-row:last-of-type { border-bottom: none; }
.kv-key { width: 220px; flex-shrink: 0; color: var(--gray-500); }
.kv-val { color: var(--gray-900); }
.w-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .w-grid { grid-template-columns: 1fr; } }
.user-add-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.user-add-form input, .user-add-form select { width: auto; flex: 1 1 180px; }
.role-select { width: auto; padding: 5px 8px; border-radius: 6px; font-size: 0.82rem; cursor: pointer; }

/* ---------------------------------------------------------- Метрики / графики аналитики */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.metric-value { font-size: 1.6rem; font-weight: 700; color: var(--blue); letter-spacing: -0.02em; }
.metric-label { font-size: 0.82rem; color: var(--gray-500); }

.chart-card { margin-bottom: 24px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.chart-head h2 { font-size: 1.05rem; margin: 0; }
.chart-legend { display: flex; gap: 16px; font-size: 0.82rem; color: var(--gray-600); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* Воронка */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 200px; flex-shrink: 0; font-size: 0.85rem; color: var(--gray-600); text-align: right; }
.funnel-track { flex: 1; background: var(--gray-100); border-radius: 8px; min-width: 0; }
.funnel-bar { min-width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; padding: 0 12px; transition: width .4s ease; }
.funnel-count { color: #fff; font-weight: 700; font-size: 0.9rem; }
.funnel-bar.step1 { background: #2563eb; } .funnel-bar.step2 { background: #4f86f0; }
.funnel-bar.step3 { background: var(--red); } .funnel-bar.step4 { background: var(--red-dark); }
.funnel-bar.step-mgr { background: var(--amber); }
.funnel-pct { width: 56px; flex-shrink: 0; font-size: 0.85rem; font-weight: 600; color: var(--gray-500); }
.funnel-aside { margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--gray-200); }
.funnel-aside .funnel-label { color: var(--gray-400); }

/* Топ-темы / источники */
.topics { display: flex; flex-direction: column; gap: 8px; }
.topic-row { display: flex; align-items: center; gap: 12px; }
.topic-word { width: 200px; flex-shrink: 0; font-size: 0.85rem; color: var(--gray-600); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-track { flex: 1; background: var(--gray-100); border-radius: 6px; min-width: 0; }
.topic-bar { height: 22px; min-width: 4px; background: #4f86f0; border-radius: 6px; transition: width .4s ease; }
.topic-count { width: 40px; flex-shrink: 0; font-size: 0.82rem; font-weight: 600; color: var(--gray-500); }

/* Столбчатый график (заказ/менеджер) */
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-stack { flex: 1; width: 100%; max-width: 22px; margin: 0 auto; display: flex; flex-direction: column; justify-content: flex-end; }
.bar-chart .bar { width: 100%; min-height: 2px; }
.bar-ord { background: var(--red); border-radius: 3px 3px 0 0; }
.bar-mgr { background: var(--blue); }
.bar-stack:has(.bar-ord) .bar-mgr { border-radius: 0; }
.bar-stack .bar-mgr:only-child { border-radius: 3px 3px 0 0; }
.bar-label { font-size: 0.6rem; color: var(--gray-400); white-space: nowrap; transform: rotate(-45deg); transform-origin: center; height: 14px; }

/* Мини-бары (распределения) */
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.bar-track { flex: 0 0 140px; background: var(--gray-100); border-radius: 5px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; }
.bar-fill.red { background: var(--red); }
.bar-fill.blue { background: var(--blue); }
.bar-count { flex: 0 0 40px; text-align: right; color: var(--gray-600); }

/* Сравнение периодов */
.compare-grid, .period-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.compare-card, .period-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.compare-card .row1 { display: flex; align-items: baseline; gap: 10px; }
.compare-card .now, .period-now { font-size: 1.7rem; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; }
.compare-card .lbl, .period-label { font-size: 0.82rem; color: var(--gray-500); margin-top: 4px; }
.compare-card .prev, .period-prev { font-size: 0.74rem; color: var(--gray-400); margin-top: 2px; }
.period-delta { font-size: 0.85rem; font-weight: 600; margin-top: 4px; }
.period-delta.up { color: var(--ok-fg); } .period-delta.down { color: var(--red); }

/* Стрелки дельт */
.delta-pill { display: inline-flex; align-items: center; gap: 3px; font-size: .82rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; }
.delta-pill.up { background: var(--ok-bg); color: var(--ok-fg); }
.delta-pill.down { background: var(--err-bg); color: var(--err-fg); }
.delta-pill.flat { background: var(--gray-100); color: var(--gray-500); }

/* Мини-график по дням */
.daychart { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding: 8px 0; }
.daychart .col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.daychart .col .b { background: var(--blue); border-radius: 3px 3px 0 0; min-height: 2px; transition: background .1s; }
.daychart .col:hover .b { background: var(--red); }
.daychart .col .tip { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--gray-900); color: #fff; font-size: .78rem; padding: 3px 7px; border-radius: 5px; white-space: nowrap; z-index: 5; }
.daychart .col:hover .tip { display: block; }
.daychart-axis { display: flex; justify-content: space-between; font-size: .8rem; color: var(--gray-400); margin-top: 4px; }

/* ---------------------------------------------------------- Прайс/каталог (карточки категорий) */
.price-cat { margin-bottom: 18px; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; }
.price-cat.inactive { opacity: 0.55; }
.price-cat-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.price-cat-head .title { font-weight: 600; font-size: 1rem; }
.price-cat-head .desc { font-size: 0.8rem; color: var(--gray-400); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price-cat-head .count { font-size: 0.78rem; color: var(--gray-400); white-space: nowrap; }
.price-item { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--gray-100); }
.price-item:last-child { border-bottom: none; }
.price-item.inactive { opacity: 0.45; }
.price-item .body { flex: 1; min-width: 0; }
.price-item .name { font-size: 0.9rem; font-weight: 500; }
.price-item .desc { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }
.price-item .url-link { font-size: 0.75rem; color: var(--blue); display: inline-block; margin-top: 3px; }
.price-item .price { font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.drag-handle { cursor: grab; color: var(--gray-300); font-size: 1rem; user-select: none; }
.empty-row { padding: 16px; color: var(--gray-400); font-size: 0.85rem; }

/* ---------------------------------------------------------- Модалки */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100; display: none; align-items: center; justify-content: center; animation: fadeIn .15s ease; }
.modal-backdrop.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box { background: var(--white); border-radius: var(--radius); padding: 24px; max-width: 520px; width: 92%; max-height: 88vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.18); }
.modal-box h3 { margin-bottom: 18px; font-size: 1.1rem; }
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-field label { font-size: 0.8rem; color: var(--gray-500); font-weight: 600; }
.form-field textarea { resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; margin: 4px 0 16px; }
.form-check input { width: 18px; height: 18px; }
.modal-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------- Пагинация / прочее */
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 0.9rem; color: var(--gray-500); }
.pagination a { padding: 6px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); color: var(--gray-700); }
.pagination a:hover { background: var(--gray-100); text-decoration: none; }
.pagination strong { color: var(--gray-900); }
.back-link { font-size: 0.85rem; color: var(--gray-500); display: inline-flex; align-items: center; gap: 4px; }
.back-link:hover { color: var(--gray-900); }
details summary { cursor: pointer; font-size: 0.9rem; color: var(--gray-600); }
pre.json { background: var(--gray-100); padding: 12px; border-radius: 6px; overflow: auto; font-size: 0.85rem; line-height: 1.45; }

/* ---------------------------------------------------------- Адаптив */
@media (max-width: 880px) {
    .admin-layout { flex-direction: column; }
    .admin-nav { width: 100%; min-height: 0; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; border-right: none; border-bottom: 1px solid var(--gray-200); }
    .nav-logo { width: 100%; padding: 2px 6px 8px; border-bottom: none; margin-bottom: 0; }
    .nav-sep, .nav-group-label, .spacer, .nav-user { display: none; }
    .admin-nav a { padding: 7px 12px; }
    .admin-main { padding: 20px 16px; }
    .chats-table { display: block; overflow-x: auto; white-space: nowrap; }
}
