:root {
  color-scheme: light;
  --ink: #101713;
  --black: #08110c;
  --muted: #5a645d;
  --line: #d7ded9;
  --surface: #f6f8f6;
  --surface-strong: #edf2ee;
  --panel: #fff;
  --panel-muted: #fbfcfb;
  --field-line: #c9d2cc;
  --detail-line: #e7ece8;
  --disclosure: #fafcfb;
  --session-surface: #f5f8f6;
  --session-line: #e1e8e3;
  --white: #fff;
  --green: #16783a;
  --green-deep: #0f6230;
  --green-soft: #e5f3e9;
  --amber: #9c6500;
  --amber-soft: #fff4d5;
  --danger: #9b2929;
  --danger-soft: #fae8e8;
  --shadow: 0 14px 40px rgba(8, 17, 12, 0.08);
  --radius: 16px;
}

.operationsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  background: var(--line);
  border-block: 1px solid var(--line);
}
.operationsGrid > div { background: var(--panel); padding: 18px 22px; min-width: 0; }
.operationsGrid > div:last-child { grid-column: 1 / -1; }
.operationsGrid span { color: var(--muted); display: block; font-size: 13px; margin-bottom: 8px; }
.operationsGrid strong { font-size: 22px; overflow-wrap: anywhere; }
.operationsAlerts { display: grid; gap: 8px; padding: 18px 22px 0; }
.operationAlert { margin: 0; padding: 12px 15px; border-radius: 10px; border: 1px solid currentColor; }
.operationAlert.isError { background: var(--danger-soft); color: var(--danger); }
.operationAlert.isWarning { background: var(--amber-soft); color: var(--amber); }
.operationAlert.isOk { background: var(--green-soft); color: var(--green-deep); }
.operationsNote { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 16px 22px 20px; }
@media (max-width: 480px) {
  .operationsGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operationsGrid > div { padding: 14px 12px; }
  .operationsGrid strong { font-size: 19px; }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf6f0;
  --black: #050b07;
  --muted: #a9b8ae;
  --line: #294033;
  --surface: #08110b;
  --surface-strong: #102117;
  --panel: #0d1911;
  --panel-muted: #101f16;
  --field-line: #385143;
  --detail-line: #24382c;
  --disclosure: #0b160f;
  --session-surface: #102017;
  --session-line: #294033;
  --green: #218c4b;
  --green-deep: #73da95;
  --green-soft: #153522;
  --amber: #f1c462;
  --amber-soft: #372d14;
  --danger: #ff9292;
  --danger-soft: #3a1c1f;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
  background-color: #070d09;
  background-image:
    radial-gradient(ellipse 105% 78% at 50% 5%, transparent 0%, rgba(7, 13, 9, 0.08) 28%, rgba(7, 13, 9, 0.38) 48%, rgba(7, 13, 9, 0.88) 76%, #070d09 92%),
    linear-gradient(rgba(69, 191, 112, 0.065) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 191, 112, 0.065) 1px, transparent 1px);
  background-attachment: fixed;
  background-size: 100% 100%, 84px 84px, 84px 84px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
  color: var(--ink);
  margin: 0;
  min-height: 100svh;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid #65b980;
  outline-offset: 3px;
}

.adminHeader {
  background: rgba(8, 17, 12, 0.98);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 20;
}

.adminHeaderInner {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1480px;
  min-height: 90px;
  padding: 16px 28px;
}

.eyebrow {
  color: #67c787;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.adminHeader h1,
.panelHeader h2 {
  letter-spacing: -0.035em;
  margin: 0;
}

.adminHeader h1 {
  font-size: clamp(25px, 3vw, 38px);
}

.headerLead {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  line-height: 1.45;
  margin: 7px 0 0;
}

.headerActions,
.searchRow,
.pagerButtons {
  align-items: center;
  display: flex;
  gap: 10px;
}

.themeToggle {
  gap: 7px;
  min-width: 112px;
}

#theme-toggle-icon {
  font-size: 19px;
  line-height: 1;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 750;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:disabled {
  cursor: default;
  opacity: 0.45;
}

.primaryButton {
  background: var(--green);
  color: var(--white);
}

.primaryButton:hover:not(:disabled) {
  background: var(--green-deep);
}

.secondaryButton {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.secondaryButton:hover:not(:disabled) {
  background: var(--surface-strong);
  border-color: #b9c5bd;
}

.dangerButton {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--white);
}

.dangerButton:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
}

.socketStatus {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.statusDot,
.presenceDot {
  background: #abb7af;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
  height: 9px;
  width: 9px;
}

.socketStatus.isConnected .statusDot,
.presenceDot {
  background: #4dd47b;
  box-shadow: 0 0 0 4px rgba(77, 212, 123, 0.14);
}

.socketStatus.isConnecting .statusDot {
  animation: statusPulse 1.2s ease-in-out infinite;
  background: #f2c14e;
}

.socketStatus.isDisconnected .statusDot,
.socketStatus.isError .statusDot {
  background: #ef6b6b;
}

@keyframes statusPulse {
  50% {
    opacity: 0.35;
  }
}

.adminMain {
  margin: 0 auto;
  max-width: 1480px;
  padding: 28px;
}

.noticePanel {
  align-items: center;
  background: var(--danger-soft);
  border: 1px solid #e8b8b8;
  border-radius: var(--radius);
  color: #6d2020;
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px 18px;
}

.noticePanel span {
  flex: 1;
}

.summaryGrid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 20px;
}

