:root {
  --bg: #10141a;
  --panel: #171d26;
  --panel-2: #1e2632;
  --line: #2a3442;
  --text: #e6ecf3;
  --muted: #8b9bb0;
  --accent: #4da3ff;
  --ok: #35c47a;
  --warn: #f0b431;
  --err: #ff5f56;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.app-shell { display: flex; align-items: stretch; min-height: 100vh; }

.sidebar {
  flex: 0 0 218px;
  width: 218px;
  background: linear-gradient(180deg, #182030, #141a23);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand { display: flex; align-items: baseline; gap: 8px; padding: 0 6px; }
.logo { font-weight: 800; letter-spacing: 2px; color: var(--accent); font-size: 18px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }

.nav-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: #1c4b7d; border-color: #2f6ea8; }
.nav-title { font-size: 13.5px; font-weight: 600; }
.nav-sub { font-size: 11.5px; color: var(--muted); }
.nav-item.active .nav-sub { color: #cfe6ff; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }

.content { flex: 1 1 auto; min-width: 0; padding: 16px 20px 24px; }

.content-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.content-head h1 { font-size: 17px; font-weight: 600; margin: 0; }
.content-head .controls { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.controls { display: flex; align-items: center; gap: 12px; }
.auto { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.conn-meta { color: var(--muted); font-size: 12px; }

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: #1c4b7d; border-color: #2f6ea8; }
.btn-primary:hover { background: #215a94; }
.btn-danger { background: #7a2320; border-color: #a8352f; color: #ffe9e8; font-weight: 600; }
.btn-danger:hover { background: #93302b; border-color: #c9443c; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

select, input[type="text"], input[type="password"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
}

.pill { padding: 3px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill-ok { background: rgba(53, 196, 122, .16); color: var(--ok); border: 1px solid rgba(53,196,122,.4); }
.pill-err { background: rgba(255, 95, 86, .14); color: var(--err); border: 1px solid rgba(255,95,86,.4); }
.pill-warn { background: rgba(240, 180, 49, .14); color: var(--warn); border: 1px solid rgba(240,180,49,.4); }
.pill-unknown { background: rgba(139,155,176,.14); color: var(--muted); border: 1px solid var(--line); }

.banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 95, 86, .12);
  border: 1px solid rgba(255, 95, 86, .35);
  color: #ffbdb9;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}
.banner.warn { background: rgba(240, 180, 49, .12); border-color: rgba(240, 180, 49, .35); color: #ffe0a3; }
.banner.ok { background: rgba(53, 196, 122, .12); border-color: rgba(53, 196, 122, .4); color: #a8f0cc; }
.hidden { display: none; }

.section { margin-bottom: 26px; }
.section h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}
.section h2 .btn { margin-left: 10px; padding: 4px 10px; font-size: 12.5px; }
.count { color: var(--muted); font-weight: 400; font-size: 13px; }

.topbar-row { display: flex; align-items: stretch; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.top-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  flex: 1 1 180px;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.top-item.wide { flex: 2 1 300px; }
.top-label { color: var(--muted); font-size: 12px; }
.top-value { font-size: 15px; font-weight: 600; word-break: break-word; }
.top-value.big { font-size: 22px; color: var(--accent); }
.top-sub { color: var(--muted); font-size: 12px; word-break: break-word; }
.top-actions { display: flex; flex-direction: column; justify-content: center; gap: 8px; margin-left: auto; }
.top-actions .btn { white-space: nowrap; }

.teams-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.team-column { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.team-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.team-column.t1 .team-column-head { border-top: 3px solid #4da3ff; }
.team-column.t2 .team-column-head { border-top: 3px solid #d1683a; }
.team-column-title { font-weight: 600; font-size: 13.5px; }
.team-column .table-wrap { border: none; border-radius: 0; }
.sub-head { font-size: 13px; color: var(--muted); margin: 18px 0 8px; }

.table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}
th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: rgba(77, 163, 255, .06); }
tbody tr:last-child td { border-bottom: none; }
td.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 18px; }
.leader-yes { color: var(--warn); font-weight: 600; }
.fail { color: var(--err); font-weight: 600; }
.op-cell { width: 108px; }
.op-select { padding: 4px 6px; font-size: 12.5px; width: 100%; }

.manual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field input, .field select { width: 100%; }

.confirm-block { margin: 12px 0 10px; }
.confirm-label { color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.confirm-cmd {
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  color: #ffd9a0;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.console-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.console-row select { min-width: 200px; }
.console-row input { flex: 1; min-width: 200px; }
.console-output {
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  color: #b9e6c8;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.console-details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 11, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 4px solid #2f6ea8;
  border-radius: 12px;
  padding: 18px 20px 16px;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6);
}
.wide-box { max-width: 720px; }
.modal-box h3 { margin: 0 0 12px; font-size: 15px; }
.modal-target { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; word-break: break-all; }
.modal-warn { color: #ff9f97; font-size: 12.5px; margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.map-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
}
.login-brand { display: flex; align-items: baseline; gap: 8px; }
.login-title { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.login-error { color: var(--err); font-size: 12.5px; margin: 0; }

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

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .content { padding: 14px 14px 20px; }
  .map-form { grid-template-columns: 1fr; }
}
