:root {
  --bg: #111214;
  --side: #16171a;
  --panel: #1b1d21;
  --panel-2: #212328;
  --line: #2b2e34;
  --line-2: #363a42;
  --text: #e4e5e7;
  --muted: #8d9199;
  --faint: #5f636b;
  --green: #67a83b;
  --green-2: #7fc24f;
  --green-bg: rgba(103, 168, 59, .12);
  --red: #e0524d;
  --red-bg: rgba(224, 82, 77, .12);
  --amber: #e5a43a;
  --amber-bg: rgba(229, 164, 58, .12);
  --blue: #5b9bd5;
  --blue-bg: rgba(91, 155, 213, .12);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--green-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(103, 168, 59, .35); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }

/* ------------------------------------------------ layout */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { padding: 16px 16px 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 30px; height: 30px; border-radius: 5px; background: var(--green); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.brand b { display: block; font-size: 13px; letter-spacing: .2px; }
.brand span { font-size: 11px; color: var(--muted); }
.srv-card { margin: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.srv-card .addr { font-family: var(--mono); font-size: 11.5px; color: var(--muted); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-card .addr:hover { color: var(--text); }
.nav { padding: 4px 8px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 5px; color: var(--muted); font-size: 13.5px; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--green); }
.nav a svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--amber); color: #1b1300; border-radius: 9px; padding: 0 6px; font-weight: 600; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.side-foot { flex-wrap: wrap; }
.side-foot .who { color: var(--muted); flex-basis: 100%; }
.side-foot .btn { white-space: nowrap; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.top h1 { font-size: 16px; font-weight: 600; margin: 0; }
.content { flex: 1; overflow-y: auto; padding: 20px; }
.content.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ------------------------------------------------ status */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.running { background: var(--green-2); box-shadow: 0 0 0 3px var(--green-bg); }
.dot.starting, .dot.stopping { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-bg); animation: pulse 1.2s infinite; }
.dot.crashed { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
@keyframes pulse { 50% { opacity: .45; } }
.state-text { font-weight: 600; text-transform: capitalize; }

/* ------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap; font-size: 13px; }
.btn:hover { border-color: #4a4f58; background: #272a30; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.primary { background: var(--green); border-color: var(--green); color: #0d1508; font-weight: 600; }
.btn.primary:hover { background: var(--green-2); border-color: var(--green-2); }
.btn.danger { color: #ffb4b1; border-color: #5a2a2a; background: #2a1919; }
.btn.danger:hover { background: #3a1e1e; border-color: #7a3533; }
.btn.warn { color: #ffd59a; border-color: #5c4420; background: #2b2213; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.input, select.input, textarea.input { height: 32px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line-2); background: #141518; width: 100%; outline: none; }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
label.row.field { display: flex; }
.hint { font-size: 12px; color: var(--faint); margin-top: 3px; }

.switch { position: relative; width: 34px; height: 19px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: #34373e; border-radius: 10px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px; background: #c9cbcf; border-radius: 50%; transition: .15s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(15px); background: #fff; }
.switch input:disabled + i { opacity: .4; cursor: not-allowed; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 8px 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--green); }
.tabs .count { font-size: 11px; color: var(--faint); margin-left: 4px; }

/* ------------------------------------------------ panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 44px; }
.card-h h3 { margin: 0; font-size: 13px; font-weight: 600; }
.card-b { padding: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 12px 14px; }
.stat .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 400; }
.banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r); margin-bottom: 14px; border: 1px solid; }
.banner.warn { background: var(--amber-bg); border-color: #5c4420; color: #f3d7a6; }
.banner.err { background: var(--red-bg); border-color: #5a2a2a; color: #f6c0bd; }
.banner.info { background: var(--blue-bg); border-color: #2c4560; color: #c3dbf2; }
.banner.ok { background: var(--green-bg); border-color: #3a5a26; color: #cde6bd; }
.empty { padding: 30px; text-align: center; color: var(--faint); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); padding: 8px 12px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--panel-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.green { color: #a6d98a; border-color: #3a5a26; background: var(--green-bg); }
.pill.red { color: #f0a3a0; border-color: #5a2a2a; background: var(--red-bg); }
.pill.amber { color: #f0c47e; border-color: #5c4420; background: var(--amber-bg); }
.pill.blue { color: #9cc4ea; border-color: #2c4560; background: var(--blue-bg); }
.head { width: 22px; height: 22px; border-radius: 3px; image-rendering: pixelated; background: #2a2c31; flex: none; }

/* ------------------------------------------------ console */
.console { flex: 1; overflow-y: auto; background: #0c0d0e; font: 12.5px/1.55 var(--mono); padding: 12px 16px; white-space: pre-wrap; word-break: break-word; }
.console .l-warn { color: #e6c06a; }
.console .l-err { color: #ff8580; }
.console .l-me { color: #8fd36a; }
.console .l-sys { color: #7fb0e0; }
.console .l-out { color: #b6b9bf; }
.cmdbar { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.cmdbar .prompt { font-family: var(--mono); color: var(--green-2); align-self: center; }
.cmdbar input { font-family: var(--mono); }

/* ------------------------------------------------ mods */
.mod { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mod:last-child { border-bottom: 0; }
.mod.off { opacity: .55; }
.mod-icon { width: 44px; height: 44px; border-radius: 6px; background: var(--panel-2); object-fit: cover; image-rendering: auto; display: grid; place-items: center; color: var(--faint); font-weight: 700; font-size: 18px; overflow: hidden; }
.mod-icon img { width: 100%; height: 100%; object-fit: cover; }
.mod-name { font-weight: 600; font-size: 14px; }
.mod-sub { font-size: 12px; color: var(--muted); }
.mod-ctl { display: flex; align-items: center; gap: 14px; }
.mod-ctl .lbl { font-size: 11px; color: var(--faint); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 56px; }

/* ------------------------------------------------ logs */
.logs { display: grid; grid-template-columns: 220px minmax(0, 1fr); height: 100%; min-height: 0; }
.people { border-right: 1px solid var(--line); overflow-y: auto; background: var(--side); padding: 8px; }
.people h4 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: var(--faint); margin: 12px 8px 6px; font-weight: 500; }
.people a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; color: var(--muted); font-size: 13px; cursor: pointer; }
.people a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.people a.on { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--green); }
.loglist { overflow-y: auto; min-height: 0; }
.ev { display: grid; grid-template-columns: 132px 96px minmax(0, 1fr); gap: 10px; padding: 7px 16px; border-bottom: 1px solid #202227; font-size: 13px; align-items: baseline; }
.ev:hover { background: #17181b; }
.ev .ts { color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.ev .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev .txt { word-break: break-word; }
.ev.hl { background: rgba(229, 164, 58, .06); box-shadow: inset 2px 0 0 var(--amber); }
.ev .src { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .5px; display: block; font-weight: 400; }

/* ------------------------------------------------ files */
.crumbs { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12.5px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); cursor: pointer; }
.crumbs a:hover { color: var(--text); }
.editor { width: 100%; min-height: 60vh; background: #0c0d0e; color: #dcdfe4; border: 0; outline: none; font: 12.5px/1.6 var(--mono); padding: 14px 16px; resize: none; tab-size: 4; }

/* ------------------------------------------------ charts */
.chart { width: 100%; height: 120px; display: block; }
.legend { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ flow banner */
.flow { display: flex; align-items: center; gap: 12px; padding: 9px 20px; background: #2b2213; border-bottom: 1px solid #5c4420; color: #f3d7a6; font-size: 13px; }
.flow b { font-variant-numeric: tabular-nums; }
.flow .bar { flex: 1; height: 4px; background: rgba(255, 255, 255, .08); border-radius: 2px; overflow: hidden; max-width: 260px; }
.flow .bar i { display: block; height: 100%; background: var(--amber); transition: width 1s linear; }

/* ------------------------------------------------ toasts + modals */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: 360px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 3px solid var(--blue); border-radius: var(--r); padding: 10px 12px; font-size: 13px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); animation: tin .18s ease-out; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast .t-actions { margin-top: 8px; display: flex; gap: 6px; }
@keyframes tin { from { transform: translateY(6px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 820px; }
.modal-h { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal-h h3 { margin: 0; font-size: 15px; }
.modal-b { padding: 16px; overflow-y: auto; }
.modal-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 360px; }
.login .brand { border: 0; padding: 0 0 20px; justify-content: center; }
.login .card { padding: 22px; }
.login h2 { margin: 0 0 4px; font-size: 18px; }
.err-text { color: #ff8f8a; font-size: 13px; min-height: 18px; margin: 4px 0 10px; }
.code-input { font-family: var(--mono); font-size: 22px; letter-spacing: 8px; text-align: center; height: 48px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  .menu-btn { display: inline-flex !important; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .logs { grid-template-columns: 1fr; }
  .people { display: none; }
  .ev { grid-template-columns: 1fr; gap: 2px; }
  .top { padding: 0 12px; }
  .content { padding: 14px; }
  .top .hide-sm { display: none; }
}
.menu-btn { display: none !important; }
