:root{
  --bg:#05070b; --panel:#0b1220cc; --line:#1d2b44;
  --text:#d7e0ff; --muted:#7f93c9; --glow:#6aa6ff;
  --ok:#57ff9a; --warn:#ffd45a; --bad:#ff5b7a;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: radial-gradient(1200px 700px at 65% 30%, #0c1733 0%, var(--bg) 55%, #030409 100%);
  color:var(--text);
  overflow:hidden; /* Default Desktop: No Scroll */
}

/* BACKGROUND ANIMATION */
.grid{
  position:fixed; inset:-20%;
  background:
    linear-gradient(to right, rgba(106,166,255,.08) 1px, transparent 1px) 0 0/52px 52px,
    linear-gradient(to bottom, rgba(106,166,255,.06) 1px, transparent 1px) 0 0/52px 52px;
  transform: perspective(900px) rotateX(62deg) translateY(120px);
  animation: drift 11s linear infinite;
  opacity:.36;
  pointer-events:none;
}
@keyframes drift{
  0%{background-position:0 0,0 0}
  100%{background-position:260px 260px, 260px 260px}
}
.scan{
  position:fixed; inset:0;
  background:repeating-linear-gradient(to bottom, rgba(255,255,255,.03) 0px, rgba(255,255,255,.03) 1px, transparent 2px, transparent 6px);
  opacity:.18;
  pointer-events:none;
}
.vignette{
  position:fixed; inset:0;
  background: radial-gradient(circle at 50% 35%, transparent 0%, rgba(0,0,0,.55) 70%, rgba(0,0,0,.85) 100%);
  pointer-events:none;
}

/* LAYOUT UTAMA */
.app{
  position:relative;
  height:100%;
  display:grid;
  grid-template-rows:72px 1fr;
  gap:12px;
  padding:14px 14px 16px;
}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  border:1px solid rgba(106,166,255,.18);
  background: linear-gradient(180deg, rgba(11,18,32,.78), rgba(8,12,20,.62));
  border-radius:16px;
  padding:12px 14px;
  box-shadow:0 16px 50px rgba(0,0,0,.45), 0 0 0 1px rgba(106,166,255,.08) inset;
}

.brand{display:flex; align-items:center; gap:10px; min-width:0}
.dot{
  width:10px;height:10px;border-radius:50%;
  background:var(--ok);
  box-shadow:0 0 14px rgba(87,255,154,.65);
}
.brand .name{letter-spacing:.18em; font-weight:800; font-size:14px; white-space:nowrap}
.brand .sub{color:var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}

.meta{display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end}
.pill{
  padding:6px 10px; border-radius:999px;
  border:1px solid rgba(106,166,255,.16);
  background: rgba(106,166,255,.06);
  color:var(--muted); font-size:12px;
}
.pill b{color:var(--text)}
.pill.ok{border-color:rgba(87,255,154,.25); background:rgba(87,255,154,.08)}

.btn{
  cursor:pointer; font-size:11px; padding:6px 10px; border-radius:999px;
  border:1px solid rgba(106,166,255,.16); background: rgba(106,166,255,.06); color:var(--text);
}
.btn:hover{border-color:rgba(106,166,255,.28)}
.mini{font-size:11px;color:var(--muted)}

/* GRID WALL (DESKTOP DEFAULT) */
.wall{
  height:100%;
  min-height:0;
  display:grid;
  grid-template-columns: 1.0fr 1.35fr 1.35fr; /* 3 Kolom */
  grid-template-rows: 1fr 1fr; /* 2 Baris */
  gap:12px;
}

.card{
  border:1px solid rgba(106,166,255,.14);
  background: rgba(9,14,24,.52);
  border-radius:16px;
  padding:12px;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden; /* ✅ penting: cegah isi nyelonong keluar / nabrak panel lain */
}

.card h3{ margin:0 0 10px; font-size:12px; letter-spacing:.16em; color:var(--muted); font-weight:800; }
.row{display:flex; justify-content:space-between; gap:10px; align-items:center; font-size:12px; margin:6px 0}
.k{color:var(--muted)}
.v{color:var(--text); font-weight:700}
.bar{height:8px;border-radius:999px;background:rgba(255,255,255,.06);overflow:hidden}
.fill{height:100%; transition: width .25s ease, background .25s ease;}
.table{width:100%; border-collapse:collapse; font-size:12px;}
.table td{border-top:1px solid rgba(106,166,255,.10); padding:8px 6px;}
.ok{color:var(--ok); font-weight:800}
.bad{color:var(--bad); font-weight:800}

.logbox{
  border:1px solid rgba(106,166,255,.12);
  background: rgba(0,0,0,.20);
  border-radius:14px;
  padding:10px;
  min-height:0;
  display:flex;
  flex-direction:column;
  flex:1;
}
.loghead{display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:8px;}
.logtitle{font-size:12px; font-weight:800; color:var(--text)}
.logmeta{font-size:11px; color:var(--muted); white-space:nowrap}
.logcontent{
  flex:1; min-height:0; overflow:auto; padding:8px;
  border-radius:10px; background: rgba(0,0,0,.28); border:1px solid rgba(255,255,255,.06);
}

