/* Kerangka: sidebar (desktop), rail ikon (tablet), bar atas + menu bawah (HP). */

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: var(--s4); height: 100vh; height: 100dvh; padding: var(--s4) var(--s3); overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 var(--s1); font-weight: var(--fw-bold); font-size: var(--fs-md); white-space: nowrap; }
.brand__mark { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: var(--r); background: var(--primary); color: var(--primary-ink); }

.nav { display: grid; gap: 2px; }
.nav__group { display: grid; gap: 2px; }
.nav__group + .nav__group { margin-top: var(--s3); }
.nav__section { padding: 0 var(--s3); margin-bottom: 2px; font-size: 0.6875rem; font-weight: var(--fw-bold); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.nav__link { display: flex; align-items: center; gap: var(--s3); height: var(--control-h); padding: 0 var(--s3); border: 0; border-radius: var(--r); background: none; color: var(--ink-2); font-weight: var(--fw-medium); cursor: pointer; }
.nav__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav__link[aria-current='page'] { background: var(--primary-soft); color: var(--primary-text); font-weight: var(--fw-bold); }

.sidebar__foot { display: flex; align-items: center; gap: var(--s1); margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--line); }
.sidebar__foot .account { flex: 1; }

.account { display: flex; align-items: center; gap: var(--s2); min-width: 0; padding: 0 var(--s2); font-size: var(--fs-sm); color: var(--ink-2); }
.account:hover { color: var(--ink); text-decoration: none; }

.content { min-width: 0; }
.main { min-width: 0; padding: var(--s6) var(--s8) var(--s8); }
.main:focus { outline: none; }

.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); width: 100%; max-width: var(--content-max); margin: 0 auto; align-content: start; }
.page--form > * { width: 100%; max-width: var(--form-max); }
.page--narrow { max-width: var(--narrow-max); }
.page__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: var(--control-h); }
.page__title { display: grid; gap: 2px; min-width: 0; }
.page__head h1 { min-width: 0; font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.page__back { display: inline-flex; align-items: center; gap: 2px; width: fit-content; margin-left: -4px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--muted); }
.page__back:hover { color: var(--ink); text-decoration: none; }
.page__back .icon { width: 16px; height: 16px; }
.page__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2) var(--s3); }

/* Sub-tab bagian (HP saja; di layar lebar sidebar sudah menampilkan semua halaman) */
.subnav { display: none; }

/* Bar simpan yang menempel di bawah form panjang */
.savebar { position: sticky; bottom: var(--s3); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-pop); }
.savebar__state { font-size: var(--fs-sm); color: var(--secondary-text); }
.savebar__state:empty::before { content: 'Semua perubahan tersimpan'; color: var(--muted); }
.savebar .row { margin-left: auto; }

.topbar, .tabbar { display: none; }

/* ---------- Tablet: rail ikon ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .sidebar { padding: var(--s3) var(--s2); }
  .brand { justify-content: center; padding: 0; }
  .brand__name { display: none; }
  .sidebar .nav__link { flex-direction: column; justify-content: center; gap: 2px; height: 52px; padding: 0 2px; font-size: 0.6875rem; text-align: center; line-height: 1.2; }
  .nav__section { display: none; }
  .nav__group + .nav__group { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
  .sidebar__foot { flex-direction: column; }
  .sidebar__foot .account { flex: none; justify-content: center; height: var(--control-h-sm); }
  .sidebar__foot .account__text { display: none; }
  .sidebar__foot [data-tip]::before { display: none; } /* rail terlalu sempit untuk tooltip */
  .main { padding: var(--s5) var(--s5) var(--s8); }
}

/* ---------- HP: bar atas dan menu bawah ---------- */
@media (max-width: 720px) {
  .layout { display: block; }
  .sidebar { display: none; }

  .topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); height: var(--topbar-h); padding: 0 var(--s4); background: var(--surface); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .topbar .brand__name { display: inline; }
  .topbar .brand__mark { width: 28px; height: 28px; border-radius: var(--r-sm); }
  .topbar .account { max-width: 55%; height: 30px; padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-pill); }

  .main { padding: var(--s4) var(--s3) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s6)); }
  .page { gap: var(--s3); }
  .page__head { padding: 0 var(--s1); }
  .page__head h1 { font-size: var(--fs-lg); }

  .tabbar { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 var(--s1) env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .tabbar__item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; padding: 0; border: 0; background: none; color: var(--muted); font-size: 0.6875rem; font-weight: var(--fw-medium); cursor: pointer; }
  .tabbar__item:hover { text-decoration: none; }
  .tabbar__item .icon { width: 20px; height: 20px; }
  .tabbar__item[aria-current='page'] { color: var(--primary-text); font-weight: var(--fw-bold); }

  .subnav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; margin: 0 0 var(--s3); padding: 3px; border-radius: var(--r); background: var(--surface-2); }
  .subnav__link { display: grid; place-items: center; height: 34px; padding: 0 var(--s2); border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; }
  .subnav__link:hover { text-decoration: none; color: var(--ink); }
  .subnav__link[aria-current='page'] { background: var(--surface); color: var(--ink); font-weight: var(--fw-bold); box-shadow: var(--shadow-card); }

  .savebar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2)); padding: var(--s2) var(--s3); }
  .savebar__state { display: none; }
  .savebar .row { width: 100%; }
  .savebar .btn { flex: 1; }
}

/* Isi lembar "Lainnya" */
.dialog__body .sheet-nav { display: grid; gap: 2px; }
.sheet-nav .nav__link { justify-content: flex-start; width: 100%; height: 48px; text-align: left; }
.sheet-nav hr { width: 100%; margin: var(--s2) 0; border: 0; border-top: 1px solid var(--line); }
