:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #dfe7f0;
  --line-strong: #c8d5e3;
  --text: #1f2937;
  --muted: #758397;
  --soft: #eef4f7;
  --accent: #0f8f83;
  --accent-strong: #08786f;
  --amber: #9a6b05;
  --red: #c2413b;
  --shadow: 0 12px 26px rgba(31, 41, 55, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell {
  width: min(1220px, calc(100vw - 32px));
  margin: 22px auto;
}
.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
h1, h2, p { margin: 0; }
h1 { font-size: 24px; font-weight: 760; letter-spacing: 0; }
h2 { font-size: 15px; font-weight: 740; letter-spacing: 0; }
#summary { color: var(--muted); margin-top: 4px; font-size: 13px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.workspace {
  display: grid;
  grid-template-columns: 300px minmax(420px, 1fr) 330px;
  gap: 14px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  min-width: 0;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.panel-head.split { align-items: flex-start; }
.panel-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.muted { color: var(--muted); font-size: 12px; }
.pill {
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 700;
}
.pill.accent { color: var(--accent-strong); background: #e6f5f2; border-color: #c4e6df; }
.btn, .segmented button {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-weight: 700;
}
.btn:hover, .segmented button:hover { border-color: #9fb2c7; }
.btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--red); border-color: #f2c5c1; background: #fff7f6; }
.btn.small { height: 30px; padding: 0 9px; font-size: 12px; }
.full { width: 100%; }
.stack-form { display: grid; gap: 8px; margin-bottom: 12px; }
input, select {
  height: 38px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 143, 131, .12); }
.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 150px 120px;
  gap: 8px;
  margin-bottom: 10px;
}
.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  min-width: 128px;
}
.segmented button {
  border: 0;
  border-radius: 0;
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.segmented button + button { border-left: 1px solid var(--line-strong); }
.list, .node-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 2px;
}
.source-item, .group-item, .node-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  min-width: 0;
}
.source-item, .group-item { padding: 10px; }
.item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.item-title {
  font-weight: 760;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.item-meta, .client-url {
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.item-actions, .link-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.status-ok { color: var(--accent-strong); }
.status-error { color: var(--red); }
.node-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) minmax(0, auto);
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}
.node-row input { width: 18px; height: 18px; justify-self: center; }
.node-main { min-width: 0; }
.node-name { font-weight: 740; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-sub { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 12px; margin-top: 2px; }
.node-side {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.node-status {
  height: 23px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.node-status.ok { color: var(--accent-strong); background: #e6f5f2; }
.node-status.down { color: var(--red); background: #fff0ef; }
.node-status.empty { color: var(--muted); background: #eef3f6; }
.type-badge {
  min-width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #eef4f7;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
}
.client-links { display: grid; gap: 7px; margin-top: 9px; }
.client-link {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.client-name { font-size: 12px; font-weight: 760; color: #334155; }
.empty {
  min-height: 92px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fbfdff;
}
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(246, 248, 251, .88);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.login-box {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 10px 12px;
  border-radius: 8px;
  background: #16202f;
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 30;
}
.hidden { display: none !important; }
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 280px 1fr; }
  .groups-panel { grid-column: 1 / -1; }
  .group-list { max-height: none; }
}
@media (max-width: 760px) {
  .app-shell { width: min(100vw - 20px, 720px); margin: 12px auto; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: stretch; }
  .top-actions .btn { flex: 1; }
  .probe-results { justify-content: stretch; }
  .probe-chip { flex: 1 1 108px; justify-content: center; }
  .workspace { grid-template-columns: 1fr; gap: 10px; }
  .filters { grid-template-columns: 1fr; }
  .list, .node-list { max-height: none; }
  .client-link { grid-template-columns: 76px minmax(0, 1fr); }
  .client-link .btn { grid-column: 1 / -1; }
  .node-row { grid-template-columns: 30px minmax(0, 1fr); }
  .node-side {
    grid-column: 2;
    justify-content: flex-start;
    gap: 5px;
    margin-top: 2px;
  }
}

.source-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name actions"
    "meta actions";
  gap: 4px 8px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 999px;
  background: #fbfdff;
}
.source-name-pill {
  grid-area: name;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.source-enabled-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px #dff3ef;
}
.source-enabled-dot.off {
  background: #94a3b8;
  box-shadow: 0 0 0 4px #eef2f6;
}
.source-toggle-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.source-meta-row {
  grid-area: meta;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.source-host {
  min-width: 0;
  max-width: 96px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.source-chip {
  flex: 0 0 auto;
  height: 21px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 780;
}
.source-chip.ok { color: var(--accent-strong); background: #e6f5f2; }
.source-chip.error, .source-chip.down { color: var(--red); background: #fff0ef; }
.source-chip.speed { color: #2563eb; background: #edf5ff; }
.source-chip.idle { color: var(--muted); background: #eef3f6; }
.source-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.btn.mini {
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
}
.compact-list { gap: 6px; }
@media (max-width: 760px) {
  .source-item {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px 9px;
  }
  .source-actions { gap: 4px; }
  .source-host { max-width: 112px; }
  .btn.mini { padding: 0 7px; }
}

.group-list { gap: 10px; }
.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
  min-width: 0;
}
.group-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  margin-bottom: 10px;
}
.group-title-wrap {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 131, .13);
}
.group-head-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex: 0 0 auto;
}
.group-count {
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef6ff;
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.group-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.group-url {
  height: 46px;
  font-weight: 760;
  color: #1f2937;
  background: #fff;
  cursor: text;
}
.icon-btn {
  width: 44px;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: #6f7f92;
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}
.icon-btn.active,
.icon-btn:hover {
  color: var(--accent-strong);
  border-color: #b8deda;
  background: #f1fbf8;
}
.group-main-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.btn.action {
  height: 40px;
  border-radius: 8px;
  background: #eef3f6;
  border-color: #d9e4ec;
  font-weight: 800;
}
.btn.action.accent-soft {
  color: var(--accent-strong);
  background: #e7f6f2;
  border-color: #bfe4dc;
}
.btn.action.danger-soft {
  color: var(--red);
  background: #fff4f3;
  border-color: #f2c5c1;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(15, 23, 42, .32);
}
.client-modal {
  width: min(620px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 28px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(15, 23, 42, .2);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.modal-title {
  font-size: 16px;
  font-weight: 820;
}
.modal-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.icon-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}
.icon-close:hover {
  color: var(--red);
  border-color: #f1b8b2;
  background: #fff5f4;
}
.modal-link-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 2px;
}
.modal-link-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}
.client-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 800;
}
.client-url {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #53677f;
  font-size: 13px;
  font-weight: 650;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}
@media (max-width: 760px) {
  .group-card { padding: 11px; }
  .group-card-head { align-items: flex-start; }
  .group-head-tools { gap: 6px; }
  .group-link-row { grid-template-columns: minmax(0, 1fr) 44px; }
  .group-main-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-modal { padding: 12px; }
  .modal-link-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .modal-link-row .client-name { grid-column: 1 / -1; }
  .modal-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.group-url {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
