/* Pantau VPS Nusora — tampilan terang saja, dirancang untuk layar HP. */

:root {
  color-scheme: light;

  --page: #e7eaf0;
  --surface: #fcfcfb;
  /* Kotak "cekung" — bayangan dalam + garis tepi + kilau tipis di bawah. */
  --tile: linear-gradient(180deg, #f1f1ed, #fafaf8 78%);
  --tile-dalam: inset 0 2px 4px rgba(11, 11, 11, 0.1), inset 0 0 0 1px rgba(11, 11, 11, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.9);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --hairline: rgba(11, 11, 11, 0.09);

  --brand: #2a78d6;
  --brand-deep: #174e96;

  --good: #0ca30c;
  --warn: #fab219;
  --crit: #d03b3b;

  --good-track: #d7efd7;
  --warn-track: #fdecc9;
  --crit-track: #f4dada;

  --s-cpu: #2a78d6;
  --s-mem: #eb6834;
  --s-disk: #1baf7a;

  --radius: 24px;
  /* Kartu "timbul" — kilau di tepi atas + 3 lapis bayangan makin lebar makin lembut. */
  /* Bayangan sengaja dibuat pendek & rapat ke kartu — kalau terlalu panjang ke
     bawah, bayangannya menggenang di celah dan kartu terlihat mepet. */
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 1px 2px rgba(11, 11, 11, 0.1),
    0 3px 6px -2px rgba(11, 11, 11, 0.13),
    0 8px 14px -8px rgba(11, 11, 11, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--page); }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

h1, h2, h3, p { margin: 0; }

/* ── Bilah atas ───────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(160deg, var(--brand), var(--brand-deep));
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 0 14px;
  box-shadow: 0 6px 18px -12px rgba(11, 11, 11, 0.5);
}

.topbar-inner {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon { border-radius: 9px; display: block; flex: none; }
.brand h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.brand p { font-size: 11.5px; opacity: 0.82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.live {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
  font-size: 11px;
  font-weight: 550;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
}

.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8ff08f;
  box-shadow: 0 0 0 0 rgba(143, 240, 143, 0.7);
  animation: pulse 2.4s ease-out infinite;
}
.live.is-stale .live-dot { background: #ffd77a; animation: none; }
.live.is-off .live-dot { background: #ff9e9e; animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 240, 143, 0.65); }
  70% { box-shadow: 0 0 0 7px rgba(143, 240, 143, 0); }
  100% { box-shadow: 0 0 0 0 rgba(143, 240, 143, 0); }
}

/* ── Kerangka halaman ─────────────────────────────────────────────────────── */

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 9px 16px 0;
  transition: opacity 0.3s ease;
}
main.is-stale { opacity: 0.55; }

.view { display: flex; flex-direction: column; gap: 22px; }

/* Kartu per VPS ada di dalam pembungkus ini, jadi jaraknya harus diatur di sini
   juga — kalau tidak, ketiganya menempel tanpa celah sama sekali. */
#ringkasan-kartu { display: flex; flex-direction: column; gap: 22px; }
.view[hidden] { display: none; }

/* ── Menu tab bawah ───────────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: rgba(252, 252, 251, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--hairline);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}

.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px 3px;
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease;
}
.tab svg { flex: none; }
.tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tab.is-active { color: var(--brand); background: #eaf1fc; }
.tab.is-active .tab-label { font-weight: 700; }

.card {
  background: linear-gradient(180deg, #ffffff, #fafaf8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 12px 9px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card-head h2 { font-size: 15.5px; font-weight: 620; letter-spacing: -0.01em; }
.card-head { align-items: center; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Banner koneksi ───────────────────────────────────────────────────────── */

.banner {
  position: fixed;
  left: 8px; right: 8px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 50;
  background: #2b2b29;
  color: #fff;
  font-size: 12.5px;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}
.banner-icon {
  flex: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--warn);
  color: #2b2b29;
  font-size: 12px;
  font-weight: 750;
  display: grid;
  place-items: center;
}

