:root {
  --bg: #14151f;
  --panel: #1d1f2d;
  --panel-2: #252839;
  --line: #33374d;
  --text: #e8e9f1;
  --muted: #9095ad;
  --accent: #8b7bff;
  --ok: #3ccf91;
  --warn: #ffbf47;
  --err: #ff6b7a;
  --r-direksi: #ef476f;
  --r-pmo: #8b6cff;
  --r-sa: #3a9bff;
  --r-dev: #2fb874;
  --r-qa: #ff9a2e;
  --r-ts: #14b8a6;
  --r-adm: #d9a92c;
  --m-opus: #f2b705;
  --m-sonnet: #4cc9f0;
  --m-haiku: #9ef0d0;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef0f6;
    --panel: #ffffff;
    --panel-2: #f3f4f9;
    --line: #d9dce8;
    --text: #1c1e2b;
    --muted: #646a85;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { height: 42px; width: auto; padding: 0 6px; border-radius: 8px; background: #ffffff; }
.brand h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .2px; }
.brand h1 span { display: block; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .3px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.err { background: var(--err); }

.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.controls label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
select, button {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px;
}
select { max-width: 260px; }
.controls select { max-width: 200px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 7px 0 0 7px; }
.seg button:last-child { border-radius: 0 7px 7px 0; border-left: 0; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.layout {
  flex: 1; min-height: 0; align-items: start;
  display: grid; grid-template-columns: 270px minmax(0, 1fr) 320px; grid-template-areas: "kiri stage kanan";
  gap: 14px; padding: 14px 16px;
}
.layout > .kiri { grid-area: kiri; }
.layout > .stage { grid-area: stage; }
.layout > .kanan { grid-area: kanan; position: sticky; top: 14px; height: calc(100vh - 96px); min-height: 360px; }
.side.kanan .card.grow { min-height: 0; }
.side.kiri .roster { max-height: calc(100vh - 560px); min-height: 120px; }
@media (max-width: 1280px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "kiri stage" "kanan kanan"; }
  .layout > .kanan { position: static; height: 420px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "kiri" "kanan"; }
}

.stage { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.canvas-wrap {
  position: relative; width: 100%;
  background: #171a2c; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
  display: flex; justify-content: center;
}
canvas { display: block; cursor: grab; touch-action: none; }
canvas.dragging { cursor: grabbing; }
.tip {
  position: absolute; pointer-events: none; max-width: 300px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35);
}
.tip b { display: block; margin-bottom: 2px; }
.tip .muted { display: block; }

.statusbar { display: flex; justify-content: space-between; gap: 12px; color: var(--text); }
.statusbar #title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12px; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 5px; vertical-align: -1px; }
.legend .sep { flex: 1; }

.badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .3px;
  padding: 1px 6px; border-radius: 999px; margin-left: 4px; color: #111;
}
.badge.opus { background: var(--m-opus); }
.badge.sonnet { background: var(--m-sonnet); }
.badge.haiku { background: var(--m-haiku); }
.badge.lain { background: #b8c0d6; color: #14151f; }

.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.card.grow { flex: 1; min-height: 220px; display: flex; flex-direction: column; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 8px; font-weight: 650; }

.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.stages li {
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 6px; color: var(--muted);
}
.stages li .n {
  width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center;
  background: var(--panel-2); font-size: 11px; font-weight: 700;
}
.stages li.touched { color: var(--text); }
.stages li.touched .n { background: color-mix(in srgb, var(--ok) 30%, var(--panel-2)); }
.stages li.active { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--text); }
.stages li.active .n { background: var(--accent); color: #fff; }
.stages li small { font-size: 11px; color: var(--muted); }

.roster { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.roster li { display: grid; grid-template-columns: 10px 1fr; gap: 8px; align-items: start; }
.roster .sw { width: 10px; height: 10px; border-radius: 2px; margin-top: 4px; }
.roster .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster .act { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster li.leaving { opacity: .5; }

.log { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 0; font-size: 12px; }
.log li { display: grid; grid-template-columns: 58px 1fr; gap: 6px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .who { font-weight: 600; }
.log .err { color: var(--err); }
.log .cmd { color: var(--accent); }
.log .hasil { color: var(--ok); }

/* ---------------------------------------------------------------- kartu kontrol */
.control { display: flex; flex-direction: column; gap: 12px; }
.ctl-head { display: flex; justify-content: space-between; align-items: center; }
.ctl-head h2 { margin: 0; }
.pill {
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.pill.running { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); border-color: var(--accent); }
.pill.waiting, .pill.checkpoint { background: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--text); border-color: var(--warn); }
.pill.selesai { background: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--text); border-color: var(--ok); }

.ctl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1200px) { .ctl-grid { grid-template-columns: minmax(0, 1fr); } }
.ctl-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-title { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.step-title .num {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
}
.fld { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; min-width: 0; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fld .row input { flex: 1; min-width: 0; }
input, textarea {
  font: inherit; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; width: 100%;
}
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
button:disabled { opacity: .45; cursor: not-allowed; }
.small { font-size: 12px; }
.err-text { color: var(--err); }

.repo-status { font-size: 12px; line-height: 1.5; }
.repo-status .ok { color: var(--ok); }
.repo-status .bad { color: var(--err); }

.drop {
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px 10px;
  display: flex; flex-direction: column; gap: 6px; align-items: center; text-align: center;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.kb-list { list-style: none; margin: 0; padding: 0; max-height: 170px; overflow: auto; font-size: 12px; }
.kb-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kb-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-list button { padding: 0 6px; font-size: 12px; line-height: 18px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.steps li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 6px; }
.steps li.running { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.steps li.cur-wait { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.steps li .meta { color: var(--muted); font-size: 11px; }
.steps li .cp { color: var(--warn); font-size: 11px; }

.inbox {
  border: 1px solid var(--warn); border-radius: 10px; padding: 10px 12px;
  background: color-mix(in srgb, var(--warn) 7%, var(--panel)); display: flex; flex-direction: column; gap: 8px;
}
.inbox-head { font-size: 13px; }
.inbox .note { font-size: 12px; color: var(--text); }
.inbox pre {
  margin: 0; max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12.5px/1.5 ui-sans-serif, system-ui, sans-serif; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}

/* ---------------------------------------------------------------- pemasang sddgen */
.install {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel-2);
  display: flex; flex-direction: column; gap: 8px;
}
.install b.n { font-variant-numeric: tabular-nums; }
.warn-list { margin: 0; padding-left: 16px; color: var(--warn); }
.warn-list:empty { display: none; }
.file-list { list-style: none; margin: 6px 0 0; padding: 0; max-height: 180px; overflow: auto; }
.file-list li { display: grid; grid-template-columns: 54px 1fr; gap: 6px; padding: 1px 0; }
.file-list .st { font-weight: 700; font-size: 11px; }
.st-baru { color: var(--ok); } .st-beda { color: var(--warn); } .st-gabung { color: var(--accent); }
.st-sama { color: var(--muted); } .st-lewati { color: var(--err); }
.chk { display: flex; gap: 8px; align-items: flex-start; }
.chk input { width: auto; margin-top: 2px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 11.5px; }
#install-out { margin: 0; max-height: 200px; overflow: auto; white-space: pre-wrap; font: 11.5px/1.45 ui-monospace, Menlo, monospace; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

/* atribut hidden harus menang atas display: flex/grid di atas */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- tab proses */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
  font-weight: 650; color: var(--muted);
}
.tab span { font-weight: 400; font-size: 11px; margin-left: 4px; }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.on span { color: #ece8ff; }
.tab .live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-left: 6px; vertical-align: 1px; }
.tabpanel { display: block; }
.warn-text { color: var(--warn); font-size: 12px; margin-top: 4px; }
.cam-hint {
  position: absolute; right: 10px; bottom: 8px; font-size: 11px; color: rgba(255,255,255,.55);
  background: rgba(15,17,30,.45); padding: 3px 8px; border-radius: 999px; pointer-events: none;
}

/* agen aktif */
.aktif { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.aktif .kosong { font-size: 12px; }
.aktif-row {
  width: 100%; text-align: left; display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; row-gap: 1px;
  padding: 6px 8px; border-radius: 8px; background: transparent; border: 1px solid transparent;
}
.aktif-row:hover { background: var(--panel-2); border-color: var(--line); }
.aktif-row.on { background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.aktif-row .pt { grid-row: span 2; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.aktif-row .pt.live { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.aktif-row .baris1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aktif-row .baris2 { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.akun { display: inline-flex; gap: 8px; align-items: center; }

/* halaman login hub */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(380px, 100%); display: grid; gap: 10px; }
.login-box h1 { font-size: 18px; margin: 4px 0 0; }
.login-box p { margin: 0; }
.login-box form { display: grid; gap: 10px; margin-top: 8px; }
.login-box input { width: 100%; box-sizing: border-box; }
.login-logo { height: 52px; width: auto; justify-self: start; padding: 4px 10px; border-radius: 10px; background: #fff; }

/* kamera "Ikuti" */
.cam-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2; font-size: 12px; padding: 4px 10px;
  background: rgba(17, 19, 34, .72); color: #e8eaf6; border-color: rgba(255, 255, 255, .18); border-radius: 999px;
}
.cam-btn.on { background: color-mix(in srgb, var(--accent) 80%, transparent); border-color: var(--accent); color: #fff; }

/* linimasa replay */
.linimasa { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; }
.linimasa input[type=range] { flex: 1; accent-color: var(--accent); }
.linimasa #posisi { font-size: 12px; white-space: nowrap; min-width: 150px; text-align: right; }
.linimasa button { width: 34px; padding: 4px 0; }
