:root {
  color-scheme: dark;
  --bg: #0b1422;
  --panel: #111d2f;
  --panel-2: #0d1828;
  --line: #22344d;
  --line-strong: #31496a;
  --text: #e6edf6;
  --muted: #9aa8bb;
  --cyan: #4cc9f0;
  --amber: #f2b84b;
  --green: #3ecf8e;
  --red: #ef6b6b;
  --violet: #c9a6ff;
  --blue: #7aa7ff;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0 auto; max-width: 1400px; padding: 20px; line-height: 1.45; }
h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 24px; letter-spacing: .01em; }
h2 { font-size: 15px; }
.eyebrow { margin: 0 0 2px; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; color: var(--cyan); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
.top { display: flex; justify-content: space-between; gap: 12px 16px; align-items: center; flex-wrap: wrap; }
.top-left { display: flex; gap: 14px; align-items: center; min-width: 0; }
.top-right { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.meta { display: flex; gap: 6px 12px; align-items: center; flex-wrap: wrap; }
.clock { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav { position: relative; }
.nav-toggle { font-size: 20px; line-height: 1; min-width: 44px; min-height: 44px; padding: 8px 12px; }
.account-panel { position: absolute; top: calc(100% + 8px); left: 0; z-index: 20; display: grid; gap: 10px; align-content: start; width: min(280px, calc(100vw - 32px)); max-height: calc(100dvh - 72px); overflow: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.account-panel p { margin: 0; overflow-wrap: anywhere; }
.account-panel button { width: 100%; }
.mode-box { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.mode-btn { text-align: left; font-weight: 700; }
.mode-btn[aria-pressed="true"] { border-color: var(--green); color: var(--green); background: rgba(62, 207, 142, .1); }
#mode-auto[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); background: rgba(242, 184, 75, .12); }
.mode-btn[aria-pressed="true"]::after { content: " ✓ aktif"; font-weight: 600; font-size: 12px; }
.s-auto { color: var(--amber); border-width: 2px; }

/* ---------- Status chips: text + symbol + colour ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid currentColor; border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; line-height: 1.5; background: rgba(255, 255, 255, .03); }
.chip .sym { font-size: 11px; line-height: 1; }
.s-live { color: var(--green); }
.s-ready { color: #7fd8ae; }
.s-old { color: var(--amber); }
.s-closed { color: var(--violet); }
.s-none { color: var(--muted); border-style: dashed; }
.s-error { color: var(--red); }
.s-pending { color: #ff8a8a; border-width: 2px; }
.s-paused { color: var(--blue); }
.s-neutral { color: var(--muted); }

/* ---------- Banners and states ---------- */
.banner { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--amber); background: rgba(242, 184, 75, .1); color: var(--amber); font-weight: 600; }
.banner.offline { border-color: var(--red); background: rgba(239, 107, 107, .1); color: #ffb0b0; }
.message { min-height: 0; margin: 8px 0 0; color: var(--amber); }
.message:empty { display: none; }
.loading { color: var(--muted); margin: 8px 0; }
.empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line); border-radius: 10px; margin: 0; }
.load-error h2 { color: var(--red); margin-bottom: 6px; }

/* ---------- Buttons and forms ---------- */
button { border: 1px solid transparent; background: #1f6feb; color: white; border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer; font: inherit; transition: background-color .15s; }
button:hover { background: #2f7cf6; }
button.ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
button.ghost:hover { background: #1a2a40; }
button.link { background: transparent; border: 0; padding: 6px 4px; min-height: 36px; color: var(--cyan); text-decoration: underline; text-align: left; }
button:disabled { opacity: .55; cursor: not-allowed; }
button:focus-visible, [tabindex]:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.danger { background: #b93838; }
.danger:hover { background: #cc4545; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
form { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 20px; width: min(380px, 92vw); max-height: calc(100dvh - 24px); overflow: auto; }
dialog h2 { position: sticky; top: -20px; background: var(--panel); padding: 4px 0; z-index: 1; }
dialog .row { position: sticky; bottom: -20px; background: var(--panel); padding: 12px 0; z-index: 1; }
dialog.wide { width: min(560px, 94vw); }
dialog h3 { margin: 12px 0 6px; color: var(--muted); }
.batch-list { margin: 10px 0; padding-left: 20px; font-size: 13px; display: grid; gap: 6px; }
.batch-list strong { display: block; }
.preview { white-space: pre-wrap; overflow-wrap: anywhere; background: #0a1220; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12px/1.5 Consolas, "Segoe UI", monospace; max-height: 220px; overflow: auto; margin: 0; }
.bulk { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px; border: 1px solid #7a3434; border-radius: 10px; background: rgba(239, 107, 107, .06); }
.bulk p { margin: 0; flex: 1 1 200px; }
dialog::backdrop { background: rgba(5, 10, 18, .7); }
dialog form { display: block; margin: 0; }
dialog label { display: grid; gap: 4px; margin: 10px 0; color: var(--muted); }
dialog input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: inherit; }

/* ---------- Summary ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat strong { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat strong small { font-size: 15px; color: var(--muted); font-weight: 600; }
.stat .sub { color: var(--muted); font-size: 12px; }
.stat.alert { border-color: #7a3434; background: linear-gradient(180deg, rgba(239, 107, 107, .12), var(--panel)); }
.stat.alert strong { color: #ff9a9a; }

/* ---------- Source cards ---------- */
.sources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.source { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.source-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.source-head h2 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.headline { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.headline.text { font-size: 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reason { color: var(--muted); font-size: 12px; margin: 0; }
details > summary { cursor: pointer; color: var(--cyan); font-size: 12px; min-height: 36px; display: flex; align-items: center; gap: 6px; list-style: none; }
details > summary::before { content: "▸"; }
details[open] > summary::before { content: "▾"; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 4px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 14px; margin-top: 14px; align-items: stretch; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; min-width: 0; }
.layout .panel { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }

/* ---------- Map ---------- */
.zoom { display: flex; gap: 8px; align-items: center; }
.zoom button { width: 40px; padding: 6px 0; }
.map-scroll { overflow: auto; border-radius: 10px; background: #0a1220; border: 1px solid var(--line); max-height: 600px; }
canvas { display: block; margin: 0 auto; }
.agent-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.agent-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: grid; gap: 4px; background: var(--panel-2); min-width: 0; }
.agent-list .name { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- Tabs ---------- */
.tabs-panel { display: flex; flex-direction: column; }
.tablist { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; scrollbar-width: thin; }
[role="tab"] { background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; min-height: 44px; white-space: nowrap; flex: none; font-weight: 600; }
[role="tab"]:hover { background: transparent; color: var(--text); }
[role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--amber); }
.count { display: inline-block; min-width: 20px; text-align: center; border-radius: 999px; background: var(--red); color: white; font-size: 11px; padding: 1px 6px; margin-left: 4px; }
.count.zero { background: var(--line); color: var(--muted); }
[role="tabpanel"] { flex: 1 1 auto; max-height: 760px; overflow: auto; padding-right: 4px; }

/* ---------- Activity / feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; line-height: 1.35; }
.feed time b { display: block; color: var(--text); font-size: 14px; }
.feed .line { display: flex; gap: 6px 8px; align-items: center; flex-wrap: wrap; }
.feed .who { font-weight: 700; }
.feed .kind { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.feed .text { margin: 3px 0 0; color: #cfd8e4; overflow-wrap: anywhere; }
.feed .need { margin-top: 6px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feed li.flagged { background: linear-gradient(90deg, rgba(239, 107, 107, .08), transparent 60%); }
.day { margin: 14px 0 4px; font-size: 12px; color: var(--cyan); text-transform: uppercase; letter-spacing: .06em; }
.day:first-child { margin-top: 0; }
.impact { font-weight: 700; }
.impact-Tinggi { color: var(--red); }
.impact-Sederhana { color: var(--amber); }
.impact-Rendah { color: var(--muted); }
.source a, [role="tabpanel"] a { color: var(--cyan); }

/* ---------- Cards (approvals, team) ---------- */
.intro { margin: 0 0 10px; }
.approval-group { margin-top: 14px; }
.approval-group:first-of-type { margin-top: 0; }
.approval-group > h3 { display: flex; gap: 8px; align-items: center; margin: 0 0 8px; font-size: 14px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel-2); }
.card.pending { border-color: #7a3434; }
.card h3 { margin: 0 0 6px; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card h4 { margin: 0 0 8px; font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.card dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 10px; font-size: 13px; margin: 8px 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.card ul { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; }
.card input[type="text"] { width: 100%; background: #0a1220; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 6px 0; font: inherit; }
.card p { margin: 6px 0 0; }

/* ---------- System ---------- */
.health { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.health li { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel-2); }
.health li span { color: var(--muted); margin-right: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1099px) {
  .layout { grid-template-columns: 1fr; }
  .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [role="tabpanel"] { max-height: 620px; }
}
@media (max-width: 719px) {
  body { padding: 12px; }
  h1 { font-size: 19px; }
  .top-right { justify-content: flex-start; width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat strong { font-size: 22px; }
  .sources { grid-template-columns: 1fr; }
  .panel { padding: 12px; }
  .agent-list { grid-template-columns: 1fr; }
  .card dl { grid-template-columns: 1fr; gap: 0; }
  .card dd { margin-bottom: 6px; }
  .feed li { grid-template-columns: 1fr; }
  .feed time { display: flex; gap: 6px; align-items: baseline; }
  .feed time b { display: inline; }
  [role="tabpanel"] { max-height: none; overflow: visible; }
  .actions button, .row button { flex: 1 1 auto; min-height: 44px; }
  button.link, details > summary { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
