/* ==========================================================================
   Social Pulse — Admin Panel
   Дизайн: тёмная data-панель ("mission control"). Референс — плотный
   navy-фон, свечение циан/синего на графиках, монохромные иконки,
   моноширинные цифры для показателей (JetBrains Mono), заголовки на
   геометрическом гротеске (Space Grotesk). Ни одного стиля не было в
   исходном проекте — /static/styles.css отсутствовал физически.
   ========================================================================== */

:root {
    /* фон */
    --bg-deep: #060a1a;
    --bg-app: #0a1128;
    --bg-card: #0e1730;
    --bg-card-alt: #121d3d;
    --bg-input: #0a1330;
    --bg-hover: #16224a;

    /* акценты данных */
    --cyan: #29e2e6;
    --cyan-dim: rgba(41, 226, 230, .14);
    --blue: #4d7cfe;
    --blue-dim: rgba(77, 124, 254, .14);
    --violet: #8b7bff;
    --violet-dim: rgba(139, 123, 255, .14);
    --amber: #f5b342;
    --amber-dim: rgba(245, 179, 66, .14);
    --rose: #fb6f92;
    --rose-dim: rgba(251, 111, 146, .14);
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, .14);

    --success: var(--green);
    --warning: var(--amber);
    --danger: var(--rose);

    /* текст */
    --text-primary: #eaf0ff;
    --text-secondary: #9aa6d4;
    --text-muted: #64709e;

    --border: rgba(148, 163, 220, .12);
    --border-strong: rgba(148, 163, 220, .22);

    --radius: 14px;
    --radius-sm: 9px;
    --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* лёгкое звёздное поле фона — единственный "рискованный" декоративный
   элемент, задаёт атмосферу data-центра, не мешает читаемости */
body {
    background-image:
        radial-gradient(circle at 15% 8%, rgba(41,226,230,.05), transparent 40%),
        radial-gradient(circle at 85% 92%, rgba(77,124,254,.06), transparent 45%);
    background-attachment: fixed;
}

a { color: var(--cyan); text-decoration: none; }
.text-muted { color: var(--text-muted) !important; }
code {
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 5px;
    font-size: .85em;
    color: var(--cyan);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ==========================================================================
   ЛОГИН
   ========================================================================== */

.login-screen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(41,226,230,.10), transparent 45%),
        radial-gradient(circle at 75% 80%, rgba(139,123,255,.10), transparent 45%),
        var(--bg-deep);
    z-index: 500;
}
.login-screen.hidden { display: none; }

.login-box {
    width: 380px; max-width: 92vw;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 0 1px rgba(41,226,230,.04);
    text-align: center;
}
.login-logo {
    width: 56px; height: 56px; margin: 0 auto 18px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 20px;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    color: #04101f;
    box-shadow: 0 0 30px rgba(41,226,230,.35);
}
.login-box h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.login-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }

.form-group { text-align: left; margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 12px; color: var(--text-secondary);
    margin-bottom: 6px; letter-spacing: .02em;
}
.form-control {
    width: 100%; padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-dim);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; font-family: var(--font-mono); }
select.form-control { cursor: pointer; }

.login-error, .lockout-info {
    display: none;
    margin-top: 14px;
    font-size: 12.5px;
    color: var(--danger);
}
.login-error.show, .lockout-info.show { display: block; }
.lockout-info.show { color: var(--text-secondary); }
.lock-timer {
    font-family: var(--font-mono); font-size: 22px; font-weight: 600;
    color: var(--danger); margin-top: 4px;
}

/* ==========================================================================
   КНОПКИ
   ========================================================================== */

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font-display); font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all .15s;
    white-space: nowrap;
}
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-primary {
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    color: #04101f; font-weight: 600;
    box-shadow: 0 4px 16px rgba(41,226,230,.20);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-secondary {
    background: var(--bg-hover); color: var(--text-primary); border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--border-strong); }
.btn-danger { background: var(--rose-dim); color: var(--rose); border-color: rgba(251,111,146,.3); }
.btn-danger:hover { background: rgba(251,111,146,.22); }
.btn:active { transform: scale(.97); }

/* ==========================================================================
   ЛЭЙАУТ / САЙДБАР
   ========================================================================== */

