/* ── Variables (design-system tokens: см. /static/ui/tokens.css) ───── */
:root {
  --bg: #05070D;
  --card: rgba(255, 255, 255, 0.03);
  --card-solid: #12151d;
  --border: rgba(255, 255, 255, 0.06);
  --border-solid: #1e2431;
  --text: #F2F5FF;
  --muted: #8A94B8;
  --green: #4ADE80;
  --red: #FB7185;
  --blue: #3E7BFF;
  --purple: #7C3AED;
  --amber: #FBBF24;
  --cyan: #22D3EE;
  --grad: linear-gradient(135deg, #3E7BFF, #7C3AED);
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font, 'Golos Text', -apple-system, 'Segoe UI', sans-serif);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  padding: 20px;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Header ───────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
  margin: -20px -20px 24px;
  padding: 13px 20px;
  background: rgba(5, 7, 13, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-star {
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.45));
  flex-shrink: 0;
}

.service-dots { display: flex; align-items: center; gap: 8px; }

.svc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.svc-badge.svc-down {
  background: rgba(251, 113, 133, 0.15) !important;
  color: var(--red) !important;
  border-color: rgba(251, 113, 133, 0.3) !important;
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.up,
.dot.dot-healthy { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.dot-throttled { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot.dot-failing { background: #FBBF24; box-shadow: 0 0 6px #FBBF24; }
.dot.down,
.dot.dot-offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.dot-idle { background: var(--muted); box-shadow: none; }

.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  justify-content: flex-end;
}

/* ── Bell Button ──────────────────────────── */
.bell-btn {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
}

.bell-btn:hover {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px rgba(251, 113, 133, 0.4);
}

.bell-badge.hidden { display: none; }

/* ── Modal ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-solid);
}

.modal-head h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--border-solid); color: var(--text); }

.modal-body {
  padding: 8px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border-solid);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-foot:empty { display: none; }

.page-btn {
  background: var(--card);
  border: 1px solid var(--border-solid);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn:not(:disabled):hover { border-color: var(--blue); }

.page-info {
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pg-jump {
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 6px;
  width: 38px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.pg-jump:focus {
  border-color: var(--blue);
  outline: none;
}
.pg-jump::-webkit-outer-spin-button,
.pg-jump::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.pg-sep { opacity: 0.6; }
.pg-total { font-variant-numeric: tabular-nums; }

/* ── Paginated table containers (stable height) ─ */
#bizAffiliatesTable {
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
#bizTrafficTable {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
#bizAffiliatesTable .table-pagination,
#bizTrafficTable .table-pagination {
  margin-top: auto;
}
.biz-table {
  width: 100%;
}
.biz-table th:first-child,
.biz-table td:first-child {
  width: 36px;
}

/* ── Sortable columns ───────────────────── */
.biz-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}
.biz-table th[data-sort]:hover {
  color: var(--blue);
}
.sort-arrow {
  font-size: 10px;
  margin-left: 3px;
  opacity: 0.5;
}
.sort-arrow.active {
  opacity: 1;
  color: var(--cyan);
}

/* ── Table Controls (search + pagination) ── */
.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.table-search {
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 10px;
  width: 180px;
  transition: border-color 0.15s;
}
.table-search:focus {
  border-color: var(--blue);
  outline: none;
}
.table-search::placeholder {
  color: var(--muted);
}
.table-pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

/* ── Uptime Card ──────────────────────────── */
.uptime-card {
  margin-top: 16px;
  margin-bottom: 20px;
}

/* ── Stats Row ────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* Extra cards row (Infra cost / Margin / MTProxy) — переменное число
   карточек 0..3. Растягивать одну на 1/5 экрана — глупо, делаем
   natural-size с фиксированным max-width. */
.stats-row#infraExtraCards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 260px));
  justify-content: start;
}

.stat-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  min-height: 0;
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.stat-card .value { font-size: 28px; font-weight: 700; line-height: 1; }
/* value-row кладёт Δ-индикатор inline справа от основной цифры — компактнее,
   не съедает целую строку под собой. baseline + gap чтобы Δ не съезжал. */
.stat-card .value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.stat-card .delta-inline { font-size: 12px; font-weight: 600; }
.stat-card .delta-inline.delta-up { color: var(--green); }
.stat-card .delta-inline.delta-down { color: var(--red); }
.stat-card .delta-inline.delta-zero { color: var(--muted); }
.stat-card .sublabel { font-size: 11px; color: var(--muted); }
.stat-card .sublabel.delta-up { color: var(--green); }
.stat-card .sublabel.delta-down { color: var(--red); }
.stat-card .sublabel.delta-zero { color: var(--muted); }
/* main · wl split / любой полезный subtext в карточке. Контрастнее muted,
   но не такой яркий как value — чтобы не конкурировать. */
.stat-card .sublabel.sublabel-split {
  font-size: 12px;
  color: var(--text);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.stat-stack {
  display: grid;
  grid-template-columns: max-content auto;
  column-gap: 10px;
  row-gap: 4px;
  align-items: baseline;
}
.stat-stack .value { font-size: 22px; }
.stat-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

/* ── Controls Bar (tabs + period) ─────────── */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.region-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  flex-wrap: wrap;
}

