/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0a0a0e;
  --panel: #131319;
  --panel-2: #191921;
  --raised: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f3f6;
  --muted: #9b9bab;
  --faint: #6d6d7c;
  --accent: #8b7cf6;
  --accent-2: #5b8def;
  --accent-soft: rgba(139, 124, 246, 0.14);
  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.12);
  --warn: #f5b94a;
  --warn-soft: rgba(245, 185, 74, 0.13);
  --bad: #ff6b7a;
  --bad-soft: rgba(255, 107, 122, 0.13);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 10px 34px rgba(0, 0, 0, 0.32);
  --glow: radial-gradient(900px 520px at 88% -12%, rgba(139, 124, 246, 0.16), transparent 62%),
          radial-gradient(760px 460px at -8% 112%, rgba(91, 141, 239, 0.11), transparent 58%);
  --radius: 16px;
  --brand: linear-gradient(135deg, #8b7cf6 0%, #5b8def 100%);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f4f8;
    --panel: #ffffff;
    --panel-2: #f8f8fb;
    --raised: rgba(20, 20, 40, 0.04);
    --border: rgba(20, 20, 40, 0.09);
    --border-strong: rgba(20, 20, 40, 0.18);
    --text: #14141c;
    --muted: #5f5f70;
    --faint: #8d8d9c;
    --accent: #6a5bea;
    --accent-2: #3f77e0;
    --accent-soft: rgba(106, 91, 234, 0.1);
    --ok: #12855a;
    --ok-soft: rgba(18, 133, 90, 0.1);
    --warn: #a86400;
    --warn-soft: rgba(168, 100, 0, 0.11);
    --bad: #c5303f;
    --bad-soft: rgba(197, 48, 63, 0.09);
    --shadow: 0 1px 2px rgba(20, 20, 40, 0.05), 0 8px 24px rgba(20, 20, 40, 0.06);
    --glow: radial-gradient(900px 520px at 88% -12%, rgba(106, 91, 234, 0.1), transparent 62%),
            radial-gradient(760px 460px at -8% 112%, rgba(63, 119, 224, 0.07), transparent 58%);
    --brand: linear-gradient(135deg, #6a5bea 0%, #3f77e0 100%);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14.5px/1.55 "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 650; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.icon { width: 1.15em; height: 1.15em; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* utilities (no inline styles are allowed by the security policy) */
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .wrap { flex-wrap: wrap; } .items-center { align-items: center; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.block { display: block; }
.w-full { width: 100%; }
.iform { display: inline; margin: 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 16px; border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 72%, transparent);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 18px rgba(139, 124, 246, 0.35);
}
.logo .icon { width: 18px; height: 18px; }
.brand b { display: block; font-size: 15px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.brand span { font-size: 12px; color: var(--faint); }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 0 10px 6px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--muted); font-weight: 500;
}
.nav-item:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active .icon { color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.nav-channels .nav-item { padding: 7px 10px; font-size: 13.5px; }
.nav-channels .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; }
.sidebar-foot .who { font-size: 13px; line-height: 1.25; min-width: 0; }
.sidebar-foot .who span { display: block; color: var(--faint); font-size: 12px; }
.sidebar-foot form { margin-left: auto; }

.content { padding: 34px 40px 80px; max-width: 1180px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- surfaces ---------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; display: flex; gap: 14px; align-items: center; box-shadow: var(--shadow); }
.kpi .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); }
.kpi .ico.bad { background: var(--bad-soft); color: var(--bad); }
.kpi .ico.warn { background: var(--warn-soft); color: var(--warn); }
.kpi b { display: block; font-size: 24px; line-height: 1.1; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 12.5px; }

