:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --bg-soft: #0f131a;
  --surface: #131820;
  --surface-2: #181f2a;
  --surface-3: #1d2531;
  --border: #25303f;
  --border-soft: #1c2532;
  --text: #e8edf5;
  --muted: #8d9aab;
  --muted-2: #687588;
  --accent: #5eead4;
  --accent-strong: #2dd4bf;
  --accent-soft: rgba(94, 234, 212, 0.12);
  --blue: #7c9cff;
  --blue-soft: rgba(124, 156, 255, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --sidebar-width: 292px;
  --font: "SF Pro Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 600px at 78% -10%, rgba(94, 234, 212, 0.07), transparent 60%),
    radial-gradient(800px 500px at 0% 100%, rgba(124, 156, 255, 0.05), transparent 60%),
    var(--bg);
}

::selection { background: rgba(94, 234, 212, 0.25); color: #fff; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: #93f5e4; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.9em; background: var(--surface-3); border: 1px solid var(--border-soft); border-radius: 6px; padding: 1px 6px; color: #cdeee8; }
hr { border: 0; border-top: 1px solid var(--border); }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  transform: translateY(-200%);
  background: var(--accent);
  color: #04110e;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
}
.skip-link:focus { transform: translateY(0); }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background: linear-gradient(180deg, #10151d 0%, #0d1117 100%);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  z-index: 30;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent) 0%, #2b9d8e 100%);
  color: #04110e;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.22);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.2; }
.brand-copy strong { font-size: 16px; letter-spacing: 0.01em; }
.brand-copy small { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted-2); }
.sidebar-close { display: none; }
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  width: fit-content;
}
.mode-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.mode-chip.public .mode-dot { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }

.field-label, .server-select-label {
  display: block;
  margin-bottom: 7px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.server-picker { position: relative; }
.server-picker-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 8px 12px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 140ms ease, background 140ms ease;
}
.server-picker-button:hover { border-color: #37455a; background: var(--surface-2); }
.server-picker-empty { color: var(--muted); }
.picker-chevron { margin-left: auto; color: var(--muted-2); }
.server-avatar-wrap { position: relative; width: 34px; height: 34px; flex: none; }
.picker-avatar { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; }
.picker-avatar-fallback, .server-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--accent);
  font-weight: 800;
}
.server-picker-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.server-picker-copy strong, .server-picker-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-picker-copy strong { font-size: 13.5px; }
.server-picker-copy small { color: var(--muted-2); font-size: 11.5px; }
.server-picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow-y: auto;
  padding: 6px;
  background: #111720;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
}
.server-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
}
.server-option:hover { background: var(--surface-2); }
.server-option-check { margin-left: auto; color: var(--accent); font-weight: 800; }
.server-picker-menu .server-picker-empty { padding: 12px; font-size: 13px; }

.main-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
  margin: 14px 10px 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.nav-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 550;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}
.nav-button .icon { width: 17px; height: 17px; color: var(--muted-2); }
.nav-button:hover { color: var(--text); background: var(--surface); }
.nav-button.active { color: var(--text); background: var(--accent-soft); border-color: rgba(94, 234, 212, 0.18); }
.nav-button.active .icon { color: var(--accent); }

.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.sidebar-status { display: flex; flex-direction: column; gap: 5px; padding: 2px 2px 8px; }
.sidebar-status small { color: var(--muted-2); font-size: 11.5px; line-height: 1.4; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  text-align: left;
  font-size: 12.5px;
}
.sidebar-link:hover { color: var(--text); background: var(--surface); }
.sidebar-link .icon { width: 16px; height: 16px; }
.external-icon { width: 13px !important; height: 13px !important; margin-left: auto; }

.local-badge, .status-badge, .badge, .count-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.status-connected { color: var(--success); border-color: rgba(52, 211, 153, 0.25); background: var(--success-soft); }
.status-disconnected { color: var(--danger); border-color: rgba(248, 113, 113, 0.25); background: var(--danger-soft); }
.status-unavailable { color: var(--warn); border-color: rgba(251, 191, 36, 0.25); background: var(--warn-soft); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-connected .live-dot { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12); }