.tab {
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab:hover { border-color: var(--blue); }

.tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.tab-count {
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  opacity: 0.8;
}

.tab.active .tab-count {
  color: #fff;
  opacity: 0.9;
}

.tab-ips {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(124, 58, 237, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.tab.active .tab-ips {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.tab-count-warn {
  color: var(--red);
  opacity: 1;
  font-weight: 700;
}

.tab.active .tab-count-warn {
  color: #FDA4AF;
}

/* ── Period Selector ──────────────────────── */
.period-selector {
  display: flex;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.period-selector button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.period-selector button:hover { color: var(--text); }
.period-selector button.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* Same look as period-selector but for in-card mini period picker */
.region-period-selector {
  display: flex;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.region-period-selector button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.region-period-selector button:hover { color: var(--text); }
.region-period-selector button.active { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* ── Node Groups Container ────────────────── */
.node-groups {
  margin-bottom: 16px;
}

/* ── Region Cards (All tab) ───────────────── */
.region-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.region-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.region-card-wide {
  grid-column: 1 / -1;
}

.region-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border-solid);
  flex-wrap: wrap;
  gap: 8px;
}

.region-card-title {
  font-size: 16px;
  letter-spacing: 0.2px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.region-count {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  opacity: 0.8;
}

.region-count.count-warn {
  color: var(--red);
  font-weight: 700;
}

.region-avg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.region-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

/* ── Relay Subgroups (by destination) ─────── */
.relay-subgroup {
  margin-bottom: 20px;
}

.relay-subgroup:last-child {
  margin-bottom: 0;
}

.relay-subgroup-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.relay-subgroup-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.2px;
}

/* ── Node Chips (stacked layout) ──────────── */
.node-chip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.node-chip-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.node-chip-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.node-name-badge {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* ── Badges ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.badge-recurring {
  background: rgba(124, 58, 237, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(124, 58, 237, 0.3);
  margin-left: 6px;
}

.badge-load {
  background: rgba(62, 123, 255, 0.15);
  color: #7CA2FF;
  border: 1px solid rgba(62, 123, 255, 0.3);
}

.badge-tx {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-ips {
  background: rgba(124, 58, 237, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.badge-loss {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.badge-loss-warn {
  background: rgba(251, 113, 133, 0.2);
  color: #FB7185;
  border: 1px solid rgba(251, 113, 133, 0.4);
}

/* «не возит» — RX >=25% (порог warden RELAY_OVERLOAD_RX_HIGH): хост задушен,
   выкинут из DNS. Громкий красный — чтобы не теряться среди обычных бейджей. */
.badge-rx-dead {
  background: #E11D48;
  color: #fff;
  border: 1px solid #FB7185;
  font-weight: 700;
}

.badge-rtt {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-mem {
  background: rgba(124, 58, 237, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.badge-users {
  background: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
  border: 1px solid rgba(20, 184, 166, 0.3);
}

.badge-traffic30d {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* DNS-LB / HAProxy weight (1..10). 7-10 = ok, 4-6 = warn, 1-3 = critical. */
.badge-weight-ok {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.badge-weight-warn {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}
.badge-weight-crit {
  background: rgba(251, 113, 133, 0.2);
  color: #FB7185;
  border: 1px solid rgba(251, 113, 133, 0.4);
}
.badge-idle {
  background: rgba(113, 113, 122, 0.18);
  color: var(--muted);
  border: 1px solid rgba(113, 113, 122, 0.4);
}

/* Live Sessions main/WL split breakdown under value */
.sub-split {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.2px;
}
.sub-split .split-main { color: var(--text); font-weight: 600; }
.sub-split .split-wl   { color: var(--cyan); font-weight: 600; }

/* Live Sessions row — те же 5 колонок что и остальные stats-rows.
   N регионов > 5 → wrap на следующую строку. Не auto-fit потому что
   одинокая карточка в последнем ряду на всю ширину выглядит уродливо;
   фиксированные 5 колонок дают предсказуемую решётку. */
#liveSessionsCards {
  grid-template-columns: repeat(5, 1fr);
}

/* ── Node State Borders (5 levels) ────────── */
.node-healthy {
  border-color: rgba(74, 222, 128, 0.45) !important;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.2) inset;
}

/* Hazard tape border (yellow + black diagonal stripes) */
.node-throttled {
  position: relative;
  border-color: transparent !important;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
}

.node-throttled::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2px;
  background: repeating-linear-gradient(
    45deg,
    #FBBF24 0 8px,
    #0a0a0a 8px 16px
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

.node-failing {
  border-color: #FBBF24 !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4) inset, 0 0 8px rgba(251, 191, 36, 0.15);
}

.node-offline {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.4) inset, 0 0 8px rgba(251, 113, 133, 0.2);
  animation: pulse-red 1.6s ease-in-out infinite;
}

/* idle = вне ротации (вес 0): отключена / не в пуле. Спокойный серый, без пульса —
   это не авария, а сознательное «нода не раздаёт VPN». */
.node-idle {
  border-color: rgba(113, 113, 122, 0.5) !important;
  box-shadow: 0 0 0 1px rgba(113, 113, 122, 0.25) inset;
  opacity: 0.7;
}

@keyframes pulse-red {
  0%, 100% {
    border-color: var(--red) !important;
    box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.4) inset, 0 0 14px rgba(251, 113, 133, 0.45);
  }
  50% {
    border-color: rgba(251, 113, 133, 0.6) !important;
    box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.25) inset, 0 0 6px rgba(251, 113, 133, 0.18);
  }
}

/* ── Group State Borders (3 levels) ───────── */
.group-healthy {
  border-color: rgba(74, 222, 128, 0.4) !important;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.18) inset;
}

.group-warn {
  border-color: #FBBF24 !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4) inset, 0 0 14px rgba(251, 191, 36, 0.18);
}

.group-critical {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 1px rgba(251, 113, 133, 0.4) inset, 0 0 14px rgba(251, 113, 133, 0.18);
  animation: pulse-red 1.6s ease-in-out infinite;
}

/* ── Charts ───────────────────────────────── */
.charts {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border-solid);
}

.chart-title {
  font-size: 16px;
  letter-spacing: 0.2px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Standalone chart-title (without chart-title-row) keeps bottom border */
.chart-card > .chart-title {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border-solid);
}

.chart-card canvas { width: 100% !important; }

/* ── Sparkline Grid (Region tabs) ─────────── */
.sparkline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.sparkline-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.sparkline-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sparkline-wrap { height: 90px; }

/* Loss/RTT section with legend + chart */
.sparkline-loss-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}


/* ── Uptime Timeline (compact) ────────────── */
#uptime-timeline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.tl-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tl-label {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  white-space: nowrap;
}

.tl-remnawave {
  background: rgba(62, 123, 255, 0.15);
  color: #7CA2FF;
  border: 1px solid rgba(62, 123, 255, 0.3);
}

.tl-bot {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}

.tl-postgres {
  background: rgba(124, 58, 237, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.tl-bar {
  flex: 1;
  display: flex;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border-solid);
}

.tl-seg { flex: 1; min-width: 0; }

.tl-pct {
  font-size: 11px;
  color: var(--muted);
  min-width: 42px;
  text-align: right;
  font-weight: 500;
}

@media (max-width: 768px) {
  #uptime-timeline {
    grid-template-columns: 1fr;
  }
}

/* ── Alert Item (used in modal) ───────────── */
.alert-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}

.alert-item:last-child { border-bottom: none; }
.alert-time { color: var(--muted); font-size: 11px; white-space: nowrap; min-width: 42px; }
.alert-msg { color: var(--text); word-break: break-word; }
.no-alerts { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ── Mode Switcher (Infrastructure / Business) */
.mode-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  width: fit-content;
}

.mode-divider { display: none; }

.mode-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active {
  background: var(--text);
  color: #05070D;
}

.hidden { display: none !important; }

/* ── Business Heading ────────────────────────── */
.biz-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* ── Business KPI Cards ─────────────────────── */
.biz-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

#bizRevenueCards,
#bizPaymentCards {
  margin-bottom: 8px;
}

#bizUserCards {
  margin-bottom: 16px;
}

.kpi-row-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 8px;
  padding-left: 2px;
  font-weight: 700;
}

.stat-card .sub-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.kpi-delta {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.kpi-delta.positive { color: var(--green); }
.kpi-delta.negative { color: var(--red); }
.kpi-delta.neutral  { color: var(--muted); }

/* ── Business Two-Column Layout ─────────────── */
.biz-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

#businessSection > .chart-card,
#usersSection > .chart-card {
  margin-bottom: 16px;
}

.biz-two-col > .chart-card {
  margin-bottom: 0;
}

/* ── Doughnut Charts ────────────────────────── */
.doughnut-row {
  display: grid;
  grid-template-columns: minmax(200px, 240px) 1fr auto;
  gap: 24px;
  padding: 0 32px;
  align-items: center;
}

@media (max-width: 720px) {
  .doughnut-row {
    grid-template-columns: 1fr;
  }
}

.doughnut-wrap {
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doughnut-legend {
  grid-column: 3;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 12px max-content auto auto auto;
  gap: 8px 14px;
  align-items: center;
  font-size: 13px;
}

@media (max-width: 720px) {
  .doughnut-legend {
    grid-column: 1;
    justify-content: start;
  }
}

.doughnut-legend li {
  display: contents;
}

.doughnut-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.doughnut-legend .name {
  color: #F2F5FF;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doughnut-legend .pct {
  color: #8A94B8;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 48px;
}

.doughnut-legend .amount {
  color: #F2F5FF;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  text-align: right;
  min-width: 70px;
}

.doughnut-legend .cnt {
  color: #8A94B8;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 32px;
}

/* ── Business Tables ────────────────────────── */
.biz-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.biz-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-solid);
  font-weight: 600;
}

.biz-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.biz-table tr:last-child td { border-bottom: none; }

.biz-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Referral Stats (summary block) ─────────── */
.ref-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
}

.ref-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.ref-stat-label { color: var(--muted); }

.ref-stat-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ref-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2px 0;
}

.ref-payout-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.ref-payout-label { color: var(--muted); }
.ref-payout-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.ref-payout-pending { color: var(--amber); }
.ref-payout-paid { color: var(--green); }
.ref-payout-rejected { color: var(--red); }

/* ── Traffic Progress Bar ───────────────────── */
.traffic-bar {
  flex: 1;
  min-width: 60px;
  height: 8px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}

.traffic-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.3s;
}

