:root {
  --bg: #0d1017;
  --panel: #151922;
  --panel-2: #1b2029;
  --line: #262c38;
  --text: #e6e9ef;
  --muted: #8b93a7;
  --accent: #4c8dff;
  --accent-dim: #2b4c86;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- gate */

.gate {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2740 0%, var(--bg) 60%);
}

.gate-card {
  width: 380px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

.gate-card h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: .5px;
}

.gate-card p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* --------------------------------------------------------------- shell */

.layout {
  display: grid;
  grid-template-columns: 268px 1fr;
  height: 100%;
}

aside {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.brand {
  padding: 16px 18px 12px;
  font-weight: 600;
  letter-spacing: .6px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.brand small {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-left: auto;
}

.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.srv {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 3px;
}

.srv:hover { background: var(--panel-2); }

.srv.active {
  background: var(--panel-2);
  border-color: var(--accent-dim);
}

.srv .row1 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.srv .name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.srv .addr {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
  margin-left: 14px;
}

.dot-status {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--muted);
}

.dot-status.up { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot-status.down { background: var(--err); }

.side-foot {
  padding: 10px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
}

/* ---------------------------------------------------------------- main */

main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.topbar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.topbar .sub {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, Consolas, monospace;
}

.topbar .spacer { flex: 1; }

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: none;
  overflow-x: auto;
}

.tab {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-size: 13px;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.content {
  flex: 1;
  overflow: auto;
  padding: 18px;
  min-height: 0;
}

.content.no-pad { padding: 0; }

/* ------------------------------------------------------------- pieces */

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.btn:hover { border-color: #3a4356; background: #232936; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: #5f99ff; }

.btn.danger { color: var(--err); }

.btn.small {
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 6px;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
  outline: none;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea {
  resize: vertical;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

label.field {
  display: block;
  margin-bottom: 14px;
}

label.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.row { display: flex; gap: 10px; align-items: center; }
.row > * { min-width: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.card .label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.card .value {
  font-size: 15px;
  font-weight: 500;
  word-break: break-all;
}

.card .value.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}

.bar {
  height: 5px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
  margin-top: 8px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.bar > i.warn { background: var(--warn); }
.bar > i.err { background: var(--err); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel > h3 {
  margin: 0;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel > h3 .spacer { flex: 1; }

.panel-body { padding: 16px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  background: var(--panel-2);
  position: sticky;
  top: 0;
}

tr:last-child td { border-bottom: none; }

td.mono, .mono { font-family: ui-monospace, Consolas, monospace; }

pre.out {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
  max-height: 420px;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.ok { color: var(--ok); border-color: #234a2b; background: #12251a; }
.badge.err { color: var(--err); border-color: #5a2222; background: #2a1414; }
.badge.warn { color: var(--warn); border-color: #4d3d13; background: #241d0c; }

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

.hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin-top: 6px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 80px 20px;
}

.empty .big {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 6px;
}

/* ----------------------------------------------------------- terminal */

.term-wrap {
  height: 100%;
  background: #0a0c11;
  padding: 8px 4px 4px 10px;
}

#term-host, .xterm { height: 100%; }

/* -------------------------------------------------------------- modal */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
}

.modal {
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}

.modal h3 {
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}

.modal .body { padding: 20px; }

.modal .foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.seg button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  cursor: pointer;
  color: var(--muted);
}

.seg button.on {
  background: var(--accent-dim);
  color: #fff;
}

/* --------------------------------------------------------------- toast */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  padding: 10px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  max-width: 460px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: slide-in .18s ease-out;
  white-space: pre-wrap;
  font-size: 13px;
}

.toast.ok { border-color: #234a2b; }
.toast.err { border-color: #5a2222; }

@keyframes slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
