/* Dashboard styling. No build step, no external fonts, no CDN — the CSP
   forbids third-party resources entirely. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfc;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #61656e;
  --line: #e3e5ea;
  --accent: #2f5bd7;
  --ok: #1a7f4b;
  --warn: #9a6b09;
  --err: #b3261e;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1b1e24;
    --ink: #e7e9ee;
    --muted: #969ba6;
    --line: #2b2f37;
    --accent: #7ea2ff;
    --ok: #52c98a;
    --warn: #e0b34a;
    --err: #ef7a72;
  }
}

* { box-sizing: border-box; }

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

/* --- top bar ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  letter-spacing: .08em;
  text-decoration: none;
  color: var(--ink);
}

.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

.topbar nav a {
  padding: 6px 10px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
}

.topbar nav a:hover { background: var(--bg); color: var(--ink); }
.topbar nav a.on { background: var(--accent); color: #fff; }

.who { font-size: 13px; color: var(--muted); }
.who em { font-style: normal; opacity: .7; text-transform: uppercase; font-size: 11px; }

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

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

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

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

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.bad .n { color: var(--err); }
.stat.warn .n { color: var(--warn); }

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

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

code, .mono { font-family: var(--mono); font-size: 13px; }

/* --- badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge.ok   { color: var(--ok);   border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.off  { color: var(--muted); border-color: var(--line); }
.badge.err  { color: var(--err);  border-color: color-mix(in srgb, var(--err) 40%, transparent); }

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

form.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
form.inline { display: flex; gap: 8px; align-items: center; margin: 0; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }

input, select, textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

textarea { width: 100%; font-family: var(--mono); font-size: 13px; }

button {
  font: inherit;
  font-weight: 550;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger  { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, transparent); }
button.link { background: none; border: 0; color: var(--muted); padding: 4px 6px; text-decoration: underline; }
button.small { padding: 4px 9px; font-size: 13px; }

.field { display: flex; flex-direction: column; }
.field.grow { flex: 1; min-width: 160px; }

/* A row inside a multi-line form, as distinct from a form that is one row. */
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
form .row + .row { margin-top: 12px; }

/* An action and the explanation of what it does to a live node. */
.row.actions { align-items: center; }
.row.actions + .row.actions {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.row.actions .muted { flex: 1; min-width: 260px; font-size: 13px; }

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* --- provisioning ------------------------------------------------------- */

/* Key/value detail, for facts about a node rather than a list of them. */
table.kv th { width: 190px; text-transform: none; letter-spacing: 0; font-size: 13px; }
table.kv td { font-size: 14px; }

/* A run transcript. Wraps rather than scrolling sideways: the interesting line
   in a failed run is usually a long one, and horizontal scrolling hides it. */
.transcript {
  margin: 0;
  max-height: 60vh;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.stat .n.small { font-size: 15px; font-weight: 600; }

/* --- flash -------------------------------------------------------------- */

.flash {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 18px;
  background: var(--panel);
}
.flash p { margin: 0; }
.flash.ok    { border-left-color: var(--ok); }
.flash.warn  { border-left-color: var(--warn); }
.flash.error { border-left-color: var(--err); }

.secret { margin-top: 10px; }
.secret code {
  display: block;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  word-break: break-all;
  user-select: all;
}

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

.centered { max-width: 380px; margin: 12vh auto; }
.centered .panel { padding: 24px; }
.centered .field { margin-bottom: 14px; }
.centered input { width: 100%; }
.centered button { width: 100%; }

/* --- misc --------------------------------------------------------------- */

.muted { color: var(--muted); }
.right { text-align: right; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 14px; }
.spacer { flex: 1; }
a { color: var(--accent); }
.warnbox {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
