/* Komponen bersama (Material 3). */
.page { padding: 4px 16px 24px; }
.has-navbar .page { padding-bottom: calc(var(--navbar-h) + 96px + var(--safe-b)); }

/* Top app bar */
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 4px;
  min-height: calc(var(--appbar-h) + var(--safe-t)); padding: var(--safe-t) 4px 0 16px;
  background: var(--bg); transition: background .2s var(--ease);
}
.appbar.has-back { padding-left: 4px; }
.appbar h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.375rem; font-weight: 500; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.scrolled .appbar { background: var(--surface-2); }

/* Ikon & tombol */
.ic { width: 24px; height: 24px; display: block; flex: none; }
.icon-btn { position: relative; display: inline-grid; place-items: center; flex: none; width: 48px; height: 48px;
  border-radius: 50%; color: var(--ink-2); transition: background .15s var(--ease); }
.icon-btn:hover { background: rgb(68 71 70 / .08); }
.icon-btn:active { background: rgb(68 71 70 / .14); }
.icon-btn:disabled { color: rgb(31 31 31 / .3); background: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 24px;
  border-radius: 999px; font-size: .875rem; font-weight: 500; letter-spacing: .01em; white-space: nowrap;
  transition: background .15s var(--ease), box-shadow .15s var(--ease), transform .1s; }
.btn .ic { width: 18px; height: 18px; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-filled { background: var(--primary); color: var(--on-primary); }
.btn-filled:hover { background: var(--primary-hover); box-shadow: var(--shadow-1); }
.btn-filled:active { background: var(--primary-press); }
.btn-filled:disabled { background: rgb(31 31 31 / .12); color: rgb(31 31 31 / .38); box-shadow: none; }
.btn-tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn-tonal:hover { box-shadow: var(--shadow-1); }
.btn-outlined { border: 1px solid var(--outline-strong); color: var(--primary); }
.btn-text, .btn-danger { padding: 0 12px; color: var(--primary); }
.btn-danger { color: var(--danger); }
.btn-text:hover, .btn-outlined:hover { background: rgb(34 78 89 / .08); }
.btn-danger:hover { background: rgb(179 38 30 / .08); }
.btn-block { width: 100%; min-height: 48px; font-size: 1rem; }
.btn[aria-busy="true"] { opacity: .7; pointer-events: none; }

/* Extended FAB */
.fab { position: fixed; z-index: 25; right: max(16px, calc(50vw - var(--maxw) / 2 + 16px));
  bottom: calc(var(--navbar-h) + 16px + var(--safe-b)); display: inline-flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px 0 16px; border-radius: 16px; background: var(--primary-container);
  color: var(--on-primary-container); font-size: .9375rem; font-weight: 500; box-shadow: var(--shadow-3);
  transition: transform .1s, box-shadow .2s; }
.fab:active { transform: scale(.97); }

/* Navigation bar */
.navbar { position: fixed; z-index: 30; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, var(--maxw));
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); min-height: calc(56px + 1rem + var(--safe-b));
  padding: 8px 8px calc(8px + var(--safe-b)); background: var(--surface);
  border-top: 1px solid var(--outline-soft); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 48px;
  border-radius: 12px; color: var(--ink-2); touch-action: manipulation;
    font-size: .75rem; line-height: 1rem; font-weight: 500; letter-spacing: 0; min-width:0; text-align:center; overflow-wrap:anywhere; }
.nav-icon { display:grid; place-items:center; flex:none; width:24px; height:24px; }
.nav-item[aria-current="page"] { color:var(--primary); font-weight:700; }
.nav-item[aria-current="page"] .nav-icon svg { fill:var(--accent-container); }

/* Kartu, judul bagian, daftar */
.card { background: var(--surface); border-radius: var(--radius-l); padding: 16px; }
.card + .card { margin-top: 12px; }
.section-title { margin: 24px 4px 8px; font-size: .875rem; font-weight: 500; color: var(--ink-2); }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-l); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--outline-soft); }

/* Chip filter / pilihan */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 1px solid var(--outline-strong); border-radius: 8px; background: var(--surface); color: var(--ink-2);
  font-size: .875rem; font-weight: 500; white-space: nowrap; }
.chip .ic { width: 18px; height: 18px; display: none; }
.chip[aria-pressed="true"], .chip[aria-checked="true"] { border-color: transparent; background: var(--primary-container);
  color: var(--on-primary-container); }
.chip[aria-pressed="true"] .ic, .chip[aria-checked="true"] .ic { display: block; margin-left: -4px; }

