:root {
  --bg: #07100f;
  --panel: rgba(13, 27, 25, .86);
  --panel-solid: #0d1b19;
  --line: rgba(151, 185, 176, .18);
  --line-strong: rgba(151, 185, 176, .34);
  --text: #edf7f2;
  --muted: #8ca49d;
  --accent: #9eff6f;
  --accent-2: #47e0c2;
  --warn: #ffc857;
  --danger: #ff7185;
  --ok: #78f0ae;
  --shadow: 0 22px 55px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 50% -20%, #183a32 0, #07100f 48%); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.ambient { position: fixed; z-index: -1; width: 34rem; height: 34rem; border-radius: 50%; filter: blur(100px); opacity: .1; pointer-events: none; }
.ambient-a { background: var(--accent-2); left: -18rem; top: 20rem; }
.ambient-b { background: var(--accent); right: -22rem; top: 2rem; }
.shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 80px; }

.masthead { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin: 0 0 24px; }
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--accent-2); font: 700 .7rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .17em; }
h1 { margin: 0; font-size: clamp(2rem, 4vw, 4.3rem); line-height: .95; letter-spacing: -.065em; }
h1 span { color: var(--muted); font-weight: 400; }
h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.025em; }
.lede { max-width: 720px; margin: 14px 0 0; color: var(--muted); }
.mast-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.panel { background: linear-gradient(145deg, rgba(17, 35, 32, .94), rgba(8, 19, 18, .92)); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.section { margin-top: 16px; padding: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.auth-strip { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.4fr); align-items: end; gap: 30px; padding: 20px 22px; border-color: rgba(158, 255, 111, .22); }
.auth-strip p:not(.section-kicker) { color: var(--muted); margin: 8px 0 0; font-size: .88rem; }
.auth-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: end; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .78rem; }

