/* g-panel — tata letak: bilah atas lengket, ringkasan, lalu bagian grafik dua kolom; zoom di <dialog>.
   Warna: palet dataviz yang sudah divalidasi (seri biru/oranye/aqua), permukaan netral hangat. */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #77756f;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.22);
  --wash: rgba(11, 11, 11, 0.05);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --accent: #2a78d6;
  --track: #cde2fb;
  --warn: #fab219;
  --good: #0ca30c;
  --warn-ink: #7a5200;
  --crit: #d03b3b;
  --shadow: 0 6px 24px rgba(11, 11, 11, 0.14);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --raised: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.24);
    --wash: rgba(255, 255, 255, 0.06);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --accent: #3987e5;
    --track: #184f95;
    --warn-ink: #fab219;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --raised: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.24);
  --wash: rgba(255, 255, 255, 0.06);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --accent: #3987e5;
  --track: #184f95;
  --warn-ink: #fab219;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- bilah atas ---- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--page);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; letter-spacing: 0.01em; }
.brand svg { width: 22px; height: 22px; }
.jump {
  display: flex;
  gap: 6px;
  flex: 1 1 320px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid transparent;
}
.jump a:hover { background: var(--wash); }
.jump a.on { color: var(--ink); border-color: var(--border-strong); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
}
.btn:hover { background: var(--wash); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { white-space: nowrap; appearance: none; background: transparent; border: 0; padding: 5px 11px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.seg button[aria-pressed="true"] { background: var(--wash); color: var(--ink); font-weight: 600; }

.status { color: var(--crit); font-size: 12px; font-weight: 600; }
.status:empty { display: none; }

/* ---- isi ---- */

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
}

.host { color: var(--ink-2); font-size: 13px; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.host b { color: var(--ink); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 28px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.tile-label { color: var(--ink-2); font-size: 12px; }
.tile-value { font-size: 24px; white-space: nowrap; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tile-note { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tile-flag { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 7px; border-radius: 999px; }
.tile-flag.warn { color: var(--warn-ink); border: 1px solid var(--warn); }
.tile-flag.crit { color: #fff; background: var(--crit); border: 1px solid var(--crit); }
.meter { height: 6px; border-radius: 3px; background: var(--track); margin-top: 8px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); width: 0; }
.meter > span.warn { background: var(--warn); }
.meter > span.crit { background: var(--crit); }

.group { margin-bottom: 36px; scroll-margin-top: 72px; }
.group-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px 16px; flex-wrap: wrap; margin: 0 0 12px; }
.group-titles { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; min-width: 0; }
.group-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.group-head small { color: var(--ink-2); font-size: 13px; }

/* geser ke masa lalu (R-14) */
.pan { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pan-status { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-right: 4px; }
.pan-status.is-live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { background: var(--surface); }
.card-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.live-btn {
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: 999px; font-size: 11px; font-weight: 600; padding: 2px 9px; cursor: pointer;
}
.live-btn:hover { background: var(--wash); }
.card.panned { border-color: var(--border-strong); }
.chart-plot.panning, .chart-plot.panning .hit { cursor: grabbing; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .cards { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 8px;
  min-width: 0;
  cursor: zoom-in;
  transition: border-color 0.12s;
}
.card:hover { border-color: var(--border-strong); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-title { margin: 0; font-size: 14px; font-weight: 600; }
.card-sub { color: var(--muted); font-size: 12px; }
.zoom-btn {
  appearance: none; background: transparent; border: 1px solid transparent; border-radius: 6px;
  width: 28px; height: 28px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; flex: none;
}
.zoom-btn:hover { background: var(--wash); border-color: var(--border); }
.zoom-btn svg { width: 16px; height: 16px; }

/* ---- grafik ---- */

.chart-readout { display: flex; flex-wrap: wrap; gap: 2px 16px; min-height: 26px; align-items: baseline; margin: 2px 0 2px; }
.readout-item { display: inline-flex; align-items: baseline; gap: 6px; }
.readout-name { color: var(--ink-2); font-size: 12px; }
.readout-value { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.chart:not(.zoomed) .readout-value { font-size: 18px; }

.key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; align-self: center; flex: none; }
.key.s1 { background: var(--s1); }
.key.s2 { background: var(--s2); }
.key.s3 { background: var(--s3); }

.chart-plot { position: relative; touch-action: pan-y; border-radius: 6px; }
.chart-plot svg { display: block; max-width: 100%; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--baseline); stroke-width: 1; }
.chart text.tick { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart text.empty { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.dash { stroke-dasharray: 1 5; }
.chart .line.s1 { stroke: var(--s1); }
.chart .line.s2 { stroke: var(--s2); }
.chart .line.s3 { stroke: var(--s3); }
.chart .area { stroke: none; fill-opacity: 0.10; }
.chart .area.s1 { fill: var(--s1); }
.chart .area.s2 { fill: var(--s2); }
.chart .area.s3 { fill: var(--s3); }
.chart .lone.s1 { fill: var(--s1); }
.chart .lone.s2 { fill: var(--s2); }
.chart .lone.s3 { fill: var(--s3); }
/* penanda ujung: titik berisi dengan cincin permukaan 2px; bucket berjalan = titik berongga */
.chart .dot { stroke-width: 2; }
.chart .dot.s1 { fill: var(--s1); }
.chart .dot.s2 { fill: var(--s2); }
.chart .dot.s3 { fill: var(--s3); }
.chart .dot:not(.running) { paint-order: stroke; stroke: var(--surface); stroke-width: 4; }
.chart .dot.running { fill: var(--surface); }
.chart .dot.running.s1 { stroke: var(--s1); }
.chart .dot.running.s2 { stroke: var(--s2); }
.chart .dot.running.s3 { stroke: var(--s3); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .hit { cursor: crosshair; }

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.tip-time { color: var(--ink-2); margin-bottom: 4px; }
.tip-running { color: var(--muted); }
.tip-row { display: flex; align-items: baseline; gap: 8px; }
.tip-row .key { transform: translateY(-2px); }
.tip-value { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tip-name, .tip-exact { color: var(--ink-2); }
.tip-value.none { color: var(--muted); font-weight: 500; }
.tip-exact { font-variant-numeric: tabular-nums; }

/* ---- zoom ---- */

dialog.zoom {
  width: min(1860px, calc(100vw - 24px));
  max-width: none;
  max-height: calc(100vh - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog.zoom::backdrop { background: rgba(0, 0, 0, 0.55); }
.zoom-inner { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.zoom-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px 8px;
}
.zoom-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.zoom-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.zoom-tools { display: flex; gap: 8px; align-items: center; }
.zoom-stats { display: flex; flex-direction: column; gap: 6px; padding: 0 18px 10px; }
.statrow { display: flex; flex-wrap: wrap; gap: 4px 28px; align-items: flex-end; }
.statrow .stat:first-child { min-width: 110px; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat span { color: var(--muted); font-size: 12px; }
.stat b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.zoom-body { padding: 0 14px 16px; overflow: auto; min-height: 0; }
.chart.zoomed .chart-readout { display: none; } /* statistik di atas sudah memuat legenda dan nilai */

.cores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 14px 4px 0; }
.core-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 4px; min-width: 0; }
.core-title { font-size: 13px; font-weight: 600; }
.core-card .readout-value { font-size: 15px; }
@media (max-width: 760px) { .cores { grid-template-columns: minmax(0, 1fr); } }
.tablewrap { max-width: 820px; max-height: 62vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin: 0 4px; }
.tablewrap table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
.tablewrap th, .tablewrap td { padding: 5px 12px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.tablewrap th:first-child, .tablewrap td:first-child { text-align: left; }
.tablewrap thead th { position: sticky; top: 0; background: var(--surface); color: var(--ink-2); font-weight: 600; z-index: 1; }
.tablewrap td.none { color: var(--muted); }

/* ---- login ---- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 26px 24px;
  box-shadow: var(--shadow);
}
.login .brand { font-size: 20px; margin-bottom: 4px; }
.login .brand svg { width: 28px; height: 28px; }
.login p { color: var(--ink-2); margin: 0 0 18px; font-size: 13px; }
.login label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.login input {
  width: 100%;
  font: inherit;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--page);
  color: var(--ink);
}
.login .btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 10px;
  font-weight: 600;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.login .btn-primary:disabled { opacity: 0.6; cursor: progress; }
.login .error { color: var(--crit); font-size: 13px; min-height: 20px; margin-top: 12px; }

@media (max-width: 760px) {
  .topbar { position: static; }
  .tile-value { font-size: 20px; }
  .group { scroll-margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
