:root {
  --bg: #060912;
  --bg2: #0a1024;
  --panel: rgba(18, 26, 51, 0.72);
  --panel-solid: #111933;
  --border: rgba(120, 145, 230, 0.16);
  --text: #e7ecff;
  --muted: #8b97c4;
  --accent: #5b8cff;
  --accent2: #9b6cff;
  --cyan: #38e0d8;
  --green: #3ddc84;
  --red: #ff5d6c;
  --amber: #ffc24b;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(91, 140, 255, 0.18), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, rgba(155, 108, 255, 0.16), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ─── Brand ─── */
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 26px; letter-spacing: 3px; }
.brand p { color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.brand.sm strong { letter-spacing: 2px; }
.logo-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent2), var(--cyan), var(--accent));
  box-shadow: 0 0 16px rgba(91, 140, 255, 0.8);
  flex: none;
}

/* ─── Login ─── */
.login-wrap {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 50;
}
.login-card {
  width: 100%; max-width: 360px; background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.login-card .brand { margin-bottom: 12px; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.login-card input {
  background: rgba(8, 12, 28, 0.7); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18); }
.err { color: var(--red); font-size: 13px; min-height: 16px; }

/* ─── Buttons ─── */
.btn {
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: var(--text);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; font-size: 14px; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary {
  margin-top: 14px; border: none; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 20px rgba(91, 140, 255, 0.35);
}
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 11px; font-size: 13px; }

/* ─── Topbar ─── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: rgba(8, 12, 28, 0.65); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--muted);
}
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--green); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); animation: pulse 1.6s infinite; }
.live.stale { color: var(--amber); } .live.stale i { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ─── Layout ─── */
.container { max-width: 1180px; margin: 0 auto; padding: 20px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.card {
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.chip { font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }

/* ─── KPI ─── */
.kpi-head { display: flex; align-items: baseline; justify-content: space-between; }
.kpi-head span { color: var(--muted); font-size: 13px; }
.kpi-head b { font-size: 26px; font-weight: 700; }
#k-net { font-size: 16px; font-weight: 700; white-space: nowrap; letter-spacing: -0.2px; }
.bar { height: 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--cyan), var(--accent)); transition: width .4s, background .4s; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
/* Wadah grafik ber-tinggi tetap — mencegah canvas Chart.js tumbuh tak terbatas */
.chart-box { position: relative; width: 100%; height: 44px; margin: 8px 0 2px; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* ─── Tables ─── */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 12px; }
.tbl td { padding: 9px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.tbl tr:last-child td { border-bottom: none; }
.mono { font-variant-numeric: tabular-nums; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600; display: inline-block; }
.badge.up { background: rgba(61, 220, 132, 0.15); color: var(--green); }
.badge.down { background: rgba(255, 93, 108, 0.15); color: var(--red); }
.badge.warn { background: rgba(255, 194, 75, 0.15); color: var(--amber); }
.rs-btn { font-size: 11px; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.rs-btn:hover { color: var(--text); border-color: var(--accent); }

/* ─── Services grid ─── */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.svc {
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
  background: rgba(8, 12, 28, 0.4); display: flex; flex-direction: column; gap: 6px;
}
.svc .name { font-size: 13px; font-weight: 600; }
.svc .meta { font-size: 11px; color: var(--muted); word-break: break-all; }
.svc.dn { border-color: rgba(255, 93, 108, 0.4); }

/* ─── Events ─── */
.events { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; font-size: 13px; }
.ev { display: flex; gap: 10px; padding: 7px 10px; border-radius: 8px; background: rgba(8, 12, 28, 0.4); }
.ev .t { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ev.ALERT { border-left: 3px solid var(--red); }
.ev.OK { border-left: 3px solid var(--green); }
.ev.ACTION { border-left: 3px solid var(--accent); }
.ev-empty { color: var(--muted); font-size: 13px; padding: 6px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 22px 0 6px; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel-solid); border: 1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 60; font-size: 14px;
}

/* ─── Banner Kesehatan (bahasa awam) ─── */
.health { margin-bottom: 14px; border-width: 1px; }
.health.ok   { border-color: rgba(61, 220, 132, 0.35); background: linear-gradient(135deg, rgba(61,220,132,0.08), var(--panel)); }
.health.warn { border-color: rgba(255, 194, 75, 0.45); background: linear-gradient(135deg, rgba(255,194,75,0.10), var(--panel)); }
.health.bad  { border-color: rgba(255, 93, 108, 0.55); background: linear-gradient(135deg, rgba(255,93,108,0.12), var(--panel)); }
.health-head { display: flex; align-items: center; gap: 14px; }
.health-emoji { font-size: 34px; line-height: 1; }
.health-title { font-size: 17px; font-weight: 700; }
.health-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.health-items { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.health-item { display: flex; gap: 10px; align-items: flex-start; background: rgba(8,12,28,0.45); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.health-item b { font-size: 14px; font-weight: 600; display: block; }
.health-item small { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }

/* ─── Kata status KPI ─── */
.kpi-alias { color: var(--muted); font-weight: 400; font-size: 11px; }
.kpi-word { min-height: 18px; margin-top: 2px; }
.word { font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.word.ok { color: var(--green); }
.word.warn { color: var(--amber); }
.word.bad { color: var(--red); }

/* ─── Deskripsi aplikasi/layanan (bahasa awam) ─── */
.app-name { font-weight: 700; }
.app-tech { color: var(--muted); font-size: 11px; font-weight: 400; }
.app-desc { color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.4; }
.loop-badge { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: rgba(255,194,75,0.15); color: var(--amber); font-weight: 700; margin-left: 6px; white-space: nowrap; }

/* ─── Mode Sederhana: sembunyikan elemen teknis ─── */
body.simple .tech-only { display: none !important; }
body.simple .tech-col { display: none; }
body.simple .app-tech { display: none; }
body.simple .svc .meta.tech { display: none; }

/* ─── Responsive ─── */
@media (max-width: 880px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .brand h1 { font-size: 22px; }
  .container { padding: 14px; }
}