.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 246px;
    background: var(--bg-app);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 20px; border-bottom: 1px solid var(--border);
}
.brand-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-weight: 700; font-size: 14px;
    background: linear-gradient(135deg, var(--cyan), var(--blue));
    color: #04101f;
}
.brand-name { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-section-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-muted); padding: 14px 10px 6px;
}
.nav-section-label:first-child { padding-top: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    font-size: 13.2px; color: var(--text-secondary);
    cursor: pointer; transition: all .12s;
    position: relative;
}
.nav-item i:first-child { width: 16px; text-align: center; font-size: 13.5px; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
    background: var(--cyan-dim); color: var(--cyan);
}
.nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
    background: var(--cyan); border-radius: 0 3px 3px 0;
}
.nav-item .badge {
    margin-left: auto;
    background: var(--bg-input); color: var(--text-secondary);
    font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
    padding: 2px 7px; border-radius: 20px; border: 1px solid var(--border);
}
.nav-item.active .badge { background: rgba(41,226,230,.18); color: var(--cyan); border-color: transparent; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.bot-status { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-secondary); }
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--rose); }
@keyframes pulse-dot {
    0%, 100% { opacity: 1; } 50% { opacity: .4; }
}

.main-wrapper { margin-left: 246px; min-height: 100vh; display: flex; flex-direction: column; }

.top-header {
    height: 64px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(10,17,40,.7);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 17px; font-weight: 600; }
.header-actions { display: flex; gap: 8px; }
.header-btn {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer; transition: all .15s;
}
.header-btn:hover { color: var(--cyan); border-color: var(--border-strong); }

.content-area { flex: 1; padding: 24px 28px 60px; max-width: 1560px; width: 100%; margin: 0 auto; }