/* ---------- channel cards ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.ch-card { margin: 0; display: flex; flex-direction: column; gap: 18px; transition: border-color .15s, transform .15s; }
.ch-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.ch-top { display: flex; gap: 14px; align-items: center; }
.ch-top .titles { min-width: 0; flex: 1; }
.ch-top h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-top h2 a { color: var(--text); }
.ch-top h2 a:hover { text-decoration: none; color: var(--accent); }
.handle { color: var(--faint); font-size: 12.5px; }

.av { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex: none; text-transform: uppercase; }
.av.lg { width: 58px; height: 58px; border-radius: 16px; font-size: 24px; }
.av-0 { background: linear-gradient(135deg, #8b7cf6, #5b8def); }
.av-1 { background: linear-gradient(135deg, #f472b6, #8b5cf6); }
.av-2 { background: linear-gradient(135deg, #34d399, #3b82f6); }
.av-3 { background: linear-gradient(135deg, #fb923c, #f43f5e); }
.av-4 { background: linear-gradient(135deg, #22d3ee, #6366f1); }
.av-5 { background: linear-gradient(135deg, #a3e635, #14b8a6); }
.av-6 { background: linear-gradient(135deg, #fbbf24, #f97316); }
.av-7 { background: linear-gradient(135deg, #c084fc, #ec4899); }

.chip { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--raised); color: var(--muted); white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.plain::before { display: none; }

.health-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; }
.health-row b { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 999px; background: var(--raised); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.bar .fill.warn { background: var(--warn); }
.bar .fill.bad { background: var(--bad); }
.f-0 { width: 2%; } .f-5 { width: 5%; } .f-10 { width: 10%; } .f-15 { width: 15%; } .f-20 { width: 20%; }
.f-25 { width: 25%; } .f-30 { width: 30%; } .f-35 { width: 35%; } .f-40 { width: 40%; } .f-45 { width: 45%; }
.f-50 { width: 50%; } .f-55 { width: 55%; } .f-60 { width: 60%; } .f-65 { width: 65%; } .f-70 { width: 70%; }
.f-75 { width: 75%; } .f-80 { width: 80%; } .f-85 { width: 85%; } .f-90 { width: 90%; } .f-95 { width: 95%; } .f-100 { width: 100%; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.fact { background: var(--raised); border-radius: 11px; padding: 10px 12px; }
.fact b { display: block; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.fact span { font-size: 12px; color: var(--muted); }
.meta-list { display: grid; gap: 7px; font-size: 13px; }
.meta-list div { display: flex; justify-content: space-between; gap: 12px; }
.meta-list span:first-child { color: var(--muted); }
.ch-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer; text-decoration: none;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--raised); color: var(--text); transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--accent-soft); border-color: transparent; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(110, 100, 240, 0.32); }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--raised); color: var(--text); }
.btn.icon-only { padding: 7px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; font: inherit; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--raised); color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select option { background: var(--panel); color: var(--text); }
textarea { min-height: 76px; resize: vertical; }
input[type=file] { font: inherit; font-size: 12.5px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-size: 12.5px; font-weight: 550; margin-right: 10px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--raised); color: var(--text); cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--accent-soft); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 18px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.check label { margin: 0; color: var(--text); font-size: 14px; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=number] { width: 74px; padding: 6px 10px; }

details.fold summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--accent); }
details.fold summary::-webkit-details-marker { display: none; }
details.fold[open] summary { margin-bottom: 16px; }

/* ---------- flash ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid transparent; }
.flash .icon { margin-top: 2px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.flash.info { background: var(--accent-soft); color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 550; color: var(--faint); font-size: 12px; letter-spacing: 0.02em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--raised); }

/* ---------- tabs and images ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tab:hover { text-decoration: none; color: var(--text); border-color: var(--border-strong); }
.tab.active { background: var(--accent-soft); color: var(--text); border-color: transparent; }
.tab.active b { color: var(--accent); }
.tab b { font-weight: 600; }

.shots { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.shot { background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.shot .pic { position: relative; }
.shot img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: var(--raised); }
.shot .pic .chip { position: absolute; top: 8px; left: 8px; backdrop-filter: blur(10px); background: rgba(10, 10, 14, 0.62); color: #fff; }
.shot .body { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.shot .name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot .sub { font-size: 12px; color: var(--faint); margin-top: -4px; }
.shot .btns { display: flex; gap: 5px; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 12px; word-break: break-word; line-height: 1.4; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 22px; }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty .icon { width: 30px; height: 30px; color: var(--faint); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.qr-preview { width: 104px; height: 104px; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; border: 1px solid var(--border); }
.split { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.status-list { display: grid; }
.status-list > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.status-list > div:last-child { border-bottom: none; }
.status-list span:first-child { color: var(--muted); }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; }
.login-box .logo { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 22px; }
.login-box .logo .icon { width: 24px; height: 24px; }
.login-box h1 { margin-bottom: 6px; }
.login-box .card { margin-top: 26px; padding: 24px; }
.field { margin-bottom: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-channels, .sidebar .who { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .content { padding: 22px 16px 60px; }
  h1 { font-size: 22px; }
}
@media (max-width: 520px) {
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid { grid-template-columns: 1fr; }
  .shots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