input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--text); background: rgba(2, 9, 8, .7); outline: none; padding: 10px 11px; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(71, 224, 194, .1); }
input::placeholder, textarea::placeholder { color: #567068; }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; }

.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; color: var(--text); background: #18312d; font-weight: 700; font-size: .8rem; white-space: nowrap; transition: transform .12s, filter .12s, border-color .12s; }
.button:hover:not(:disabled) { filter: brightness(1.13); transform: translateY(-1px); }
.button:disabled { opacity: .38; cursor: not-allowed; }
.button.primary { color: #07100f; background: var(--accent); }
.button.secondary { color: #caffe0; background: rgba(71, 224, 194, .11); border-color: rgba(71, 224, 194, .3); }
.button.ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.button.danger { color: #ffd6dc; background: rgba(255, 113, 133, .1); border-color: rgba(255, 113, 133, .25); }
.button.small { padding: 7px 9px; font-size: .72rem; }

.switch-row { display: flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; }
.switch-row input, .check input { width: 16px; height: 16px; accent-color: var(--accent); }
.status-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 16px; }
.metric { min-height: 86px; padding: 17px; display: flex; align-items: center; gap: 12px; box-shadow: none; }
.metric p { margin: 0 0 5px; color: var(--muted); font-size: .75rem; }
.metric strong { font: 650 1.08rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.signal { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(140, 164, 157, .08); }
.signal.ok { background: var(--ok); box-shadow: 0 0 0 5px rgba(120, 240, 174, .1), 0 0 14px rgba(120, 240, 174, .6); }
.signal.bad { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 113, 133, .1); }

.filters { display: flex; gap: 8px; }
.filters input { min-width: 280px; }
.snapshot-note, .muted { color: var(--muted); }
.snapshot-note { margin: -7px 0 15px; font-size: .78rem; }
.compact { margin: 12px 0 0; font-size: .76rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th { padding: 10px 13px; text-align: left; color: #6f8b83; background: rgba(1, 7, 6, .34); font: 700 .68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 13px; border-top: 1px solid var(--line); font-size: .84rem; vertical-align: middle; }
tbody tr:hover { background: rgba(158, 255, 111, .025); }
.room-name { font-weight: 750; }
.subline { display: block; color: var(--muted); font-size: .7rem; margin-top: 3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .75rem; }
.align-right { text-align: right; }
.badge { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 7px; color: var(--muted); background: rgba(255,255,255,.025); font: 700 .65rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.badge.ok, .badge.ready, .badge.in_game, .badge.idle, .badge.completed { color: #abf8ca; border-color: rgba(120, 240, 174, .25); background: rgba(120, 240, 174, .06); }
.badge.warn, .badge.assigning, .badge.joining, .badge.creating, .badge.stopping { color: #ffe1a0; border-color: rgba(255, 200, 87, .25); background: rgba(255, 200, 87, .06); }
.badge.bad, .badge.error, .badge.failed, .badge.attention_required, .badge.offline { color: #ffb1bd; border-color: rgba(255, 113, 133, .26); background: rgba(255, 113, 133, .06); }
.empty { color: var(--muted); text-align: center; padding: 28px !important; }

.node-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 10px; }
.node-card { border: 1px solid var(--line); border-radius: 12px; padding: 15px; background: rgba(0,0,0,.12); }
.node-top, .node-actions, .task-top, .task-actions { display: flex; align-items: center; justify-content: space-between; gap: 9px; flex-wrap: wrap; }
.node-card h3, .task-card h3 { margin: 0; font-size: .95rem; }
.node-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 15px; margin-top: 14px; }
.node-meta p { margin: 0; color: var(--muted); font-size: .7rem; }
.node-meta strong { display: block; margin-top: 3px; color: var(--text); font: 500 .77rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.node-actions { justify-content: flex-start; margin-top: 14px; }
.task-list { display: grid; gap: 9px; }
.task-card { padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .12); }
.task-summary { display: flex; gap: 13px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .76rem; margin-top: 8px; }
.task-message { margin: 9px 0 0; color: #b8cbc5; font-size: .78rem; }
.task-actions { justify-content: flex-end; }
.boundary-note { margin: 15px 0 0; border-left: 2px solid var(--warn); padding: 3px 0 3px 10px; color: #c8b889; font-size: .75rem; }

.workbench { display: grid; grid-template-columns: minmax(340px, .8fr) minmax(420px, 1.2fr); gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; align-self: end; min-height: 39px; }
.api-form { display: grid; gap: 12px; }
.api-route { display: grid; grid-template-columns: 105px 1fr; gap: 8px; }
.response-box { min-height: 120px; max-height: 300px; overflow: auto; margin: 14px 0 0; padding: 13px; border: 1px solid var(--line); border-radius: 10px; color: #b8e9dc; background: rgba(0,0,0,.28); font: .74rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.request-log { display: grid; gap: 6px; }
.log-row { display: grid; grid-template-columns: 92px 62px 1fr minmax(120px, auto); gap: 9px; align-items: center; border-top: 1px solid var(--line); padding: 9px 2px; font: .72rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace; }
.log-row:first-child { border-top: 0; }
.log-status.ok { color: var(--ok); }
.log-status.bad { color: var(--danger); }

dialog { width: min(560px, calc(100% - 32px)); border: 1px solid var(--line-strong); border-radius: 16px; padding: 0; color: var(--text); background: var(--panel-solid); box-shadow: 0 30px 100px #000; }
dialog::backdrop { background: rgba(0, 5, 4, .78); backdrop-filter: blur(6px); }
.dialog-card { padding: 22px; }
.dialog-room { margin: 0 0 16px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.icon-button { border: 0; color: var(--muted); background: transparent; font-size: 1.5rem; }
.toast-region { position: fixed; z-index: 20; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(380px, calc(100% - 40px)); }
.toast { border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px 14px; color: var(--text); background: #10231f; box-shadow: 0 15px 45px #0008; font-size: .8rem; animation: toast-in .18s ease-out; }
.toast.bad { border-color: rgba(255, 113, 133, .45); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1020px) {
  .status-grid { grid-template-columns: repeat(3, 1fr); }
  .auth-strip, .workbench { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { width: min(100% - 22px, 1480px); padding-top: 24px; }
  .masthead, .section-head { align-items: flex-start; flex-direction: column; }
  .mast-actions { justify-content: flex-start; }
  .auth-form { grid-template-columns: 1fr 1fr; }
  .auth-form label { grid-column: 1 / -1; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .filters { width: 100%; flex-direction: column; }
  .filters input { min-width: 0; }
  .workbench { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 76px 54px 1fr; }
  .log-row .log-duration { display: none; }
}
@media (max-width: 430px) {
  .status-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .auth-form { grid-template-columns: 1fr; }
  .auth-form label { grid-column: auto; }
  .section { padding: 17px; }
}
