:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-2: #f0eeea;
  --ink: #1c2230;
  --ink-2: #4b5363;
  --muted: #7a8090;
  --line: #e2dfd8;
  --brand: #e8641b;
  --brand-ink: #ffffff;
  --brand-soft: #fdeadd;
  --good: #1f8a4c;
  --good-soft: #dcf2e4;
  --warn: #b7791f;
  --warn-soft: #fbefd5;
  --bad: #c0392b;
  --bad-soft: #f9dfdb;
  --info: #2f6db3;
  --info-soft: #dde9f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 2px 8px rgba(20, 24, 33, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --surface-2: #262b35;
    --ink: #eceef2;
    --ink-2: #c3c8d2;
    --muted: #8b92a1;
    --line: #313744;
    --brand: #f07a36;
    --brand-soft: #3a2619;
    --good: #4cc27f;
    --good-soft: #17301f;
    --warn: #e0a548;
    --warn-soft: #33290f;
    --bad: #ef6b5c;
    --bad-soft: #3a1b18;
    --info: #6ea6e6;
    --info-soft: #182839;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.2em; margin: 0; font-size: .9rem; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Tombol & isian ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seg button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--ink-2); font-weight: 600; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px; padding: 28px 22px;
  box-shadow: var(--shadow); display: grid; gap: 14px; border: 1px solid var(--line);
}
.login-card h1 { font-size: 1.25rem; text-align: center; }
.login-card .muted { text-align: center; margin: -10px 0 4px; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; justify-self: center; }

/* ---------- Kepala & navigasi ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 8px 14px; border-radius: 999px; color: var(--ink-2); font-weight: 600; }
.tabs a.on { background: var(--brand-soft); color: var(--brand); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--ink-2); }
#whoName { color: var(--ink-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 96px; outline: none; }

@media (max-width: 720px) {
  .brand span { display: none; }
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .tabs a { flex: 1; text-align: center; }
  main { padding-top: 14px; }
}

/* ---------- Kartu & grid ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.page-title p { margin: 2px 0 0; }

.hero { display: grid; gap: 12px; }
.hero .big { font-size: 2.4rem; font-weight: 800; letter-spacing: -.02em; }
.hero .big small { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.thin { height: 6px; }

.kpi { display: grid; gap: 2px; }
.kpi b { font-size: 1.5rem; font-weight: 750; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

.tps-split { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.tps-split i { display: block; height: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }

.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; gap: 10px; align-items: center; font-size: .9rem; }
.funnel-row .bar { height: 22px; border-radius: 6px; }
.funnel-row .bar > i { border-radius: 6px; }
.funnel-row b { min-width: 92px; text-align: right; }
@media (max-width: 520px) {
  .funnel-row { grid-template-columns: 1fr auto; }
  .funnel-row .bar { grid-column: 1 / -1; grid-row: 2; }
}

.list-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }

.cta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--brand-soft); border-color: transparent; }
.cta b { font-size: 1.05rem; }

.flaglist a { display: flex; justify-content: space-between; padding: 6px 0; color: var(--ink); border-bottom: 1px dashed var(--line); font-size: .9rem; }
.flaglist a:last-child { border-bottom: 0; }

/* ---------- Tabel sebaran ---------- */
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9rem; margin-bottom: 10px; }
.crumbs a, .crumbs span { white-space: nowrap; }
.crumbs i { color: var(--muted); font-style: normal; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
th { font-size: .78rem; color: var(--ink-2); font-weight: 650; background: var(--surface); cursor: pointer; user-select: none; position: sticky; top: 0; }
thead th:first-child { z-index: 2; }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.static { cursor: default; }
tbody tr.static:hover td { background: var(--surface); }
.people .person.row { display: flex; }
tfoot td { font-weight: 700; background: var(--surface-2); border-bottom: 0; }
tfoot td:first-child { background: var(--surface-2); }
.pct { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.pct .bar { width: 56px; height: 6px; }
.pill { display: inline-block; min-width: 2.2em; padding: 1px 8px; border-radius: 999px; font-weight: 700; text-align: center; font-size: .8rem; }
.lv0 { background: var(--bad-soft); color: var(--bad); }
.lv1 { background: var(--warn-soft); color: var(--warn); }
.lv2 { background: var(--good-soft); color: var(--good); }
.hide-sm { }
@media (max-width: 720px) { .hide-sm { display: none; } }

/* ---------- Daftar orang ---------- */
.filters { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.filters .search { grid-column: 1 / -1; }
.people { display: grid; gap: 8px; }
.person {
  display: grid; gap: 6px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--ink);
}
.person:hover { border-color: var(--brand); }
.person .name { font-weight: 700; }
.person .meta { font-size: .84rem; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: .76rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- Kartu orang ---------- */
.back { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 10px; font-weight: 600; }
.contact { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.q { display: grid; gap: 8px; }
.q > span { font-weight: 650; font-size: .92rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button {
  border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: .88rem; font-weight: 600; padding: 10px 6px; min-height: 44px; cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--surface); }
.seg button.on.good { background: var(--good); color: #fff; }
.seg button.on.bad { background: var(--bad); color: #fff; }
.seg button:disabled { cursor: not-allowed; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .95rem; color: var(--ink); font-weight: 600; }
.toggle:last-child { border-bottom: 0; }
.toggle small { display: block; font-weight: 400; color: var(--muted); }
.toggle input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--brand); flex: none; }
.sub { padding: 0 0 10px 0; }
.note { font-size: .85rem; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.note.info { background: var(--info-soft); color: var(--info); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.hist { list-style: none; margin: 0; padding: 0; font-size: .84rem; display: grid; gap: 6px; }
.hist li { color: var(--ink-2); }
.hist time { color: var(--muted); margin-right: 6px; }

.two-col { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; align-items: start; } }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--bad); color: #fff; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

table.wrap td:first-child, table.wrap th:first-child { white-space: normal; min-width: 160px; position: static; }