.summaryCard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(8, 17, 12, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 145px;
  padding: 20px;
}

.summaryCard.isPrimary {
  border-top: 4px solid var(--green);
}

.summaryCard.isSecondary {
  background: var(--panel-muted);
  min-height: 125px;
}

.summaryCard.isSecondary strong {
  color: var(--ink);
  font-size: clamp(32px, 4vw, 46px);
}

.summaryCard span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.summaryCard strong {
  color: var(--green);
  font-size: clamp(38px, 5vw, 58px);
  letter-spacing: -0.06em;
  line-height: 1;
  margin: 12px 0 9px;
}

.summaryCard small {
  color: var(--muted);
  font-size: 12px;
  margin-top: auto;
}

.connectionsPanel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panelHeader {
  align-items: end;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  padding: 22px;
}

.panelHeader h2 {
  font-size: clamp(23px, 3vw, 34px);
}

.panelMeta {
  color: var(--muted);
  font-size: 13px;
  margin: 7px 0 0;
}

.searchForm {
  flex: 1 1 560px;
}

.searchForm label {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 7px;
}

.searchRow input {
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: 10px;
  color: var(--ink);
  flex: 1;
  height: 44px;
  min-width: 220px;
  padding: 9px 13px;
}

.searchRow input::placeholder {
  color: #7b867f;
}

.panelControls {
  align-items: end;
  display: flex;
  flex: 0 1 760px;
  gap: 12px;
  justify-content: flex-end;
}

.pageSizeControl {
  color: var(--muted);
  display: grid;
  flex: 0 0 112px;
  font-size: 12px;
  font-weight: 700;
  gap: 7px;
}

.pageSizeControl select {
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  height: 44px;
  padding: 8px 30px 8px 12px;
}

.connectionList {
  background: var(--surface);
  display: grid;
  gap: 14px;
  padding: 18px;
}

.connectionList[aria-busy="true"] {
  opacity: 0.72;
}

.emptyState {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: 180px;
  padding: 28px;
  text-align: center;
}

.emptyState {
  flex-direction: column;
  gap: 8px;
}

.emptyState strong {
  color: var(--ink);
  font-size: 18px;
}

.emptyState span {
  font-size: 13px;
  line-height: 1.5;
  max-width: 560px;
}

.connectionCard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}

.connectionCardHeader {
  align-items: center;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 17px;
}

.connectionIdentity {
  align-items: center;
  display: flex;
  gap: 13px;
  min-width: 0;
}

.connectionIdentity h3 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
  overflow-wrap: anywhere;
}

.connectionIdentity p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.connectionBadges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.badge {
  background: var(--green-soft);
  border: 1px solid #bfdcc8;
  border-radius: 999px;
  color: var(--green-deep);
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 8px;
  text-transform: uppercase;
}

.badge.isAdmin {
  background: var(--amber-soft);
  border-color: #ead290;
  color: var(--amber);
}

.badge.isGuest {
  background: #eef1ef;
  border-color: #d3dad5;
  color: #566159;
}

.badge.isMode {
  background: #eef4ff;
  border-color: #ccd9ef;
  color: #315b96;
}

.badge.isWarning {
  background: var(--amber-soft);
  border-color: #ead290;
  color: var(--amber);
}

.badge.isConnectionCount {
  background: #f1f7f3;
  border-color: #c7d9cc;
  color: #315a3d;
}

.connectionOverview {
  background: var(--panel);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 0;
}

.connectionOverview .detailItem {
  background: var(--panel);
  border-bottom: 1px solid var(--detail-line);
  border-right: 1px solid var(--detail-line);
  min-height: 78px;
}

.connectionDisclosure summary {
  align-items: center;
  background: var(--disclosure);
  color: var(--green-deep);
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 800;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  min-height: 50px;
  padding: 12px 17px;
  user-select: none;
}

.connectionDisclosure summary::-webkit-details-marker {
  display: none;
}

.connectionDisclosure summary::before {
  content: "+";
  font-size: 20px;
  line-height: 1;
}

.connectionDisclosure[open] summary::before {
  content: "−";
}

.connectionDisclosure summary:hover {
  background: var(--green-soft);
}

.detailCount {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}

.connectionDetails {
  margin: 0;
}

.connectionSession + .connectionSession {
  border-top: 5px solid var(--surface-strong);
}

