:root {
  --bg: #0c1118;
  --bg-2: #121925;
  --panel: #161e2c;
  --line: #2a3548;
  --text: #eef3fb;
  --muted: #8d9bb0;
  --accent: #2fdb8a;
  --accent-2: #1aa35f;
  --danger: #ff6b6b;
  --warn: #f5c451;
  --info: #5aa8ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(47, 219, 138, .12), transparent 50%),
    var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  background: #0e1520;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #3d8a64; }

.primary, .ghost, .danger, .mini {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
}
.primary { background: linear-gradient(180deg, #34e394, var(--accent-2)); color: #062416; font-weight: 600; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.danger { background: #3a1717; color: #ffb4b4; border: 1px solid #5a2424; }
.mini { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card .brand, aside .brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.logo-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(180deg, #34e394, var(--accent-2));
  color: #062416;
  font-weight: 700;
}
.login-card p, .hint { color: var(--muted); margin: 6px 0 0; }
.login-card form, .stack { display: grid; gap: 14px; margin-top: 22px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.err { color: var(--danger); min-height: 1.2em; }
.login-card .primary { width: 100%; padding: 12px; font-size: 15px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}
aside {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
aside nav { display: grid; gap: 6px; }
.nav {
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 10px;
}
.nav.on, .nav:hover { background: #1c2738; color: var(--text); }
.aside-foot { margin-top: auto; display: grid; gap: 10px; }

main { padding: 28px 32px 48px; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}
h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); }
.top-actions, .row-actions, .dlg-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line);
}
.pill.up { color: var(--accent); background: rgba(47, 219, 138, .1); border-color: rgba(47, 219, 138, .3); }
.pill.down { color: var(--danger); background: rgba(255, 107, 107, .1); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
}
.stat b { display: block; font-size: 28px; margin-top: 4px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.panel.narrow { max-width: 640px; }
.panel-h { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }

.session-list { display: grid; gap: 10px; }
.session-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #101826;
}
.session-row .name { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 14px; }
.token-line { word-break: break-all; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
}
.badge:before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-WORKING { color: var(--accent); background: rgba(47, 219, 138, .1); }
.st-SCAN_QR, .st-SCAN_QR_CODE, .st-STARTING { color: var(--warn); background: rgba(245, 196, 81, .12); }
.st-STOPPED, .st-UNKNOWN { color: var(--muted); background: #222b3a; }
.st-FAILED { color: var(--danger); background: rgba(255, 107, 107, .12); }

.logs { display: grid; gap: 8px; }
.log {
  display: grid;
  grid-template-columns: 180px 110px 1fr;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.log .t { color: var(--muted); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }
.empty { color: var(--muted); padding: 28px 8px; }

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 18px;
  padding: 22px;
  width: min(440px, 92vw);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(6, 10, 16, .72); }
.qr-box {
  min-height: 240px;
  display: grid;
  place-items: center;
  background: #0b1018;
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
}
.qr-box img { max-width: 240px; background: #fff; border-radius: 8px; }
.flash { min-height: 1.2em; color: var(--accent); }
.flash.bad { color: var(--danger); }
code { font-family: "IBM Plex Mono", ui-monospace, monospace; color: var(--accent); }
.token-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.token-once {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed var(--accent-2);
  border-radius: 12px;
  background: #102018;
}
.token-once p { margin: 0 0 10px; color: var(--warn); }
.token-once pre, .curl {
  margin: 0 0 10px;
  overflow: auto;
  background: #0b1018;
  border-radius: 10px;
  padding: 12px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  aside { flex-direction: row; flex-wrap: wrap; align-items: center; }
  aside nav { display: flex; flex-wrap: wrap; }
  .aside-foot { margin: 0 0 0 auto; }
  .stats { grid-template-columns: 1fr 1fr; }
  .log { grid-template-columns: 1fr; }
  .session-row { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .token-form { grid-template-columns: 1fr; }
}
