:root {
  color-scheme: light dark;
  --ground: #f4f6f7; --card: #ffffff; --ink: #17262b; --muted: #55676d; --line: #d5dee0;
  --brand: #1f5c57; --on-brand: #ffffff; --tint: #e6f0ee; --danger: #b3261e; --on-danger: #ffffff;
  --healthy: #11603c; --healthy-bg: #dff3e7; --safe: #714b00; --safe-bg: #fbefcf; --unhealthy: #98201a; --unhealthy-bg: #fbe3e1;
  --tabs: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #10191e; --card: #19252b; --ink: #e6eef0; --muted: #a3b4ba; --line: #33454c;
    --brand: #7fc7be; --on-brand: #0c2623; --tint: #1f3635; --danger: #f2a39d; --on-danger: #3b0906;
    --healthy: #8fddb3; --healthy-bg: #173b2a; --safe: #f1cd7e; --safe-bg: #3d3115; --unhealthy: #f5aaa5; --unhealthy-bg: #46201e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.5 system-ui, sans-serif; -webkit-text-size-adjust: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(var(--tabs) + 72px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
main { max-width: 640px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; outline: none; }
h1 { font-size: 22px; line-height: 1.3; margin: 0; }
h2 { font-size: 16px; line-height: 1.4; margin: 0; }
p { margin: 0; }
.muted, .hint { color: var(--muted); }
.hint { font-size: 14px; }
.error { color: var(--unhealthy); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 14px; min-width: 0; }

.field { display: grid; gap: 6px; min-width: 0; align-content: end; }
.label { font-size: 14px; font-weight: 600; }
.pair, .trio { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.trio { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); }
/* 16px mencegah iPhone memperbesar layar saat mengetik. */
input { width: 100%; min-width: 0; min-height: 48px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); background: var(--ground); border: 1px solid var(--line); border-radius: 8px; }
input::placeholder { color: var(--muted); opacity: .75; }
.affix { position: relative; display: block; }
.affix input { padding-left: 40px; font-variant-numeric: tabular-nums; }
.affix.percent input { padding: 0 30px 0 12px; }
.unit { position: absolute; left: 12px; top: 0; line-height: 48px; color: var(--muted); pointer-events: none; }
.percent .unit { left: auto; right: 10px; }

button { font: inherit; min-height: 48px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; cursor: pointer; touch-action: manipulation; color: var(--ink); background: none; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand); color: var(--on-brand); }
button.secondary { border-color: var(--line); background: var(--card); }
button.danger { background: var(--danger); color: var(--on-danger); }
button.text { padding: 0 8px; color: var(--brand); }
button.danger-text { color: var(--unhealthy); }
button.icon { width: 48px; padding: 0; font-size: 22px; color: var(--muted); align-self: end; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
main:focus-visible { outline: none; }

.scenarios { display: grid; gap: 12px; }
.scenario { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.scenario.selected { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.scenario-inputs { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 12px; }
.scenario-result { width: 100%; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: var(--tint); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 12px; font-weight: 400; text-align: left; font-variant-numeric: tabular-nums; }
.scenario-result:disabled { opacity: 1; background: none; }
.scenario-result:focus-visible { outline-offset: -3px; }
.badge { display: inline-block; justify-self: start; padding: 2px 8px; border-radius: 6px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.badge.healthy { color: var(--healthy); background: var(--healthy-bg); }
.badge.safe { color: var(--safe); background: var(--safe-bg); }
.badge.unhealthy { color: var(--unhealthy); background: var(--unhealthy-bg); }

dl { margin: 0; }
dl > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); }
dd { margin: 0 0 0 auto; font-variant-numeric: tabular-nums; }
.total dt, .total dd { color: var(--ink); font-weight: 700; }
.actions, .stack, .list { display: grid; gap: 12px; }
.empty { justify-items: start; }
.record { padding: 0; gap: 0; overflow: hidden; }
.record-open { display: grid; gap: 4px; padding: 14px 16px; text-align: left; font-weight: 400; overflow-wrap: anywhere; }
.record-open:focus-visible { outline-offset: -3px; }
.record-result { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.record-actions { display: flex; justify-content: flex-end; border-top: 1px solid var(--line); padding: 0 8px; }

.tabs, .summary { position: fixed; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); }
.tabs { bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); z-index: 2; }
.tabs button { min-height: var(--tabs); border-radius: 0; padding: 0 4px; color: var(--muted); font-size: 15px; }
.tabs [aria-current] { color: var(--brand); box-shadow: inset 0 3px var(--brand); }
.summary { bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); z-index: 1; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 14px; min-height: 48px; padding: 8px 16px; font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs) + 76px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px; padding: 12px 16px; border-radius: 10px; background: var(--ink); color: var(--ground); z-index: 3; }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; max-width: 608px; margin: 16px auto 0; width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px; background: var(--tint); }
.banner p { flex: 1 1 200px; }
dialog { width: min(420px, calc(100% - 32px)); border: 0; border-radius: 14px; padding: 20px; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog[open] { display: grid; gap: 12px; }
dialog p { overflow-wrap: anywhere; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.installing { padding-bottom: env(safe-area-inset-bottom); }
.install-head { display: grid; justify-items: center; gap: 12px; padding-top: 24px; text-align: center; }
ol { margin: 0; padding-left: 24px; display: grid; gap: 8px; }
