:root {
  --bg: #f6f7f5; --panel: #ffffff; --text: #1d2521; --muted: #66716b; --line: #e2e6e3;
  --brand: #1f8a3b; --brand-ink: #ffffff; --brand-soft: #e6f4ea;
  --warn: #9a6700; --warn-soft: #fff4d6; --err: #b42318; --err-soft: #fde8e7;
  --info: #1f5fbf; --info-soft: #e7effc; --gray-soft: #eef0ee;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 20, .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --panel: #181e1b; --text: #e6ebe8; --muted: #9aa59f; --line: #2a332e;
    --brand: #3fb660; --brand-ink: #0b1a10; --brand-soft: #173222;
    --warn: #f2c14e; --warn-soft: #3a2f10; --err: #ff8a80; --err-soft: #3d1a17;
    --info: #8ab4ff; --info-soft: #182840; --gray-soft: #232b27;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.warn { color: var(--warn); }

.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 1.1rem; }
.brand span, .login h1 span { color: var(--brand); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.topbar nav a[aria-current] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.who { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.who strong { color: var(--text); }
.who form { margin: 0; }

button, .button { font: inherit; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
a.button { display: inline-block; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
button.link { border: 0; background: none; color: var(--brand); padding: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid2 { display: grid; gap: 16px; grid-template-columns: 1.3fr 1fr; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats dd a { text-decoration: none; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 500px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }

.alert { padding: 10px 12px; border-radius: 8px; }
.alert.ok { background: var(--brand-soft); color: var(--brand); }
.alert.error { background: var(--err-soft); color: var(--err); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem;
  background: var(--gray-soft); color: var(--muted); white-space: nowrap; }
.st-closed, .fu-selesai { background: var(--brand-soft); color: var(--brand); }
.st-awaiting_confirmation, .fu-baru { background: var(--warn-soft); color: var(--warn); }
.fu-dihubungi, .fu-terjadwal { background: var(--info-soft); color: var(--info); }
.st-error, .fu-batal { background: var(--err-soft); color: var(--err); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label { min-width: 140px; }
.filters .grow { flex: 1 1 200px; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table.leads { width: 100%; border-collapse: collapse; font-size: .9rem; }
.leads th, .leads td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.leads th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--gray-soft); }
.leads tbody tr:hover { background: var(--gray-soft); }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; padding: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--panel);
  border: 1px dashed var(--line); border-radius: var(--radius); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand); }
.timeline time { color: var(--muted); font-size: .85rem; margin-right: 6px; }

.login { max-width: 360px; margin: 10vh auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin-bottom: 0; }
.htmx-request #tabel, #tabel.htmx-request { opacity: .6; transition: opacity .2s; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; }
.field-error { color: var(--err); font-size: .82rem; }
tr.inactive td { opacity: .55; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--err); color: #fff; font-size: .72rem; text-align: center; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; }
button.danger { color: var(--err); border-color: var(--err); background: none; }
pre.context { white-space: pre-wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; font-size: .82rem; line-height: 1.55; max-height: 70vh; overflow: auto; }
.topbar nav { flex-wrap: wrap; }
