:root {
  color-scheme: dark;
  --bg: #12140f;
  --bg-raise: #1b1f17;
  --bg-sunken: #0d0f0b;
  --line: #31362b;
  --text: #ebe7d8;
  --muted: #b7bba8;
  --faint: #7e8472;
  --amber: #e3a453;
  --amber-ink: #2a1c0a;
  --green: #b7d48a;
  --green-bg: #24301a;
  --red: #f0a79c;
  --red-bg: #3a221c;
  --warn: #ead392;
  --warn-bg: #332c18;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}

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

button { cursor: pointer; }

.skip {
  position: absolute;
  left: 8px;
  top: -40px;
  background: var(--amber);
  color: var(--amber-ink);
  padding: 6px 10px;
}

.skip:focus { top: 8px; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunken);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; gap: 8px; align-items: center; }
.brand strong { display: block; letter-spacing: 0.04em; }
.brand span, .muted, .faint { color: var(--muted); }
.brand span { font-size: 12px; }

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1;
}

.metric {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.top-actions { display: flex; gap: 8px; }

.btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-height: 36px;
}

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

.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--amber-ink);
  font-weight: 650;
}

.btn-danger { border-color: #8d4a40; color: var(--red); }
.btn-tiny { padding: 3px 7px; min-height: 28px; font-size: 12px; }

.banner {
  margin: 10px 16px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-raise);
  border: 1px solid var(--line);
}

.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--red-bg); color: var(--red); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 12px 16px;
}

.search { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.search input, label input[type="password"], label input[type="text"], label input[type="search"], #confirm-totp, #username, #password, #totp {
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 220px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
}
.chip[aria-pressed="true"] {
  background: var(--bg-raise);
  color: var(--text);
  border-color: var(--amber);
}

.table-wrap { padding: 0 16px 16px; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); }
th button {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
}
td, th { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #1a1e16; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, monospace; font-size: 12px; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  letter-spacing: 0.03em;
  background: var(--bg-raise);
  color: var(--muted);
}
.pill.on { background: var(--green-bg); color: var(--green); }
.pill.off { background: var(--red-bg); color: var(--red); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.port-line { display: block; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; white-space: nowrap; }

.empty { padding: 12px 4px 24px; color: var(--muted); }

.nodes { margin: 0 16px 20px; }
.config-card { width: min(720px, 100%); max-height: min(80vh, 720px); display: flex; flex-direction: column; }
.config-card pre { flex: 1; }
.detail-head, .nodes h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
h2 { font-size: 15px; margin: 0 0 8px; }
pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  background: var(--bg-sunken);
  padding: 10px;
  border-radius: 8px;
  font-size: 12px;
}

.node-table { width: 100%; }

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 5, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal-card {
  width: min(480px, 100%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.modal-card h2 { margin-top: 0; }
.modal-card ul { padding-left: 18px; }
.modal-card label, .login-card label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.check { flex-direction: row !important; align-items: flex-start; gap: 8px !important; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { min-height: 1.2em; color: var(--red); margin: 0; }
.toast {
  position: fixed;
  z-index: 30;
  left: 16px;
  right: 16px;
  bottom: 16px;
  margin: 0 auto;
  max-width: 520px;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.login-card h1 { font-size: 22px; margin: 16px 0 8px; }
.lede { color: var(--muted); margin-top: 0; }
.login-card input { min-width: 0; width: 100%; }

@media (max-width: 860px) {
  .top { position: static; }
  .search input { min-width: 0; width: 100%; }
  .search { width: 100%; }
  table thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 4px 0;
    background: var(--bg-raise);
  }
  td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    text-align: right;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    text-align: left;
  }
  .num { text-align: right; }
  .btn { min-height: 40px; }
}
