/* ───────────────────────────────────────────────
   players :: dark UI
   Палитра строится на токенах — тему можно сменить
   переопределением :root, не трогая компоненты.
   ─────────────────────────────────────────────── */
:root {
  --bg:            #07080d;
  --bg-deep:       #04050a;
  --surface:       rgba(20, 23, 34, 0.72);
  --surface-solid: #12151f;
  --surface-hi:    rgba(32, 37, 52, 0.85);
  --line:          rgba(255, 255, 255, 0.07);
  --line-hi:       rgba(255, 255, 255, 0.14);

  --text:          #e8eaf2;
  --text-dim:      #9aa1b8;
  --text-faint:    #646b82;

  --accent:        #7c5cff;
  --accent-2:      #22d3ee;
  --accent-3:      #f472b6;
  --ok:            #34d399;
  --warn:          #fbbf24;
  --err:           #f87171;

  --glow-a: rgba(124, 92, 255, 0.45);
  --glow-b: rgba(34, 211, 238, 0.35);
  --glow-c: rgba(244, 114, 182, 0.28);

  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;

  --sidebar-w: 236px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

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

/* ─────────── живой фон: медленно дышащие свечения ─────────── */
.bg-glow {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; overflow: hidden;
}
.bg-glow::before,
.bg-glow::after,
.bg-glow i {
  content: ""; position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}
.bg-glow::before {
  width: 52vw; height: 52vw; left: -14vw; top: -18vw;
  background: radial-gradient(circle, var(--glow-a) 0%, transparent 68%);
  animation: drift-a 26s var(--ease) infinite alternate;
}
.bg-glow::after {
  width: 44vw; height: 44vw; right: -12vw; top: 8vh;
  background: radial-gradient(circle, var(--glow-b) 0%, transparent 68%);
  animation: drift-b 32s var(--ease) infinite alternate;
}
.bg-glow i {
  width: 38vw; height: 38vw; left: 34vw; bottom: -20vh;
  background: radial-gradient(circle, var(--glow-c) 0%, transparent 70%);
  animation: drift-c 38s var(--ease) infinite alternate;
}
@keyframes drift-a {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(8vw, 6vh, 0) scale(1.18); }
}
@keyframes drift-b {
  from { transform: translate3d(0,0,0) scale(1.1); }
  to   { transform: translate3d(-7vw, 10vh, 0) scale(0.92); }
}
@keyframes drift-c {
  from { transform: translate3d(0,0,0) scale(0.95); }
  to   { transform: translate3d(-10vw, -8vh, 0) scale(1.2); }
}
/* мелкая сетка поверх свечений — добавляет «технологичности» */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  opacity: 0.5;
}
@media (prefers-reduced-motion: reduce) {
  .bg-glow::before, .bg-glow::after, .bg-glow i { animation: none; }
}

/* ─────────── каркас ─────────── */
.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12,14,22,0.9), rgba(7,8,13,0.75));
  backdrop-filter: blur(16px);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 22px var(--glow-a), inset 0 1px 0 rgba(255,255,255,0.3);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff;
}
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.2px; }
.brand-sub { font-size: 11px; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-faint); padding: 0 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-dim); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background 0.18s, color 0.18s, box-shadow 0.25s;
  position: relative;
}
.nav a:hover { background: var(--surface-hi); color: var(--text); }
.nav a.on {
  background: linear-gradient(90deg, rgba(124,92,255,0.18), rgba(124,92,255,0.04));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124,92,255,0.25);
}
.nav a.on::before {
  content: ""; position: absolute; left: 0; top: 22%; height: 56%;
  width: 2px; border-radius: 2px;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.nav svg { width: 16px; height: 16px; flex: 0 0 16px; stroke-width: 1.8; }

.sidebar-foot { margin-top: auto; font-size: 11.5px; color: var(--text-faint); padding: 0 8px; }
.sidebar-foot a { color: var(--text-dim); text-decoration: none; }
.sidebar-foot a:hover { color: var(--accent-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  background: rgba(7,8,13,0.55);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 620; letter-spacing: -0.3px; }
.topbar .spacer { flex: 1; }

.content { padding: 22px 26px 56px; }

/* ─────────── карточки ─────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  backdrop-filter: blur(14px);
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s, transform 0.25s var(--ease);
}
.card::after {
  /* тонкий блик по верхней кромке */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.16), transparent);
}
.card:hover { border-color: var(--line-hi); }
.card-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 11.5px; color: var(--text-faint); }
.card-head .spacer { flex: 1; }

/* align-items:start — иначе карточка растягивается по высоте соседней
   и под короткой таблицей зияет пустота */
