:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel-2: #1e242c;
  --line: #2a323c;
  --text: #e6eaef;
  --muted: #8d99a8;
  --accent: #4f9dff;
  --ok: #35c48a;
  --warn: #e8b93c;
  --err: #f0604d;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- layout ---------------- */

header.top {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .brand { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
header.top .brand span { color: var(--accent); }
header.top nav { display: flex; gap: 16px; }
header.top nav a { color: var(--muted); font-weight: 500; }
header.top nav a.active, header.top nav a:hover { color: var(--text); text-decoration: none; }
header.top .spacer { flex: 1; }
header.top .who { color: var(--muted); font-size: 13px; }

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 16px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 20px; font-weight: 600; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------- panels ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.card .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 820px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* ---------------- forms ---------------- */

label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
label .req { color: var(--err); }

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
input[type=checkbox] { width: auto; margin-right: 8px; accent-color: var(--accent); }
.check { display: flex; align-items: center; color: var(--text); font-size: 13px; margin-top: 22px; }
.field-help { color: var(--muted); font-size: 11.5px; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #08121f; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

form.inline { display: inline; }

/* ---------------- tables ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 10px; color: var(--muted);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .4px; border-bottom: 1px solid var(--line);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------------- bits ---------------- */

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.running { color: var(--ok); border-color: rgba(53,196,138,.4); }
.pill.stopped { color: var(--muted); }
.pill.error   { color: var(--err); border-color: rgba(240,96,77,.4); }
.pill.proto   { color: var(--accent); border-color: rgba(79,157,255,.35); margin-right: 4px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.on  { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,196,138,.15); }
.dot.off { background: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs a {
  padding: 9px 14px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.stat .v { font-size: 19px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; }
.alert.err { background: rgba(240,96,77,.12); border: 1px solid rgba(240,96,77,.35); color: #ffb4a8; }
.alert.ok  { background: rgba(53,196,138,.12); border: 1px solid rgba(53,196,138,.35); color: #96e9c4; }
.alert.info{ background: rgba(79,157,255,.1); border: 1px solid rgba(79,157,255,.3); color: #b9d8ff; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p { margin: 8px 0 16px; }

pre.preview {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; overflow-x: auto; font-size: 12px; max-height: 340px;
  color: var(--muted); margin: 0;
}

.muted { color: var(--muted); }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- auth pages ---------------- */

.auth-wrap { max-width: 380px; margin: 9vh auto; padding: 0 20px; }
.auth-wrap .brand { text-align: center; font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.auth-wrap .brand span { color: var(--accent); }
.auth-wrap .tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-wrap .card { padding: 22px; }
.auth-wrap .field { margin-bottom: 14px; }
.auth-wrap .btn { width: 100%; justify-content: center; }
