:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e7ecf1;
  --muted: #9aa7b5;
  --accent: #3d8bfd;
  --line: #2a3542;
  --ok: #3ecf8e;
  --warn: #f0b429;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a3d, var(--bg));
  color: var(--text);
  min-height: 100vh;
}
.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }
nav button, .auth button, .row button, .form button, #btnApprove {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}
nav button.active, .auth button:hover, .row button:hover, .form button:hover, #btnApprove {
  border-color: var(--accent);
  color: #fff;
}
#btnApprove { background: #1e3a5f; }
.auth { display: flex; gap: 0.5rem; align-items: end; flex-wrap: wrap; }
.auth label { font-size: 0.75rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.2rem; }
.auth input, .form input {
  background: #0c1015;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  min-width: 10rem;
}
main { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
th, td { padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: rgba(61, 139, 253, 0.06); }
.panel {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.block, pre {
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem;
  overflow: auto;
  font-size: 0.8rem;
}
.form { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 0.75rem; }
.form button { grid-column: 1 / -1; justify-self: start; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 1rem; }
.versions-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.4fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .versions-layout { grid-template-columns: 1fr; }
}
.tree {
  font-family: ui-monospace, "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  background: #0c1015;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.35rem;
  max-height: 28rem;
  overflow: auto;
}
.tree details { margin-left: 0.75rem; }
.tree > details { margin-left: 0; }
.tree summary {
  cursor: pointer;
  list-style: none;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before {
  content: "▸ ";
  color: var(--muted);
}
.tree details[open] > summary::before { content: "▾ "; }
.tree summary:hover, .tree .file:hover {
  background: rgba(61, 139, 253, 0.12);
}
.tree .file {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 0.15rem 0.35rem 0.15rem 1.1rem;
  cursor: pointer;
  border-radius: 4px;
}
.tree .file.active { color: #fff; background: rgba(61, 139, 253, 0.25); }
#fileView { min-height: 8rem; max-height: 18rem; }
#treeKind {
  background: #0c1015;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
}
.toast {
  position: fixed; bottom: 1rem; right: 1rem;
  background: #123;
  border: 1px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  max-width: 24rem;
}
.state-READY { color: var(--ok); font-weight: 600; }
.state-HEALTHY { color: var(--ok); font-weight: 600; }
.state-FAILED, .state-ROLLED_BACK { color: #ff6b6b; font-weight: 600; }
.state-DOWNLOADING, .state-VERIFYING { color: var(--warn); }
.mqtt-on { color: var(--ok); font-weight: 600; }
.mqtt-off { color: var(--muted); }
.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(24rem, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.5rem;
  display: grid;
  gap: 0.75rem;
}
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card label {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.login-card input {
  background: #0c1015;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
}
.login-card button {
  background: #1e3a5f;
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}
.error { color: #ff6b6b; font-size: 0.85rem; margin: 0; }
#userBadge { align-self: center; margin-right: 0.5rem; }
