/* Server console. Slate ink, one blue accent, flat surfaces with 1px lines, no shadows, gradients or glow.
   Blue marks what you can act on (primary buttons, focus, the active section); green, amber and red are used only
   for status, always with a word or a shape beside them. Everything is a token on :root. Dark only. No external requests: fonts come from fonts/. */

@font-face { font-family: "Inter"; src: url("fonts/Inter-Variable.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("fonts/JetBrainsMono-Variable.ttf") format("truetype"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #0b0e13;
  --surface: #11151c;
  --surface-2: #171c25;
  --sunken: #0a0d12;
  --line: #1f2631;
  --line-strong: #2d3644;
  --text: #e8ecf3;
  --muted: #9aa5b6;
  --faint: #667184;

  --accent: #5b8cff;
  --accent-hover: #7ba2ff;
  --accent-text: #ffffff;
  --good: #3ccf91;
  --warn: #f5b544;
  --bad: #ff6a6a;
  --focus: #5b8cff;

  --radius: 8px;
  --radius-sm: 6px;
  --sidebar: 224px;
  --gap: 14px;
  --shadow: none;

  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.5 var(--font-ui);
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-size: 12px; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.eyebrow { font: 600 10.5px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 16px; border-bottom: 1px solid var(--line); }
/* Logo mark: a flat pine on a plain tile. The same shape is in favicon.svg. */
.brand-mark {
  width: 32px; height: 32px; flex: none; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
}
.brand-mark svg { width: 20px; height: 20px; fill: currentColor; }
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 11.5px; color: var(--faint); }

.nav { display: grid; gap: 2px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: var(--accent); }
.nav-badge { margin-left: auto; min-width: 18px; padding: 0 6px; border-radius: 9px; font: 600 10.5px/18px var(--font-ui); text-align: center; color: var(--accent-text); background: var(--accent); }
.nav-badge:empty { display: none; }

.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 14px 8px 0; border-top: 1px solid var(--line); }

/* ---------- shell: top bar, content, footer ---------- */
.shell { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--gap);
  padding: 14px 28px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.page-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.page-sub { margin: 2px 0 0; color: var(--faint); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: flex-end; }