.traffic-bar-fill.low    { background: #4ade80; }
.traffic-bar-fill.medium { background: #fbbf24; }
.traffic-bar-fill.high   { background: #FB7185; }

.usage-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-pct {
  min-width: 36px;
  text-align: right;
}

/* ── Traffic Summary Badges ──────────────────── */
.traffic-summary {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.traffic-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* ── No Data State ──────────────────────────── */
/* Используется как sibling канваса (canvas: display:none) — overlay должен
   занимать всю высоту контейнера и центрировать текст. */
.biz-no-data {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 0;
  box-sizing: border-box;
}

/* ── Traffic table: flat per-key + stacked M/WL ──
   table-layout:fixed чтобы ширины колонок не зависели от длины username. */
.biz-table.traffic-table {
  table-layout: fixed;
  width: 100%;
}
.biz-table.traffic-table th,
.biz-table.traffic-table td { vertical-align: middle; }
/* Ширины подобраны под 10-колоночную ленту, помещается на 1280px viewport
   с боковым sidebar'ом. Лишних пикселей нет — при добавлении следующей
   колонки нужно пересчитывать заново. */
.biz-table.traffic-table th:nth-child(1)  { width: 44px; }   /* # */
.biz-table.traffic-table th:nth-child(2)  { width: 16%; min-width: 200px; }  /* User / Key */
.biz-table.traffic-table th:nth-child(3)  { width: 80px; }   /* Tariff */
.biz-table.traffic-table th:nth-child(4)  { width: 82px; }   /* Status */
.biz-table.traffic-table th:nth-child(5)  { width: 88px; }   /* Started */
.biz-table.traffic-table th:nth-child(6)  { width: 92px; }   /* Expires (стек date + days) */
.biz-table.traffic-table th:nth-child(7)  { width: 88px; }   /* Reset */
.biz-table.traffic-table th:nth-child(8)  { width: 84px; }   /* Paid */
.biz-table.traffic-table th:nth-child(9)  { width: 14%; }    /* Used M/W */
.biz-table.traffic-table th:nth-child(10) { width: 148px; }  /* Usage M/W */

/* Paid-cell: число жирным + ₽ муто-серым, выглядит как "1 997₽" */
.paid-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.paid-unit {
  color: var(--muted);
  margin-left: 2px;
  font-size: 11px;
}
.muted-dash { color: var(--muted); }

/* Reset-дата которая наступит ПОСЛЕ expire ключа (типично для 1m-тарифов:
   30d MONTH_ROLLING ≈ 30d тариф → reset почти всегда после expire). Не скрываем
   совсем — admin может хотеть знать «когда сбросится если юзер продлит», — но
   глушим визуально чтобы не воспринималось как обещание счётчику. */
.reset-after-expiry {
  color: var(--muted);
  opacity: 0.5;
  cursor: help;
}

/* Дата + "12d" stack для Expires-колонки. Абсолютная дата сверху мелким/muted,
   relative days снизу крупнее и с цветом по срочности. */
.date-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}
.date-stack .date-abs {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.date-stack .date-rel {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.date-rel.days-ok      { color: #4ade80; }
.date-rel.days-warning { color: #fbbf24; }
.date-rel.days-urgent  { color: #FB7185; }
.date-rel.days-expired { color: #8A94B8; }
.date-rel.date-time-muted {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
}
.date-stack-started .date-abs {
  color: inherit;
  font-size: 12px;
}

/* Status pill */
.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.5;
  white-space: nowrap;
}
.status-active  { background: rgba(74, 222, 128, 0.14); color: #4ade80; }
.status-limited { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.status-expired { background: rgba(251, 113, 133, 0.14); color: #FB7185; }
.biz-table.traffic-table tr.row-expired .status-pill { opacity: 0.85; }

/* Длинный username не должен ломать layout */
.user-cell .user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Реферрал-бейдж — мелкий 👥 рядом с username, hover показывает реферера */
.referral-badge {
  font-size: 11px;
  margin-left: 2px;
  cursor: help;
  opacity: 0.9;
  vertical-align: middle;
}

/* Гифт-бейдж — 🎁 перед суммой в колонке Paid, hover показывает список гифтов */
.gift-badge {
  font-size: 11px;
  margin-right: 2px;
  cursor: help;
  opacity: 0.9;
  vertical-align: middle;
}

.used-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
  line-height: 1.3;
}
.used-row b { font-weight: 600; color: var(--text); }
.used-label {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: #4ade80;
  margin-right: 2px;
  min-width: 10px;
}
.used-label-wl { color: #a78bfa; }
.used-unit { color: var(--muted); font-weight: 400; margin-left: 2px; }

.usage-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}
.usage-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.usage-row .traffic-bar { height: 6px; }
.usage-row .usage-pct {
  min-width: 32px;
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.key-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 4px;
}

.user-name { font-weight: 600; }
.user-cell {
  font-size: 12px;
  line-height: 1.3;
}
.user-cell .key-code {
  display: inline-block;
  margin-top: 3px;
}

/* ── Filter bar + popover-кнопки ─────────────────────────
   Стилистика: тёмный elevated card, чёткие fokус-ринги (rgba(124,162,255)),
   тонкие borders, monospaced цифры в значениях. */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: stretch;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  font-family: inherit;
  line-height: 1.35;
}
.filter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}
.filter-btn.active {
  border-color: rgba(124, 162, 255, 0.55);
  background: rgba(124, 162, 255, 0.10);
  box-shadow: 0 0 0 1px rgba(124, 162, 255, 0.18) inset;
}
.filter-btn .filter-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #7CA2FF;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(124, 162, 255, 0.7);
}
.filter-btn .filter-summary {
  color: #A5C2FF;
  font-weight: 600;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: left;
  letter-spacing: 0;
}
.filter-btn .filter-chev {
  color: #8A94B8;
  font-size: 12px;
  margin-left: 4px;
  line-height: 1;
  transition: transform 0.12s ease, color 0.12s ease;
}
.filter-btn:hover .filter-chev { color: var(--text); }
.filter-btn.active .filter-chev { color: #A5C2FF; }

.filter-clear {
  padding: 7px 12px;
  background: transparent;
  border: 1px dashed rgba(251, 113, 133, 0.4);
  border-radius: 8px;
  color: #FB7185;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, border-style 0.12s ease;
}
.filter-clear:hover {
  background: rgba(251, 113, 133, 0.08);
  border-style: solid;
}

/* Payments filter bar — select/date inputs в одном стиле с filter-кнопками */
.payments-search {
  flex: 0 1 220px;
  min-width: 160px;
}
/* Filter pill — общий стиль для filter-pill кнопок (Traffic by User + Payments).
   Структура: [LABEL] | [VALUE] [▾] */
.filter-pill {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, border-color 0.12s;
}
.filter-pill:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); }
.filter-pill.active {
  border-color: rgba(124, 162, 255, 0.55);
}
.filter-pill .filter-pill-label {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border-solid);
}
.filter-pill.active .filter-pill-label {
  color: #A5C2FF;
  background: rgba(124, 162, 255, 0.08);
  border-right-color: rgba(124, 162, 255, 0.3);
}
.filter-pill .filter-pill-value {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filter-pill .filter-chev {
  display: inline-flex;
  align-items: center;
  padding-right: 8px;
  color: var(--muted);
}
.payments-filter {
  padding: 7px 10px;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.payments-filter:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); }
.payments-filter:focus {
  outline: none;
  border-color: rgba(124, 162, 255, 0.55);
}

/* Payments table — компактные cells (11 колонок не помещаются с дефолтными отступами) */
.biz-table.payments-table {
  table-layout: fixed;  /* колонки берут ширину из colgroup, не из max-content */
  width: 100%;
}
.biz-table.payments-table th,
.biz-table.payments-table td {
  padding: 8px 8px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;  /* длинные username не растягивают столбец */
}
.biz-table.payments-table .muted { color: var(--muted); font-size: 11px; }

/* Фиксированная высота строки. Status-pill (padding+line-height) делает
   data-row ~36.5px; tr height — это min, поэтому ставим 38px + box-sizing
   на td: гарантированно равные строки независимо от содержимого. */
.biz-table.payments-table tbody tr { height: 38px; }
.biz-table.payments-table tbody td {
  height: 38px;
  box-sizing: border-box;
  vertical-align: middle;
}

/* Empty padding rows — фиксируют высоту таблицы при <20 платежах */
.biz-table.payments-table tr.empty-row {
  pointer-events: none;
}
.biz-table.payments-table tr.empty-row td {
  border-color: transparent;
  color: transparent;
}
.biz-table.payments-table tr.empty-row.no-data-row td {
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* Export-кнопка (⬇ XLSX) — прижимается вправо, выделена контрастом */
.filter-export {
  padding: 7px 12px;
  margin-left: auto;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.35);
  border-radius: 8px;
  color: #86efac;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.filter-export:hover {
  background: rgba(74, 222, 128, 0.14);
  border-color: rgba(74, 222, 128, 0.6);
  color: #bbf7d0;
}

/* Toggle-кнопка (Show expired) — checkbox-style без popover */
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.filter-toggle:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); }
.filter-toggle.active {
  border-color: rgba(124, 162, 255, 0.55);
  background: rgba(124, 162, 255, 0.10);
  color: var(--text);
}
.filter-toggle-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
  line-height: 1;
}
.filter-toggle.active .filter-toggle-box {
  background: #3E7BFF;
  border-color: #3E7BFF;
}

/* Traffic table — фиксированная ширина колонок (иначе username "прыгает")
   + единая высота строки (~55px т.к. user-cell/date-stack/used-stack/usage-stack
   двухстрочные) + empty-row padding для стабильности высоты на любой странице */
.biz-table.traffic-table {
  table-layout: fixed;
  width: 100%;
}
.biz-table.traffic-table th,
.biz-table.traffic-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.biz-table.traffic-table tbody tr { height: 56px; }
.biz-table.traffic-table tbody td {
  height: 56px;
  box-sizing: border-box;
  vertical-align: middle;
}
.biz-table.traffic-table tr.empty-row { pointer-events: none; }
.biz-table.traffic-table tr.empty-row td {
  border-color: transparent;
  color: transparent;
}
.biz-table.traffic-table tr.empty-row.no-data-row td {
  color: var(--muted);
  text-align: center;
  font-style: italic;
}

/* Expired rows — приглушены */
.biz-table.traffic-table tr.row-expired td {
  opacity: 0.55;
  font-style: italic;
}
.biz-table.traffic-table tr.row-expired .user-name {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(251, 113, 133, 0.4);
}

/* Popover host — живёт в body, не в tableEl (см. ensureTrafficPopoverHost) */
.filter-popover-host { position: relative; z-index: 50; }
.filter-popover-host-fixed {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  z-index: 1000;
  pointer-events: none;  /* сами popover'ы переопределяют */
}
.filter-popover-host-fixed > * { pointer-events: auto; }
.popover {
  position: fixed;
  min-width: 320px;
  max-width: 400px;
  background: #0e1220;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  padding: 14px;
  z-index: 100;
  animation: popoverIn 0.12s ease-out;
}
@keyframes popoverIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.popover-inner { display: flex; flex-direction: column; gap: 10px; }
.popover-search {
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.popover-search::placeholder { color: var(--muted); }
.popover-search:focus {
  border-color: rgba(124, 162, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 162, 255, 0.12);
}

.ms-counter {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 2px 2px;
}
.ms-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 2px;
}
.ms-row-selected {
  background: rgba(124, 162, 255, 0.08);
}
.ms-row-selected .ms-label {
  color: #A5C2FF;
  font-weight: 500;
}
.ms-list::-webkit-scrollbar { width: 6px; }
.ms-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.09); border-radius: 3px; }
.ms-list::-webkit-scrollbar-track { background: transparent; }