/* Status: badge, titik, bar range */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge.tone-green { background: var(--green-tint); color: var(--green-ink); }
.badge.tone-yellow { background: var(--amber-tint); color: var(--amber-ink); }
.badge.tone-none { background: var(--surface-2); color: var(--ink-3); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.tone-green { background: var(--green); }
.dot.tone-yellow { background: var(--amber); }
.dot.tone-none { box-shadow: inset 0 0 0 2px var(--outline-strong); }
.rangebar { position: relative; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.rangebar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: var(--green); }
.rangebar.tone-yellow i { background: var(--amber); }

/* Cincin progres (Google Fit) */
.ring-wrap { position: relative; display: grid; place-items: center; flex: none; }
.ring { display: block; }
.ring-track { stroke: var(--track); }
.ring-green { stroke: var(--green); }
.ring-yellow { stroke: var(--amber); }
.ring-arc { animation: ring-draw 1.1s var(--ease-out) both; }
@keyframes ring-draw { from { stroke-dasharray: 0 1000; } }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-center b { font-size: 1.5rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.ring-center small { font-size: .75rem; color: var(--ink-3); }

/* Field, stepper, segmented */
.field { display: block; }
.field-label { display: block; margin: 0 0 6px 4px; font-size: .875rem; font-weight: 500; color: var(--ink-2); }
.input { width: 100%; height: 56px; padding: 0 16px; border: 1px solid var(--outline-strong); border-radius: 12px;
  background: var(--surface); font-size: 1rem; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.field-help { margin: 6px 4px 0; font-size: .75rem; line-height: 1.4; color: var(--ink-3); }
.field-error { margin: 6px 4px 0; font-size: .8125rem; font-weight: 500; color: var(--danger); }
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; }
.stepper .input { height: 64px; text-align: center; font-size: 2rem; font-weight: 500; font-variant-numeric: tabular-nums; appearance: textfield; }
.stepper .input::-webkit-inner-spin-button, .stepper .input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--ink); }
.step-btn:active { background: var(--surface-3); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; height: 48px; border: 1px solid var(--outline-strong); border-radius: 999px; overflow: hidden; }
.seg { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: .9375rem; font-weight: 500; }
.seg + .seg { border-left: 1px solid var(--outline-strong); }
.seg .ic { width: 18px; height: 18px; display: none; }
.seg[aria-checked="true"] .ic { display: block; }
.seg.tone-green[aria-checked="true"] { background: var(--green-tint); color: var(--green-ink); }
.seg.tone-yellow[aria-checked="true"] { background: var(--amber-tint); color: var(--amber-ink); }

/* Dialog */
dialog { padding: 0; border: 0; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: rgb(31 31 31 / .32); }

/* Snackbar, banner, empty, loading */
.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(var(--toast-b, 16px) + var(--safe-b));
  width: min(calc(100% - 32px), calc(var(--maxw) - 32px)); padding: 14px 16px; border-radius: 8px;
  background: var(--snackbar); color: var(--on-snackbar); font-size: .875rem; line-height: 1.43; box-shadow: var(--shadow-3);
  opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .2s var(--ease), transform .25s var(--ease-out); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.has-navbar { --toast-b: calc(var(--navbar-h) + 88px); }
.banner { display: flex; align-items: center; gap: 12px; margin: 0 0 12px; padding: 12px 16px; border-radius: var(--radius-m);
  background: var(--amber-tint); color: var(--amber-ink); font-size: .875rem; }
.ui-notice { display:flex; align-items:flex-start; gap:8px; padding:12px; border-radius:12px; font-size:.875rem; line-height:1.45; }
.ui-notice > .ic { flex:none; width:20px; height:20px; }
.ui-notice > span { min-width:0; overflow-wrap:anywhere; }
.ui-notice-info { background:var(--primary-container); color:var(--on-primary-container); }
.ui-notice-warning { background:var(--amber-tint); color:var(--amber-ink); }
.ui-notice-error { background:var(--danger-tint); color:var(--danger); }
.empty { padding: 40px 24px; text-align: center; color: var(--ink-2); }
.empty h2 { margin: 16px 0 8px; font-size: 1.375rem; font-weight: 400; color: var(--ink); }
.empty p { margin: 0 auto 24px; max-width: 32ch; font-size: .875rem; }
.shimmer { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.pwa-install-snackbar,.pwa-install-banner{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;min-height:56px;padding:4px 4px 4px 12px;border-radius:8px;background:var(--primary);color:var(--on-primary);font-size:.875rem;line-height:1.5}
.pwa-install-snackbar[hidden],.pwa-install-banner[hidden]{display:none}
[data-pwa-install][hidden]{display:none}
.pwa-install-snackbar{position:fixed;z-index:35;left:50%;transform:translateX(-50%);width:min(calc(100% - 32px),calc(var(--maxw) - 32px));bottom:calc(var(--safe-b) + 16px);box-shadow:var(--shadow-3)}
.has-navbar .pwa-install-snackbar{bottom:calc(var(--navbar-h) + var(--safe-b) + 16px)}
.pwa-install-banner{margin:16px 0}
.pwa-install-snackbar p,.pwa-install-banner p{margin:0}
.pwa-install-actions{display:flex;justify-content:flex-end;flex-wrap:wrap;flex:none;max-width:100%;gap:0;margin:0 0 0 auto}
.pwa-install-snackbar p,.pwa-install-banner p{flex:1 1 90px;overflow-wrap:anywhere}
.pwa-promo-visible .fab{bottom:calc(var(--navbar-h) + var(--safe-b) + var(--pwa-promo-height,112px) + 32px)}
.pwa-install-guide{display:grid;gap:16px;font-size:1rem;line-height:1.6}
.pwa-install-guide ol{margin:0;padding-inline-start:24px}
.pwa-install-guide li+li{margin-top:12px}
.pwa-install-snackbar.pwa-install-inline{position:static;transform:none;width:100%;margin:16px 0;box-shadow:none}