/* state indicator: a dot and a word */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--surface-2); font: 600 12px var(--font-ui); color: var(--muted); }
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.pill[data-tone="good"] { color: var(--text); background: color-mix(in srgb, var(--good) 15%, transparent); }
.pill[data-tone="good"] .pill-dot { background: var(--good); }
.pill[data-tone="busy"] { color: var(--text); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.pill[data-tone="busy"] .pill-dot { background: var(--warn); }
.pill[data-tone="bad"] { color: var(--text); background: color-mix(in srgb, var(--bad) 15%, transparent); }
.pill[data-tone="bad"] .pill-dot { background: var(--bad); }

.link { display: inline-flex; align-items: center; gap: 6px; font: 500 11.5px var(--font-ui); color: var(--faint); padding-left: 16px; border-left: 1px solid var(--line); }
.link-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.link[data-ok="true"] .link-dot { background: var(--good); }
.link[data-ok="false"] { color: var(--bad); }
.link[data-ok="false"] .link-dot { background: var(--bad); }

/* ---------- layout & pages ---------- */
.layout {
  flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 26px 32px 36px;
  display: grid; gap: var(--gap); align-content: start;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
}
.layout > .panel { grid-column: 1 / -1; }
.layout[data-active="overview"] > .status { grid-column: 1; }
.layout[data-active="overview"] > .controls { grid-column: 2; }
.layout[data-active] > .panel { display: none; }
.layout[data-active="overview"] > .panel[data-page="overview"],
.layout[data-active="config"] > .panel[data-page="config"],
.layout[data-active="mods"] > .panel[data-page="mods"],
.layout[data-active="updates"] > .panel[data-page="updates"],
.layout[data-active="files"] > .panel[data-page="files"],
.layout[data-active="account"] > .panel[data-page="account"],
.layout[data-active="backups"] > .panel[data-page="backups"],
.layout[data-active="logs"] > .panel[data-page="logs"] { display: block; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel-title { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: var(--text); }
.hint { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

/* ---------- status ---------- */
.status { --state-color: var(--faint); border-left: 3px solid var(--state-color); }
.status-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.status-root { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-main { display: flex; align-items: center; gap: 12px; margin: 12px 0 2px; }
.state { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: .02em; color: var(--text); }
.state-light { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--state-color); }
.state-detail { margin: 4px 0 16px; min-height: 1.5em; color: var(--muted); overflow-wrap: anywhere; }

.status[data-state="online"] { --state-color: var(--good); }
.status[data-state="offline"], .status[data-state="not_installed"] { --state-color: var(--faint); }
.status[data-state="starting"], .status[data-state="stopping"], .status[data-state="restarting"],
.status[data-state="booting"], .status[data-state="running"] { --state-color: var(--warn); }
.status[data-state="ambiguous"], .status[data-state="unverifiable"], .status[data-state="unreachable"] { --state-color: var(--bad); }
.status[data-state="starting"] .state-light, .status[data-state="stopping"] .state-light,
.status[data-state="restarting"] .state-light, .status[data-state="booting"] .state-light { animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.facts div { padding: 9px 12px; min-width: 0; border-left: 1px solid var(--line); }
.facts div:first-child { border-left: 0; }
.facts dt { font: 600 10.5px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.facts dd { margin: 3px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ready-line { margin-top: 12px; display: grid; gap: 5px; }
.ready-line code { display: block; padding: 8px 10px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); overflow-wrap: anywhere; }
.ready-line code.found { color: var(--text); border-left: 3px solid var(--good); }

/* ---------- buttons ---------- */
.buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font: 600 12px var(--font-ui); letter-spacing: .02em; cursor: pointer; transition: background .12s, border-color .12s;
}
.btn svg { width: 13px; height: 13px; fill: currentColor; flex: none; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled, .btn-primary:disabled { background: transparent; border-color: var(--line); color: var(--faint); box-shadow: none; cursor: not-allowed; }
.btn-small { min-height: 26px; padding: 0 9px; font-size: 10.5px; }
/* "Update available": a plain solid button that is only there when a newer release exists. No animation. */
.du-log { margin: 8px 0 0; padding: 10px 12px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; color: var(--muted); }

/* ---------- operations, badges ---------- */
.operation { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.operation-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 10.5px var(--font-ui); letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); color: var(--muted);
}
.badge:empty { display: none; }
.badge { background: var(--surface-2); border-color: transparent; border-radius: 999px; padding: 3px 10px; }
.badge[data-tone="good"] { color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); }
.badge[data-tone="busy"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.badge[data-tone="bad"] { color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, transparent); }

/* A small round marker before attention / error text. */
.badge[data-tone="busy"]::before, .badge[data-tone="bad"]::before,
.feed .o[data-tone="busy"]::before, .feed .o[data-tone="bad"]::before,
.config-state[data-dirty="true"]::before, .mod-issues li::before,
.ws-idcheck[data-tone="busy"]::before, .ws-idcheck[data-tone="bad"]::before,
.ws-installed::before, .ws-name-problem::before {
  content: ""; display: inline-block; flex: none; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%;
  vertical-align: .08em; background: var(--warn);
}
.badge[data-tone="bad"]::before, .feed .o[data-tone="bad"]::before, .mod-issues li[data-error="true"]::before,
.ws-idcheck[data-tone="bad"]::before, .ws-name-problem::before { background: var(--bad); }
.badge::before { margin-right: 0; }

.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 9px; color: var(--faint); font-size: 12.5px; }
.steps li::before { content: ""; width: 9px; height: 9px; flex: none; border-radius: 50%; border: 1.5px solid var(--line-strong); }
.steps li[data-step="done"] { color: var(--text); }
.steps li[data-step="done"]::before { background: var(--good); border-color: var(--good); }
.steps li[data-step="active"] { color: var(--text); font-weight: 600; }
.steps li[data-step="active"]::before { background: var(--warn); border-color: var(--warn); animation: blink 1.4s ease-in-out infinite; }
.operation-message { margin: 10px 0 0; color: var(--text); overflow-wrap: anywhere; font-size: 12.5px; }

/* ---------- activity (a log table) ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li {
  display: grid; grid-template-columns: 150px 150px 110px minmax(0, 1fr); gap: 12px; align-items: baseline;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px;
}
.feed li:first-child { border-top: 0; }
.feed .t { font-family: var(--font-mono); font-size: 11.5px; color: var(--faint); }
.feed .a { font-weight: 600; }
.feed .o { font: 600 10.5px var(--font-ui); letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.feed .o[data-tone="good"] { color: var(--good); }
.feed .o[data-tone="busy"] { color: var(--warn); }
.feed .o[data-tone="bad"] { color: var(--bad); }
.feed .m { color: var(--text); overflow-wrap: anywhere; }
.feed .feed-empty { display: block; color: var(--faint); }

/* ---------- notices ---------- */
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 10px 12px; background: var(--sunken);
  border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: var(--radius-sm);
}
.notice[role="alert"] { border-left-color: var(--bad); }
.notice p { margin: 0; flex: 1 1 320px; }
.notice-buttons { display: flex; gap: 8px; }

/* ---------- config editor ---------- */
.config-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.config-head .panel-title { margin-bottom: 10px; }
.config-meta { color: var(--faint); overflow-wrap: anywhere; }
.editor { display: flex; height: min(62vh, 580px); min-height: 240px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.editor:focus-within { border-color: var(--focus); }
.gutter { margin: 0; padding: 10px 10px 10px 12px; min-width: 46px; overflow: hidden; text-align: right; color: var(--faint); line-height: 1.6; user-select: none; border-right: 1px solid var(--line); }
.editor textarea { flex: 1; min-width: 0; margin: 0; padding: 10px 12px; resize: none; border: 0; outline: none; background: transparent; color: var(--text); line-height: 1.6; tab-size: 4; white-space: pre; overflow: auto; }
.editor textarea:disabled { color: var(--faint); }
.config-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.config-state { color: var(--muted); font-size: 12.5px; }
.config-state[data-dirty="true"] { color: var(--text); }
.config-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.config-buttons .btn { min-width: 88px; }
.config-lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.backup-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.backups-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.backup-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.backup-list li:first-child { border-top: 0; }
.backup-list .t { font-family: var(--font-mono); font-size: 11.5px; }
.backup-list .s { color: var(--faint); font-size: 11.5px; }
.backup-list .feed-empty { display: block; color: var(--faint); }

/* ---------- form controls ---------- */
select, input[type="text"], input[type="password"] {
  min-height: 34px; padding: 0 10px; background: var(--sunken); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: 400 12.5px var(--font-ui);
}
input[type="text"].mono { font: 400 12px var(--font-mono); }
select { padding: 0 8px; font-weight: 500; }
select:disabled, input[type="text"]:disabled, input[type="password"]:disabled { color: var(--faint); border-color: var(--line); background: var(--surface); cursor: not-allowed; }
input[type="text"]::placeholder { color: var(--faint); }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---------- mod list ---------- */
.mod-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mod-list .feed-empty { color: var(--faint); padding: 10px 12px; }
.mod-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-top: 1px solid var(--line); border-left: 3px solid transparent;
}
.mod-row:first-child { border-top: 0; }
.mod-row[data-state="warning"] { border-left-color: var(--warn); }
.mod-row[data-state="error"] { border-left-color: var(--bad); }
.mod-index { color: var(--faint); text-align: right; }
.mod-name { overflow-wrap: anywhere; }
.mod-actions { display: flex; gap: 6px; }
.mod-issues { grid-column: 2 / -1; list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 12px; }
.mod-issues li { color: var(--text); overflow-wrap: anywhere; }
.mod-add { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.mod-command { display: grid; gap: 5px; margin-top: 12px; }
.mod-command code { display: block; padding: 8px 10px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text); overflow-wrap: anywhere; }
.mods-last { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
#mods-notice { margin-bottom: 12px; }

/* ---------- workshop ---------- */
.ws-intro { margin: 0 0 12px; }
.ws-intro strong, .upd-intro strong, .inst-hint strong { color: var(--text); font-weight: 600; }
.ws-input, .ws-install-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
.ws-install-row { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.inst-hint { margin: 8px 0 12px; }
.inst-warnings { margin: 6px 0 0; padding-left: 18px; font-size: 11.5px; color: var(--faint); overflow-wrap: anywhere; }
#ws-progress { margin: 12px 0 0; }
.ws-staged { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.ws-idcheck { margin: 0; font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }
.ws-idcheck[data-tone="good"] { color: var(--good); }
.ws-installed { margin: 0; color: var(--text); font-size: 12.5px; }
.ws-name-label { display: block; }
.ws-name-problem { margin: 0; color: var(--text); font-size: 12px; }
.ws-name-problem:empty { display: none; }
.ws-staged .hint { margin: 0; }
.ws-details { margin: 8px 0 0; padding-left: 18px; color: var(--text); font-size: 12px; }
.ws-details:empty { display: none; }

/* ---------- schedule & updates ---------- */
.sched-intro { margin: 0 0 12px; }
.check { display: flex; align-items: flex-start; gap: 9px; margin: 6px 0 12px; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 2px 0 0; flex: none; }
.feed-audit { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.sched-times-label { display: block; margin-bottom: 5px; }
#sched-times { width: 100%; }
#sched-zone { margin: 6px 0 0; }
#sched-problem { margin-top: 6px; }
.upd-intro { margin: 0 0 12px; }
.upd-toolbar { margin: 0 0 8px; }
.upd-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; max-height: 680px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.upd-list .feed-empty { color: var(--faint); padding: 10px 12px; }
.upd-row { padding: 11px 12px; border-top: 1px solid var(--line); border-left: 3px solid transparent; }
.upd-row:first-child { border-top: 0; }
.upd-row[data-state="ready"], .upd-row[data-state="queued"], .upd-row[data-state="downloading"], .upd-row[data-state="applying"] { border-left-color: var(--warn); }
.upd-row[data-state="up_to_date"] { border-left-color: var(--good); }
.upd-row[data-state="failed"] { border-left-color: var(--bad); }
.upd-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upd-head .mono { flex: 1 1 auto; overflow-wrap: anywhere; }
.upd-head input { width: 15px; height: 15px; margin: 0; flex: none; }
.upd-id { color: var(--faint); font-size: 11.5px; }
.upd-summary { margin: 5px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.upd-summary.meta { color: var(--faint); }
.upd-error { margin: 5px 0 0; font-size: 12px; color: var(--text); overflow-wrap: anywhere; }
.upd-error::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; vertical-align: .08em; background: var(--bad); }
.upd-error[data-tone="busy"]::before { background: var(--warn); }
.upd-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.upd-actions:empty { display: none; }
.upd-hint { margin: 0; flex: 1 1 200px; }
.updates .eyebrow { display: block; margin: 18px 0 4px; }

/* ---------- COT permissions ---------- */
.confirm-typed { display: grid; gap: 6px; margin: 0 0 14px; }

/* ---------- footer & dialogs ---------- */
.footer { display: flex; justify-content: space-between; gap: var(--gap); flex-wrap: wrap; padding: 12px 28px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; }
.footer .mono { overflow-wrap: anywhere; font-size: 11.5px; }

.confirm {
  width: min(460px, calc(100vw - 32px)); padding: 22px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 24px 70px rgb(0 0 0 / .5);
}
.confirm::backdrop { background: rgb(5 8 14 / .6); backdrop-filter: blur(3px); }
.confirm p { margin: 0 0 16px; color: var(--text); }
.confirm-buttons { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.confirm.uninstall { width: min(700px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; }
.acct-form label.al-check { display: flex; align-items: center; gap: 8px; }
.acct-form label.al-check input { width: auto; margin: 0; }
.un-facts { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 3px 12px; margin: 0 0 12px; font-size: 12px; }
.un-facts dt { color: var(--faint); }
.un-facts dd { margin: 0; overflow-wrap: anywhere; }
.un-section { margin: 0 0 12px; }
.un-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.un-list li { margin: 0 0 3px; overflow-wrap: anywhere; }
.un-blockers .un-list li::marker { color: var(--bad); }
.un-files summary { cursor: pointer; color: var(--text); font-size: 12px; }
.un-files ol { max-height: 220px; overflow-y: auto; margin: 6px 0 0; padding-left: 28px; font-size: 11.5px; color: var(--faint); }
.un-files li { overflow-wrap: anywhere; }
/* ---------- review before saving, and compare ---------- */
.confirm.diff { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.confirm.diff[open] { display: flex; flex-direction: column; }
.confirm.diff form { display: flex; flex-direction: column; min-height: 0; gap: 10px; }
.diff-meta { margin: 0; color: var(--muted); font-size: 12.5px; }
.diff-pick { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.diff-pick label { display: grid; gap: 4px; min-width: 0; flex: 1 1 220px; }
.diff-pick select { width: 100%; }
.diff-body { min-height: 80px; max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunken); }
.diff-empty { margin: 0; padding: 14px; color: var(--faint); font-family: var(--font-ui); }
.dl { display: flex; white-space: pre; min-width: max-content; line-height: 1.5; }
.dl-mark { flex: 0 0 22px; text-align: center; color: var(--faint); user-select: none; }
.dl-text { padding-right: 12px; }
.dl[data-kind="add"] { background: color-mix(in srgb, var(--good) 16%, var(--sunken)); }
.dl[data-kind="add"] .dl-mark { color: var(--good); }
.dl[data-kind="del"] { background: color-mix(in srgb, var(--bad) 16%, var(--sunken)); }
.dl[data-kind="del"] .dl-mark { color: var(--bad); }
.dl-hunk { padding: 3px 12px; background: var(--surface-2); color: var(--muted); }
.quar { margin-top: 18px; }
.quar .eyebrow { margin: 0 0 4px; }
.quar-list { max-height: 360px; }
.sf-facts { margin-top: 4px; }
.sf-progress { margin: 0 0 10px; color: var(--text); }

/* ---------- sign-in overlay & account ---------- */
body.auth-open { overflow: hidden; }
.auth { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: var(--bg); overflow-y: auto; }
.auth-card { width: min(420px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; font-weight: 650; }
.auth-title { margin: 0 0 6px; font-size: 20px; font-weight: 650; }
.auth-intro { margin: 0 0 16px; }
.auth-card form { display: grid; gap: 12px; }
.auth-card label, .acct-form label { display: grid; gap: 5px; }
.auth-card input, .acct-form input { width: 100%; }
.auth-error { margin: 0; min-height: 1.2em; color: var(--bad); font-size: 12.5px; }
.auth-submit { width: 100%; }
.acct-sub { margin: 24px 0 8px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 650; }
.acct-intro strong { color: var(--text); }
.acct-form { display: grid; gap: 12px; max-width: 460px; }
.acct-msg[data-tone="good"] { color: var(--good); }
.acct-msg[data-tone="bad"] { color: var(--bad); }
.acct-secret { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--sunken); }
.acct-secret-text { margin: 0; font-size: 15px; letter-spacing: .08em; overflow-wrap: anywhere; }

/* ---------- roles ---------- */
.readonly-banner { margin: 0; padding: 8px 28px; background: color-mix(in srgb, var(--warn) 14%, var(--bg)); border-bottom: 1px solid var(--line); color: var(--text); font-size: 12.5px; }
body:not([data-role="owner"]) [data-upd-uninstall], body:not([data-role="owner"]) [data-quar-restore], body:not([data-role="owner"]) [data-sf-restore],
body:not([data-role="owner"]) #sf-install, body:not([data-role="owner"]) #sf-clear, body:not([data-role="owner"]) #inst-clear { display: none !important; }
body[data-role="viewer"] [data-nav="config"], body[data-role="viewer"] [data-nav="logs"], body[data-role="viewer"] .panel.alerts { display: none; }
body[data-role="viewer"] .layout > .panel:not([data-page="account"]) :is(.btn, select, input, textarea, button) { pointer-events: none; opacity: .45; }
.users-list { list-style: none; margin: 10px 0 14px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.users-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line); }
.users-row:first-child { border-top: 0; }
.users-row .users-name { flex: 1 1 140px; font-weight: 600; overflow-wrap: anywhere; }
.users-row .users-meta { color: var(--faint); font-size: 11.5px; }
.users-row[data-disabled="true"] .users-name { text-decoration: line-through; color: var(--faint); }
.users-confirm { margin-bottom: 8px; }
.users-sub { margin-top: 18px; padding-top: 0; border-top: 0; }

/* ---------- logs ---------- */
.log-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.log-bar #log-file { flex: 1 1 280px; min-width: 0; }
.log-bar #log-search { flex: 1 1 200px; min-width: 0; }
.log-follow { margin: 0; align-items: center; }
.log-box { height: min(68vh, 700px); min-height: 260px; overflow: auto; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.log-lines { list-style: none; margin: 0; padding: 8px 0; font: 400 12px/1.55 var(--font-mono); }
.log-line { padding: 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 3px solid transparent; }
.log-line:hover { background: var(--surface-2); }
.log-line[data-tone="busy"] { border-left-color: var(--warn); }
.log-line[data-tone="bad"] { border-left-color: var(--bad); color: var(--text); background: color-mix(in srgb, var(--bad) 8%, transparent); }
.log-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.log-chips[hidden] { display: none; }
.log-chips-label { color: var(--faint); font-size: 12px; margin-right: 2px; }
.log-chip { border: 1px solid var(--line-strong); background: transparent; color: var(--text); border-radius: 999px; padding: 2px 10px; font: 600 11.5px var(--font-ui); cursor: pointer; }
.log-chip[data-severity="bad"] { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
.log-chip[data-severity="warn"] { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); }
.log-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.log-tag { display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 3px; font: 700 10px/16px var(--font-ui); letter-spacing: .05em; color: var(--accent-text); background: var(--faint); vertical-align: 1px; }
.log-tag[data-severity="bad"] { background: var(--bad); }
.log-tag[data-severity="warn"] { background: var(--warn); }
.log-count { display: inline-block; margin-right: 2px; padding: 0 6px; border-radius: 3px; font: 600 11px/16px var(--font-mono); color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong); }
.log-mod { margin-right: 2px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 3px; font-size: 11px; color: var(--muted); }
.log-line mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 2px; }

/* ---------- small screens: the sidebar becomes a bottom tab bar ---------- */
@media (max-width: 960px) {
  body { grid-template-columns: minmax(0, 1fr); padding-bottom: 62px; }
  .sidebar {
    position: fixed; inset: auto 0 0 0; top: auto; height: auto; z-index: 10;
    flex-direction: row; align-items: center; gap: 0; padding: 4px 6px;
    border-right: 0; border-top: 1px solid var(--line);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; gap: 2px; }
  .nav-item { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 10.5px; text-align: center; justify-content: center; }
  .nav-item[aria-current="page"]::before { left: 20%; right: 20%; top: -5px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 2px 2px; }
  .nav-item .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-badge { position: absolute; top: 0; right: 14%; margin: 0; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .layout[data-active="overview"] > .status, .layout[data-active="overview"] > .controls { grid-column: 1 / -1; }
  .topbar, .footer { padding-left: 14px; padding-right: 14px; }
  .ws-input, .ws-install-row { grid-template-columns: minmax(0, 1fr); }
  .mod-row { grid-template-columns: 24px minmax(0, 1fr); }
  .mod-row .mod-side, .mod-row .mod-actions { grid-column: 2; }
  .mod-add { grid-template-columns: minmax(0, 1fr); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div:nth-child(3) { border-left: 0; }
  .facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .feed li { grid-template-columns: minmax(0, 1fr) auto; }
  .feed .m { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .buttons { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px; }
  .state { font-size: 24px; }
  .page-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- summary strip (Overview) ---------- */
.layout[data-active] > .strip { display: none; }
.layout[data-active="overview"] > .strip { display: grid; grid-column: 1 / -1; }
.strip { grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.strip-item { padding: 11px 16px; min-width: 0; border-left: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.strip-item:first-child { border-left: 0; }
.strip-label { font: 600 10.5px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.strip-value { font: 500 13px var(--font-ui); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strip-value[data-tone="busy"] { color: var(--warn); }
.strip-value[data-tone="bad"] { color: var(--bad); }
.strip-sub { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- plain data tables (backups, and later the other lists) ---------- */
.table-wrap { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th { text-align: left; padding: 8px 12px; font: 600 10.5px var(--font-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); background: var(--sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { text-align: right; font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.table .name { font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * + * { margin-left: 6px; }

/* ---------- types.xml table ---------- */
.types-mode { display: flex; gap: 6px; margin: 0 0 10px; }
.types-mode .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.types-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.types-bar #types-search { flex: 1 1 200px; min-width: 0; }
.types-bar select { min-width: 0; max-width: 100%; }
.types-grid th { padding: 0; }
#globals-table .types-grid th, #events-table .types-grid th, #spawn-table .types-grid th { padding: 8px 12px; }
#events-table .types-num { width: 64px; }
#events-table .types-grid td { padding: 6px 8px; }
#ms-body td.name { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spawn-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 24px; padding: 6px 4px 8px; }
.spawn-group { min-width: 0; }
.spawn-head, .spawn-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 3px 0; }
.spawn-head .eyebrow { flex: 1 1 auto; }
.spawn-item .mono { overflow-wrap: anywhere; font-size: 12px; color: var(--muted); }
.spawn-chance { display: inline-flex; align-items: center; gap: 6px; }
.spawn-chance[data-changed="true"] .types-num { border-color: var(--accent); }
.events-child { margin: 2px 0; font-size: 12px; color: var(--muted); }
.th-sort { display: block; width: 100%; padding: 8px 12px; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit; white-space: nowrap; cursor: pointer; }
.th-sort:hover { color: var(--text); }
.types-grid td.types-usage { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.types-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0 0; flex-wrap: wrap; }
.types-pager { display: flex; gap: 6px; }
.health .problems-list .line { color: var(--muted); cursor: default; }
.health .problems-list .line:hover { text-decoration: none; }
.types-grid tbody tr[data-changed="true"] td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.types-num { width: 76px; min-height: 26px; padding: 0 6px; text-align: right; font: 400 12px var(--font-mono); color: var(--text); background: var(--sunken); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.types-num[aria-invalid="true"] { border-color: var(--bad); }
.types-num::placeholder { color: var(--faint); }
.types-cat { max-width: 150px; min-height: 26px; font-size: 12px; }
td[data-changed="true"] .types-num { border-color: var(--accent); }
.types-detail td { background: var(--sunken); border-top: 0; }
.types-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 20px; padding: 6px 4px 8px; }
.types-group { min-width: 0; }
.types-group .check { margin: 3px 0; font-size: 12px; }
.types-group .eyebrow { display: block; margin-bottom: 4px; }
.table .empty { color: var(--faint); padding: 14px 12px; }
.table .flag { color: var(--warn); }
.table .when { white-space: nowrap; }
.btn-text { min-height: 24px; padding: 0 8px; background: transparent; border-color: transparent; color: var(--muted); font: 600 11px var(--font-ui); text-decoration: none; }
.btn-text:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.btn-text[data-danger="true"]:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }

/* ---------- long explanations live behind a small disclosure ---------- */
.help { margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.help summary { cursor: pointer; color: var(--faint); font-weight: 500; width: max-content; }
.help summary:hover { color: var(--text); }
.help p { margin: 8px 0 0; max-width: 78ch; }

@media (max-width: 860px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip-item:nth-child(odd) { border-left: 0; }
  .strip-item:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- config editor: file picker and problem list ---------- */
.config-file { max-width: 100%; min-height: 30px; padding: 0 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: 500 12px var(--font-ui); }
.config-head + .config-meta { margin: -4px 0 10px; font-size: 12px; }
.problems { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.problems-head { padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--sunken); }
.problems-head[data-tone="bad"] .eyebrow { color: var(--bad); }
.problems-head[data-tone="busy"] .eyebrow { color: var(--warn); }
.problems-head[data-tone="good"] .eyebrow { color: var(--good); }
.problems-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.problems-list li { display: grid; grid-template-columns: 62px 64px minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 6px 12px; border-top: 1px solid var(--line); font-size: 12.5px; }
.problems-list li:first-child { border-top: 0; }
.problems-list .sev { font: 600 10.5px var(--font-ui); letter-spacing: .05em; text-transform: uppercase; }
.problems-list li[data-severity="error"] .sev { color: var(--bad); }
.problems-list li[data-severity="warning"] .sev { color: var(--warn); }
.problems-list .line { padding: 0; border: 0; background: transparent; color: var(--accent); font: 500 12px var(--font-mono); text-align: left; cursor: pointer; }
.problems-list .line:hover { text-decoration: underline; }
.problems-list .msg { overflow-wrap: anywhere; }
.problems-list .empty { grid-column: 1 / -1; color: var(--faint); }

/* ---------- crash auto-restart ---------- */
.arpaused { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-left: 3px solid var(--bad); }
.arpaused p { margin: 0; flex: 1 1 360px; }
.arpaused .btn { text-decoration: none; }
