@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url("fonts/archivo-var-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/jetbrains-mono-var-latin.woff2") format("woff2");
}

:root {
  --bg: #0b0d11;
  --panel: #151923;
  --panel-2: #1b2030;
  --line: rgba(255, 255, 255, 0.1);
  --ink: #edf1f7;
  --ink-60: #99a3b6;
  --mint: #3fe8b0;
  --mint-ink: #07130e;
  --amber: #f5b84b;
  --danger: #ff6b74;
  --ok: #45dd97;
  --display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --touch: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--ink-60); font-size: 0.82rem; }
.err { color: var(--danger); font-size: 0.88rem; margin-top: 0.75rem; }

/* Login */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 24px;
  text-align: center;
}
.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mint);
}
h1 { font-size: 1.6rem; margin: 6px 0 4px; letter-spacing: -0.02em; }
.sub { color: var(--ink-60); margin-bottom: 18px; }
.dots { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; min-height: 12px; }
.dot {
  width: 10px; height: 10px; border-radius: 999px;
  border: 1.5px solid var(--line); background: transparent;
}
.dot.on { background: var(--mint); border-color: var(--mint); }
.pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.key {
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
}
.key:active { transform: scale(0.97); }
.key.del { font-size: 0.9rem; color: var(--ink-60); }

/* App */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #10131a;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; }
.mark {
  width: 36px; height: 36px; border-radius: 8px;
  overflow: hidden; flex: 0 0 auto;
  display: grid;
}
.mark svg { width: 100%; height: 100%; display: block; }
.mark-lg { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 12px; }
.top-actions, .toolbar { display: flex; gap: 8px; align-items: center; }
main { padding: 20px 24px 48px; max-width: 1200px; width: 100%; margin: 0 auto; }
.toolbar { justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; }
.create {
  display: grid;
  grid-template-columns: 1fr auto 1fr 1fr auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.create[hidden] { display: none; }
.create label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-60);
}
.create input {
  min-height: var(--touch);
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
}
.host-preview { color: var(--ink-60); font-family: var(--mono); padding-bottom: 14px; }
.create .err, .create .hint { grid-column: 1 / -1; margin: 0; }
.create .hint { color: var(--ink-60); font-size: 0.82rem; }
@media (max-width: 900px) {
  .create { grid-template-columns: 1fr; }
  .host-preview { padding-bottom: 0; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}
a.btn, a.btn:hover, a.btn:visited { color: inherit; text-decoration: none; }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--mint); color: var(--mint-ink); border-color: var(--mint); }
a.btn.primary, a.btn.primary:hover, a.btn.primary:visited { color: var(--mint-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-60);
  font-weight: 700;
}
tr:last-child td { border-bottom: 0; }
.name { font-weight: 700; }
.host, .port, .bytes { font-family: var(--mono); font-size: 0.84rem; }
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pill.ok { background: rgba(69, 221, 151, 0.16); color: var(--ok); }
.pill.bad { background: rgba(255, 107, 116, 0.16); color: var(--danger); }
.pill.demo { background: rgba(63, 232, 176, 0.14); color: var(--mint); }
.pill.live { background: rgba(255,255,255,0.08); color: var(--ink-60); }
.link {
  color: var(--mint);
  font-weight: 700;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .top, main { padding-left: 14px; padding-right: 14px; }
  th:nth-child(3), td:nth-child(3),
  th:nth-child(6), td:nth-child(6) { display: none; }
}

.stats-caption { margin-bottom: 10px; }
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}
.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px 14px;
}
.stat-k {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-60);
}
.stats strong {
  display: block;
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.stats article .muted { display: block; margin-top: 2px; font-size: 0.72rem; }
.bar {
  display: block;
  height: 3px;
  margin-top: 10px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--mint);
  transition: width 0.6s ease;
}
.bar i.warn { background: var(--amber); }
.bar i.bad { background: var(--danger); }
@media (max-width: 960px) {
  .stats { grid-template-columns: 1fr 1fr; }
}

.busy {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 8, 11, 0.78);
  backdrop-filter: blur(12px);
}
.busy-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.busy-card h2 {
  font-size: 1.25rem;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}
