:root {
  --paper: #eef1ec;
  --surface: #ffffff;
  --ink: #16211e;
  --muted: #5a6a64;
  --line: #d6ded7;
  --line-strong: #b9c6be;
  --accent: #0b6b57;
  --accent-deep: #084d40;
  --accent-soft: #ddeae4;
  --warn: #9a5b08;
  --danger: #9c2e24;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 5px;
  --shadow: 0 1px 0 rgba(22, 33, 30, .04), 0 8px 24px -18px rgba(22, 33, 30, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wordmark {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
}
.wordmark--small { font-size: 17px; }

/* ---------- login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login__panel {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 32px 28px 24px;
  box-shadow: var(--shadow);
}

.login__head { margin-bottom: 24px; }
.login__lede {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 32ch;
}

.login__form { display: grid; gap: 10px; }

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

input[type="password"],
input[type="search"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
}

input::placeholder { color: #8a9993; }

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  background: none;
  color: var(--ink);
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.primary:hover { background: var(--accent-deep); }
.primary:disabled { background: var(--line-strong); border-color: var(--line-strong); cursor: not-allowed; }

.ghost {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}
.ghost:hover { border-color: var(--accent); color: var(--accent-deep); }
.ghost:disabled { color: #8a9993; border-color: var(--line); cursor: not-allowed; }

.form-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.login__foot {
  margin: 24px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar__brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar__sep { width: 1px; height: 20px; background: var(--line-strong); }

.tabs { display: flex; gap: 2px; }

.tab {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-radius: var(--radius);
}
.tab:hover { color: var(--ink); background: var(--paper); }
.tab.is-active {
  color: var(--accent-deep);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ---------- layout ---------- */

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.view { display: block; }

#view-cari {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas:
    "search search"
    "meta meta"
    "results detail";
  gap: 16px 24px;
  align-items: start;
}

.search { grid-area: search; display: flex; gap: 10px; align-items: stretch; }

.search__field {
  flex: 1;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.search__field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.search__field input[type="search"] {
  border: 0;
  border-radius: 0;
  background: transparent;
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
}
.search__field input:focus-visible { outline: none; }

.search__field select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-left: 1px solid var(--line);
  padding: 0 10px;
  cursor: pointer;
}

.result-meta {
  grid-area: meta;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.result-meta strong { color: var(--ink); font-weight: 600; }

.results { grid-area: results; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.results[hidden] { display: none; }

/* ---------- tabel ledger ---------- */

table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.ledger thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--paper);
  border-bottom: 1px solid var(--line-strong);
  padding: 8px 12px;
  white-space: nowrap;
}

.ledger tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
.ledger tbody tr:last-child td { border-bottom: 0; }

.ledger tbody tr { cursor: pointer; }
.ledger tbody tr:hover { background: #f7f9f6; }
.ledger tbody tr.is-selected { background: var(--accent-soft); }
.ledger tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.ledger tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.ledger .num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.name-cell { font-weight: 600; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  border: 1px solid var(--line-strong);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}
.tag--ok { color: var(--accent-deep); border-color: #b7d3c9; background: var(--accent-soft); }
.tag--no { color: var(--danger); border-color: #e2c3bf; background: #f8ecea; }
.tag--warn { color: var(--warn); border-color: #e6d3b6; background: #faf2e4; }

/* ---------- slip detail ---------- */

.slip {
  grid-area: detail;
  position: sticky;
  top: 76px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 2px dashed var(--line-strong);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 20px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.slip__placeholder { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 34ch; }

.slip__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.slip__no {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.slip__name { margin: 2px 0 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }

.slip__section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.slip__section h3 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 5px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv dd.plain { font-family: var(--sans); font-weight: 500; }

.slip__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.slip__actions button { padding: 7px 12px; font-size: 13px; }

.slip__text {
  margin: 8px 0 0;
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  background: #f7f9f6;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- statistik ---------- */

.stats { display: grid; gap: 28px; }

.stats__numbers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}
.stats__cell { padding: 16px 18px 14px; border-left: 1px solid var(--line); }
.stats__cell:first-child { border-left: 0; padding-left: 0; }
.stats__value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.stats__label { margin-top: 4px; font-size: 12.5px; color: var(--muted); }

.stats__list { max-width: 640px; }
.stats__list h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.bar-row { display: grid; grid-template-columns: 160px 1fr 44px; gap: 12px; align-items: center; padding: 5px 0; font-size: 13px; }
.bar-row__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { height: 8px; background: var(--paper); border-radius: 2px; overflow: hidden; }
.bar-row__fill { height: 100%; background: var(--accent); }
.bar-row__n { font-family: var(--mono); text-align: right; color: var(--muted); }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: 0 10px 30px -12px rgba(22, 33, 30, .6);
  z-index: 50;
}
.toast[hidden] { display: none; }

/* ---------- responsif ---------- */

@media (max-width: 900px) {
  #view-cari {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "search" "meta" "results" "detail";
  }
  .slip { position: static; max-height: none; }
  .stats__numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats__cell:nth-child(odd) { border-left: 0; padding-left: 0; }
}

@media (max-width: 640px) {
  .shell { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .search { flex-wrap: wrap; }
  .search__field { flex-basis: 100%; }
  .bar-row { grid-template-columns: 110px 1fr 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