.ms-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.08s ease;
}
.ms-row:hover { background: rgba(255, 255, 255, 0.05); }
.ms-row input {
  accent-color: #7CA2FF;
  cursor: pointer;
  width: 14px;
  height: 14px;
}
.ms-label { flex: 1; color: var(--text); }
.ms-hint {
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.popover-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.popover-field > span {
  color: var(--muted);
  min-width: 50px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 10px;
}
.popover-field input {
  flex: 1;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  color-scheme: dark;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.popover-field input:focus {
  border-color: rgba(124, 162, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 162, 255, 0.12);
}

.popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.popover-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.popover-btn:hover { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); }
.popover-btn.primary {
  background: #3E7BFF;
  border-color: #3E7BFF;
  color: #fff;
}
.popover-btn.primary:hover { background: #2F63E6; border-color: #2F63E6; }

/* ── Кастомный календарь (Date popover) ──────────────── */
.date-popover { min-width: 280px; }
.date-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.date-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  text-align: left;
}
.date-tab:hover { background: rgba(255, 255, 255, 0.06); }
.date-tab.active {
  border-color: rgba(124, 162, 255, 0.55);
  background: rgba(124, 162, 255, 0.10);
}
.date-tab-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.date-tab-value {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.date-tab.active .date-tab-value { color: #A5C2FF; }

.date-calendar {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  padding: 10px;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.cal-nav {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background 0.1s, color 0.1s;
}
.cal-nav:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.cal-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 0;
}
.cal-weekdays .cal-we { color: #FB7185; opacity: 0.7; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  height: 30px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.cal-day:hover:not([disabled]):not(.cal-selected) {
  background: rgba(124, 162, 255, 0.15);
}
.cal-day.cal-mute { color: var(--muted); opacity: 0.35; cursor: default; }
.cal-day.cal-we { color: #FDA4AF; }
.cal-day.cal-today {
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(124, 162, 255, 0.5) inset;
}
.cal-day.cal-in-range {
  background: rgba(124, 162, 255, 0.08);
  border-radius: 0;
}
.cal-day.cal-selected {
  background: #3E7BFF;
  color: #fff;
  font-weight: 600;
}
.cal-day.cal-selected:hover { background: #2F63E6; }
.cal-day.cal-from { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-day.cal-to { border-top-left-radius: 0; border-bottom-left-radius: 0; }
/* Если from и to в один день — оставить полный radius */
.cal-day.cal-from.cal-to { border-radius: 5px; }

.cal-footer {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.cal-action {
  flex: 1;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.cal-action:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }

/* ── Dual-handle range slider (Usage popover) ──────── */
.pct-popover { min-width: 240px; }
.pct-values {
  display: flex;
  justify-content: space-between;
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}
.pct-val-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.pct-val-wrap:focus-within {
  border-color: rgba(124, 162, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 162, 255, 0.12);
}
.pct-val-min-wrap { border-color: rgba(74, 222, 128, 0.18); }
.pct-val-max-wrap { border-color: rgba(251, 113, 133, 0.18); }
.pct-val-input {
  width: 30px;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 0;
  -moz-appearance: textfield;
  font-family: inherit;
}
.pct-val-input::-webkit-outer-spin-button,
.pct-val-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.pct-val-min { color: #4ade80; }
.pct-val-max { color: #FB7185; }
.pct-val-suffix {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.range-slider {
  position: relative;
  height: 28px;
  margin: 6px 6px 10px;
}
.range-track {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}
.range-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.7), rgba(124, 162, 255, 0.75), rgba(251, 113, 133, 0.7));
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}
.range-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  pointer-events: none;
  outline: none;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #7CA2FF;
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(124, 162, 255, 0);
  transition: box-shadow 0.15s ease, transform 0.08s ease;
}
.range-input::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 6px rgba(124, 162, 255, 0.12);
}
.range-input::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6), 0 0 0 8px rgba(124, 162, 255, 0.18);
}
.range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #7CA2FF;
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.range-input::-moz-range-thumb:active { cursor: grabbing; }
/* Min handle = зелёный border, max = красный — соответствует pct value bg */
.range-min::-webkit-slider-thumb { border-color: #4ade80; }
.range-max::-webkit-slider-thumb { border-color: #FB7185; }
.range-min::-moz-range-thumb { border-color: #4ade80; }
.range-max::-moz-range-thumb { border-color: #FB7185; }
.range-input::-webkit-slider-runnable-track { background: transparent; }
.range-input::-moz-range-track { background: transparent; }

/* Sub-sort кнопки (M / W) внутри Used / Usage headers */
.sub-sort {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--lbl, var(--muted));
  font-weight: 700;
  font-size: 11px;
  user-select: none;
  transition: background 0.1s;
}
.sub-sort:hover { background: rgba(255, 255, 255, 0.06); }
.sub-sort.active { background: rgba(124, 162, 255, 0.18); }
.sub-sort-sep { color: var(--muted); font-weight: 400; }

/* ── Responsive ───────────────────────────── */
@media (max-width: 768px) {
  body { padding: 14px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .biz-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .stat-card .value { font-size: 22px; }
  .sparkline-grid { grid-template-columns: 1fr; }
  .node-grid-compact { grid-template-columns: repeat(2, 1fr); }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .header-left { flex-direction: column; align-items: flex-start; gap: 8px; }
  .controls-bar { flex-direction: column; align-items: flex-start; }
  .biz-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .node-grid-compact { grid-template-columns: 1fr; }
}

/* ── Billing CRUD modal ─────────────────────────────────── */
.billing-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.billing-modal.hidden { display: none; }
.billing-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.billing-modal-content { position: relative; background: var(--card-solid); border: 1px solid var(--border-solid); border-radius: var(--radius); max-width: 560px; width: 92%; max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.billing-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-solid); }
.billing-modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.billing-modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.billing-modal-close:hover { background: var(--border-solid); color: var(--text); }
.billing-modal-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.billing-modal-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.billing-modal-form input, .billing-modal-form select, .billing-modal-form textarea { padding: 6px 10px; border: 1px solid var(--border-solid); border-radius: 4px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--bg); }
.billing-modal-form input:focus, .billing-modal-form select:focus, .billing-modal-form textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; border-color: transparent; }
.billing-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.billing-form-hint { font-size: 11px; font-weight: normal; color: var(--muted); margin-left: 4px; }
.billing-modal-error { color: var(--red); font-size: 13px; min-height: 18px; }
.billing-modal-error:empty { display: none; }
.billing-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.billing-btn-primary, .billing-btn-secondary { padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; border: 1px solid transparent; }
.billing-btn-primary { background: var(--blue); color: #fff; }
.billing-btn-primary:hover:not(:disabled) { opacity: 0.9; }
.billing-btn-primary:disabled { opacity: 0.6; cursor: wait; }
.billing-btn-secondary { background: transparent; color: var(--text); border-color: var(--border-solid); }
.billing-btn-secondary:hover { background: var(--border-solid); }

/* Row action buttons */
.row-actions { display: inline-flex; gap: 6px; }
.row-action-btn { background: none; border: 1px solid var(--border-solid); border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 12px; color: var(--muted); }
.row-action-btn:hover { background: var(--border-solid); color: var(--text); }
.row-action-btn.danger { color: var(--red); }
.row-action-btn.danger:hover { background: rgba(251, 113, 133, 0.15); }

/* ── Billing tab — additional styles ────────────────────────── */

/* Vertical breathing room between stacked sections inside Billing.
   .chart-card has no global margin-bottom; Business/Users have their own
   16px override. Billing was inheriting nothing → cards touched. */
#billingSection > .stats-row,
#billingSection > .chart-card,
#billingSection > section.chart-card {
  margin-bottom: 22px;
}
#billingSection > :last-child { margin-bottom: 0; }

/* Empty-state in KPI row: span all grid columns + center text.
   Without grid-column:1/-1, the .empty would take 1/5 width and wrap to
   4 narrow lines next to 4 implicit-empty grid slots. */
#billingKpiCards .empty {
  grid-column: 1 / -1;
  padding: 18px 16px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  background: rgba(124, 162, 255, 0.04);
  border: 1px dashed var(--border-solid);
  border-radius: var(--radius);
}


/* card-controls in billing tab — right-side toolbar of chart-title-row.
   Globally undefined elsewhere; only used by billing. */
#billingSection .card-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Second-row toolbar under the Серверы title (filters + search).
   Separated from card-controls so the title-row stays clean even when
   there are many filter pills. */
.billing-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.billing-filters-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.billing-search {
  padding: 7px 10px;
  background: var(--card-solid);
  border: 1px solid var(--border-solid);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  min-width: 220px;
  flex: 0 1 280px;
  outline: none;
  transition: border-color 0.12s;
}
.billing-search:focus { border-color: rgba(124, 162, 255, 0.55); }

/* Breakdown horizontal bar */
.billing-breakdown {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 0;
}
.billing-breakdown-bar {
  display: flex;
  gap: 2px;
  width: 100%;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border-solid);
}
.billing-breakdown-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  transition: filter 0.12s, opacity 0.12s;
  cursor: default;
  min-width: 2px;
}
.billing-breakdown-seg:hover { filter: brightness(1.18); }
.billing-breakdown-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--text);
}
.billing-breakdown-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.billing-breakdown-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.billing-breakdown-legend-name {
  font-weight: 500;
}
.billing-breakdown-legend-val {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.billing-breakdown-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Group rows in servers table */
.biz-table.billing-table {
  table-layout: fixed;
  width: 100%;
}
.biz-table.billing-table th,
.biz-table.billing-table td {
  padding: 9px 10px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.biz-table.billing-table tbody tr.billing-group-row {
  background: rgba(124, 162, 255, 0.06);
  cursor: pointer;
  font-weight: 600;
}
.biz-table.billing-table tbody tr.billing-group-row:hover {
  background: rgba(124, 162, 255, 0.12);
}
.biz-table.billing-table tbody tr.billing-group-row td {
  padding: 13px 10px;
  border-top: 1px solid var(--border-solid);
  border-bottom: 1px solid var(--border-solid);
  color: var(--text);
}
/* First group row has no border-top (no separator above the very first group). */
.biz-table.billing-table tbody tr.billing-group-row:first-child td {
  border-top: none;
}
.billing-group-toggle {
  display: inline-block;
  width: 12px;
  margin-right: 6px;
  color: var(--muted);
  transition: transform 0.12s;
  font-size: 10px;
}
.billing-group-row.collapsed .billing-group-toggle {
  transform: rotate(-90deg);
}
.billing-group-meta {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: 8px;
}
/* Data rows keep the same padding as header cells so column values align
   under their column headers. Visual hierarchy under groups comes from the
   tinted background + top border of the group row, not from indent. */
.biz-table.billing-table tbody tr.billing-data-row td {
  padding-left: 10px;
}
/* Last cell: pull actions in a touch from the right edge for visual rhythm. */
.biz-table.billing-table tbody tr.billing-data-row td.row-actions {
  padding-right: 12px;
}
.biz-table.billing-table th:last-child {
  padding-right: 12px;
}
.biz-table.billing-table tbody tr.billing-data-row.row-retired {
  opacity: 0.55;
}
.biz-table.billing-table tbody tr.billing-grand-total {
  background: rgba(74, 222, 128, 0.06);
  font-weight: 700;
  border-top: 2px solid var(--border-solid);
}
.biz-table.billing-table tbody tr.billing-grand-total td {
  padding: 12px 8px;
  color: var(--text);
}
.billing-currency-native {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}
.billing-variable-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Заметка под именем сервера — объясняет странную сумму в строке (напр. счёт
   всего облака записан на один сервер). Читается сразу, без наведения мышью. */
.billing-row-note {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
  color: #8A96B4;
  max-width: 34ch;
}
.billing-retired-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #C9D4F2;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Tooltip hint for disabled name field in edit */
.billing-form-disabled-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-style: italic;
}

/* Help icon — small circled "?" with native tooltip on hover (via title=).
   Used in modal labels next to fields with non-obvious meaning (Kind, Cycle). */
.bf-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(124, 162, 255, 0.10);
  border: 1px solid rgba(124, 162, 255, 0.35);
  border-radius: 50%;
  cursor: help;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.bf-help:hover {
  background: rgba(124, 162, 255, 0.25);
  color: var(--text);
  border-color: rgba(124, 162, 255, 0.6);
}

/* ── Support tickets tab (support v3) ── */
.sup-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.sup-list { display: flex; flex-direction: column; gap: 8px; max-height: 75vh; overflow-y: auto; }
.sup-item { background: var(--card-solid); border: 1px solid var(--border-solid); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.sup-item:hover { border-color: #3E7BFF; }
.sup-item.selected { border-color: #3E7BFF; }
.sup-item-top { display: flex; justify-content: space-between; gap: 8px; }
.sup-item-user { font-weight: 600; }
.sup-item-preview { color: var(--text); opacity: 0.75; font-size: 0.85em; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-item-date { font-size: 0.78em; margin-top: 4px; }
.sup-thread-card { display: flex; flex-direction: column; }
.sup-thread-header { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-solid); }
.sup-act-btn { margin-left: auto; background: var(--card-solid); border: 1px solid var(--border-solid); color: var(--text); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.sup-act-btn:hover { border-color: #3E7BFF; }
.sup-thread { max-height: 60vh; overflow-y: auto; padding: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.sup-bubble { max-width: 75%; border-radius: 12px; padding: 8px 12px; background: var(--card-solid); border: 1px solid var(--border-solid); }
.sup-bubble.op { align-self: flex-end; background: linear-gradient(135deg, rgba(62, 123, 255, 0.18), rgba(124, 58, 237, 0.14)); border-color: rgba(115, 150, 255, 0.28); }
.sup-bubble.user { align-self: flex-start; }
.sup-bubble-meta { font-size: 0.75em; opacity: 0.6; margin-bottom: 4px; }
.sup-bubble-text { white-space: pre-wrap; word-break: break-word; }
.sup-img { display: block; max-width: 320px; max-height: 320px; border-radius: 8px; margin: 4px 0; }
.sup-file { display: inline-block; margin: 4px 0; }
.sup-reply { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border-solid); }
.sup-reply textarea { flex: 1; background: var(--bg); border: 1px solid var(--border-solid); color: var(--text); border-radius: 8px; padding: 8px; resize: vertical; font: inherit; }
.sup-send-btn { background: var(--grad); border: none; color: #fff; border-radius: 8px; padding: 0 18px; cursor: pointer; font-weight: 600; }
@media (max-width: 900px) { .sup-layout { grid-template-columns: 1fr; } }

/* ══ Redesign (web-redesign, этап 3): token-полиш поверх базовых правил ══ */

/* JetBrains Mono для «телеметрийных» значений — код-подписи и часы в шапке */
.updated {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}
.key-code { font-family: var(--font-mono, ui-monospace, monospace); }

/* Inline-SVG иконки внутри бейджей/кнопок (замена эмодзи-глифов).
   1em — масштабируются с окружающим текстом (KPI-звезда крупная, бейджи мелкие) */
.icon-inline { width: 1em; height: 1em; vertical-align: -0.12em; flex-shrink: 0; }
.badge svg { width: 12px; height: 12px; vertical-align: -1.5px; }
.row-action-btn svg { width: 13px; height: 13px; vertical-align: -2px; display: block; }
.filter-clear svg, .filter-export svg, .filter-toggle svg { flex-shrink: 0; }

/* Статус-дот — замена эмодзи-статусов (промокоды, тикеты) */
.sdot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; vertical-align: middle;
}
.sdot.ok   { background: var(--green); box-shadow: 0 0 6px rgba(74, 222, 128, 0.6); }
.sdot.warn { background: var(--amber); box-shadow: 0 0 6px rgba(251, 191, 36, 0.55); }
.sdot.bad  { background: var(--red);   box-shadow: 0 0 6px rgba(251, 113, 133, 0.55); }
.sdot.idle { background: var(--muted); }

/* Export/Add/Clear-кнопки: inline-flex под иконку + текст */
.filter-export { display: inline-flex; align-items: center; gap: 6px; }
.filter-clear  { display: inline-flex; align-items: center; gap: 6px; }
.billing-btn-add {
  background: rgba(62, 123, 255, 0.10);
  border-color: rgba(62, 123, 255, 0.35);
  color: #A5C2FF;
}
.billing-btn-add:hover {
  background: rgba(62, 123, 255, 0.16);
  border-color: rgba(62, 123, 255, 0.55);
  color: #C9D4F2;
}

/* Мобильная шапка — не sticky (стек логотип+режимы съедал бы пол-экрана).
   mode-switcher переносится (5 pill-кнопок шире 400px); liveSessions — ID-грид
   repeat(5) специфичнее media .stats-row → нужен явный mobile-override. */
@media (max-width: 768px) {
  .header { position: static; margin: -14px -14px 16px; }
  .mode-switcher { flex-wrap: wrap; border-radius: 18px; max-width: 100%; }
  #liveSessionsCards { grid-template-columns: repeat(2, 1fr); }
}
