/* pm dashboard — token mengikuti palet referensi dataviz (mode gelap dipilih; terang via prefers-color-scheme) */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #222220;
  --surface-3: #2c2c2a;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5; /* S3 */
  --series-2: #d95926; /* H2b */
  --good: #0ca30c;
  --good-text: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --neutral-mid: #383835;
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --page: #f9f9f7;
    --surface-1: #fcfcfb;
    --surface-2: #f3f2ee;
    --surface-3: #e9e8e2;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #898781;
    --grid: #e1e0d9;
    --axis: #c3c2b7;
    --border: rgba(11, 11, 11, 0.10);
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --good-text: #006300;
    --neutral-mid: #f0efec;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 24px rgba(0, 0, 0, 0.06);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-primary); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; }
.brand-mark rect { fill: var(--series-1); }
.brand-mark path { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 650; letter-spacing: 0.01em; }
.brand-sub { font-size: 12px; color: var(--text-muted); }
.brand-lg .brand-mark { width: 40px; height: 40px; }
.brand-lg .brand-name { font-size: 20px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, color-mix(in oklab, var(--series-1) 18%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in oklab, var(--series-2) 14%, transparent), transparent 60%), var(--page); }
.login-card { width: min(380px, 100%); background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.login-form { display: grid; gap: 10px; margin-top: 24px; }
.login-form label { font-size: 13px; color: var(--text-secondary); }
.login-form input { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); outline: none; }
.login-form input:focus { border-color: var(--series-1); box-shadow: 0 0 0 3px color-mix(in oklab, var(--series-1) 30%, transparent); }
.login-error { display: none; margin: 0; color: var(--critical); font-size: 13px; }
.has-error .login-error { display: block; }
.login-note { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); text-align: center; }
.btn-primary { padding: 11px 14px; border: 0; border-radius: 10px; background: var(--series-1); color: #fff; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px;
  background: color-mix(in oklab, var(--page) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.cols-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: 2fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cols-kpi { grid-template-columns: repeat(3, 1fr); } .cols-2, .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .cols-kpi { grid-template-columns: repeat(2, 1fr); } .wrap { padding: 14px; } .topbar { padding: 10px 14px; } }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 15px; font-weight: 620; margin: 0; }
.card-sub { font-size: 12px; color: var(--text-muted); }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.badge.good .dot { background: var(--good); box-shadow: 0 0 0 0 color-mix(in oklab, var(--good) 60%, transparent); animation: ping 1.8s infinite; }
.badge.warning { border-color: color-mix(in oklab, var(--warning) 50%, transparent); }
.badge.warning .dot { background: var(--warning); }
.badge.critical .dot { background: var(--critical); }
.badge.serious .dot { background: var(--serious); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--good) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-primary); white-space: nowrap; }
.chip .sw { width: 8px; height: 8px; border-radius: 2px; }
.chip.s3 .sw { background: var(--series-1); }
.chip.h2b .sw { background: var(--series-2); }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.st.good::before { background: var(--good); }
.st.warning::before { background: var(--warning); }
.st.critical::before { background: var(--critical); }
.st.info::before { background: var(--series-1); }
.btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 13px; }
.btn:hover { background: var(--surface-3); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text-primary); font-weight: 600; }

/* ---------- KPI ---------- */
.kpi { display: grid; gap: 4px; align-content: start; }
.kpi-label { font-size: 12px; color: var(--text-secondary); }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.kpi-hero .kpi-value { font-size: 40px; line-height: 1.1; }
.kpi-foot { font-size: 12px; color: var(--text-muted); }
.pos { color: var(--good-text); }
.neg { color: var(--critical); }

