:root {
  color-scheme: dark;
  --bg: #070a10;
  --bg-elevated: #0b0f17;
  --panel: #0e131c;
  --panel-hover: #111827;
  --muted: #8b95a8;
  --fg: #eef2f8;
  --fg-soft: #c8d0dc;
  --accent: #2ee89a;
  --accent-muted: #1fa86a;
  --accent-dim: rgba(46, 232, 154, 0.12);
  --accent-ring: rgba(46, 232, 154, 0.45);
  --accent-glow: rgba(46, 232, 154, 0.4);
  --line: rgba(255, 255, 255, 0.055);
  --line-strong: rgba(255, 255, 255, 0.09);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.55);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  --ease: cubic-bezier(0.25, 0.08, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -25%, rgba(46, 232, 154, 0.055), transparent 50%),
    radial-gradient(ellipse 55% 45% at 95% 20%, rgba(99, 140, 255, 0.035), transparent);
  color: var(--fg);
  font: 14px/1.5 var(--font);
  letter-spacing: -0.011em;
}

body.is-loading {
  overflow: hidden;
}

/* —— Preloader —— */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(46, 232, 154, 0.08), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, rgba(99, 140, 255, 0.05), transparent);
  transition: opacity 0.55s var(--ease-out), visibility 0.55s;
}

.preloader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
}

.preloader-logo {
  display: grid;
  grid-template-columns: repeat(2, 14px);
  gap: 5px;
  margin-bottom: 4px;
}

.preloader-logo span {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--accent);
  animation: preloader-pulse 1.2s var(--ease) infinite;
  box-shadow: 0 0 12px var(--accent-glow);
}

.preloader-logo span:nth-child(1) { animation-delay: 0s; opacity: 1; }
.preloader-logo span:nth-child(2) { animation-delay: 0.15s; opacity: 0.85; }
.preloader-logo span:nth-child(3) { animation-delay: 0.3s; opacity: 0.7; }
.preloader-logo span:nth-child(4) { animation-delay: 0.45s; opacity: 0.55; }

@keyframes preloader-pulse {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.08); opacity: 1; }
}

.preloader-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--fg);
}

.preloader-sub {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.preloader-track {
  width: min(220px, 70vw);
  height: 3px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.preloader-bar {
  display: block;
  height: 100%;
  width: 35%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent), var(--accent-muted));
  animation: preloader-slide 1.1s var(--ease) infinite;
}

@keyframes preloader-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(340%); }
}

.wrap {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  background: linear-gradient(180deg, #0f141e 0%, var(--panel) 48px);
  border-right: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  width: 340px;
  min-height: 0;
  overflow: hidden;
}

.sidebar::-webkit-scrollbar,
.sb-list::-webkit-scrollbar,
.content::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sidebar::-webkit-scrollbar-thumb,
.sb-list::-webkit-scrollbar-thumb,
.content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.sidebar::-webkit-scrollbar-track,
.sb-list::-webkit-scrollbar-track {
  background: transparent;
}

.content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018) 0%, transparent 120px);
}

/* —— Sidebar header —— */
.sb-header {
  flex-shrink: 0;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--fg);
  border-radius: var(--radius-md);
  padding: 4px 8px 4px 4px;
  margin: -4px;
  min-width: 0;
  transition: background 0.18s var(--ease);
}

.brand:hover {
  background: rgba(255, 255, 255, 0.04);
}

.brand:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(46, 232, 154, 0.15), rgba(8, 12, 18, 0.9));
  box-shadow: var(--shadow-inset), 0 0 0 1px rgba(46, 232, 154, 0.2);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.brand .t1 {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand .t2 {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.admin-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.admin-btn:hover {
  color: var(--fg);
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.admin-btn:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
}

/* —— Selected server preview —— */
.sb-preview {
  flex-shrink: 0;
  margin: 12px 14px 16px;
  padding: 14px 14px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.045), rgba(0, 0, 0, 0.25));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

.preview-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-shrink: 0;
}

.preview-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  flex-shrink: 0;
  overflow: hidden;
  background: #0a0e14;
  box-shadow: 0 0 0 1px var(--line-strong);
}

.preview-avatar-inner {
  width: 100%;
  height: 100%;
  display: block;
}

.preview-avatar-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-info {
  flex: 1;
  min-width: 0;
}

