:root {
  --bg: #0d1220;
  --panel: #141b2c;
  --card-bg: #182033;
  --line: #243049;
  --text: #e6eaf2;
  --muted: #8a94a8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --card-w: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button {
  background: #22304d; border: 1px solid #2e3d5e; border-radius: 8px; padding: 7px 12px; cursor: pointer;
}
button:hover { background: #2a3a5c; }
button.ghost { background: transparent; border-color: var(--line); }
button.ghost:hover { background: #1c2740; }
button.warn { border-color: #7a5a14; background: #3a2c0c; }
button.danger { border-color: #7f1d1d; background: #3b1212; }
button.small { font-size: 12px; padding: 5px 10px; }
[hidden] { display: none !important; }
code { background: #1c2740; padding: 1px 5px; border-radius: 4px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.logo {
  width: 22px; height: 16px; border: 2px solid var(--blue); border-radius: 3px; position: relative;
}
.logo::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 8px; height: 2px; margin-left: -4px; background: var(--blue); }
.conn { font-size: 12px; color: var(--muted); margin-left: 4px; }
.conn.ok { color: var(--green); }
.conn.bad { color: var(--red); }
.stats { display: flex; gap: 14px; }
.stat { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.stat b { color: var(--text); font-variant-numeric: tabular-nums; }
.stat i { width: 8px; height: 8px; border-radius: 50%; }
.stat.on i { background: var(--green); }
.stat.off i { background: var(--red); }
.stat.idle i { background: var(--amber); }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-left: auto; }
.tools input[type=search] {
  background: #0f1626; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 200px;
}
.chk { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.size { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.size input { width: 90px; }

/* ---------- grup ---------- */
.groups { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.groups button { border-radius: 999px; padding: 4px 12px; font-size: 13px; background: transparent; border-color: var(--line); }
.groups button.active { background: #22304d; border-color: var(--blue); }
.groups button small { color: var(--muted); margin-left: 4px; }

/* ---------- grid ---------- */
main { padding: 12px 16px 40px; }
.hidden-note { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-w), 1fr)); gap: 10px; }
.card {
  background: var(--card-bg); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--blue); transform: translateY(-1px); }
.shot { position: relative; aspect-ratio: 16 / 9; background: #05070c; }
.shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot img:not([src]) { visibility: hidden; }
.tag {
  position: absolute; top: 6px; left: 6px; padding: 2px 7px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; color: #fff; text-shadow: 0 1px 1px #0006;
  max-width: calc(100% - 12px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-head .tag { position: static; }
.badge {
  position: absolute; inset: auto 6px 6px auto; padding: 2px 7px; border-radius: 5px; font-size: 11px; font-weight: 700;
}
.noimg {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px;
}
.card .info { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 12px; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.app { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #cfd6e4; }
.idle { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.idle.warm { color: var(--amber); }
.idle.act { color: var(--green); }

.card.off .shot img { filter: grayscale(1); opacity: .25; }
.card.off .dot { background: var(--red); }
.card.off .badge { background: var(--red); color: #fff; }
.card.locked .badge { background: var(--amber); color: #111; }
.card.locked .dot { background: var(--amber); }

.empty-all { text-align: center; color: var(--muted); margin-top: 80px; }
.empty-all b { color: var(--text); font-size: 16px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 10; background: #000a; display: grid; place-items: center; padding: 16px; }
.modal-box {
  width: min(1400px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.modal-head b { font-size: 16px; }
.spacer { flex: 1; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #1c2740; color: var(--muted); }
.pill.on { background: #0f3a22; color: #86efac; }
.pill.off { background: #3b1212; color: #fca5a5; }
.pill.locked { background: #3a2c0c; color: #fcd34d; }
.modal-body { display: grid; grid-template-columns: 1fr 280px; gap: 14px; padding: 14px; }
.big { position: relative; background: #05070c; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
.big img { width: 100%; height: 100%; object-fit: contain; display: block; }
aside dl { margin: 0 0 14px; display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 13px; }
aside dt { color: var(--muted); }
aside dd { margin: 0; word-break: break-word; }
.actions { display: grid; gap: 8px; }
@media (max-width: 900px) { .modal-body { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 20;
  background: #22304d; border: 1px solid #2e3d5e; padding: 9px 16px; border-radius: 8px;
}
.toast.err { background: #3b1212; border-color: #7f1d1d; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-box {
  width: 300px; display: grid; gap: 10px; padding: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.login-box .brand { margin-bottom: 8px; }
.login-box label { color: var(--muted); font-size: 13px; }
.login-box input { background: #0f1626; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.login-box button { background: var(--blue); border-color: var(--blue); padding: 9px; font-weight: 600; }
.err { color: #fca5a5; margin: 0; font-size: 13px; }

/* ---------- tombol umum ---------- */
button.primary { background: var(--blue); border-color: var(--blue); font-weight: 600; }
button.primary:hover { background: #2f6fdc; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- halaman bagikan layar ---------- */
.share-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.share-box {
  width: min(460px, 100%); display: grid; gap: 12px; padding: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.share-box h1 { font-size: 20px; margin: 4px 0 0; }
.muted { color: var(--muted); margin: 0; }
.form { display: grid; gap: 8px; }
.form label { color: var(--muted); font-size: 13px; }
.form input { background: #0f1626; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
.form button { padding: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.state { padding: 10px 12px; border-radius: 8px; background: #1c2740; }
.state.ok { background: #0f3a22; color: #86efac; }
.state.bad { background: #3b1212; color: #fca5a5; }
.warnline { margin: 0; padding: 8px 10px; border-radius: 8px; background: #3a2c0c; color: #fcd34d; font-size: 13px; }
.share-box video { width: 100%; border-radius: 8px; background: #05070c; aspect-ratio: 16 / 9; }
.opmsg-box { width: min(420px, 100%); display: grid; gap: 12px; padding: 20px; }
.opmsg-box p { margin: 0; font-size: 16px; white-space: pre-wrap; }

/* ---------- modal tambah perangkat ---------- */
.add-box { width: min(620px, 100%); }
.add-body { display: grid; gap: 16px; padding: 16px; }
.add-body h3 { margin: 0 0 6px; font-size: 15px; }
.add-body p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; background: #0f1626; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
