:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --border: #dde3ec;
  --text: #1b2433;
  --muted: #5d6b80;
  --primary: #1d4f91;
  --primary-ink: #ffffff;
  --primary-soft: #e3ecf8;
  --ok: #1f7a4d;      --ok-soft: #e0f2e9;
  --warn: #9a6200;    --warn-soft: #fbefd6;
  --bad: #b3261e;     --bad-soft: #f9e1df;
  --grey-soft: #e9edf2;
  --c-lsp: #1d4f91;
  --c-dudi: #2a9d8f;
  --c-tanpa: #e09f3e;
  --c-belum: #c5ccd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11151c; --surface: #1a2029; --surface-2: #222a35; --border: #2f3946;
    --text: #e6ebf2; --muted: #9aa7b8; --primary: #7fb0f0; --primary-ink: #0d1520; --primary-soft: #1f2f45;
    --ok: #6fd3a0; --ok-soft: #173327; --warn: #f0c060; --warn-soft: #3a2f15; --bad: #ff8a80; --bad-soft: #3d1d1b;
    --grey-soft: #2a323d; --c-lsp: #7fb0f0; --c-dudi: #5fd1c1; --c-tanpa: #f0b860; --c-belum: #4a5563;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11151c; --surface: #1a2029; --surface-2: #222a35; --border: #2f3946;
  --text: #e6ebf2; --muted: #9aa7b8; --primary: #7fb0f0; --primary-ink: #0d1520; --primary-soft: #1f2f45;
  --ok: #6fd3a0; --ok-soft: #173327; --warn: #f0c060; --warn-soft: #3a2f15; --bad: #ff8a80; --bad-soft: #3d1d1b;
  --grey-soft: #2a323d; --c-lsp: #7fb0f0; --c-dudi: #5fd1c1; --c-tanpa: #f0b860; --c-belum: #4a5563;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.topbar {
  background: var(--primary); color: var(--primary-ink);
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; }
.topbar .brand small { display: block; font-weight: 400; opacity: .85; font-size: .78rem; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: var(--primary-ink); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.demo-banner {
  background: var(--warn-soft); color: var(--warn); text-align: center;
  padding: 6px 16px; font-size: .85rem; border-bottom: 1px solid var(--border);
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
}
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: .8rem; }

/* ---------- form ---------- */
label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

/* ---------- chips ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.grey { background: var(--grey-soft); color: var(--muted); }
.chip.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: var(--muted); position: sticky; top: 0; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ---------- progress & bars ---------- */
.progress { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > span { display: block; height: 100%; background: var(--ok); }
.stackbar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--c-belum); min-width: 120px; }
.stackbar > span { height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 70px; gap: 8px; align-items: center; font-size: .88rem; margin: 6px 0; }
.hbar .track { background: var(--grey-soft); border-radius: 4px; height: 14px; overflow: hidden; }
.hbar .track span { display: block; height: 100%; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button[aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- KK card (SMK) ---------- */
.kk { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; }
.kk.excluded { opacity: .7; background: var(--surface-2); }
.kk-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.kk-title { font-weight: 700; }
.kk-form { display: grid; grid-template-columns: 1.2fr 1fr 1.6fr auto; gap: 10px; margin-top: 12px; align-items: end; }
@media (max-width: 820px) { .kk-form { grid-template-columns: 1fr; } }
.kk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.program-head { margin: 22px 0 8px; font-size: .9rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 25, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); color: var(--text); border-radius: 12px; width: 100%; max-width: 720px; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 1000px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 60; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: .9rem; }
.alert.info { background: var(--primary-soft); color: var(--text); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--text); }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--border); padding: 0 0 14px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* ---------- login ---------- */
.login { max-width: 460px; margin: 6vh auto; padding: 0 16px; }
.login .hero { text-align: center; margin-bottom: 20px; }
.login .hero h1 { font-size: 1.5rem; }
.role-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.role-tabs button { border: 0; background: none; padding: 9px 4px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.role-tabs button[aria-selected=true] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.hidden { display: none !important; }