/* ---------- flow ---------- */
.flow-wrap { position: relative; }
.flow { width: 100%; height: auto; display: block; }
.flow .edge { fill: none; stroke: var(--axis); stroke-width: 2; }
.flow .edge.active { stroke: color-mix(in oklab, var(--series-1) 45%, var(--axis)); }
.flow .edge.blocked { stroke: var(--critical); stroke-dasharray: 6 6; opacity: 0.8; }
.flow .edge.dim { stroke-dasharray: 3 6; opacity: 0.5; }
.flow .node rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; rx: 12; }
.flow .node.dim { opacity: 0.45; }
.flow .node .t { fill: var(--text-primary); font-size: 13px; font-weight: 620; }
.flow .node .s { fill: var(--text-muted); font-size: 11px; }
.flow .node .r { fill: var(--text-secondary); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.flow .node .bar { fill: var(--series-1); }
.flow .node.src .bar { fill: var(--series-1); }
.flow .node.exec .bar { fill: var(--warning); }
.flow .node.dest .bar { fill: var(--critical); }
.flow .node.pulse rect { animation: nodepulse 0.9s ease-out; }
@keyframes nodepulse { 0% { stroke: var(--series-2); stroke-width: 3; } 100% { stroke: var(--border); stroke-width: 1; } }
.flow .pk { fill: var(--series-1); }
.flow .pk.order { fill: var(--series-2); }
.flow .pk.blocked { fill: var(--critical); }
.flow .lbl { fill: var(--text-muted); font-size: 11px; }
.flow .lbl.crit { fill: var(--critical); font-weight: 600; }
.flow-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 8px; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- rounds ---------- */
.rounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.round { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.round-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.round-title { font-weight: 620; }
.countdown { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.timeline .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in oklab, var(--series-1) 70%, transparent); border-radius: 5px; transition: width 0.9s linear; }
.timeline .win { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--page); border-right: 2px solid var(--page); }
.timeline .win.s3 { background: repeating-linear-gradient(45deg, color-mix(in oklab, var(--series-1) 55%, transparent) 0 3px, transparent 3px 6px); }
.timeline .win.h2b { background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--series-2) 60%, transparent) 0 3px, transparent 3px 6px); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--text-secondary); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.prob { display: grid; gap: 6px; }
.prob-row { display: grid; grid-template-columns: 92px 1fr 48px; align-items: center; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.prob-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); }
.prob-track .mk { position: absolute; top: -3px; width: 4px; height: 14px; border-radius: 2px; transform: translateX(-2px); transition: left 0.6s ease; }
.prob-track .mk.model { background: var(--series-1); }
.prob-track .mk.market { background: var(--text-primary); }
.prob-track .half { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.round-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 260px; display: block; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s3 { stroke: var(--series-1); }
.chart .line.h2b { stroke: var(--series-2); }
.chart .end { stroke: var(--surface-1); stroke-width: 2; }
.chart .end.s3 { fill: var(--series-1); }
.chart .end.h2b { fill: var(--series-2); }
.chart .dl { fill: var(--text-secondary); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .xh { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); display: none; min-width: 160px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.empty { display: grid; place-items: center; min-height: 160px; color: var(--text-muted); font-size: 13px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; padding: 16px; }

/* ---------- progress ---------- */
.meter { display: grid; gap: 4px; }
.meter-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.meter-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter-track .v { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--series-2); }
.meter-track .v.s1 { background: var(--series-1); }
.meter-track .tgt { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text-primary); }
.verdict { margin-top: 10px; font-size: 13px; }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input, .toolbar select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); }
.toolbar input { min-width: 200px; }
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary); font-weight: 600; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover { background: var(--surface-2); }
tbody tr.row.new { animation: rowin 1.2s ease-out; }
@keyframes rowin { from { background: color-mix(in oklab, var(--series-2) 25%, transparent); } to { background: transparent; } }
tbody tr.detail td { white-space: normal; background: var(--surface-2); padding: 12px 14px 16px; }
.why { margin: 0 0 10px; color: var(--text-primary); max-width: 900px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; font-size: 12.5px; }
.detail-grid div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border); padding: 3px 0; }
.detail-grid span:first-child { color: var(--text-secondary); }
.detail-grid span:last-child { font-variant-numeric: tabular-nums; }
.caret { display: inline-block; width: 12px; color: var(--text-muted); transition: transform 0.15s; }
tr.open .caret { transform: rotate(90deg); }
.more { margin-top: 10px; text-align: center; }

/* ---------- feeds / lists ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 340px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 64px auto 1fr; gap: 10px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.feed li.new { animation: rowin 1.2s ease-out; }
.feed time { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.svc { display: grid; gap: 8px; }
.svc-row { display: flex; justify-content: space-between; font-size: 13px; }
.alerts { list-style: none; margin: 0; padding: 0; font-size: 12px; display: grid; gap: 4px; max-height: 220px; overflow: auto; color: var(--text-secondary); }
.feeds-table td, .feeds-table th { padding: 6px 8px; }
footer.foot { color: var(--text-muted); font-size: 12px; text-align: center; padding: 8px 0 0; }

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

.sw-s1 { background: var(--series-1); }
.sw-s2 { background: var(--series-2); }
.sw-crit { background: var(--critical); }
[data-gap] { gap: 12px; }
.mt16 { margin-top: 16px; }

[hidden] { display: none !important; }