/* ── Bar status ringkas (bisa diketuk) ───────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  padding: 9px 13px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.status-bar:active { transform: scale(0.985); }

.status-lampu {
  flex: none;
  width: 31px; height: 31px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--muted);
}
.status-bar.is-good .status-lampu { background: var(--good); }
.status-bar.is-bad .status-lampu { background: var(--crit); }

.status-teks { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.status-judul { font-size: 14.5px; font-weight: 640; letter-spacing: -0.01em; }
.status-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-chev {
  flex: none;
  width: 7px; height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  margin-right: 3px;
}

.tally { text-align: center; }
.tally-val { font-size: 16px; font-weight: 620; letter-spacing: -0.01em; }
.tally-lab { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* ── Popup detail (bottom sheet) ──────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(11, 11, 11, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.26s ease;
}
.sheet-backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  max-width: 520px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px -18px rgba(11, 11, 11, 0.55);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  transform: translateY(102%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.is-open { transform: translateY(0); }

.sheet-grip { padding: 9px 0 3px; display: grid; place-items: center; cursor: grab; touch-action: none; }
.sheet-grip span { width: 38px; height: 4px; border-radius: 999px; background: #dddcd5; display: block; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 18px 12px;
  border-bottom: 1px solid var(--hairline);
}
.sheet-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; }
.sheet-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.sheet-close {
  flex: none;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: #f1f0ec;
  color: var(--ink-2);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.sheet-body { overflow-y: auto; padding: 4px 18px 18px; -webkit-overflow-scrolling: touch; }

.sheet-grup { margin-top: 14px; }
.sheet-grup-judul {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.sheet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--hairline);
  padding: 10px 0;
  cursor: pointer;
}
.sheet-row:last-child { border-bottom: 0; }
.sheet-row:active { background: #f7f6f2; }
.sheet-row-teks { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sheet-row-nama { font-size: 13.5px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-row-ket { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sheet-aman { text-align: center; padding: 18px 10px 6px; }
.sheet-aman-ikon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #eaf6ea;
  color: var(--good);
  font-size: 26px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
}
.sheet-aman p { font-size: 13px; color: var(--ink-2); }

.sheet-angka {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--hairline);
}

/* ── Lencana status ───────────────────────────────────────────────────────── */