.preview-name {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-stats {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: end;
  flex-shrink: 0;
}

.preview-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.preview-stat-val {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  line-height: 1;
}

.preview-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.preview-divider {
  width: 1px;
  height: 32px;
  background: var(--line-strong);
  align-self: center;
}

.preview-fill-wrap {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-fill {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.preview-fill span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  transition: width 0.4s var(--ease-out);
}

.preview-fill-pct {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 2.5em;
  text-align: right;
}

.preview-addr {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.preview-addr-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.preview-addr-val {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 11px;
  color: var(--fg-soft);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  line-height: 1.45;
  word-break: break-all;
  display: block;
}

.preview-motd-slot {
  flex-shrink: 0;
  height: 84px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.14);
  border: 1px dashed var(--line);
}

.preview-motd-slot:has(.preview-motd:not(:empty)) {
  background: rgba(0, 0, 0, 0.22);
  border-style: solid;
}

.preview-motd {
  margin: 0;
  padding: 10px 11px;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.preview-motd:empty::before {
  content: "Sunucu mesajı burada görünür";
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
  opacity: 0.55;
  padding: 10px 11px;
}

.preview-motd-slot.is-idle .preview-motd:empty::before {
  content: none;
}

.motd {
  font-size: 13px;
  color: var(--fg-soft);
  word-break: break-word;
  line-height: 1.55;
}

/* —— Server list nav —— */
.sb-nav {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.sb-nav-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 10px;
}

.sb-nav-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.sb-nav-badge {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--fg-soft);
}

.sb-search-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 10px;
  padding: 0 12px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.sb-search-wrap:focus-within {
  border-color: rgba(46, 232, 154, 0.35);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.sb-search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.sb-search {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.sb-search::placeholder {
  color: var(--muted);
}

.sb-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sb-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* —— Server list item —— */
.srv-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition:
    background 0.16s var(--ease),
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
  position: relative;
}

.srv-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transform: scaleY(0.6);
  transition: opacity 0.16s var(--ease), transform 0.16s var(--ease-out);
}

.srv-item:hover {
  background: rgba(255, 255, 255, 0.035);
}

.srv-item:focus-visible {
  outline: none;
  border-color: rgba(46, 232, 154, 0.35);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.srv-item.active {
  background: rgba(46, 232, 154, 0.08);
  border-color: rgba(46, 232, 154, 0.22);
}

.srv-item.active::before {
  opacity: 1;
  transform: scaleY(1);
}

.srv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  overflow: hidden;
  background: #0a0e14;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 0 1px var(--line);
  display: grid;
  place-items: stretch;
}

.srv-avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  background: var(--muted);
}

.srv-avatar[data-status="online"]::after {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.srv-avatar[data-status="offline"]::after {
  background: #ff5a5a;
}

.srv-avatar--all {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(46, 232, 154, 0.1), rgba(8, 12, 18, 0.95));
  color: var(--accent);
}

.srv-avatar--all::after {
  display: none;
}

.srv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
}

.avatar-fallback {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--fg-soft);
  background: linear-gradient(145deg, #141c28, #0a0e14);
}

.srv-body {
  min-width: 0;
}

.srv-name {
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.srv-host {
  margin-top: 1px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cap-bar {
  margin-top: 6px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.cap-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  min-width: 0;
  transition: width 0.35s var(--ease-out);
}

.srv-count {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #d4f5e8;
  padding: 4px 0;
  text-align: right;
  min-width: 2.5em;
  line-height: 1;
}

.srv-item:not(.active) .srv-count {
  color: var(--fg-soft);
  font-weight: 700;
  font-size: 13px;
}

.status-pill {
  flex-shrink: 0;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.3);
  color: var(--muted);
}

.status-pill[data-status="online"] {
  color: #9ef0c8;
  border-color: rgba(46, 232, 154, 0.35);
  background: rgba(46, 232, 154, 0.12);
}

.status-pill[data-status="offline"] {
  color: #ffb0b0;
  border-color: rgba(255, 90, 90, 0.35);
  background: rgba(255, 90, 90, 0.1);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 19, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.tsel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tdot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 14px var(--accent-glow);
  flex-shrink: 0;
}

.toolbar-title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.03em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(420px, 55vw);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.range-group {
  padding: 4px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-inset);
}

.btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-soft);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.01em;
  transition:
    color 0.15s var(--ease),
    background 0.15s var(--ease),
    border-color 0.15s var(--ease),
    box-shadow 0.15s var(--ease);
  font-family: inherit;
}

