:root {
  --bg: #f6f7f9; --surface: #ffffff; --fg: #12151a; --muted: #5b6472;
  --border: #e3e6ea; --accent: #2563eb; --ok: #0a8f5b; --warn: #b45309; --err: #c0332e;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #161b22; --fg: #e8ebef; --muted: #8b95a3;
    --border: #262c36; --accent: #4d84f5; --ok: #2bb57c; --warn: #d99a3a; --err: #e2635e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
button {
  font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--fg); cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
input {
  font: inherit; width: 100%; padding: 9px 11px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* --- token ekrani --- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card {
  width: 100%; max-width: 380px; padding: 32px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 14px;
}
.gate-card p { margin: 0; color: var(--muted); font-size: 14px; }
.gate-error { color: var(--err) !important; }

/* --- sarlavha --- */
header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; padding: 18px 16px; max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.conn { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.conn.live { color: var(--ok); }
.conn.down { color: var(--err); }
.head-actions { display: flex; gap: 8px; }

/* --- statistika --- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  max-width: 1100px; margin: 0 auto; padding: 0 16px 18px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 2px;
}
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.stat-value.ok { color: var(--ok); }
.stat-label { font-size: 13px; color: var(--muted); }

/* --- asosiy --- */
main {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; align-items: start;
}
@media (max-width: 860px) { main { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* --- qurilmalar --- */
.device-list { display: flex; flex-direction: column; gap: 10px; }
.device {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.device-head { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.device-name { font-weight: 600; }
.device-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); }
.device-meta { margin-top: 6px; font-size: 13px; color: var(--muted); }
.device-actions { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.device-actions button { padding: 5px 10px; font-size: 13px; }
.device-actions .danger { color: var(--err); }
.device-last {
  margin-top: 8px; padding: 8px 10px; background: var(--bg); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  word-break: break-all; max-height: 90px; overflow: auto;
}

/* --- oqim --- */
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 480px; overflow-y: auto; }
.feed-row {
  display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 7px 9px;
  border-radius: 7px; background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  animation: slide .22s ease-out;
}
@keyframes slide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.feed-time { color: var(--muted); }
.feed-body { word-break: break-all; }
.feed-dev { color: var(--accent); font-weight: 600; }
.feed-row.evt .feed-body { color: var(--warn); }

/* --- oynalar --- */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--fg); padding: 24px; max-width: 460px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 500; }
dialog label input { margin-top: 5px; font-weight: 400; }
dialog small { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.form-error { color: var(--err); font-size: 14px; }
.warn { color: var(--warn); font-size: 14px; }
pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow-x: auto; font-size: 12px; line-height: 1.6;
}