.scope {
  position: relative;
  width: 104px;
  height: 104px;
  margin: 0 auto 16px;
}
.scope svg { width: 100%; height: 100%; }
.scope-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 2.2;
}
.scope-arc {
  fill: none;
  stroke: var(--mint);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 48 190;
}
.scope-spin {
  transform-origin: 40px 40px;
  animation: sweep 1.35s linear infinite;
}
.scope-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--mint);
  letter-spacing: 0.04em;
}
.busy-steps {
  list-style: none;
  text-align: left;
  margin: 18px 0 10px;
}
.busy-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  color: var(--ink-60);
  font-size: 0.9rem;
  border-bottom: 1px solid transparent;
}
.busy-steps li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
}
.busy-steps li.on { color: var(--ink); }
.busy-steps li.on::before {
  background: var(--mint);
  box-shadow: 0 0 10px rgba(63, 232, 176, 0.7);
}
.busy-steps li.done { color: var(--ok); }
.busy-steps li.done::before { background: var(--ok); box-shadow: none; }
.busy-card .hint { color: var(--ink-60); font-size: 0.8rem; margin-top: 8px; }
.busy-card .btn { margin-top: 14px; }
.busy.ok .scope-spin { animation: none; }
.busy.ok .scope-arc {
  stroke: var(--ok);
  stroke-dasharray: 188 0;
}
.busy.ok .scope-time { color: var(--ok); }
.busy.err .scope-spin { animation: none; }
.busy.err .scope-arc {
  stroke: var(--danger);
  stroke-dasharray: 188 0;
}
.busy.err .scope-time { color: var(--danger); }

@keyframes sweep {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .scope-spin { animation: none; }
  .bar i { transition: none; }
}

tr.row { cursor: pointer; }
tr.row:hover td { background: rgba(63, 232, 176, 0.04); }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px 24px;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(6, 8, 11, 0.42);
  cursor: pointer;
}
.sheet-panel {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  height: min(820px, calc(100dvh - 48px));
  overflow: hidden;
  background: #12151c;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
}
.sheet-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  flex: 0 0 auto;
}
.sheet-panel h2 { font-size: 1.35rem; letter-spacing: -0.03em; }
.sheet-panel h3 { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-60); margin: 0; }
.sheet-body {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 16px;
}
.sheet-panel.split .sheet-body {
  grid-template-columns: minmax(260px, 0.88fr) minmax(0, 1.22fr);
}
.sheet-panel.stack .sheet-body {
  grid-template-columns: 1fr;
  grid-template-rows: auto minmax(0, 1fr);
}
.sheet-panel.cards .sheet-body { display: flex; flex-direction: column; }
.sheet-meta { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
.sheet-panel.stack .facts,
.sheet-panel.cards .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.facts dt {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-60);
}
.facts dd { margin: 3px 0 0; font-family: var(--mono); font-size: 0.84rem; }
.facts dd.warn { color: var(--amber); }
.facts dd.bad { color: var(--danger); }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pin-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.sheet-panel.split .pin-form { grid-template-columns: 1fr; }
.sheet-panel.split .pin-form button,
.sheet-panel.cards .pin-form button { grid-column: 1 / -1; }
.pin-form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-60);
}
.pin-form input {
  min-height: 42px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-family: inherit; font-size: 1rem;
}
.log-panel {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c0e13;
}
.log-head { display: flex; justify-content: space-between; align-items: center; flex: 0 0 auto; }
.logbox {
  margin: 0;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #08090c;
  color: #b7c0d0;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.sheet-panel.cards .logbox { flex: none; max-height: min(36vh, 280px); }
@media (max-width: 900px) {
  .sheet-panel.split .sheet-body,
  .sheet-panel.stack .facts,
  .sheet-panel.cards .facts { grid-template-columns: 1fr 1fr; }
  .sheet-panel.split .sheet-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(220px, 1fr);
  }
}
@media (max-width: 720px) {
  .sheet { padding: 12px; }
  .sheet-panel { height: calc(100dvh - 24px); padding: 16px 14px 14px; }
  .pin-form { grid-template-columns: 1fr; }
}