.btn:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.06);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent-ring);
}

.btn.active {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(46, 232, 154, 0.28);
  box-shadow: 0 1px 8px rgba(46, 232, 154, 0.08);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 22, 0.6);
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-soft);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.leg-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}

.leg-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.chart-hint {
  margin: 0;
  padding: 8px 20px 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.chart-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  font-size: 10px;
  font-family: inherit;
  font-weight: 600;
  color: var(--fg-soft);
}

.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 20px 20px;
  gap: 0;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #060910;
  border: 1px solid var(--line-strong);
  box-shadow:
    var(--shadow-inset),
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 16px 48px rgba(0, 0, 0, 0.35);
}

#chart {
  width: 100%;
  height: 100%;
  min-height: 200px;
  display: block;
  flex: 1;
  background: #060910;
  cursor: crosshair;
}

.hover {
  position: absolute;
  pointer-events: none;
  min-width: 220px;
  max-width: 300px;
  background: rgba(16, 22, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 12px 14px;
  display: none;
}

.hover .h-time {
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.hover .h-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
}

.hover .h-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.hover .left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-soft);
  min-width: 0;
}

.hover .val {
  font-weight: 700;
  color: var(--fg);
  flex-shrink: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.sum {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hide {
  display: none;
}

.brush {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(46, 232, 154, 0.12);
  border: 1px solid rgba(46, 232, 154, 0.4);
  display: none;
  border-radius: 2px;
}

.content-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px 20px 0;
}

.head-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.head-sub {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.content-head .chart-hint {
  margin: 0;
  padding: 0;
  max-width: 280px;
  text-align: right;
  line-height: 1.45;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fg-soft);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}

.live-badge[data-state="live"] {
  border-color: rgba(46, 232, 154, 0.35);
  color: #b8f5d8;
  box-shadow: 0 0 20px rgba(46, 232, 154, 0.12);
}

.live-badge[data-state="live"] .live-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: live-pulse 2s var(--ease) infinite;
}

.live-badge[data-state="connecting"] .live-dot {
  background: #f0b429;
  animation: live-pulse 1.2s var(--ease) infinite;
}

.live-badge[data-state="error"] {
  border-color: rgba(255, 90, 90, 0.35);
  color: #ffb4b4;
}

.live-badge[data-state="error"] .live-dot {
  background: #ff5a5a;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.85); }
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 20px;
}

.stat-card {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.2));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease-out);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  opacity: 0.8;
}

.stat-card.accent {
  border-color: rgba(46, 232, 154, 0.28);
  background: linear-gradient(145deg, rgba(46, 232, 154, 0.12), rgba(8, 12, 18, 0.95));
}

.stat-card.accent::before {
  background: linear-gradient(90deg, var(--accent-muted), var(--accent), var(--accent-muted));
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  display: block;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.stat-card.accent .stat-value {
  color: #d4fce8;
}

.stat-sub {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.fill-bar {
  margin-top: 10px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.fill-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-muted), var(--accent));
  transition: width 0.45s var(--ease-out);
}

@media (max-width: 768px) {
  .wrap {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--line-strong);
    max-height: none;
    overflow: visible;
  }

  .sb-nav {
    max-height: 42vh;
  }

  .sb-preview {
    margin-left: 12px;
    margin-right: 12px;
  }

  .preview-stats {
    grid-template-columns: 1fr auto 1fr;
  }

  .content {
    min-height: 52vh;
    overflow: visible;
  }

  .toolbar {
    padding: 12px 16px;
    position: relative;
  }

  .toolbar-title {
    max-width: 100%;
    font-size: 16px;
  }

  .range-group {
    width: 100%;
    justify-content: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1 1 auto;
    text-align: center;
    padding: 10px 8px;
  }

  .legend {
    padding: 10px 16px;
  }

  .chart-wrap {
    padding: 10px 16px 16px;
    min-height: min(45vh, 360px);
  }

  .canvas-wrap {
    min-height: 220px;
  }

  .chart-hint {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sb-preview {
    min-width: 0;
  }

  .stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 16px;
  }

  .content-head {
    padding: 12px 16px 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .content-head .chart-hint {
    text-align: left;
    max-width: none;
  }

  .stat-value {
    font-size: 1.35rem;
  }
}

@media (max-width: 420px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .srv-item:active {
    transform: none;
  }

  .preloader-bar {
    width: 100%;
    animation: none;
  }
}
