:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c232c;
  --line: #2a313c;
  --txt: #e6edf3;
  --muted: #9aa6b4;
  --accent: #4ea1ff;
  --ok: #3fb950;
  --off: #6e7781;
  --warn: #d29922;
  --bad: #f85149;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.who { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.spacer { flex: 1; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; }

.gate {
  max-width: 390px;
  margin: 10vh auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px;
}
.gate h2 { margin: 0 0 6px; font-size: 18px; }
.gate p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
}
button {
  background: var(--accent);
  color: #061018;
  border: 0;
  border-radius: 8px;
  padding: 8px 13px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost {
  background: transparent;
  color: var(--txt);
  border: 1px solid var(--line);
  font-weight: 500;
}
button.danger {
  background: #3a1416;
  color: #ff9c97;
  border: 1px solid #6e2427;
}
button.sm { padding: 4px 9px; font-size: 12px; }
.btn-full { width: 100%; margin-top: 16px; padding: 10px 14px; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 8px; margin-right: 12px; }
.brand h1 { font-size: 15px; margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 6px 11px;
  border-radius: 8px;
  font-weight: 500;
}
.tab.active {
  background: var(--panel2);
  color: var(--txt);
  border-color: var(--line);
}
.count {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--line);
  color: var(--txt);
}
.count.warn { background: #3b2a09; color: var(--warn); }
.count.bad { background: #3d1417; color: var(--bad); }

.wrap { padding: 20px; max-width: 1280px; margin: 0 auto; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-val { font-size: 24px; font-weight: 700; margin-top: 4px; }
.stat-val.ok { color: var(--ok); }
.stat-val.warn { color: var(--warn); }
.stat-val.bad { color: var(--bad); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.toolbar input[type="search"] { max-width: 340px; }
.toolbar select { max-width: 210px; }
.section-title { font-size: 15px; }

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--panel2);
}
.empty-cell { text-align: center; padding: 26px; color: var(--muted); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--off); }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.b-on { background: #11271a; color: var(--ok); }
.b-off { background: var(--panel2); color: var(--muted); }
.b-pend { background: #2a2208; color: var(--warn); }
.b-bad { background: #3a1416; color: var(--bad); }
.b-info { background: #10253f; color: var(--accent); }

.inline-actions { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sw {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--off);
  position: relative;
  cursor: pointer;
  display: inline-block;
  border: 0;
  padding: 0;
  vertical-align: middle;
}
.sw.on { background: var(--ok); }
.sw::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.sw.on::after { left: 18px; }

.bars { display: inline-flex; align-items: flex-end; gap: 4px; height: 28px; }
.bar {
  width: 12px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: 0.85;
}

.toast {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #10253f;
  border: 1px solid #264d7d;
  color: var(--txt);
  font-size: 13px;
}
.toast.err-toast {
  background: #3a1416;
  border-color: #6e2427;
  color: #ffb4b0;
}

dialog.modal {
  background: var(--panel);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(500px, 94vw);
  max-height: 90vh;
}
dialog.modal-lg { width: min(820px, 95vw); }
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel2);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; max-height: calc(90vh - 64px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kv {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.kv-k { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.kv-v { font-size: 13.5px; margin-top: 3px; word-break: break-all; }

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.detail-section h4 { margin: 0 0 10px; font-size: 14px; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.log-box {
  background: #090c10;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  color: #c9d1d9;
}
