/* Dashboard Monitoring PPPoE — One Wan Solution
   Warna grafik memakai palet yang sudah divalidasi: biru = unduh, oranye = unggah,
   dan empat warna status khusus untuk mutu redaman (selalu berpasangan dengan label). */

:root {
  color-scheme: light;

  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  --series-dn: #2a78d6;
  --series-up: #eb6834;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-dn: #3987e5;
    --series-up: #d95926;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-dn: #3987e5;
  --series-up: #d95926;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  background: var(--plane);
  color: var(--text-primary);
}

a { color: inherit; }

/* ── kerangka halaman ─────────────────────────────────────────────────────── */
header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -0.01em; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

nav.tabs { display: flex; gap: 2px; margin-left: 8px; }
nav.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
}
nav.tabs a:hover { background: var(--plane); }
nav.tabs a.active { background: var(--plane); color: var(--text-primary); }

.spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.dot.stale { background: var(--warning); }
.dot.off { background: var(--critical); }

button, .btn {
  font: inherit;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
button:hover { background: var(--plane); }
button.primary { background: var(--series-dn); border-color: transparent; color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ── kartu & petak ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary);
}
.card .sub { margin: 0 0 14px; font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1000px) { .cols-2 { grid-template-columns: 1fr; } }

.tile .value {
  font-size: 26px;
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.tile .value .unit { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.tile .note { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── legenda & rentang ────────────────────────────────────────────────────── */
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

.rangebar { display: flex; gap: 4px; }
.rangebar button { padding: 4px 10px; font-size: 12px; }
.rangebar button.active { background: var(--plane); border-color: var(--axis); font-weight: 600; }
/* Tombol "Langsung" diberi warna status agar mode berjalan langsung terlihat jelas. */
.rangebar button.live.active { color: #056b05; border-color: color-mix(in srgb, var(--good) 50%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rangebar button.live.active { color: #4fd44f; } }
:root[data-theme="dark"] .rangebar button.live.active { color: #4fd44f; }

.cardhead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.cardhead .spacer { flex: 1; }

/* ── grafik ───────────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; }

.tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  min-width: 150px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.1s;
}
.tooltip.on { opacity: 1; }
.tooltip .t { color: var(--muted); margin-bottom: 5px; }
.tooltip .r { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }

.empty { color: var(--muted); padding: 28px 0; text-align: center; font-size: 13px; }

/* ── tabel ────────────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 10px; text-align: left; white-space: nowrap; }
th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--axis);
  cursor: pointer;
  user-select: none;
}
th.no-sort { cursor: default; }
th .arrow { color: var(--muted); font-size: 10px; }
td { border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--plane); }
td.name { font-variant-numeric: normal; }
td.name a { text-decoration: none; font-weight: 550; }
td.name a:hover { text-decoration: underline; }
.num { text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  border: 1px solid var(--border);
}
.badge .ic { font-size: 10px; line-height: 1; }
.badge.good { color: #056b05; background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.warn { color: #7a5300; background: color-mix(in srgb, var(--warning) 20%, transparent); }
.badge.bad { color: #8f2020; background: color-mix(in srgb, var(--critical) 14%, transparent); }
.badge.too_strong { color: #8a3d18; background: color-mix(in srgb, var(--serious) 18%, transparent); }
.badge.unknown { color: var(--muted); }
.badge.on { color: #056b05; background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.off { color: #8f2020; background: color-mix(in srgb, var(--critical) 14%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.good,
  :root:not([data-theme="light"]) .badge.on { color: #4fd44f; }
  :root:not([data-theme="light"]) .badge.warn { color: #fac95e; }
  :root:not([data-theme="light"]) .badge.bad,
  :root:not([data-theme="light"]) .badge.off { color: #ff8a8a; }
  :root:not([data-theme="light"]) .badge.too_strong { color: #f0a884; }
}
:root[data-theme="dark"] .badge.good,
:root[data-theme="dark"] .badge.on { color: #4fd44f; }
:root[data-theme="dark"] .badge.warn { color: #fac95e; }
:root[data-theme="dark"] .badge.bad,
:root[data-theme="dark"] .badge.off { color: #ff8a8a; }
:root[data-theme="dark"] .badge.too_strong { color: #f0a884; }

/* ── kendali ──────────────────────────────────────────────────────────────── */
.controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
input[type="search"], select {
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  min-width: 190px;
}
.count { color: var(--muted); font-size: 12px; }

/* ── batang sebaran ───────────────────────────────────────────────────────── */
.dist { display: grid; gap: 9px; }
.dist .row { display: grid; grid-template-columns: 116px 1fr 62px; align-items: center; gap: 10px; }
.dist .track { height: 12px; background: var(--grid); border-radius: 6px; overflow: hidden; }
/* .fill harus block: sebagai anak <span> biasa ia inline dan tingginya tak berlaku. */
.dist .fill { display: block; height: 100%; border-radius: 6px; min-width: 2px; }
.dist .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.dist .lbl { font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }

/* ── halaman detail ───────────────────────────────────────────────────────── */
.detailhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.detailhead h1 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.statrow .s .k { font-size: 11.5px; color: var(--muted); }
.statrow .s .v { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

/* ── login ────────────────────────────────────────────────────────────────── */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.loginwrap form { width: 100%; max-width: 330px; display: grid; gap: 10px; }
.loginwrap input {
  font: inherit;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  width: 100%;
}
.loginwrap .err { color: var(--critical); font-size: 12.5px; min-height: 18px; }
