:root {
  color-scheme: light dark;
  --bg: #f6f6f9; --card: #ffffff; --raised: #f0eff5; --sunken: #f9f9fb; --text: #17161d; --muted: #63616f; --line: #e4e3ec; --line-strong: #cfcddb;
  --accent: #6d28d9; --accent-fill: #7c3aed; --accent-soft: #f1eafe; --accent-line: #b79cf5; --accent-text: #ffffff;
  --glow: 0 0 0 1px var(--accent-line);
  --good: #0f7a46; --good-soft: #e0f4ea; --warn: #94590a; --warn-soft: #fbf0dc; --bad: #c02626; --bad-soft: #fdeaea; --idle: #8e8c9a;
  --code-bg: #111018; --code-text: #e4e1ee;
  --shadow: 0 1px 2px rgb(30 20 60 / .05), 0 2px 8px rgb(30 20 60 / .04);
  --radius: 12px; --radius-small: 8px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08080b; --card: #101014; --raised: #1a1a20; --sunken: #0c0c10; --text: #ededf2; --muted: #9b9aa8; --line: #222229; --line-strong: #33333d;
    --accent: #a98bfa; --accent-fill: #7c3aed; --accent-soft: rgb(124 58 237 / .16); --accent-line: #6d3fd8; --accent-text: #ffffff;
    --glow: 0 0 0 1px var(--accent-line), 0 0 18px rgb(124 58 237 / .22);
    --good: #4fd193; --good-soft: rgb(79 209 147 / .1); --warn: #efb057; --warn-soft: rgb(239 176 87 / .1); --bad: #ff8585; --bad-soft: rgb(255 133 133 / .1); --idle: #6f6e7b;
    --code-bg: #060609; --code-text: #e4e1ee;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 640; margin: 0; letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 620; margin: 0; }
p { margin: 6px 0 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }

/* Frame */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; background: var(--card); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); }
.brand h1 { font-size: 15px; }
.logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent-fill); color: var(--accent-text); flex: none; box-shadow: 0 0 16px rgb(124 58 237 / .35); }
.logo svg.icon { width: 19px; height: 19px; stroke-width: 2.1; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.nav-head { padding: 14px 10px 5px; color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid transparent; border-radius: var(--radius-small); color: var(--muted); font-weight: 520; }
.nav-link:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); box-shadow: var(--glow); }
.nav-link[aria-current="page"] svg.icon { color: var(--accent); }
.nav-link .count { margin-left: auto; }
.side-foot { margin-top: auto; display: grid; gap: 2px; }
main { padding: 22px 28px 48px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; min-height: 40px; }
.page-head .crumb { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.page-head .crumb a { display: inline-flex; align-items: center; gap: 2px; }
.page-head .crumb svg.icon { width: 15px; height: 15px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 3; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .brand { padding: 0; margin: 0 6px 0 0; border: 0; background: none; }
  .nav-head { display: none; }
  .brand div { display: none; }
  .nav-link { flex: none; padding: 7px 10px; }
  .nav-link span.label { display: none; }
  .nav-link[aria-current="page"] span.label { display: inline; }
  .side-foot { margin: 0 0 0 auto; display: flex; }
  main { padding: 16px 16px 40px; }
}

/* Surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); margin-bottom: 14px; }
.grid > .card { margin-bottom: 0; }
.card.current { border-color: var(--accent-line); box-shadow: var(--glow); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; color: inherit; }
a.tile:hover { border-color: var(--accent-line); text-decoration: none; }
.tile span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.tile span svg.icon { width: 15px; height: 15px; }
.tile b { display: block; font-size: 26px; line-height: 1.2; margin-top: 6px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; }
.good { color: var(--good); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.banner { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; font-weight: 540; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Pills and status */
.pill { --tone: var(--muted); display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent); background: color-mix(in srgb, var(--tone) 10%, transparent); color: var(--tone); font-size: 12px; font-weight: 560; white-space: nowrap; vertical-align: 1px; }
.pill.good { --tone: var(--good); }
.pill.warn { --tone: var(--warn); }
.pill.bad { --tone: var(--bad); }
.pill.accent { --tone: var(--accent); }
.pill.dotted::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.running { background: var(--good); box-shadow: 0 0 6px color-mix(in srgb, var(--good) 70%, transparent); }
.dot.paused, .dot.restarting, .dot.partial { background: var(--warn); }
.dot.dead, .dot.unhealthy { background: var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px -16px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 560; color: var(--muted); font-size: 12.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--sunken); }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--sunken); }
td.actions, th.actions { text-align: right; white-space: nowrap; width: 1%; }
td .sub { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.name-cell { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.name-cell img { width: 22px; height: 22px; border-radius: 5px; object-fit: contain; flex: none; }
.name-cell a { color: var(--text); font-weight: 560; }
.group-row td { background: var(--sunken); font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 6px 12px; }
@media (max-width: 700px) {
  .hide-sm { display: none; }
}

/* Controls */
label { display: block; font-size: 13px; color: var(--muted); }
label + label { margin-top: 12px; }
input, select, button, textarea { font: inherit; color: var(--text); }
input[type=text], input[type=password], input[type=search], select { min-height: 38px; padding: 7px 11px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius-small); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--glow); }
label input[type=text], label input[type=password], label select { width: 100%; margin-top: 5px; }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input::placeholder, textarea::placeholder { color: var(--muted); }
textarea.code { display: block; width: 100%; min-height: 360px; resize: vertical; padding: 12px; margin-top: 5px; border-radius: var(--radius-small); border: 1px solid var(--line); background: var(--sunken); font: 13px/1.5 var(--mono); tab-size: 2; white-space: pre; overflow-wrap: normal; }
textarea.code.short { min-height: 120px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: var(--radius-small); border: 1px solid var(--line-strong); background: var(--card); color: var(--text); font-weight: 540; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--raised); text-decoration: none; }
.btn svg.icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-text); font-weight: 620; box-shadow: 0 0 14px rgb(124 58 237 / .3); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: var(--bad-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-small); background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); }
.icon-btn svg.icon { width: 17px; height: 17px; }
.seg { display: inline-flex; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-small); padding: 3px; gap: 2px; }
.seg button { border: 1px solid transparent; background: none; padding: 4px 11px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 540; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tabs { display: flex; width: fit-content; max-width: 100%; gap: 2px; padding: 4px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunken); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { flex: none; border: 1px solid transparent; background: none; padding: 6px 13px; border-radius: var(--radius-small); cursor: pointer; color: var(--muted); font-weight: 540; display: flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button svg.icon { width: 16px; height: 16px; }
.tabs button[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); box-shadow: var(--glow); }
.form-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 160px; margin: 0; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.error-text { color: var(--bad); font-size: 13px; margin-top: 8px; }

/* Logs, terminal and job output */
.log { margin: 0; background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-small); padding: 12px 14px; font: 12.5px/1.5 var(--mono); height: min(64vh, 640px); overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.log .err { color: #ff9b9b; }
.log.short { height: 320px; }
.log mark { background: #8a6d00; color: #fff; }
.terminal { background: var(--code-bg); border-radius: var(--radius-small); padding: 8px; height: min(64vh, 640px); }
.terminal .xterm { height: 100%; }

/* Charts */
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.chart { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-small); padding: 12px; }
.chart b { font-size: 20px; font-weight: 660; font-variant-numeric: tabular-nums; }
.chart canvas { display: block; width: 100%; height: 70px; margin-top: 8px; }
.meter { height: 6px; border-radius: 999px; background: var(--raised); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; min-width: 6px; background: linear-gradient(90deg, var(--accent-fill), var(--accent)); border-radius: 999px; box-shadow: 0 0 10px rgb(124 58 237 / .45); transition: width .4s; }
.meter.warn i { background: var(--warn); box-shadow: none; }
.meter.bad i { background: var(--bad); box-shadow: none; }
.usage { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.usage-head { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11.5px; font-weight: 640; letter-spacing: .04em; text-transform: uppercase; }
.usage-head svg.icon { width: 15px; height: 15px; }
.usage-head b { margin-left: auto; color: var(--text); font-size: 17px; letter-spacing: -.01em; text-transform: none; font-variant-numeric: tabular-nums; }
.usage small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; font-variant-numeric: tabular-nums; }

/* Dialog and toast */
dialog { border: 1px solid var(--accent-line); border-radius: var(--radius); background: var(--card); color: var(--text); padding: 20px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(0 0 0 / .25); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { font-size: 16px; margin-bottom: 6px; }
dialog .actions-row { justify-content: flex-end; margin-top: 18px; }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; transition: .2s; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 540; z-index: 10; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); color: #fff; }

/* Sign in */
.login-page main { max-width: 400px; margin: 0 auto; padding-top: 14vh; }
.login-page .brand { padding: 0 0 18px; }
.login-page .actions-row { margin-top: 16px; }
