
:root {
  --bg: #0B0F14;
  --bg-elev: #121822;
  --bg-sunk: #0E131B;
  --line: #1E2836;
  --line-soft: #172130;
  --text: #E9EEF6;
  --text-dim: #94A3B8;
  --text-faint: #64748B;
  --accent: #3FE0A5;
  --accent-dim: #1B7A5C;
  --warn: #FFC24B;
  --crit: #FF6B7A;
  --info: #6BB4FF;
  --radius: 10px;
  --radius-sm: 7px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar: 236px;
}

* { box-sizing: border-box; }

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

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

/* Keyboard users must always be able to see where they are. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── shell ─────────────────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-sunk);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: baseline; gap: 9px; padding: 0 10px; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.14em;
  color: var(--text);
}
.brand-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 11px 5px;
}
.nav-group:first-child { padding-top: 0; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav a:hover { background: var(--line-soft); color: var(--text); text-decoration: none; }
.nav a.active {
  background: var(--line-soft);
  color: var(--text);
  border-left-color: var(--accent);
}
.nav-badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: #041A12;
  font-weight: 700;
}
.nav-badge.warn { background: var(--warn); color: #221703; }
.nav-badge.crit { background: var(--crit); color: #260408; }

.sidebar-foot { margin-top: auto; padding: 0 11px; color: var(--text-faint); font-size: 12px; }
.sidebar-foot .mono { color: var(--text-dim); }

/* ── main ──────────────────────────────────────────────────────────────────── */

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }

/* Who you are signed in as. Always visible: with more than one account, an action taken from
   the wrong session is a real mistake, and the only cure is never having to wonder. */
.whoami { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.whoami-login { font-family: var(--mono); font-size: 13px; }
.whoami-role {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.content { padding: 26px 28px 60px; max-width: 1240px; width: 100%; }

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 10px;
}

/* ── cards ─────────────────────────────────────────────────────────────────── */

.grid { display: grid; gap: 16px; }
.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)); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.card h2 .h2-note { float: right; font-weight: 400; letter-spacing: 0; text-transform: none; }

.stat-label { font-size: 12px; color: var(--text-faint); margin-bottom: 6px; }
.stat-value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-value.good { color: var(--accent); }
.stat-value.warn { color: var(--warn); }
.stat-value.crit { color: var(--crit); }
.stat-note { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

/* ── tables ────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; margin: 0 -20px -18px; padding: 0 20px 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 12px 9px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.mono, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
td.wrap { word-break: break-all; }
.empty { color: var(--text-faint); font-size: 14px; padding: 6px 0; }

/* ── pills / badges ────────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.pill.good { color: var(--accent); border-color: var(--accent-dim); background: rgba(63,224,165,0.08); }
.pill.warn { color: var(--warn); border-color: #5A4415; background: rgba(255,194,75,0.08); }
.pill.crit { color: var(--crit); border-color: #5C2028; background: rgba(255,107,122,0.10); }
.pill.info { color: var(--info); border-color: #1C3A5E; background: rgba(107,180,255,0.08); }

/* ── buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-sunk);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--line-soft); border-color: #2A3746; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04150F; font-weight: 600; }
.btn.primary:hover { background: #55EDB6; }
.btn.danger { color: var(--crit); border-color: #4A1B21; }
.btn.danger:hover { background: rgba(255,107,122,0.10); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ── forms ─────────────────────────────────────────────────────────────────── */

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  min-width: 0;
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); }
label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 5px; }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row > div { display: flex; flex-direction: column; }
.form-row input[type="text"] { min-width: 160px; }
.field-wide input { min-width: 320px; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { width: 130px; }

/* ── notices ───────────────────────────────────────────────────────────────── */

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-faint);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  margin-bottom: 16px;
  font-size: 14px;
  background: var(--bg-elev);
}
.notice.ok { border-left-color: var(--accent); }
.notice.err { border-left-color: var(--crit); }
.notice.warn { border-left-color: var(--warn); }

.banner {
  border: 1px solid #5C2028;
  background: rgba(255, 107, 122, 0.09);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.banner strong { color: var(--crit); }

/* ── login ─────────────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 30px;
  text-align: center;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-hint { color: var(--text-dim); font-size: 13px; margin: 0 0 22px; }
.code-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: 0.34em;
  text-align: center;
  padding: 13px 0 13px 0.34em;
  margin-bottom: 14px;
}
.login-card .btn { width: 100%; justify-content: center; }
.login-input {
  width: 100%;
  font-family: var(--mono);
  font-size: 15px;
  text-align: center;
  padding: 11px 12px;
  margin-bottom: 10px;
}
.login-foot { margin-top: 20px; font-size: 12px; color: var(--text-faint); }

/* ── misc ──────────────────────────────────────────────────────────────────── */

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 8px 18px; font-size: 14px; }
.kv dt { color: var(--text-faint); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; word-break: break-all; }

.sep { height: 1px; background: var(--line); margin: 18px 0; }
.muted { color: var(--text-faint); }
.err-text { color: var(--crit); }
.warn-text { color: var(--warn); }
.dim { color: var(--text-dim); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }

/* Bar widths as classes, because a strict CSP forbids the inline style a width would need. */
.bar { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.w0{width:0}.w5{width:5%}.w10{width:10%}.w15{width:15%}.w20{width:20%}.w25{width:25%}
.w30{width:30%}.w35{width:35%}.w40{width:40%}.w45{width:45%}.w50{width:50%}.w55{width:55%}
.w60{width:60%}.w65{width:65%}.w70{width:70%}.w75{width:75%}.w80{width:80%}.w85{width:85%}
.w90{width:90%}.w95{width:95%}.w100{width:100%}

/* The one-time reveal of a new account's key: it exists on screen and nowhere else. */
.secret-box {
  border: 1px solid var(--accent-dim);
  background: rgba(63, 224, 165, 0.06);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
}
.secret-box img { width: 168px; height: 168px; border-radius: 8px; background: #fff; padding: 8px; }
.secret-key {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--accent);
  margin: 8px 0;
}
.secret-note { font-size: 13px; color: var(--text-dim); max-width: 46ch; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs a {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
}
.tabs a:hover { background: var(--line-soft); text-decoration: none; }
.tabs a.active { background: var(--line-soft); color: var(--text); border-color: #2A3746; }

/* ── responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { display: none; }
  .nav a { border-left: none; border-bottom: 2px solid transparent; padding: 7px 10px; }
  .nav a.active { border-left-color: transparent; border-bottom-color: var(--accent); }
  .sidebar-foot { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
