:root {
  --bg: #0d1117; --panel: #151b23; --panel2: #1c242e; --line: #2a3441;
  --text: #e6edf3; --dim: #8b98a7; --accent: #22c55e; --accent-ink: #052e16;
  --warn: #f59e0b; --bad: #ef4444; --info: #60a5fa;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
.hidden { display: none !important; }
a { color: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -1px; }

.btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 7px 13px; border-radius: 6px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--dim); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.primary, .btn.good { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.warn { color: var(--warn); }
.btn.bad { color: var(--bad); }
.btn.ghost { background: none; }
.btn.link { background: none; border: none; padding: 2px 6px; color: var(--dim); }
.btn.link:hover { color: var(--text); }
.btn.link.danger:hover { color: var(--bad); }

.logo { display: inline-block; width: 18px; height: 18px; border-radius: 4px; background: var(--accent); box-shadow: inset 0 0 0 4px #15803d; vertical-align: -3px; }
.brand { font-weight: 700; font-size: 16px; display: flex; gap: 9px; align-items: center; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; color: var(--dim); font-size: 13px; }
.api-box summary { color: var(--dim); cursor: pointer; font-size: 13px; }
.api-box label { margin-top: 8px; }
.err { color: var(--bad); margin: 0; min-height: 1.2em; }

/* layout */
.app { display: grid; grid-template-columns: 200px 1fr; min-height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a { padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--dim); }
#nav a:hover { background: var(--panel2); color: var(--text); }
#nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
main { min-width: 0; padding: 0 22px 30px; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.power { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.pill { padding: 3px 10px; border-radius: 99px; font-weight: 600; font-size: 12px; background: var(--panel2); color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.pill.online { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.pill.starting { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.offline { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.addr { font: 13px var(--mono); background: none; border: 1px dashed var(--line); color: var(--text); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.addr:hover { border-color: var(--dim); }

.tab { display: none; }
.tab.on { display: block; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.note, .sub { color: var(--dim); font-size: 13px; }
.note { margin: 8px 0 14px; }
.chk { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.num { width: 70px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); font-weight: 600; }
.big { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.card canvas { width: 100%; height: 50px; display: block; margin-top: 6px; }
.bar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; width: 0; background: var(--info); transition: width .4s; }
.bar i.hot { background: var(--warn); }

/* console */
.console { background: #090c10; border: 1px solid var(--line); border-radius: 8px 8px 0 0; margin: 0; padding: 10px 12px; height: calc(100vh - 230px); min-height: 280px; overflow: auto; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.console .w { color: var(--warn); }
.console .e { color: var(--bad); }
.console .c { color: var(--info); }
.console .o { color: var(--accent); }
.cmd { display: flex; align-items: center; gap: 8px; background: #090c10; border: 1px solid var(--line); border-top: none; border-radius: 0 0 8px 8px; padding: 6px 12px; }
.cmd span { color: var(--accent); font: 14px var(--mono); }
.cmd input { flex: 1; border: none; background: none; font-family: var(--mono); outline: none; padding: 4px 0; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbl th { text-align: left; font-size: 12px; color: var(--dim); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel2); }
.tbl td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: color-mix(in srgb, var(--panel2) 60%, transparent); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .acts { text-align: right; white-space: nowrap; }
.tbl .name { cursor: pointer; }
.tbl .name:hover { text-decoration: underline; }
.tbl .desc { color: var(--dim); font-size: 12px; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tr.off td:not(.acts) { opacity: .5; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel2); color: var(--dim); }
.tag.client { color: var(--warn); }
.tag.auto { color: var(--info); }
.tag.manual { color: var(--accent); }
.crumbs { font-family: var(--mono); }
.crumbs a { cursor: pointer; color: var(--info); }
.icon { display: inline-block; width: 1.3em; color: var(--dim); }

.list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
.list .it { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.list .it b { font-weight: 500; flex: 1; }
.list .empty { color: var(--dim); }
.head { width: 20px; height: 20px; border-radius: 3px; image-rendering: pixelated; background: var(--panel2); }

.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 8px 16px; }
.props label { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; font: 13px var(--mono); color: var(--dim); padding: 4px 0; border-bottom: 1px solid var(--line); }
.props label.changed { color: var(--warn); }

dialog.editor { width: min(1100px, 95vw); height: 85vh; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
dialog.editor[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
.ed-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-family: var(--mono); }
#ed-text { flex: 1; resize: none; border: none; border-radius: 0; font: 13px/1.5 var(--mono); background: #090c10; padding: 12px; tab-size: 4; }
#journal .console { flex: 1; height: auto; border-radius: 0; border: none; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 20px); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; transition: .25s; pointer-events: none; max-width: 90vw; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; gap: 10px; }
  #nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  #nav a { padding: 6px 9px; }
  #logout { margin-left: auto; }
  main { padding: 0 16px 24px; }
  .power { margin-left: 0; }
  .console { height: 60vh; }
  .tbl .hide-sm { display: none; }
  .props label { grid-template-columns: 1fr 120px; }
}