.grid { display: grid; gap: 14px; align-items: start; }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1240px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-1-2, .g-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .g-4, .g-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ─────────── KPI ─────────── */
.kpi { display: flex; flex-direction: column; gap: 7px; }
.kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); display: flex; align-items: center; gap: 6px;
}
.kpi-value {
  font-size: 27px; font-weight: 680; letter-spacing: -0.8px;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 7px;
}
.kpi-unit { font-size: 13px; font-weight: 500; color: var(--text-faint); }
.kpi-foot { font-size: 11.5px; color: var(--text-dim); }
.kpi-spark { height: 34px; margin: -4px -4px -8px; }

.glow-ring {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 9px var(--ok);
  animation: pulse 2.4s ease-in-out infinite;
}
.glow-ring.warn { background: var(--warn); box-shadow: 0 0 9px var(--warn); }
.glow-ring.err  { background: var(--err);  box-shadow: 0 0 9px var(--err); }
.glow-ring.off  { background: var(--text-faint); box-shadow: none; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ─────────── таблицы ─────────── */
.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 14px;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0; background: var(--surface-solid);
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
  vertical-align: middle;
}
tbody tr { transition: background 0.14s; }
tbody tr:hover td { background: rgba(255,255,255,0.025); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.strong { color: var(--text); font-weight: 550; }

/* ─────────── элементы ─────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 550; line-height: 1.5;
  background: var(--surface-hi); color: var(--text-dim);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.ok   { color: var(--ok);   border-color: rgba(52,211,153,0.28); background: rgba(52,211,153,0.1); }
.pill.warn { color: var(--warn); border-color: rgba(251,191,36,0.28); background: rgba(251,191,36,0.1); }
.pill.err  { color: var(--err);  border-color: rgba(248,113,113,0.28); background: rgba(248,113,113,0.1); }
.pill.acc  { color: #b9a7ff; border-color: rgba(124,92,255,0.3); background: rgba(124,92,255,0.12); }
.pill.cyan { color: #7fe3f3; border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.1); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line-hi);
  background: var(--surface-hi); color: var(--text);
  font-size: 12.5px; font-weight: 550; font-family: inherit;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, box-shadow 0.22s, transform 0.12s;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #6344e8);
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 18px rgba(124,92,255,0.35);
}
.btn.primary:hover { box-shadow: 0 5px 24px rgba(124,92,255,0.5); }
.btn.sm { padding: 5px 9px; font-size: 11.5px; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { color: var(--err); border-color: rgba(248,113,113,0.3); }

.seg { display: inline-flex; background: var(--surface-hi); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button {
  padding: 5px 11px; border: none; background: transparent;
  color: var(--text-dim); font-size: 12px; font-weight: 550; font-family: inherit;
  border-radius: 6px; cursor: pointer; transition: background 0.16s, color 0.16s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: rgba(124,92,255,0.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(124,92,255,0.3); }

input, select, textarea {
  background: rgba(0,0,0,0.3); color: var(--text);
  border: 1px solid var(--line-hi); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 13px; font-family: inherit;
  width: 100%; transition: border-color 0.18s, box-shadow 0.18s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.16);
}
input::placeholder { color: var(--text-faint); }
textarea { font-family: var(--mono); font-size: 12px; line-height: 1.55; resize: vertical; }
label { display: block; font-size: 11.5px; color: var(--text-dim); margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 13px; }
.row { display: flex; gap: 10px; align-items: center; }

.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 1px; }

.chart { width: 100%; height: 280px; }
.chart.sm { height: 190px; }

.empty {
  padding: 34px 18px; text-align: center;
  color: var(--text-faint); font-size: 13px;
}

/* полоса доли (hit-rate, доменов и т.п.) */
.bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,0.07); overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 10px var(--glow-a);
  transition: width 0.5s var(--ease);
}

/* постер в топе контента */
.poster {
  width: 34px; height: 50px; border-radius: 5px; object-fit: cover;
  background: var(--surface-hi); flex: 0 0 34px;
  border: 1px solid var(--line);
}
.media { display: flex; align-items: center; gap: 11px; min-width: 0; }
.media-body { min-width: 0; }
.media-title { color: var(--text); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─────────── страница входа ─────────── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; position: relative; z-index: 1; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { justify-content: center; margin-bottom: 22px; }

/* ─────────── служебное ─────────── */
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.1), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px; height: 1em;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

[x-cloak] { display: none !important; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--surface-solid); border: 1px solid var(--line-hi);
  border-radius: var(--r-sm); padding: 11px 14px; font-size: 13px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.55);
  max-width: 340px;
  animation: slide-in 0.3s var(--ease);
}
.toast.ok  { border-color: rgba(52,211,153,0.35); }
.toast.err { border-color: rgba(248,113,113,0.35); }
@keyframes slide-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }

.modal-back {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(3,4,8,0.74); backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 0.2s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface-solid); border: 1px solid var(--line-hi);
  border-radius: var(--r-lg); padding: 22px;
  width: 100%; max-width: 560px; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,0.6);
}
.modal.wide { max-width: 760px; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.11); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
