:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --sidebar: #111827;
  --sidebar-muted: #9ca3af;
  --text: #111827;
  --muted: #6b7280;
  --line: #d9e2ec;
  --line-strong: #c7d2df;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #dc2626;
  --success: #15803d;
  --warning: #b45309;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
}

body {
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel .panel {
  width: min(440px, 100%);
}

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

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block h1 {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: var(--sidebar-muted);
  margin-bottom: 10px;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.sidebar .muted {
  color: var(--sidebar-muted);
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: #e5e7eb;
  border-radius: 10px;
  padding: 11px 12px;
  cursor: default;
}

.nav-item-active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.main-stage {
  padding: 20px 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.page-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.topbar-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.control-rail {
  display: grid;
  gap: 18px;
}

.module,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}

.sidebar-module {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-module .section-title {
  color: #fff;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.toolbar-text,
.small {
  font-size: 12px;
  color: var(--muted);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.status-item {
  padding: 14px 12px;
  background: var(--surface-muted);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-item dt {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.status-item dd {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.stack {
  display: grid;
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--text);
}

button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

button.ghost:hover {
  background: var(--surface-muted);
}

button.danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--danger);
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.inline-note {
  margin-top: 12px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: #fbfdff;
}

.meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.protocol-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.online {
  color: var(--success);
  background: #dcfce7;
}

.status-pill.idle {
  color: var(--warning);
  background: #fef3c7;
}

.status-pill.offline {
  color: var(--danger);
  background: #fee2e2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 240px;
}

.actions button {
  white-space: nowrap;
  flex: 0 0 auto;
  padding: 8px 12px;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.config-dialog {
  width: min(1080px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

.config-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-panel {
  margin: 0;
}

pre {
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 12px;
  }

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

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

@media (max-width: 760px) {
  .main-stage {
    padding: 14px;
  }

  .topbar {
    flex-direction: column;
  }

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

  table {
    min-width: 980px;
  }
}

@media (max-width: 560px) {
  .login-panel,
  .main-stage,
  .sidebar {
    padding: 12px;
  }

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