:root {
  --bg: #0f1216;
  --panel: #151920;
  --panel-2: #1b2029;
  --line: #252c36;
  --line-soft: #1e242c;
  --text: #d7dce3;
  --dim: #7d868f;
  --dimmer: #5a636c;
  --accent: #6d92bd;
  --accent-soft: #6d92bd22;
  --ok: #62a97b;
  --warn: #c2a03f;
  --bad: #c96a6a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

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

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

.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }

.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.brand .mark { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand .host { font-family: var(--mono); font-size: 11px; color: var(--dimmer); margin-top: 2px; }

nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 5px;
  color: var(--dim);
  font-size: 13.5px;
  margin-bottom: 1px;
}
nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
nav a.on { background: var(--accent-soft); color: #a9c4e6; }
nav a svg { width: 15px; height: 15px; flex: none; opacity: .85; }
nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--dimmer); padding: 14px 10px 6px; }

.whoami {
  border-top: 1px solid var(--line-soft);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.whoami img { width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); }
.whoami .who { min-width: 0; flex: 1; }
.whoami .who b { display: block; font-size: 12.5px; font-weight: 500; }
.whoami .who span { display: block; font-size: 11px; color: var(--dimmer); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 48px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  flex: none;
}
.topbar h1 { font-size: 15px; font-weight: 550; margin: 0; }
.topbar .spacer { flex: 1; }

.content { flex: 1; overflow-y: auto; padding: 18px; }
.content.flush { padding: 0; }

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

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.card > header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--dim);
}
.card > header b { color: var(--text); font-weight: 550; font-size: 13px; }
.card > header .spacer { flex: 1; }
.card .body { padding: 14px; }

.stat { padding: 13px 15px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dimmer); }
.stat .v { font-family: var(--mono); font-size: 22px; margin-top: 5px; letter-spacing: -0.02em; }
.stat .v small { font-size: 12px; color: var(--dim); letter-spacing: 0; }
.stat .sub { font-size: 11.5px; color: var(--dimmer); margin-top: 3px; }

.bar { height: 4px; background: var(--panel-2); border-radius: 2px; overflow: hidden; margin-top: 9px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--dimmer);
  font-weight: 500;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #1a1f27; }
td.mono, th.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
td.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }
td.tight { width: 1%; white-space: nowrap; }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; background: var(--dimmer); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--warn); }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
}
.tag.ok { color: var(--ok); border-color: #2c4436; }
.tag.bad { color: var(--bad); border-color: #4a2e2e; }
.tag.warn { color: var(--warn); border-color: #47401f; }

button, .btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  line-height: 20px;
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: #333c48; background: #212734; text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.primary { background: #294061; border-color: #3a5680; color: #cfe0f5; }
button.primary:hover { background: #31496e; }
button.danger { color: #dc9090; border-color: #45302f; }
button.danger:hover { background: #2c1f1f; }
button.sm { padding: 2px 8px; font-size: 12px; line-height: 18px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button.link:hover { text-decoration: underline; background: none; }

input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  background: #10141a;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 9px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3c536f; }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 120px; }
label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.hint { font-size: 11.5px; color: var(--dimmer); margin-top: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--dim);
  padding: 7px 12px;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:hover { background: none; color: var(--text); }

pre.term, pre.logs {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  background: #0b0e12;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #b9c1cb;
}

.empty { padding: 34px 14px; text-align: center; color: var(--dimmer); font-size: 13px; }

.crumbs { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12.5px; flex-wrap: wrap; }
.crumbs span { color: var(--dimmer); }

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

.veil {
  position: fixed;
  inset: 0;
  background: #06080ab8;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  z-index: 40;
  overflow-y: auto;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 18px 50px #0009;
}
.modal.wide { max-width: 880px; }
.modal > header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 550;
  display: flex;
  align-items: center;
}
.modal > header .spacer { flex: 1; }
.modal .body { padding: 16px; }
.modal > footer {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ---------- toasts ---------- */

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 5px;
  padding: 9px 13px;
  max-width: 380px;
  font-size: 13px;
  box-shadow: 0 8px 22px #0007;
}
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- login ---------- */

.login-wrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login {
  width: 100%;
  max-width: 348px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 26px 24px;
}
.login h1 { font-size: 17px; margin: 0 0 4px; font-weight: 600; }
.login p.sub { color: var(--dim); font-size: 13px; margin: 0 0 22px; }
.gbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #ffffff;
  color: #1f1f1f;
  border: none;
  border-radius: 5px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.gbtn:hover { background: #f1f2f4; }
.login .err {
  background: #2a1c1c;
  border: 1px solid #4a2e2e;
  color: #dda2a2;
  border-radius: 5px;
  padding: 8px 11px;
  font-size: 12.5px;
  margin-bottom: 16px;
}
.login .foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--dimmer); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #262d37; border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333c48; }
