:root {
  --bg: #0b0e14;
  --panel: #131822;
  --line: #263041;
  --fg: #e6edf6;
  --muted: #8792a4;
  --ok: #2ea043;
  --bad: #c93c37;
  --accent: #3b82f6;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel);
}
header form { margin-left: auto; }
select, textarea, input, button { font: inherit; color: inherit; }
select { background: #0f141d; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.status { color: var(--muted); font-size: 12px; }
.status.on { color: var(--ok); }
.status.off { color: var(--bad); }
button {
  background: #1b2230; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.ok { background: #16351f; border-color: var(--ok); }
button.bad { background: #3a1a19; border-color: var(--bad); }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; padding: 12px; height: calc(100vh - 46px); }
.screen { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.screen-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding-bottom: 6px; }
.viewport {
  flex: 1; min-height: 0; display: grid; place-items: center;
  background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
#frame { max-width: 100%; max-height: 100%; cursor: crosshair; image-rendering: auto; }

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.approvals { background: #2a220f; border: 1px solid #6b5518; border-radius: 8px; padding: 12px; }
.approvals h2 { margin: 0 0 8px; font-size: 14px; }
.approvals pre { margin: 0 0 10px; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
.row { display: flex; gap: 8px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.log { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.msg.me { background: #1d2637; align-self: flex-end; max-width: 90%; }
.msg.bot { background: #141b26; border: 1px solid var(--line); }
.msg.sys { color: var(--muted); font-size: 12px; background: none; padding: 2px 4px; }
.composer { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; background: #0f141d; border: 1px solid var(--line); border-radius: 6px; padding: 8px; }

.login { display: grid; place-items: center; }
.login main { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: 320px; }
.login h1 { margin: 0 0 16px; font-size: 18px; }
.login label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.login input { width: 100%; background: #0f141d; border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 12px; }
.login button { width: 100%; }
.err { color: var(--bad); font-size: 13px; margin: 0 0 12px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .chat { min-height: 40vh; }
}