.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  background: #f1f0ec;
  border-radius: 999px;
  padding: 4px 9px 4px 7px;
  white-space: nowrap;
}
.badge-icon {
  width: 14px; height: 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 800;
  color: #fff;
  flex: none;
}
.badge.good .badge-icon { background: var(--good); }
.badge.warning .badge-icon { background: var(--warn); color: #3a2a00; }
.badge.critical .badge-icon { background: var(--crit); }
.badge.down .badge-icon { background: #2b2b29; }
.badge.good { background: #eaf6ea; }
.badge.warning { background: #fdf3dd; }
.badge.critical { background: #faeaea; }
.badge.down { background: #ececea; }

/* ── Kotak ringkasan per VPS ──────────────────────────────────────────────── */

.kartu-ringkas {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kartu-ringkas:active { transform: scale(0.985); box-shadow: 0 1px 2px rgba(11, 11, 11, 0.06); }

.ringkas-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ringkas-judul { display: flex; align-items: center; gap: 3px; min-width: 0; }
.ringkas-judul h2 { font-size: 14.5px; font-weight: 630; letter-spacing: -0.01em; }
.chev { color: var(--muted); flex: none; }

/* ── Halaman detail VPS ───────────────────────────────────────────────────── */

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
}
.detail-nyala { font-size: 12px; color: var(--muted); text-align: right; }

.gauges {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 9px;
}
.gauges.mini { margin-top: 8px; }

.gauge {
  text-align: center;
  background: var(--tile);
  border-radius: 15px;
  padding: 7px 3px 6px;
  box-shadow: var(--tile-dalam);
}
.gauge svg { width: 100%; height: auto; display: block; max-width: 66px; margin: 0 auto; }
.gauge-arc { transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.4s ease; }
.gauge-val { font-size: 20px; font-weight: 640; letter-spacing: -0.02em; fill: var(--ink); }
.gauge-unit { font-size: 10px; font-weight: 600; fill: var(--muted); }
.gauge-name { font-size: 9.5px; font-weight: 650; fill: var(--muted); letter-spacing: 0.02em; }
.gauge-detail { font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.gauges.mini .gauge-detail { font-size: 9.5px; line-height: 1.25; white-space: nowrap; }

.gauge-state {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 650;
  margin-top: 3px;
  padding: 1.5px 6px;
  border-radius: 999px;
}
.gauge-state.warning { background: #fdf3dd; color: #5c4300; }
.gauge-state.critical { background: #faeaea; color: #7c1f1f; }

/* ── Pengukur suhu ────────────────────────────────────────────────────────── */

.temp {
  margin-top: 7px;
  padding: 8px 12px;
  background: var(--tile);
  border-radius: 15px;
  box-shadow: var(--tile-dalam);
}
.temp-ringkas { padding: 7px 12px; }

.temp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.temp-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.temp-label svg { color: var(--muted); flex: none; }
.temp-val { font-size: 17.5px; font-weight: 640; letter-spacing: -0.02em; line-height: 1; }
.temp-ringkas .temp-val { font-size: 15.5px; }
.temp-unit { font-size: 10.5px; font-weight: 600; color: var(--muted); margin-left: 1px; }

.temp-track {
  height: 6px;
  border-radius: 999px;
  background: var(--good-track);
  overflow: hidden;
}
.temp-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--good);
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1), background 0.4s ease;
}

.temp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
}
.temp-state { font-weight: 650; }
.temp-state.good { color: #0a7a0a; }
.temp-state.warning { color: #6b4e00; }
.temp-state.critical { color: #a02c2c; }

.temp-spark { width: 100%; height: 26px; display: block; margin-top: 4px; }

.temp-kosong .temp-track { display: none; }
.temp-kosong .temp-spark { display: none; }
.temp-kosong .temp-top { margin-bottom: 0; }
.temp-kosong .temp-val { font-size: 12px; font-weight: 550; color: var(--muted); }
.temp-kosong .temp-foot { justify-content: flex-start; margin-top: 3px; }
.temp-kosong .temp-foot span:first-child,
.temp-kosong .temp-foot span:last-child { display: none; }
.temp-kosong .temp-state { color: var(--muted); font-weight: 550; }

/* ── Grafik berjalan ──────────────────────────────────────────────────────── */

.chart-wrap { margin-top: 14px; }

.chart-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.legend { display: flex; gap: 10px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-2); font-weight: 550; }
.legend-key { width: 11px; height: 3px; border-radius: 2px; flex: none; }

.chart-toggle {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: #f1f0ec;
  border: 0;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  flex: none;
}

.chart { position: relative; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-geser { will-change: transform; }
.chart-grid { stroke: var(--grid); stroke-width: 1; }
.chart-axis { font-size: 9px; fill: var(--muted); }
.chart-end-label { font-size: 9.5px; font-weight: 650; fill: var(--ink-2); }
.chart-foot { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 2px; }

.tip {
  position: absolute;
  pointer-events: none;
  background: #2b2b29;
  color: #fff;
  font-size: 10.5px;
  line-height: 1.5;
  border-radius: 9px;
  padding: 7px 9px;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tip.is-on { opacity: 1; }
.tip b { font-weight: 650; }
.tip-row { display: flex; align-items: center; gap: 5px; }
.tip-key { width: 7px; height: 7px; border-radius: 2px; flex: none; }

.table-view { margin-top: 8px; width: 100%; border-collapse: collapse; font-size: 11.5px; }
.table-view th, .table-view td { padding: 4px 2px; text-align: right; font-variant-numeric: tabular-nums; }
.table-view th:first-child, .table-view td:first-child { text-align: left; font-variant-numeric: normal; }
.table-view th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--hairline); }
.table-view td { color: var(--ink-2); border-bottom: 1px solid var(--hairline); }

/* ── Daftar aplikasi & situs ──────────────────────────────────────────────── */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}
.list-head.list-atas { margin-top: 0; padding-top: 0; border-top: 0; }
.list-title { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }

.toggle {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand);
  background: none;
  border: 0;
  padding: 4px 0 4px 8px;
  cursor: pointer;
}

.rows { margin-top: 8px; display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 13px;
}
.row:last-child { border-bottom: 0; }
.row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { flex: none; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dot {
  flex: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 800;
  color: #fff;
}
.dot.up { background: var(--good); }
.dot.down { background: var(--crit); }

.empty { font-size: 12px; color: var(--muted); padding: 6px 0; }

.sites-body { margin-top: 4px; }

.footer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0 8px;
}

[hidden] { display: none !important; }
