:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8a93a5;
  --accent: #4f8cff;
  --ok: #3ccf8e;
  --warn: #f0b429;
  --bad: #ef5350;
  color-scheme: dark;
  font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
button, .btn, select, input {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px;
}
button, .btn { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: #3d4554; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.danger { color: var(--bad); }
.danger:hover { border-color: var(--bad); }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.4em; }
[hidden] { display: none !important; }

.login { max-width: 320px; margin: 18vh auto; display: grid; gap: 12px; }

header {
  position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 12px 20px; background: rgba(15, 17, 21, .92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.stats { display: flex; gap: 16px; color: var(--muted); }
.stats b { color: var(--text); }
.tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tools label { color: var(--muted); }

.banner { margin: 16px 20px 0; padding: 10px 14px; border-radius: 8px; background: #2a2210; border: 1px solid #5a4614; color: #f3d48a; }
.banner.bad { background: #2a1414; border-color: #5a2020; color: #f2a5a3; }
.empty { text-align: center; color: var(--muted); margin-top: 15vh; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; padding: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.screen { position: relative; aspect-ratio: 16 / 9; background: #07080a; display: grid; place-items: center; cursor: zoom-in; }
.screen img { width: 100%; height: 100%; object-fit: contain; }
.screen-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); }
.screen img:not([hidden]) + .screen-msg:empty { display: none; }
.screen-msg:not(:empty) { background: rgba(7, 8, 10, .75); }
.shot-age { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #c6ccd8; background: rgba(0, 0, 0, .55); padding: 1px 6px; border-radius: 4px; }
.shot-age:empty { display: none; }
.info { padding: 12px 14px 14px; display: grid; gap: 6px; }
.title { display: flex; align-items: center; gap: 8px; }
.name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.pill.running { color: var(--ok); border-color: #1f5a41; }
.pill.loading, .pill.created, .pill.scheduling { color: var(--warn); border-color: #5a4614; }
.pill.exited, .pill.stopped, .pill.offline { color: var(--bad); border-color: #5a2020; }
.meta { color: var(--muted); }
.msg { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg:empty { display: none; }
.mcp { display: flex; align-items: center; gap: 8px; font-size: 12px; min-width: 0; }
.mcp code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
.mcp button { padding: 2px 8px; font-size: 12px; margin-left: auto; }
.deadline { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.deadline select { padding: 2px 6px; font-size: 12px; }
.countdown.soon { color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.actions .open { background: var(--accent); border-color: var(--accent); color: #fff; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(980px, 96vw); max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog > form, dialog > pre, dialog > img { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.close { background: none; border: 0; font-size: 16px; }
.rent { width: auto; }
.rent form { display: flex; gap: 10px; padding: 18px; }
.choice[aria-pressed="true"] { border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; }

.viewer { width: 96vw; }
.viewer img { display: block; width: 100%; height: auto; }
.logs pre { padding: 14px 18px; margin: 0; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: 90vw; }
.toast.bad { border-color: var(--bad); color: #f2a5a3; }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; padding: 12px; }
}
