/* ==========================================================
   Token & kerangka layout — gaya minimal & lapang.
   Prinsipnya: garis setipis mungkin, bayangan hampir tidak ada,
   ruang kosong yang banyak, warna aksen dipakai hemat.
   Mobile-first: bottom-nav dulu, sidebar muncul di >=900px.
   ========================================================== */

:root {
  /* --- netral --- */
  --bg:         #fbfbfc;
  --surface:    #ffffff;
  --surface-2:  #f7f7f8;
  --surface-3:  #f1f1f3;
  --line:       #e9e9ec;   /* garis utama, sengaja sangat tipis */
  --line-2:     #dededf;   /* garis yang perlu sedikit lebih terlihat */

  --text:       #18181b;
  --text-2:     #52525b;   /* teks pendukung */
  --muted:      #8b8b94;   /* keterangan kecil */

  /* --- aksen (dipakai hemat: nav aktif, fokus, tombol utama) --- */
  --accent:      #0f766e;
  --accent-hover:#115e59;
  --accent-soft: #f0fdfa;
  --accent-line: #99f6e4;

  /* --- status --- */
  --ok:        #15803d;
  --ok-soft:   #f0fdf4;
  --ok-line:   #bbf7d0;
  --warn:      #a16207;
  --warn-soft: #fefce8;
  --warn-line: #fde68a;
  --bad:       #b91c1c;
  --bad-soft:  #fef2f2;
  --bad-line:  #fecaca;
  --info:      #1d4ed8;
  --info-soft: #eff6ff;

  /* --- jarak: kelipatan 4 --- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;

  /* --- sudut: lebih kecil dari sebelumnya, terasa lebih rapi --- */
  --r-xs:   6px;
  --r-sm:   8px;
  --r:     10px;
  --r-lg:  12px;
  --r-full: 999px;

  /* --- bayangan: nyaris tak terlihat, kartu mengandalkan garis --- */
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, .04);
  --shadow:    0 1px 3px rgba(24, 24, 27, .06), 0 1px 2px rgba(24, 24, 27, .04);
  --shadow-lg: 0 8px 28px rgba(24, 24, 27, .10);
  --ring: 0 0 0 3px rgba(15, 118, 110, .14);

  --sidebar-w:   244px;
  --bottomnav-h: 62px;
  --topbar-h:    58px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.018em; font-weight: 600; }
p { margin: 0; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* ikon selalu sejajar dengan teks di sebelahnya */
.ico { flex: none; display: block; }

/* ---------- kerangka ---------- */
.shell { min-height: 100%; }
.main-wrap { min-height: 100vh; display: flex; flex-direction: column; }

.main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--s5) var(--s4) calc(var(--bottomnav-h) + var(--s8));
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s4);
  background: rgba(251, 251, 252, .82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; flex: 1; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s4) var(--s6); }
.brand-mark {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  background: var(--text); color: #fff;
  border-radius: var(--r-sm);
  font-weight: 700; font-size: 15px; letter-spacing: -0.02em;
}
.brand-mark.sm { width: 26px; height: 26px; font-size: 13px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em; }
.brand-text small { color: var(--muted); font-size: 12px; }

/* ---------- penukar grup ---------- */
/* Select bawaan peramban sengaja dipakai apa adanya: pemilih native jauh lebih
   enak dipakai di HP daripada dropdown buatan sendiri. */
.grup-switch { position: relative; display: flex; align-items: center; }
.grup-switch select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent;
  color: var(--muted); font-size: 12px; font-family: inherit;
  padding: 0 14px 0 0; margin: 0; height: auto; min-height: 0;
  cursor: pointer; max-width: 150px;
}
.grup-switch::after {
  content: ''; position: absolute; right: 3px; top: 50%;
  width: 5px; height: 5px; margin-top: -3px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
/* Varian topbar: selectnya bening dan menutupi kotak inisial. */
.grup-switch-mark { flex: none; }
.grup-switch-mark select {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; max-width: none; padding: 0;
}
.grup-switch-mark::after { display: none; }

/* ---------- sidebar ---------- */
.sidebar { display: none; }

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 var(--s3); }
.nav a {
  display: flex; align-items: center; gap: var(--s3);
  padding: 8px var(--s3);
  border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a .ico { color: var(--muted); transition: color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a:hover .ico { color: var(--text-2); }
.nav a.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav a.active .ico { color: var(--accent); }
/* pemisah sebelum menu sekunder (Pengaturan) */
.nav a.nav-sep { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-sm) var(--r-sm); }

/* Pintu masuk Pengaturan di topbar — hanya untuk layar kecil; di desktop
   tempatnya sudah ada di sidebar. */
.settings-link { text-decoration: none; }
.settings-link.active { color: var(--accent); background: var(--surface-2); }

.sidebar-foot { margin-top: auto; padding: var(--s4); }
.usage { font-size: 11.5px; color: var(--muted); }
.usage-label { margin-bottom: 6px; letter-spacing: -0.005em; }
.usage-track { height: 4px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.usage-fill { height: 100%; width: 0; background: var(--accent); border-radius: var(--r-full); transition: width .3s ease; }
.usage-fill.hot { background: var(--warn); }
.usage-fill.full { background: var(--bad); }
.usage-num { margin-top: 5px; font-variant-numeric: tabular-nums; }

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.bottomnav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); text-decoration: none;
  font-size: 10.5px; font-weight: 500; letter-spacing: -0.005em;
  transition: color .12s;
}
.bottomnav a.active { color: var(--accent); font-weight: 600; }

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .topbar { padding: 0 var(--s7); }
  .topbar .brand-mark, .bottomnav, .settings-link { display: none; }
  .topbar h1 { font-size: 19px; }

  .main { padding: var(--s7) var(--s7) var(--s8); }
}

/* ---------- utilitas ---------- */
.muted { color: var(--muted); font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