.line{ display:block; padding:2px 0; white-space:pre-wrap; word-break:break-word; color:rgba(215,224,255,.92); border-bottom:1px dashed rgba(255,255,255,.03); }
.line small{color:var(--muted)}
.line.collapsed{max-height:34px; overflow:hidden; position:relative;}
.line.collapsed:after{
  content:"… expand"; position:absolute; right:0; bottom:0; padding:0 6px;
  color:var(--warn); background: linear-gradient(to left, rgba(0,0,0,.85), transparent);
}

/* LOGIN SCREEN */
.authwrap{position:relative; height:100%; display:flex; align-items:center; justify-content:center; padding:24px;}
.authcard{
  width:min(520px, 92vw); border:1px solid rgba(106,166,255,.18);
  background: linear-gradient(180deg, rgba(11,18,32,.78), rgba(8,12,20,.62));
  border-radius:18px; box-shadow:0 20px 60px rgba(0,0,0,.55); padding:18px;
}
.authcard h1{margin:0 0 6px; font-size:16px; letter-spacing:.16em}
.authcard p{margin:0 0 14px; color:var(--muted); font-size:12px; line-height:1.5}
.field{margin:10px 0}
.input{ width:100%; padding:12px 12px; border-radius:12px; border:1px solid rgba(106,166,255,.14); background: rgba(0,0,0,.25); color:var(--text); outline:none; }
.input:focus{border-color:rgba(106,166,255,.35)}
.errbox{
  border:1px solid rgba(255,91,122,.30); background: rgba(255,91,122,.08);
  padding:10px 12px; border-radius:12px; color:var(--text); font-size:12px; margin-bottom:10px;
}

/* =========================================================
   LIVE ROW (dipakai SYSTEM STATUS & ELECTRICITY)
   ========================================================= */
.live-stack{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:0;
}

.live-row{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:12px;
  line-height:1;
  margin:6px 0;
  min-width:0;
}

.live-lbl{
  flex:0 0 70px;
  width:70px;
  color:var(--muted);
  font-weight:800;
  white-space:nowrap;
}

.live-bar-track{
  flex:1 1 auto;
  min-width:0;
  height:8px;
  border-radius:999px;
  background:rgba(255,255,255,.06);
  overflow:hidden;
}

.live-fill{
  height:100%;
  width:0%;
  transition: width .25s ease, background .25s ease;
}

.live-val{
  flex:0 0 78px;
  width:78px;
  text-align:right;
  color:var(--text);
  font-weight:800;
  white-space:nowrap;
}

.live-val .unit{
  font-size:.72em;
  color:var(--muted);
  margin-left:4px;
  font-weight:700;
}

.live-row.offline{
  opacity:.55;
}

.sep{
  height:1px;
  background:rgba(255,255,255,.08);
  margin:12px 0 10px;
}

.subhead{
  margin:0 0 8px;
  font-size:12px;
  letter-spacing:.16em;
  color:var(--muted);
  font-weight:800;
}

/* =========================================================
   ELECTRICITY (compact, no glow, no overflow)
   Format: [MCB] [BAR]
           [WATT] [VOLT]
   ========================================================= */
#electricity-container{
  min-height:0;
}

/* lebih rapat & kecil */
#electricity-container.live-stack{
  gap:4px;
}

.elec-row{
  margin:4px 0;
  padding:0;              /* no padding */
  border:0;               /* no border/glow */
  background:transparent;
}

/* label MCB lebih kecil */
.elec-lbl{
  flex:0 0 56px;
  width:56px;
  font-size:11px;
  letter-spacing:.08em;
}

/* bar lebih tipis */
.elec-track{
  height:6px;
  border-radius:999px;
}

/* kolom watt ringkas */
.elec-watt{
  flex:0 0 62px;
  width:62px;
  font-size:11px;
  text-align:right;
}

/* kolom volt dipendekin (3 digit) */
.elec-volt{
  flex:0 0 44px;
  width:44px;
  font-size:11px;
  text-align:right;
}

.dim{
  color: rgba(255,255,255,.35);
}

/* =========================================================
   MOBILE / RESPONSIVE (MAX-WIDTH 900px)
   ========================================================= */
@media (max-width: 900px){

  /* Buka Scroll di HP */
  html, body {
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  /* Ubah App jadi Flex Vertical */
  .app {
    display: flex !important;
    flex-direction: column;
    height: auto !important;
    padding: 10px !important;
    gap: 15px;
  }

  /* Reset Grid Wall jadi 1 Kolom ke Bawah */
  .wall {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    gap: 15px !important;
  }

  /* Topbar Responsive */
  .topbar { flex-wrap: wrap; gap: 10px; height: auto !important; }
  .brand { width: 100%; margin-bottom: 5px; }
  .meta { width: 100%; justify-content: flex-start; gap: 8px; }

  /* Card Full Width */
  .card { width: 100% !important; min-height: auto !important; }

  /* Logbox Fix Height */
  .logbox { height: 300px !important; min-height: 300px !important; }
  .grid { display: none !important; } /* Hemat baterai HP */

  /* === REORDER LOGIC (Agar Port Status Naik di HP) === */
  .wall .card:nth-child(1) { order: 1; } /* Live Status */
  .wall .card:nth-child(4) { order: 2; } /* Port Status (Naik!) */
  .wall .card:nth-child(2) { order: 3; } /* Adinaya */
  .wall .card:nth-child(3) { order: 4; } /* TRPH */
  .wall .card:nth-child(5) { order: 5; } /* IP Log */
  .wall .card:nth-child(6) { order: 6; } /* RF Logs */
}