.page { display: none; }
.page.active { display: block; animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==========================================================================
   ДАШБОРД — ПАНЕЛЬ ИНСТРУМЕНТОВ / РЕЖИМ НАСТРОЙКИ
   ========================================================================== */

.dash-toolbar {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.dash-toolbar-title { margin: 0; font-size: 17px; font-weight: 600; }
.dash-toolbar-actions { display: flex; gap: 8px; }
#dashCustomizeBtn.active { background: var(--cyan-dim); color: var(--cyan); border-color: transparent; }

.widget-library {
    display: none;
    background: var(--bg-card-alt); border: 1px dashed var(--border-strong);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.widget-library.show { display: block; animation: fade-in .2s ease; }
.widget-library-head {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
    font-size: 12.5px; color: var(--text-secondary); margin-bottom: 10px;
}
.widget-library-head i { color: var(--cyan); }
.widget-library-list { display: flex; flex-wrap: wrap; gap: 8px; }
.widget-library-empty { font-size: 12px; color: var(--text-muted); padding: 6px 0; }
.widget-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 20px; padding: 7px 14px 7px 12px; font-size: 12px;
    cursor: pointer; transition: all .15s;
}
.widget-chip:hover { border-color: var(--cyan); color: var(--cyan); }
.widget-chip i.fa-plus { font-size: 10px; color: var(--cyan); }

/* режим настройки: показать ручки, подсветить сетку */
.grid-stack.edit-mode {
    background-image: linear-gradient(rgba(41,226,230,.05) 1px, transparent 1px);
    background-size: 100% calc(100% / 14);
    border-radius: var(--radius);
}
.grid-stack.edit-mode .grid-stack-item-content { outline: 1.5px dashed rgba(41,226,230,.25); }
.grid-stack.edit-mode .panel { cursor: grab; }
.grid-stack.edit-mode .widget-remove { display: flex; }
.grid-stack-item:not(.ui-draggable-disabled) .grid-stack-item-content { transition: outline-color .15s; }

.widget-remove {
    display: none; margin-left: auto;
    width: 22px; height: 22px; border-radius: 50%;
    align-items: center; justify-content: center;
    background: var(--rose-dim); color: var(--rose); border: none; cursor: pointer;
    font-size: 10px; flex-shrink: 0;
}
.widget-remove:hover { background: rgba(251,111,146,.3); }

/* ==========================================================================
   GRIDSTACK — тёмная тема, компактные виджеты
   ========================================================================== */

.grid-stack { margin: 0; }
.grid-stack-item-content {
    inset: 0 !important;
    overflow: hidden; border-radius: var(--radius);
    container-type: inline-size;
    container-name: widget;
}
.grid-stack-item-content .panel { height: 100%; margin: 0; }
.grid-stack-item-content .panel canvas { max-height: 100%; }
.ui-resizable-handle { z-index: 20; }
.ui-resizable-se {
    width: 14px !important; height: 14px !important;
    background: var(--cyan-dim) !important; border-radius: 4px 0 8px 0;
}
.ui-resizable-e { width: 8px !important; background: transparent; cursor: ew-resize; }
.ui-resizable-s { height: 8px !important; background: transparent; cursor: ns-resize; }
.grid-stack.edit-mode .ui-resizable-e:hover,
.grid-stack.edit-mode .ui-resizable-s:hover { background: var(--cyan-dim) !important; }
/* GridStack сам показывает/скрывает ручки в зависимости от setStatic() —
   не дублируем это через CSS-видимость, чтобы не рассинхронизироваться
   с фактическими классами библиотеки и не сделать ручку невидимой,
   но при этом технически кликабельной. */
.grid-stack-placeholder > .placeholder-content {
    background: var(--cyan-dim) !important; border: 1.5px dashed var(--cyan) !important;
    border-radius: var(--radius) !important;
}

/* ==========================================================================
   ДАШБОРД — KPI (компактнее, чем в первой версии)
   ========================================================================== */

.kpi-grid {
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;
    height: 100%;
}
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 13px 11px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.kpi-label { font-size: 10.8px; color: var(--text-secondary); font-weight: 500; }
.kpi-icon { font-size: 12px; color: var(--text-muted); }
.kpi-icon.accent-cyan { color: var(--cyan); }
.kpi-icon.accent-violet { color: var(--violet); }
.kpi-icon.accent-rose { color: var(--rose); }
.kpi-value {
    font-family: var(--font-mono); font-size: 22px; font-weight: 700;
    letter-spacing: -.01em; line-height: 1; margin-bottom: 6px;
    font-variant-numeric: tabular-nums;
}
.kpi-delta { font-size: 10.3px; color: var(--green); display: flex; align-items: center; gap: 4px; }
.kpi-delta.neutral { color: var(--text-muted); }
.kpi-delta i { font-size: 8px; }

/* ==========================================================================
   ПАНЕЛИ (компактнее)
   ========================================================================== */

.panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 15px 12px;
    display: flex; flex-direction: column; overflow: hidden;
}
.panel canvas { flex: 1; min-height: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 12.8px; font-weight: 600; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.panel-head h3 i { color: var(--cyan); font-size: 12px; }
.panel-note { font-size: 10.3px; color: var(--text-muted); }

/* ---- адаптивный текст внутри виджетов: масштабируется по размеру
   самого виджета (container query), а не по размеру окна браузера —
   поэтому растянутый вширь виджет получает крупный шрифт, а сжатый
   в узкую колонку — компактный, независимо от разрешения экрана ---- */
@container widget (max-width: 260px) {
    .panel-head h3 { font-size: 11.5px; }
    .panel-head h3 i { font-size: 10.5px; }
    .panel-note { display: none; }
    .kpi-value { font-size: 18px; }
    .kpi-label { font-size: 10px; }
    .top-place-name { font-size: 12px; }
    .query-chip, .health-bar-top { font-size: 10.5px; }
}
@container widget (min-width: 520px) {
    .panel-head h3 { font-size: 14.5px; }
    .kpi-value { font-size: 25px; }
    .top-place-name { font-size: 14px; }
}
@container widget (min-width: 780px) {
    .panel-head h3 { font-size: 16px; }
    .panel-note { font-size: 11.5px; }
}

.range-switch { display: flex; gap: 3px; background: var(--bg-input); border-radius: 8px; padding: 3px; }
.range-btn {
    border: none; background: transparent; color: var(--text-muted);
    font-family: var(--font-mono); font-size: 10.5px; padding: 4px 9px;
    border-radius: 6px; cursor: pointer; transition: all .15s;
}
.range-btn.active { background: var(--cyan-dim); color: var(--cyan); }
.range-btn:hover:not(.active) { color: var(--text-secondary); }

/* ---- карта ---- */
.panel-map { padding: 14px 15px 10px; }
.world-map {
    flex: 1; min-height: 0; border-radius: 10px; overflow: hidden;
    background: #071022; border: 1px solid var(--border);
}
.map-legend { display: flex; gap: 16px; margin-top: 9px; font-size: 10.5px; color: var(--text-secondary); flex-shrink: 0; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-dot.exact { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.legend-dot.estimated { background: var(--violet); box-shadow: 0 0 6px var(--violet); }

/* маркеры Leaflet */
.geo-marker { display: flex; align-items: center; justify-content: center; position: relative; }
.geo-marker-dot {
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    font-family: var(--font-mono); font-weight: 700; color: #04101f;
    background: radial-gradient(circle at 35% 30%, #6ff2f4, var(--cyan));
    box-shadow: 0 0 0 4px rgba(41,226,230,.14), 0 0 18px rgba(41,226,230,.55);
}
.geo-marker-dot.is-est {
    background: radial-gradient(circle at 35% 30%, #c2b8ff, var(--violet));
    box-shadow: 0 0 0 4px rgba(139,123,255,.14), 0 0 18px rgba(139,123,255,.5);
}
.geo-marker-ping {
    position: absolute; inset: 0; border-radius: 50%;
    border: 1.5px solid var(--cyan); opacity: 0;
    animation: geo-ping 2.6s ease-out infinite;
}
.geo-marker-dot.is-est ~ .geo-marker-ping { border-color: var(--violet); }
@keyframes geo-ping {
    0% { transform: scale(.6); opacity: .55; }
    100% { transform: scale(2.1); opacity: 0; }
}
.leaflet-popup-content-wrapper {
    background: var(--bg-card-alt); color: var(--text-primary);
    border: 1px solid var(--border-strong); border-radius: 10px;
    font-family: var(--font-display);
}
.leaflet-popup-tip { background: var(--bg-card-alt); }
.leaflet-popup-content { margin: 10px 12px; font-size: 12.5px; }
.leaflet-popup-content b { font-family: var(--font-mono); color: var(--cyan); font-size: 15px; }
.leaflet-container { background: #071022 !important; font-family: var(--font-display); }
.leaflet-control-attribution {
    background: rgba(6,10,26,.7) !important; color: var(--text-muted) !important;
    font-size: 9.5px !important;
}
.leaflet-control-attribution a { color: var(--text-secondary) !important; }
.leaflet-control-zoom a {
    background: var(--bg-card-alt) !important; color: var(--text-secondary) !important;
    border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { color: var(--cyan) !important; }

/* ---- донаты ---- */
.donut-wrap { position: relative; height: 168px; margin-bottom: 6px; }
.legend-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-row .sw { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-row .lbl { color: var(--text-secondary); flex: 1; }
.legend-row .val { font-family: var(--font-mono); color: var(--text-primary); font-weight: 600; }

/* ---- retention rings ---- */
.retention-rings { display: flex; justify-content: space-around; align-items: center; flex: 1; padding-top: 6px; }
.ring-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ring {
    width: 74px; height: 74px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.ring::before {
    content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg-card);
}
.ring-val { position: relative; font-family: var(--font-mono); font-weight: 700; font-size: 15px; }
.ring-label { font-size: 10.5px; color: var(--text-muted); text-align: center; }

/* ---- топ мест ---- */
.top-places-list { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
.top-place-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 4px; border-bottom: 1px solid var(--border);
}
.top-place-row:last-child { border-bottom: none; }
.top-place-rank {
    width: 24px; text-align: center; font-family: var(--font-mono);
    color: var(--text-muted); font-size: 12px; flex-shrink: 0;
}
.top-place-name { flex: 1; font-size: 13px; font-weight: 500; }
.top-place-cat { font-size: 11px; color: var(--text-muted); }
.top-place-rating {
    font-family: var(--font-mono); font-size: 12.5px; color: var(--amber);
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
}
.sponsor-tag {
    font-size: 9.5px; font-weight: 700; letter-spacing: .04em;
    color: var(--violet); background: var(--violet-dim);
    padding: 2px 7px; border-radius: 20px; flex-shrink: 0;
}

/* ---- полнота карточек каталога (SEO-виджет) ---- */
.health-bars { display: flex; flex-direction: column; gap: 12px; justify-content: center; flex: 1; }
.health-bar-row { display: flex; flex-direction: column; gap: 5px; }
.health-bar-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-secondary); }
.health-bar-top b { font-family: var(--font-mono); color: var(--text-primary); }
.health-bar-track { height: 7px; border-radius: 20px; background: var(--bg-input); overflow: hidden; }
.health-bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--cyan), var(--blue)); }
.health-bar-fill.low { background: linear-gradient(90deg, var(--rose), var(--amber)); }

/* ---- топ AI-запросов (SEO-виджет) ---- */
.top-queries-list { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; flex: 1; overflow-y: auto; }
.query-chip {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 20px; padding: 6px 13px; font-size: 12px; color: var(--text-secondary);
}
.query-chip b { font-family: var(--font-mono); color: var(--cyan); font-weight: 700; }

@media (max-width: 1400px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   ОБЩИЕ КАРТОЧКИ СТАТИСТИКИ (используются в других местах, если нужно)
   ========================================================================== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-icon {
    width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px; font-size: 15px; background: var(--bg-input); color: var(--cyan);
}
.stat-card.gold .stat-icon { color: var(--amber); background: var(--amber-dim); }
.stat-card.green .stat-icon { color: var(--green); background: var(--green-dim); }
.stat-card.blue .stat-icon { color: var(--blue); background: var(--blue-dim); }
.stat-card.red .stat-icon { color: var(--rose); background: var(--rose-dim); }
.stat-value { font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ==========================================================================
   ТАБЛИЦЫ
   ========================================================================== */

.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.table-header h3 { margin: 0; font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.search-wrapper { position: relative; }
.search-wrapper i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.search-input {
    padding: 8px 12px 8px 30px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary); font-size: 12.5px; width: 200px;
    font-family: var(--font-display);
}
.search-input:focus { outline: none; border-color: var(--cyan); }

table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
thead th {
    text-align: left; padding: 10px 16px; font-size: 10.8px; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted); border-bottom: 1px solid var(--border);
    background: var(--bg-app); white-space: nowrap;
    position: sticky; top: 0; z-index: 5;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td:first-child, thead th:first-child { color: var(--text-muted); font-family: var(--font-mono); font-size: 11.5px; }

.pill {
    display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
}
.pill-free { background: var(--bg-input); color: var(--text-muted); }
.pill-premium { background: var(--blue-dim); color: var(--blue); }
.pill-vip { background: var(--amber-dim); color: var(--amber); }
.pill-active { background: var(--green-dim); color: var(--green); }
.pill-blocked { background: var(--rose-dim); color: var(--rose); }
.pill-online { background: var(--green-dim); color: var(--green); }
.pill-offline { background: var(--bg-input); color: var(--text-muted); }

.row-actions { display: flex; gap: 6px; }
.icon-btn {
    width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text-secondary); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px;
    transition: all .15s;
}
.icon-btn:hover { color: var(--cyan); border-color: var(--border-strong); }
.icon-btn.danger:hover { color: var(--rose); }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.pagination-btns button {
    width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text-secondary); cursor: pointer; font-size: 11.5px; font-family: var(--font-mono);
}
.pagination-btns button.active { background: var(--cyan-dim); color: var(--cyan); border-color: transparent; }
.pagination-btns button:hover:not(.active) { border-color: var(--border-strong); }

/* вертикальный скролл внутри таблицы Событий — при большом числе записей
   скроллится только тело таблицы, а не вся страница целиком */
.table-scroll { max-height: calc(100vh - 320px); overflow-y: auto; }

/* ==========================================================================
   ПРОЧИЕ СТРАНИЦЫ
   ========================================================================== */

.two-col { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1200px) { .two-col { grid-template-columns: 1fr; } }

.db-note {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--cyan);
    border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px;
    font-size: 12.5px; color: var(--text-secondary);
}
.db-note i { color: var(--cyan); }

.settings-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; overflow: hidden; }
.settings-section-header { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.settings-section-header h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.settings-section-header i { color: var(--cyan); }
.settings-section-body { padding: 18px; }
.settings-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.env-field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 5px; font-family: var(--font-mono); }

.feature-checks {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
    background: var(--bg-input); border-radius: var(--radius-sm); padding: 12px;
}
.feature-check {
    display: flex; align-items: center; gap: 9px;
    font-size: 12.5px; color: var(--text-secondary); cursor: pointer;
    padding: 5px 6px; border-radius: 7px; transition: background .12s;
}
.feature-check:hover { background: var(--bg-hover); color: var(--text-primary); }
.feature-check input { accent-color: var(--cyan); width: 15px; height: 15px; cursor: pointer; }

.env-status-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 14px; background: var(--bg-input); border-radius: var(--radius-sm);
    font-size: 12.5px; font-family: var(--font-mono);
}
.env-badge { padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.env-badge.set { background: var(--green-dim); color: var(--green); }
.env-badge.unset { background: var(--rose-dim); color: var(--rose); }
.env-badge.info { background: var(--blue-dim); color: var(--blue); }

.log-output { padding: 14px 18px; font-family: var(--font-mono); font-size: 12px; max-height: 60vh; overflow-y: auto; }
.log-line { padding: 5px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.log-line .lt { color: var(--text-muted); flex-shrink: 0; }
.log-line.lvl-error { color: var(--rose); }
.log-line.lvl-warn { color: var(--amber); }
.log-line.lvl-info { color: var(--text-secondary); }

/* каталог мест — карточки */
.places-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.place-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.place-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; gap: 8px; }
.place-card h4 { margin: 0; font-size: 13.5px; font-weight: 600; }
.place-card .cat-tag { font-size: 10.5px; color: var(--cyan); background: var(--cyan-dim); padding: 2px 8px; border-radius: 20px; }
.place-card p { margin: 6px 0; font-size: 12px; color: var(--text-secondary); }
.place-card .place-actions { display: flex; gap: 6px; margin-top: 10px; }

/* единое прокручиваемое полотно каталога — вместо постраничных кнопок:
   подгрузка следующей порции срабатывает при приближении к низу этого
   контейнера (IntersectionObserver за #placesSentinel), а не всей страницы */
.places-feed {
    max-height: calc(100vh - 210px);
    overflow-y: auto;
    padding-right: 6px;
}
.places-sentinel { padding: 22px 0; display: flex; justify-content: center; }
.places-spinner { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }

/* дерево меню */
.menu-tree-node { margin-bottom: 4px; }
.menu-tree-row {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px;
    border-radius: var(--radius-sm); cursor: pointer; font-size: 12.5px;
}
.menu-tree-row:hover { background: var(--bg-hover); }
.menu-tree-row.selected { background: var(--cyan-dim); color: var(--cyan); }
.menu-tree-children { margin-left: 22px; border-left: 1px solid var(--border); padding-left: 10px; }

/* ==========================================================================
   МОДАЛКИ
   ========================================================================== */

.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(4,8,20,.72);
    backdrop-filter: blur(4px); z-index: 300; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    width: 460px; max-width: 100%; max-height: 88vh; overflow-y: auto;
    background: var(--bg-card); border: 1px solid var(--border-strong);
    border-radius: var(--radius); box-shadow: 0 30px 80px rgba(0,0,0,.5);
    animation: modal-in .18s ease;
}
.modal-lg { width: 640px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 18px 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ==========================================================================
   TOAST
   ========================================================================== */

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 260px; max-width: 340px;
    background: var(--bg-card-alt); border: 1px solid var(--border-strong);
    border-left: 3px solid var(--cyan);
    border-radius: var(--radius-sm); padding: 12px 16px;
    display: flex; align-items: center; gap: 10px;
    font-size: 12.8px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
    animation: toast-in .2s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--rose); }
.toast.info { border-left-color: var(--blue); }
.toast i { font-size: 14px; }
.toast.success i { color: var(--green); }
.toast.error i { color: var(--rose); }
.toast.info i { color: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.toast.hide { animation: toast-out .2s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* ==========================================================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================================================== */

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 30px 0 60px rgba(0,0,0,.4); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    #menuTgl { display: flex !important; }
    .content-area { padding: 18px 14px 40px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .modal-lg { width: 100%; }
}
