/* ============================================================================
 *  Посетители — стили (обе темы). Самодостаточно, без зависимостей.
 * ========================================================================== */
.vis-wrap { padding: 16px 20px 48px; max-width: 1560px; margin: 0 auto; color: var(--text, #e2e8f0); }

/* ── hero ── */
.vis-hero {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 18px;
    padding: 18px 22px; border-radius: 16px; margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(99,102,241,0.16), rgba(14,165,233,0.10));
    border: 1px solid rgba(99,102,241,0.25);
}
.vis-title { font-size: 1.5rem; font-weight: 800; letter-spacing: .2px; }
.vis-sub { font-size: .82rem; opacity: .75; margin-top: 4px; max-width: 720px; line-height: 1.4; }
.vis-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.vis-chip {
    display: flex; flex-direction: column; align-items: center; min-width: 86px;
    padding: 8px 14px; border-radius: 12px; background: rgba(15,23,42,0.35);
    border: 1px solid rgba(148,163,184,0.18);
}
.vis-chip-v { font-size: 1.35rem; font-weight: 800; line-height: 1.1; }
.vis-chip-l { font-size: .68rem; text-transform: uppercase; letter-spacing: .4px; opacity: .7; margin-top: 2px; }
.vis-chip-u .vis-chip-v { color: #818cf8; }
.vis-chip-s .vis-chip-v { color: #38bdf8; }
.vis-chip-a .vis-chip-v { color: #22c55e; }
.vis-chip-e .vis-chip-v { color: #e2e8f0; }
.vis-chip-bg .vis-chip-v { color: #f59e0b; }

/* ── toolbar ── */
.vis-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.vis-seg { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid rgba(148,163,184,0.25); }
.vis-seg-btn {
    background: transparent; color: var(--text, #cbd5e1); border: none; padding: 7px 14px;
    font-size: .82rem; cursor: pointer; border-right: 1px solid rgba(148,163,184,0.15);
}
.vis-seg-btn:last-child { border-right: none; }
.vis-seg-btn:hover { background: rgba(99,102,241,0.15); }
.vis-seg-btn.active { background: rgba(99,102,241,0.45); color: #fff; font-weight: 600; }
.vis-inp {
    background: rgba(15,23,42,0.35); color: var(--text, #e2e8f0); border: 1px solid rgba(148,163,184,0.25);
    border-radius: 9px; padding: 7px 11px; font-size: .82rem; outline: none;
}
.vis-inp:focus { border-color: #6366f1; }
.vis-inp[type=text] { min-width: 240px; flex: 1 1 240px; max-width: 360px; }
.vis-date { color-scheme: dark; }
.vis-sel { cursor: pointer; }
.vis-btn {
    background: rgba(99,102,241,0.35); color: #fff; border: 1px solid rgba(99,102,241,0.5);
    border-radius: 9px; padding: 7px 14px; font-size: .82rem; cursor: pointer;
}
.vis-btn:hover { background: rgba(99,102,241,0.55); }
.vis-btn:disabled { opacity: .4; cursor: default; }

/* ── charts ── */
.vis-charts { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.vis-card {
    background: rgba(15,23,42,0.30); border: 1px solid rgba(148,163,184,0.16);
    border-radius: 14px; padding: 12px 14px;
}
.vis-card-h { font-size: .82rem; font-weight: 600; opacity: .85; margin-bottom: 8px; }
.vis-canvas-wrap { position: relative; height: 220px; }
.vis-nochart { font-size: .8rem; opacity: .6; padding: 20px; text-align: center; }
@media (max-width: 1180px) { .vis-charts { grid-template-columns: 1fr 1fr; } .vis-card-wide { grid-column: 1 / -1; } }
@media (max-width: 760px) { .vis-charts { grid-template-columns: 1fr; } }

/* ── grid: sessions + side ── */
.vis-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .vis-grid { grid-template-columns: 1fr; } }
.vis-sec-h {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .95rem; font-weight: 700; margin: 4px 0 8px;
}
.vis-sec-count { font-size: .75rem; font-weight: 500; opacity: .65; }

.vis-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid rgba(148,163,184,0.14); }
.vis-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.vis-table thead th {
    text-align: left; padding: 9px 10px; background: rgba(99,102,241,0.12);
    font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .3px;
    position: sticky; top: 0; white-space: nowrap;
}
.vis-table td { padding: 8px 10px; border-top: 1px solid rgba(148,163,184,0.10); vertical-align: middle; }
.vis-table .vis-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vis-row { cursor: pointer; }
.vis-row:hover { background: rgba(99,102,241,0.10); }
.vis-row-bg { opacity: .62; }
.vis-c-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vis-c-tabs { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.vis-user { font-weight: 600; }
.vis-role { margin-left: 6px; font-size: .62rem; background: rgba(239,68,68,0.25); color: #fca5a5; padding: 1px 6px; border-radius: 6px; }
.vis-frame { margin-left: 5px; opacity: .7; }
.vis-active { color: #22c55e; font-weight: 600; }
.vis-act { display: inline-flex; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vis-act-i { font-size: .74rem; opacity: .85; }
.vis-badge { font-size: .68rem; padding: 2px 8px; border-radius: 8px; white-space: nowrap; }
.vis-badge-bg { background: rgba(245,158,11,0.18); color: #fbbf24; }
.vis-badge-act { background: rgba(34,197,94,0.16); color: #4ade80; }
.vis-empty { padding: 26px; text-align: center; opacity: .6; }
.vis-empty-sm { padding: 12px; text-align: center; opacity: .55; font-size: .8rem; }

.vis-pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; }
.vis-pg-info { font-size: .78rem; opacity: .7; font-variant-numeric: tabular-nums; }

/* ── side: top lists ── */
.vis-col-side .vis-sec-h:not(:first-child) { margin-top: 18px; }
.vis-toplist {
    background: rgba(15,23,42,0.25); border: 1px solid rgba(148,163,184,0.14);
    border-radius: 12px; padding: 8px 10px;
}
.vis-top { display: grid; grid-template-columns: 1fr 70px 46px; gap: 8px; align-items: center; padding: 5px 2px; }
.vis-top-lab { min-width: 0; }
.vis-top-name { display: block; font-size: .78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vis-top-tab { font-size: .66rem; opacity: .6; }
.vis-top-bar { height: 8px; background: rgba(148,163,184,0.15); border-radius: 5px; overflow: hidden; }
.vis-top-bar-in { height: 100%; background: linear-gradient(90deg, #6366f1, #818cf8); }
.vis-top-bar-tab { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }
.vis-top-val { font-size: .76rem; text-align: right; font-variant-numeric: tabular-nums; opacity: .85; }

/* ── feed ── */
.vis-feed-sec { margin-top: 22px; }
.vis-feed-head { cursor: pointer; user-select: none; }
.vis-feed-head:hover { color: #818cf8; }
.vis-feed-seg { margin-bottom: 10px; }
.vis-feed-more { display: flex; justify-content: center; margin-top: 10px; min-height: 20px; font-size: .78rem; opacity: .8; }

/* ── modal ── */
.vis-modal-backdrop {
    position: fixed; inset: 0; background: rgba(2,6,23,0.66); z-index: 4000;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.vis-modal {
    background: var(--card-bg, #0f172a); border: 1px solid rgba(148,163,184,0.25);
    border-radius: 16px; width: min(760px, 96vw); max-height: 88vh; display: flex; flex-direction: column;
    box-shadow: 0 24px 70px rgba(0,0,0,0.5);
}
.vis-modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px; border-bottom: 1px solid rgba(148,163,184,0.18); font-weight: 700;
}
.vis-modal-x { background: transparent; border: none; color: var(--text, #cbd5e1); font-size: 1.1rem; cursor: pointer; }
.vis-modal-x:hover { color: #ef4444; }
.vis-modal-body { padding: 16px 18px; overflow-y: auto; }
.vis-m-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; margin-bottom: 16px; }
.vis-m-kv { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; padding: 4px 0; border-bottom: 1px dashed rgba(148,163,184,0.12); }
.vis-m-k { opacity: .65; }
.vis-m-v { font-weight: 600; text-align: right; }
.vis-m-h { font-size: .9rem; font-weight: 700; margin: 6px 0 10px; }

.vis-timeline { display: flex; flex-direction: column; gap: 2px; }
.vis-tl-item { display: grid; grid-template-columns: 64px 22px 1fr; gap: 8px; align-items: start; padding: 6px 4px; border-left: 2px solid rgba(148,163,184,0.18); padding-left: 10px; }
.vis-tl-session_start { border-left-color: #22c55e; }
.vis-tl-click { border-left-color: #818cf8; }
.vis-tl-view { border-left-color: #38bdf8; }
.vis-tl-session_end { border-left-color: #94a3b8; }
.vis-tl-time { font-size: .72rem; opacity: .6; font-variant-numeric: tabular-nums; }
.vis-tl-ic { text-align: center; }
.vis-tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.vis-tl-type { font-size: .8rem; font-weight: 600; }
.vis-tl-label { font-size: .78rem; opacity: .8; }
.vis-tl-meta { font-size: .72rem; opacity: .62; margin-top: 2px; font-variant-numeric: tabular-nums; }
/* Домен-контекст: КАКУЮ конкретную сущность смотрел (ТМЦ/клиент/документ). */
.vis-tl-entity { margin-top: 3px; font-size: .76rem; display: flex; gap: 5px; align-items: baseline; flex-wrap: wrap;
    padding: 2px 7px; border-radius: 6px; background: rgba(56,189,248,.10); border: 1px solid rgba(56,189,248,.22); }
.vis-tl-ent-kind { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; opacity: .6; }
.vis-tl-ent-name { font-weight: 700; color: #7dd3fc; }
.vis-tl-ent-id  { font-size: .68rem; opacity: .55; font-variant-numeric: tabular-nums; }
.vis-tl-ent-detail { font-size: .72rem; opacity: .72; }
.vis-feed-ent { font-weight: 600; color: #0369a1; }
.vis-feed-detail { opacity: .7; font-size: .82em; }
@media (prefers-color-scheme: dark) { .vis-feed-ent { color: #7dd3fc; } }

/* ── toast ── */
.vis-toast {
    position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .82rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4); opacity: 0; transition: all .25s ease; z-index: 5000;
    border: 1px solid rgba(148,163,184,0.25);
}
.vis-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── light theme tweaks ── */
body.light .vis-wrap, html.light .vis-wrap { color: #1e293b; }
body.light .vis-chip, body.light .vis-card, body.light .vis-toplist, body.light .vis-inp {
    background: #fff; border-color: #e2e8f0;
}
body.light .vis-table thead th { background: #eef2ff; color: #475569; }
body.light .vis-modal { background: #fff; }
