:root {
  --ink: #1d2a33;
  --ink-soft: #52626c;
  --panel: #eef2f4;
  --surface: #ffffff;
  --line: #c9d3d9;
  --line-soft: #e1e7ea;
  --amber: #e8a317;
  --amber-ink: #3a2a00;
  --amber-soft: #fbf0d6;
  --ok: #2f9e5b;
  --off: #8a979f;
  --bad: #c8402f;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e3eaee;
    --ink-soft: #9aabb5;
    --panel: #121a20;
    --surface: #18232b;
    --line: #2c3a44;
    --line-soft: #22303a;
    --amber-soft: #3a2f14;
    --amber-ink: #1d1500;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 var(--font);
  color: var(--ink);
  background: var(--panel);
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; max-width: 72ch; }
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); font-size: 13px; }

/* shell */
.shell { display: grid; grid-template-columns: 260px 1fr; grid-template-rows: 52px 1fr; height: 100vh; }
.top {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 24px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; min-width: 216px; }
.brand-mark { width: 14px; height: 14px; border-radius: 3px; background: var(--amber); box-shadow: 6px 6px 0 -2px var(--ink); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 12px; text-decoration: none;
  color: var(--ink-soft); border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--amber); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.rail { background: var(--surface); border-right: 1px solid var(--line); overflow: auto; padding: 16px 10px; }
.rail h2 { font-size: 13px; color: var(--ink-soft); font-weight: 600; padding: 0 8px 8px; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .node {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  width: 100%; border: 0; background: none; text-align: left; cursor: pointer;
  padding: 6px 8px; border-radius: 6px;
}
.tree .node:hover { background: var(--panel); }
.tree .node[aria-current="true"] { background: var(--amber-soft); }
.tree .node .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leds { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.bar { width: 36px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: block; }
.bar > span { display: block; height: 100%; background: var(--ok); }

.main { overflow: auto; padding: 20px 24px 40px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.head .sub { color: var(--ink-soft); }
.spacer { flex: 1; }

/* controls */
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 6px 12px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.link { border: 0; background: none; padding: 0; color: var(--ink-soft); text-decoration: underline; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 8px;
}
textarea { width: 100%; min-height: 220px; font-family: var(--mono); font-size: 13px; line-height: 1.5; }
label.field { display: grid; gap: 4px; margin-bottom: 12px; }
label.field > span { font-weight: 600; font-size: 13px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label.field { flex: 1 1 160px; }

/* tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--ink-soft); background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--panel); }
tbody tr.sel { background: var(--amber-soft); }
td.num { text-align: right; white-space: nowrap; }
th, .nowrap { white-space: nowrap; }
.compact .opt { display: none; }
.empty { padding: 32px; text-align: center; color: var(--ink-soft); }

.status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--off); flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.bad { background: var(--bad); }
.dot.wait { background: var(--amber); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.tag.warn { border-color: var(--amber); }

/* side panel */
.split { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { margin-bottom: 12px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
dl.facts dt { color: var(--ink-soft); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
pre.out {
  background: var(--panel); border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px;
  margin: 8px 0 0; max-height: 360px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap;
}
.settings-group { margin-bottom: 20px; }
.setting { display: grid; grid-template-columns: 1fr 160px; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.setting:last-child { border-bottom: 0; }
.setting .desc { color: var(--ink-soft); font-size: 13px; }
.setting .from { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--amber-soft); border: 1px solid var(--amber); border-radius: 6px; padding: 10px; margin: 8px 0; overflow-wrap: anywhere; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login form { width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.login .brand { margin-bottom: 20px; }
.error { color: var(--bad); margin: 8px 0; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(640px, 94vw); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
dialog form { padding: 20px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.choice { display: flex; gap: 4px; margin-bottom: 12px; }
.choice button { flex: 1; }
.choice button[aria-pressed="true"] { border-color: var(--amber); background: var(--amber-soft); font-weight: 600; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 8px 16px; border-radius: 6px; z-index: 10;
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
  .top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { min-width: 0; }
  .shell > * { min-width: 0; }
  .tabs { order: 3; width: 100%; overflow-x: auto; height: 40px; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; }
  .split { grid-template-columns: 1fr; }
  .main { padding: 16px 12px 32px; }
  .opt { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.pill { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent, #0f6e74); color: #fff; font-size: 12px; font-weight: 600; }
details { margin-top: 14px; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
input[type="file"] { padding: 6px 0; }

.disks { display: flex; flex-direction: column; gap: 3px; min-width: 210px; }
.disk { display: grid; grid-template-columns: 2.2em 70px auto; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.disk .dname { font-weight: 600; }
.disk meter { width: 70px; height: 8px; }
.disk.low .dval { color: var(--bad, #b42318); font-weight: 600; }