.connectionSessionHeader {
  align-items: baseline;
  background: var(--session-surface);
  border-bottom: 1px solid var(--session-line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 15px;
}

.connectionSessionHeader h4 {
  font-size: 13px;
  margin: 0;
}

.connectionSessionHeader span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  text-align: right;
}

.connectionDetailsGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.detailItem {
  border-bottom: 1px solid var(--detail-line);
  border-right: 1px solid var(--detail-line);
  min-height: 83px;
  min-width: 0;
  padding: 13px 15px;
}

.detailItem:nth-child(4n) {
  border-right: 0;
}

.detailItem dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.055em;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.detailItem dd {
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detailItem dd.isTechnical {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.detailItem.isWide {
  grid-column: span 2;
}

.pager {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 18px;
  justify-content: space-between;
  min-height: 72px;
  padding: 13px 20px;
}

.privacyNote {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 15px 4px 0;
}

.siteFooter {
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: 13px;
  gap: 20px;
  justify-content: space-between;
  margin: 24px auto 0;
  max-width: 1480px;
  padding: 18px 28px 24px;
}

.siteFooter nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.siteFooter a:hover {
  color: var(--green-deep);
}

.siteFooter p {
  margin: 0;
}

html[data-theme="dark"] .adminHeader {
  background: rgba(5, 11, 7, 0.96);
  border-bottom: 1px solid var(--line);
}

html[data-theme="dark"] .secondaryButton:hover:not(:disabled),
html[data-theme="dark"] .connectionDisclosure summary:hover {
  background: var(--surface-strong);
  border-color: #456652;
}

html[data-theme="dark"] .searchRow input::placeholder {
  color: #74877a;
}

html[data-theme="dark"] .badge.isGuest {
  background: #1b2920;
  border-color: #35483b;
  color: #c2cec5;
}

html[data-theme="dark"] .badge.isMode {
  background: #17283a;
  border-color: #2f4a66;
  color: #9ec4ed;
}

html[data-theme="dark"] .badge.isConnectionCount {
  background: #14301f;
  border-color: #2b5137;
  color: #94d8a9;
}

html[data-theme="dark"] .noticePanel {
  border-color: #694047;
  color: #ffb2b2;
}

@media (max-width: 1100px) {
  .adminHeaderInner,
  .panelHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .headerActions {
    flex-wrap: wrap;
  }

  .searchForm {
    flex-basis: auto;
    width: 100%;
  }

  .panelControls {
    align-items: stretch;
    flex-basis: auto;
    width: 100%;
  }

  .connectionDetailsGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detailItem:nth-child(4n) {
    border-right: 1px solid var(--detail-line);
  }

  .detailItem:nth-child(3n) {
    border-right: 0;
  }
}

@media (max-width: 760px) {
  .adminHeader {
    position: static;
  }

  .adminHeaderInner,
  .adminMain {
    padding-left: 14px;
    padding-right: 14px;
  }

  .headerActions .socketStatus {
    width: 100%;
  }

  .summaryGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summaryCard {
    min-height: 128px;
    padding: 16px;
  }

  .panelHeader,
  .connectionList {
    padding: 14px;
  }

  .searchRow {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .panelControls {
    flex-direction: column;
  }

  .pageSizeControl {
    align-items: center;
    display: flex;
    flex-basis: auto;
    justify-content: space-between;
  }

  .pageSizeControl select {
    width: 112px;
  }

  .searchRow input {
    flex-basis: 100%;
    min-width: 0;
  }

  .searchRow .button {
    flex: 1;
  }

  .connectionCardHeader {
    align-items: flex-start;
    flex-direction: column;
  }

  .connectionBadges {
    justify-content: flex-start;
  }

  .connectionDetailsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .connectionOverview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detailItem:nth-child(3n) {
    border-right: 1px solid var(--detail-line);
  }

  .detailItem:nth-child(2n) {
    border-right: 0;
  }

  .detailItem.isWide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .adminHeaderInner {
    padding-bottom: 14px;
    padding-top: 14px;
  }

  .headerActions .button {
    flex: 1;
  }

  .adminMain {
    padding-top: 16px;
  }

  .noticePanel {
    align-items: stretch;
    flex-direction: column;
  }

  .summaryGrid {
    gap: 9px;
  }

  .summaryCard {
    border-radius: 12px;
    min-height: 116px;
    padding: 13px;
  }

  .summaryCard span {
    font-size: 12px;
  }

  .summaryCard strong {
    font-size: 36px;
  }

  .connectionList {
    gap: 10px;
    padding: 10px;
  }

  .connectionDetailsGrid {
    grid-template-columns: 1fr;
  }

  .connectionOverview {
    grid-template-columns: 1fr;
  }

  .detailItem,
  .detailItem:nth-child(2n),
  .detailItem:nth-child(3n),
  .detailItem:nth-child(4n) {
    border-right: 0;
  }

  .detailItem.isWide {
    grid-column: auto;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .pagerButtons .button {
    flex: 1;
  }
}

@media (max-width: 360px) {
  .summaryGrid {
    grid-template-columns: 1fr;
  }
}

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