.main { min-width: 0; display: flex; flex-direction: column; padding: 26px 32px 20px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.topbar-left { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.page-heading { min-width: 0; }
.page-heading h1 { margin: 4px 0 3px; font-size: clamp(24px, 2.6vw, 34px); line-height: 1.15; letter-spacing: -0.02em; }
.page-subtitle { margin: 0; max-width: 680px; color: var(--muted); font-size: 13.5px; }
.top-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.menu-toggle { display: none; }
.viewer-badge { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.2;
  color: var(--text);
  background: var(--surface-2);
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.button:hover { background: var(--surface-3); }
.button:active { transform: translateY(1px); }
.button .icon { width: 15px; height: 15px; }
.button-primary { color: #04110e; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: #7df3df; border-color: #7df3df; }
.button-quiet { color: var(--muted); background: transparent; border-color: var(--border); }
.button-quiet:hover { color: var(--text); background: var(--surface); border-color: #364458; }
.button-danger { color: #25090b; background: var(--danger); border-color: var(--danger); }
.button-danger:hover { background: #fb9494; }
.button.small { min-height: 31px; padding: 5px 9px; font-size: 11.5px; }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.back-button .icon { transform: rotate(180deg); }

.notice {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 44px));
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid rgba(94, 234, 212, 0.3);
  background: #10201d;
  color: #c9fff4;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.notice.visible { opacity: 1; transform: translateY(0); }
.notice.error { border-color: rgba(248, 113, 113, 0.35); background: #241214; color: #ffd4d4; }

.state-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(140deg, var(--surface) 0%, #10161f 100%);
  box-shadow: var(--shadow);
}
.state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 14px;
  color: var(--accent);
  background: var(--accent-soft);
}
.state-icon .icon { width: 23px; height: 23px; }
.state-copy h2 { margin: 5px 0 6px; font-size: 21px; }
.state-copy p { margin: 0; color: var(--muted); max-width: 720px; }
.state-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-grid[data-count="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid[data-count="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card {
  position: relative;
  overflow: hidden;
  padding: 16px 17px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: linear-gradient(150deg, var(--surface) 0%, #11161e 100%);
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -50px auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(94, 234, 212, 0.04);
}
.stat-label { display: block; margin-bottom: 8px; color: var(--muted-2); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.stat-value { display: block; font-size: 26px; line-height: 1.1; letter-spacing: -0.03em; }
.stat-detail { display: block; margin-top: 4px; color: var(--muted-2); font-size: 11.5px; }

.panel-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.panel-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel-grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface) 0%, #121821 100%);
}
.panel-highlight { border-color: rgba(94, 234, 212, 0.2); background: linear-gradient(150deg, rgba(94, 234, 212, 0.06), var(--surface)); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-heading h2, .panel-heading h3 { margin: 4px 0 3px; font-size: 17px; letter-spacing: -0.01em; }
.panel-heading p { margin: 0; color: var(--muted-2); font-size: 12.5px; }
.panel-heading .button { flex: none; }
.count-pill { color: var(--muted); background: var(--surface-2); }
.panel-actions-row { display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }

.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.server-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  transition: border-color 140ms ease, transform 140ms ease;
}
.server-card:hover { border-color: rgba(94, 234, 212, 0.3); transform: translateY(-1px); }
.server-card-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-card-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.server-card-copy strong, .server-card-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card-copy strong { font-size: 13.5px; }
.server-card-copy small { color: var(--muted-2); font-size: 11.5px; }
.server-card .button { width: 100%; }
.server-card-icon { width: 38px; height: 38px; border-radius: 11px; object-fit: cover; flex: none; }
.server-card-fallback { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px; flex: none; background: var(--surface-3); color: var(--accent); font-weight: 800; }

.health-list { display: flex; flex-direction: column; gap: 2px; }
.health-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.health-row:last-child { border-bottom: 0; }
.health-row-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.health-row-main .icon { color: var(--muted-2); }
.health-row-copy { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.health-row-copy strong { font-size: 12.5px; }
.health-row-copy small { color: var(--muted-2); font-size: 11px; }
.health-row-value { font-size: 12.5px; font-weight: 700; color: var(--text); white-space: nowrap; }
.health-row-value.ok { color: var(--success); }
.health-row-value.warn { color: var(--warn); }
.health-row-value.bad { color: var(--danger); }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.quick-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  transition: border-color 140ms ease, background 140ms ease;
}
.quick-card:hover { border-color: rgba(94, 234, 212, 0.3); background: var(--surface-3); }
.quick-card > .icon:first-child { color: var(--accent); }
.quick-card > .icon:last-child { margin-left: auto; color: var(--muted-2); width: 15px; height: 15px; }
.quick-card span { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.quick-card strong { font-size: 12.8px; }
.quick-card small { color: var(--muted-2); font-size: 11.2px; }

.server-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.server-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.server-icon { width: 58px; height: 58px; border-radius: 16px; object-fit: cover; flex: none; background: var(--surface-2); }
.server-icon-fallback { display: flex; align-items: center; justify-content: center; width: 58px; height: 58px; border-radius: 16px; flex: none; background: linear-gradient(145deg, var(--accent), #2b9d8e); color: #04110e; font-size: 20px; font-weight: 800; }
.server-copy { min-width: 0; }
.server-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.server-title-row h2 { margin: 0; font-size: 23px; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.server-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.view-panel { display: none; }
.view-panel.active { display: block; }

.analytics-block { display: flex; flex-direction: column; gap: 13px; }
.analytics-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.metric-tile { padding: 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border-soft); }
.metric-tile span { display: block; color: var(--muted-2); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.metric-tile strong { display: block; margin-top: 4px; font-size: 19px; letter-spacing: -0.02em; }
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 58px minmax(60px, 1fr) 48px; align-items: center; gap: 9px; }
.bar-row span { color: var(--muted-2); font-size: 11px; }
.bar-row b { color: var(--muted); font-size: 11px; text-align: right; font-weight: 600; }
.bar-row progress { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); appearance: none; }
.bar-row progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.bar-row progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); border-radius: 999px; }
.bar-row progress::-moz-progress-bar { background: linear-gradient(90deg, var(--accent-strong), var(--accent)); border-radius: 999px; }
.top-channel-list { display: flex; flex-direction: column; gap: 6px; }
.top-channel-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 9px; border-radius: 8px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.top-channel-row strong { color: var(--text); font-weight: 600; }

.queue-list, .mini-module-list, .activity-list, .compact-list { display: flex; flex-direction: column; gap: 7px; }
.queue-item, .mini-module, .activity-item, .audit-item, .security-event, .role-row, .channel-row, .toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
}
.activity-item, .audit-item, .security-event { align-items: flex-start; }
.activity-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-item-main strong { font-size: 12.5px; line-height: 1.35; overflow-wrap: anywhere; }
.activity-item-main small, .activity-item-main span { color: var(--muted-2); font-size: 11.2px; line-height: 1.4; overflow-wrap: anywhere; }
.activity-item-main a { color: var(--accent); }
.queue-item { align-items: flex-start; }
.queue-item strong { font-size: 12.5px; }
.queue-item small { color: var(--muted-2); font-size: 11.2px; }
.queue-count { font-size: 17px; font-weight: 800; color: var(--accent); }
.mini-module { align-items: flex-start; }
.mini-module span { color: var(--muted-2); font-size: 11.2px; }
.mini-module strong { font-size: 12.5px; }
.empty-state { padding: 18px; text-align: center; color: var(--muted-2); font-size: 12.5px; border: 1px dashed var(--border); border-radius: 11px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 600; }
.chip.ok { color: var(--success); border-color: rgba(52, 211, 153, 0.22); background: var(--success-soft); }
.chip.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.22); background: var(--warn-soft); }
.chip.bad { color: var(--danger); border-color: rgba(248, 113, 113, 0.22); background: var(--danger-soft); }
.chip.info { color: var(--blue); border-color: rgba(124, 156, 255, 0.22); background: var(--blue-soft); }

.security-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
  padding: 20px;
  border: 1px solid rgba(94, 234, 212, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.06), var(--surface));
}
.security-score { position: relative; width: 118px; height: 118px; flex: none; }
.score-ring { width: 118px; height: 118px; transform: rotate(-90deg); }
.score-track { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.score-value { fill: none; stroke: var(--accent); stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 500ms ease, stroke 300ms ease; }
.score-value.good { stroke: var(--success); }
.score-value.warn { stroke: var(--warn); }
.score-value.bad { stroke: var(--danger); }
.score-copy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; line-height: 1.1; }
.score-copy strong { font-size: 25px; letter-spacing: -0.04em; }
.score-copy small { margin-top: 2px; color: var(--muted-2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; }
.security-summary h2 { margin: 4px 0 5px; font-size: 20px; }
.security-summary p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.security-actions { display: flex; flex-direction: column; gap: 8px; }

.finding-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 11px; border-radius: 10px; background: var(--surface-2); }
.finding-copy { min-width: 0; }
.finding-copy strong { display: block; font-size: 12.5px; }
.finding-copy small { color: var(--muted-2); font-size: 11.2px; }
.severity { flex: none; padding: 4px 7px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.severity.critical { color: var(--danger); background: var(--danger-soft); }
.severity.high { color: #fb923c; background: rgba(251, 146, 60, 0.12); }
.severity.medium { color: var(--warn); background: var(--warn-soft); }
.severity.low { color: var(--blue); background: var(--blue-soft); }

.readonly-list .toggle-row { background: transparent; border: 1px solid var(--border-soft); }
.readonly-row .badge { margin-left: auto; flex: none; }
.toggle-row { cursor: default; }
.channel-setting-group { display: flex; flex-direction: column; gap: 8px; }
.channel-setting-group + .channel-setting-group { padding-top: 10px; border-top: 1px solid var(--border-soft); }
.toggle-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-row strong { font-size: 12.3px; line-height: 1.35; }
.toggle-row small { color: var(--muted-2); font-size: 11px; line-height: 1.4; }
.toggle-row input[type="checkbox"] { width: 34px; height: 18px; flex: none; appearance: none; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; transition: background 160ms ease, border-color 160ms ease; }
.toggle-row input[type="checkbox"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 160ms ease, background 160ms ease; }
.toggle-row input[type="checkbox"]:checked { background: var(--accent-soft); border-color: rgba(94, 234, 212, 0.5); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(16px); background: var(--accent); }
.toggle-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.module-toolbar { display: flex; gap: 9px; margin-bottom: 14px; }
.module-toolbar select { min-width: 190px; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); width: 16px; height: 16px; }
.search-field input { padding-left: 35px; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color 140ms ease, background 140ms ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { border-color: rgba(94, 234, 212, 0.55); background: #141b25; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted-2) 50%), linear-gradient(135deg, var(--muted-2) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
label input, label select, label textarea { margin-top: 5px; font-weight: 400; }
.stack-form { display: flex; flex-direction: column; gap: 10px; }
.inline-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.inline-fields label { display: flex; flex-direction: column; gap: 0; }
.form-subheading { color: var(--text); font-size: 12.5px; padding-top: 2px; }
.helper-text { margin: 0; color: var(--muted-2); font-size: 11.5px; line-height: 1.45; }

.module-groups { display: flex; flex-direction: column; gap: 17px; }
.module-group-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.module-group-heading h3 { margin: 0; font-size: 14px; }
.module-group-heading p { margin: 2px 0 0; color: var(--muted-2); font-size: 11.5px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 9px; }
.module-card { display: flex; flex-direction: column; gap: 7px; padding: 12px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border-soft); }
.module-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.module-status { padding: 3px 7px; border-radius: 999px; font-size: 9.5px; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.module-status.status-on { color: var(--success); background: var(--success-soft); }
.module-status.status-off { color: var(--muted-2); background: var(--surface-3); }
.module-status.status-config { color: var(--warn); background: var(--warn-soft); }
.module-card h3 { margin: 0; font-size: 13px; line-height: 1.3; }
.module-card p { margin: 0; color: var(--muted-2); font-size: 11.5px; line-height: 1.4; }
.module-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: auto; padding-top: 5px; }
.module-card-bottom small { color: var(--muted-2); font-size: 10px; overflow-wrap: anywhere; }
.mini-switch { display: inline-flex; align-items: center; flex: none; cursor: pointer; }
.mini-switch input { width: 34px; height: 18px; appearance: none; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); position: relative; margin: 0; padding: 0; transition: background 160ms ease; }
.mini-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 160ms ease, background 160ms ease; }
.mini-switch input:checked { background: var(--accent-soft); border-color: rgba(94, 234, 212, 0.5); }
.mini-switch input:checked::after { transform: translateX(16px); background: var(--accent); }
.panel-hint { color: var(--muted-2); font-size: 10px; }

.search-row { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.search-row .search-field { flex: 1; }
.compact-search { margin-bottom: 12px; }
.member-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 9px; margin-top: 14px; }
.member-card { display: flex; flex-direction: column; gap: 9px; padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-soft); }
.member-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.member-avatar { width: 40px; height: 40px; border-radius: 12px; object-fit: cover; flex: none; background: var(--surface-3); }
.member-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.member-info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-info small { color: var(--muted-2); font-size: 10.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-roles { color: var(--muted-2); font-size: 10.8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.member-actions .button { min-height: 29px; padding: 4px 7px; font-size: 10.5px; }

.channel-list, .role-list { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow-y: auto; padding-right: 2px; }
.channel-row { align-items: center; padding: 9px 10px; }
.channel-copy { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.channel-copy strong { font-size: 12.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-copy small { color: var(--muted-2); font-size: 10.8px; }
.channel-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.slowmode-form { display: flex; align-items: center; gap: 4px; }
.slowmode-form input { width: 64px; padding: 5px 7px; font-size: 11px; }
.role-row { padding: 8px 10px; }
.role-copy { display: flex; align-items: center; gap: 8px; min-width: 0; }
.role-swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.role-copy strong { font-size: 12.3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-meta { color: var(--muted-2); font-size: 10.8px; white-space: nowrap; }

.automation-groups { display: flex; flex-direction: column; gap: 18px; }
.automation-group h3 { margin: 0 0 8px; font-size: 13.5px; }
.automation-group .toggle-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }
.automation-group .toggle-row { padding: 9px 10px; }

.settings-action-list { display: flex; flex-direction: column; gap: 7px; }
.settings-action { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px; text-align: left; color: var(--text); background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 11px; }
.settings-action:hover { background: var(--surface-3); border-color: var(--border); }
.settings-action .icon { color: var(--accent); }
.settings-action span { display: flex; flex-direction: column; line-height: 1.35; }
.settings-action strong { font-size: 12.3px; }
.settings-action small { color: var(--muted-2); font-size: 11px; }
.settings-action.danger .icon { color: var(--danger); }
.settings-action.danger:hover { border-color: rgba(248, 113, 113, 0.3); }

.footer { display: flex; justify-content: space-between; gap: 14px; margin-top: auto; padding: 22px 2px 4px; color: var(--muted-2); font-size: 10.8px; border-top: 1px solid var(--border-soft); }

.dialog { width: min(520px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(3, 6, 10, 0.72); backdrop-filter: blur(4px); }
.dialog-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 24px; }
.dialog-card h2 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.dialog-card p { margin: 0; }
.dialog-close { position: absolute; top: 12px; right: 12px; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; }
.dialog-close:hover { color: var(--text); background: var(--surface-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.badge { font-size: 10.5px; padding: 4px 8px; }
.badge.ok { color: var(--success); background: var(--success-soft); border-color: rgba(52, 211, 153, 0.22); }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: rgba(251, 191, 36, 0.22); }
.badge.bad { color: var(--danger); background: var(--danger-soft); border-color: rgba(248, 113, 113, 0.22); }
.badge.info { color: var(--blue); background: var(--blue-soft); border-color: rgba(124, 156, 255, 0.22); }

.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(3, 6, 10, 0.62); backdrop-filter: blur(3px); }

@media (max-width: 1180px) {
  .panel-grid.two-col { grid-template-columns: 1fr; }
  .security-hero { grid-template-columns: auto minmax(0, 1fr); }
  .security-actions { grid-column: 1 / -1; flex-direction: row; }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-104%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-toggle { display: inline-flex; }
  .main { padding: 20px 18px 18px; }
  .topbar { align-items: flex-start; }
  .top-actions { justify-content: flex-start; }
  .viewer-badge { display: none; }
}

@media (max-width: 900px) {
  .stat-grid[data-count="4"], .stat-grid[data-count="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body { font-size: 14px; }
  .main { padding: 16px 12px 14px; }
  .topbar { flex-direction: column; gap: 12px; }
  .top-actions { width: 100%; justify-content: space-between; }
  .top-actions .button span { display: none; }
  .top-actions .button { min-width: 38px; padding: 8px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 21px; }
  .server-heading { align-items: flex-start; flex-direction: column; }
  .server-actions { width: 100%; }
  .panel { padding: 14px; }
  .panel-heading { flex-direction: column; align-items: flex-start; }
  .panel-heading .button { width: 100%; }
  .module-toolbar { flex-direction: column; }
  .module-toolbar select { min-width: 0; width: 100%; }
  .inline-fields { grid-template-columns: 1fr; }
  .security-hero { grid-template-columns: 1fr; justify-items: start; }
  .security-score { width: 100px; height: 100px; }
  .score-ring { width: 100px; height: 100px; }
  .score-copy strong { font-size: 22px; }
  .footer { flex-direction: column; gap: 4px; }
  .member-list { grid-template-columns: 1fr; }
  .dialog-card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
