/* No @import here — blocked Google Fonts would void the whole sheet in some browsers. */
:root {
  --bg: #0a0b0e;
  --surface: #12141a;
  --line: rgba(255, 255, 255, 0.07);
  --text: #eceef2;
  --muted: #8b92a0;
  --accent: #7c83ff;
  --seed: #e5b84a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --off: #555;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14px/1.45 var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: clip;
}

.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }

/* Login */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-card {
  width: min(100%, 360px);
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.login-card h1 { margin: 0 0 0.5rem; font-size: 1.25rem; font-weight: 600; }
.login-card .lead { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.9rem; }
label { display: block; margin-bottom: 1rem; font-weight: 500; font-size: 0.85rem; }
input[type="password"] {
  width: 100%; margin-top: 0.35rem; padding: 0.65rem 0.75rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
.btn-primary {
  width: 100%; padding: 0.65rem; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 500; cursor: pointer;
}
.err { color: #f87171; }

/* App shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }

.shell-bar {
  position: sticky; top: 0; z-index: 10;
  height: var(--bar-h);
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  margin-right: auto;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-text, .logout-form button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
}
.btn-text:hover, .logout-form button:hover { color: var(--text); }

.shell-main {
  flex: 1;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 0.75rem 1rem 2rem;
  min-width: 0;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.view { display: none; }
.view.is-active { display: block; }

/* Device accordion */
.dev-list { display: flex; flex-direction: column; gap: 0.35rem; }

.dev {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.dev-meta.warn {
  color: #b45309;
  font-size: 0.72rem;
}

.ua-line {
  font-size: 0.72rem;
  word-break: break-all;
  margin-top: 0.25rem;
}

.dev-sum {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.65rem;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  list-style: none;
  font-size: 0.8125rem;
  min-width: 0;
}
.dev-sum::-webkit-details-marker { display: none; }

.dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.dot-online { background: var(--ok); }
.dot-idle { background: var(--warn); }
.dot-offline { background: var(--off); }

.dev-line { min-width: 0; }
.dev-line strong { font-weight: 600; }
.lab { font-style: normal; font-size: 0.65rem; color: var(--warn); margin-left: 0.25rem; }

.dev-meta { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }

.dev-badge {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--seed);
  background: rgba(229, 184, 74, 0.12);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.dev-zip {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.dev-zip:hover { background: var(--bg); }

.dev-body {
  padding: 0 0.65rem 0.55rem;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
}

.dev-detail {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.fold {
  margin-top: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.fold summary {
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  list-style: none;
}
.fold summary::-webkit-details-marker { display: none; }

.seed-line, .file-line {
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.from, .tag-sm {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.tag-sm { display: inline; margin-right: 0.35rem; }

.seed-txt {
  display: block;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--seed);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.file-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
}
.file-line .mono { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.file-line a { color: var(--accent); text-decoration: none; font-weight: 600; }

.empty { color: var(--muted); text-align: center; padding: 2rem 0.5rem; font-size: 0.875rem; }
.foot-actions { margin-top: 1rem; text-align: center; font-size: 0.75rem; }

/* Logs */
.log-lead {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
}

.log-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}
.chip {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.chip b { color: var(--text); margin-left: 0.2rem; }

.log-scroll {
  max-height: calc(100dvh - var(--bar-h) - 6rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.log-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.75rem;
}
.log-row summary {
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  list-style: none;
  overflow-wrap: anywhere;
}
.log-row summary::-webkit-details-marker { display: none; }

.log-payload {
  margin: 0;
  padding: 0.4rem 0.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 8rem;
  overflow-y: auto;
}

@media (max-width: 520px) {
  .shell-bar { padding: 0 0.65rem; gap: 0.5rem; }
  .brand { font-size: 0.85rem; }
  .dev-meta { display: none; }
  .dev-meta:first-of-type { display: inline; }
}
