:root {
  /* Tema ALBWSTORE — emas & biru elektrik (mengikuti logo) */
  --bg: #070b14;
  --bg-soft: #0d1424;
  --card: #111b30;
  --card-2: #16233d;
  --border: #21385f;
  --text: #eaf1ff;
  --muted: #8ea3c8;
  --primary: #f5b50a;          /* emas */
  --primary-d: #d49600;
  --gold-2: #ffd34d;
  --blue: #1e7bff;             /* biru elektrik */
  --blue-d: #0a5bd6;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(0,0,0,.45);
  --glow-gold: 0 0 0 1px rgba(245,181,10,.25), 0 8px 26px rgba(245,181,10,.18);
  --glow-blue: 0 0 0 1px rgba(30,123,255,.25), 0 8px 26px rgba(30,123,255,.20);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(245,181,10,.10) 0%, transparent 55%),
    radial-gradient(1100px 620px at 92% -5%, rgba(30,123,255,.16) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; width: 100%; padding: 11px 13px;
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; outline: none; font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245,181,10,.12); }

/* Brand logo bulat ala ALBWSTORE */
.logo-badge {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; font-size: 19px;
  color: #1a1200; background: linear-gradient(145deg, var(--gold-2), var(--primary) 55%, var(--primary-d));
  border: 2px solid rgba(30,123,255,.55);
  box-shadow: var(--glow-gold);
}
.brand-text { font-weight: 900; letter-spacing: .5px; }
.brand-text .gold { color: var(--primary); }
.brand-text .blue { color: var(--blue); }
.brand-tag { font-size: 10px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; font-weight: 700; }

/* Logo gambar (file di /img/logo.png) — bulat dengan cincin biru ala logo ALBWSTORE */
.logo-img {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(30,123,255,.55);
  box-shadow: var(--glow-gold); background: #0a0f1c;
}
.logo-img-lg { width: 52px; height: 52px; }
textarea { resize: vertical; min-height: 90px; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 10px;
  background: var(--card-2); color: var(--text); font-weight: 600; font-size: 14px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: linear-gradient(145deg, var(--gold-2), var(--primary) 60%, var(--primary-d)); color: #1a1200; box-shadow: var(--glow-gold); }
.btn-blue { background: linear-gradient(145deg, var(--blue), var(--blue-d)); color: #fff; box-shadow: var(--glow-blue); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.center { display: flex; align-items: center; justify-content: center; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 390px; background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 36px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; font-size: 24px; font-weight: 900; }
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--bg-soft), #0a0f1c);
  border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 900; font-size: 18px; padding: 4px 6px 20px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 14px; transition: .12s;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card-2); color: var(--text); box-shadow: inset 3px 0 0 var(--primary); }
.nav-item .ic { width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; }

.main { padding: 26px 30px; overflow-y: auto; max-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.topbar h1 { font-size: 22px; }
.page { display: none; }
.page.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Cards & grids ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 26px; }
.stat {
  background: linear-gradient(160deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--primary), var(--blue));
}
.stat .n { font-size: 30px; font-weight: 800; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat .ic { float: right; font-size: 22px; opacity: .5; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 18px; }
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel .desc { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* ---------- Devices ---------- */
.device-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.device-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device-name { font-weight: 700; font-size: 16px; }
.device-phone { color: var(--muted); font-size: 13px; margin-top: 2px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.badge.connected { background: rgba(245,181,10,.16); color: var(--primary); }
.badge.disconnected { background: rgba(239,68,68,.13); color: #f87171; }
.badge.connecting, .badge.qr { background: rgba(30,123,255,.18); color: #7fb2ff; }
.token-box { display: flex; gap: 8px; align-items: center; }
.token-box code { flex: 1; background: var(--bg-soft); padding: 8px 10px; border-radius: 8px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid var(--border); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: var(--card-2); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 700; }
.tag.in { background: rgba(30,123,255,.18); color: #7fb2ff; }
.tag.out { background: rgba(245,181,10,.16); color: var(--primary); }
.tag.failed { background: rgba(239,68,68,.16); color: #f87171; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,15,.7); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow); }
.modal h3 { margin-bottom: 16px; font-size: 18px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.qr-img { width: 260px; height: 260px; background: #fff; border-radius: 12px; padding: 10px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--card-2); border: 1px solid var(--border); border-left: 4px solid var(--primary); padding: 13px 16px; border-radius: 10px; min-width: 240px; box-shadow: var(--shadow); font-size: 14px; animation: fade .2s; }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--blue); }

.codeblock { background: #0b0f1a; border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-x: auto; font-family: 'SF Mono', Consolas, monospace; font-size: 13px; line-height: 1.6; color: #c8d3ea; white-space: pre; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* Daftar grup (multi-select dengan centang) */
.group-list {
  max-height: 240px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg-soft); padding: 6px;
}
.group-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.group-item:hover { background: var(--card-2); }
.group-item input { width: auto; }
.group-item .gi-name { flex: 1; }
.group-item .gi-count { color: var(--muted); font-size: 12px; }
