/* ============================================================
   LAYOUT — App Shell, Sidebar, Header, Bottom Nav
   ============================================================ */

.app { padding-bottom: 100px; }

/* ---------- MOBILE HEADER ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #fff;
  padding: 14px 18px 18px;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 20px rgba(15,23,42,.15);
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -.3px;
}
.brand-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10B981, #059669);
  display: grid;
  place-items: center;
  font-size: 14px;
}
.header-date {
  font-size: 12px;
  color: #94A3B8;
  font-weight: 500;
}
/* Baris label total + badge sync */
.total-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.total-label {
  font-size: 12px;
  color: #94A3B8;
  font-weight: 500;
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-bottom: 0;  /* hapus margin lama */
}
.total-amount {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-top: 2px;
  color: #34D399;
}
.total-sub {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  font-size: 12px;
  color: #CBD5E1;
}
.total-sub span b { color: #fff; font-weight: 700; }

/* ---------- PAGE ---------- */
.page {
  display: none;
  padding: 18px 16px 24px;
  animation: fade .25s ease;
}
.page.active { display: block; }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.4px;
  margin-bottom: 4px;
}
.page-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ---------- MAIN ---------- */
.main { width: 100%; }

/* ---------- BOTTOM NAV (MOBILE) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 60;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 2px;
  box-shadow: 0 -4px 20px rgba(15,23,42,.06);
}
.nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 2px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  transition: .2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  flex-shrink: 0;
}
.nav-item.active { color: var(--navy); }
.nav-item.active svg { stroke: var(--navy); }

.nav-fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10B981, #059669);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(16,185,129,.4);
  margin-top: -22px;
  flex-shrink: 0;
  font-size: 24px;
  font-weight: 300;
  transition: .2s;
}
.nav-fab:active { transform: scale(.92); }

/* ---------- SIDEBAR (hidden di mobile) ---------- */
.sidebar { display: none; }

/* ============================================================
   DESKTOP (>= 900px)
   ============================================================ */
@media (min-width: 900px) {

  body { padding-bottom: 0; background: #F8FAFC; }

  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
    padding-bottom: 0;
  }

  .bottom-nav { display: none; }
  .header { display: none; }

  /* ---------- SIDEBAR ---------- */
  .sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
    color: #fff;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -.4px;
    padding: 0 8px;
    margin-bottom: 24px;
  }
  .sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    font-size: 18px;
  }
  .sidebar-total {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 20px;
  }
  .sidebar-total .label {
    font-size: 11px;
    color: #94A3B8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
  }
  .sidebar-total .amount {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.6px;
    margin-top: 4px;
    color: #34D399;
  }
  .sidebar-total .sub {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 11px;
    color: #CBD5E1;
  }
  .sidebar-total .sub b { color: #fff; }

  .sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }
  .sidebar-menu .label {
    font-size: 10px;
    color: #64748B;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    padding: 12px 12px 6px;
  }
  .side-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 12px;
    color: #94A3B8;
    font-size: 14px;
    font-weight: 600;
    transition: .15s;
    text-align: left;
    width: 100%;
  }
  .side-link svg { width: 20px; height: 20px; stroke-width: 2; flex-shrink: 0; }
  .side-link:hover { background: rgba(255,255,255,.05); color: #fff; }
  .side-link.active {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16,185,129,.3);
  }

  .sidebar-cta {
    margin-top: 16px;
    background: linear-gradient(135deg, #10B981, #059669);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 14px;
    transition: .15s;
    box-shadow: 0 6px 16px rgba(16,185,129,.3);
    color: #fff;
  }
  .sidebar-cta:hover { transform: translateY(-2px); }
  .sidebar-cta .plus {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: rgba(255,255,255,.2);
    display: grid;
    place-items: center;
    font-size: 20px;
    font-weight: 300;
  }

  /* ---------- MAIN ---------- */
  .main {
    padding: 28px 36px 40px;
    max-width: 1500px;
    width: 100%;
  }

  /* ---------- DESKTOP TOPBAR ---------- */
  .desktop-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 20px;
  }
  .desktop-topbar .welcome h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.6px;
  }
  .desktop-topbar .welcome p {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
  }
  .desktop-topbar .actions {
    display: flex;
    gap: 10px;
    align-items: center;
  }
    .desktop-topbar .actions .btn {
    width: auto;
    padding: 11px 20px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .total-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
  }
  .total-badge b { color: #059669; font-weight: 800; }

  .icon-bell {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    font-size: 16px;
    position: relative;
  }
  .icon-bell::after {
    content: '';
    position: absolute;
    top: 8px; right: 9px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid #fff;
  }

  .user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 100px;
    background: #fff;
    border: 1px solid var(--border);
  }
  .user-pill .av {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10B981, #059669);
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 12px;
  }
  .user-pill .name { font-size: 12px; font-weight: 700; }
  .user-pill .role { font-size: 10px; color: var(--muted); }

  /* ---- FIX: cegah topbar actions kepepet & tulisan wrap ---- */
  .desktop-topbar .actions > * {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .total-badge { white-space: nowrap; }
  .total-badge b { white-space: nowrap; }
  .user-pill .name,
  .user-pill .role { white-space: nowrap; }

  .page { padding: 0; }
}

/* ---------- TABLET / SMALL DESKTOP ---------- */
@media (min-width: 900px) and (max-width: 1250px) {
  .main { padding: 22px 26px; }
}
/* ============================================================
   MENU BOTTOM SHEET
   ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .2s;
  overflow-y: auto;
}
.overlay.show { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  background: #fff;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(20px + env(safe-area-inset-bottom));
  animation: slideUp .3s cubic-bezier(.32,.72,0,1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin: 0 auto 16px;
}
.sheet-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -.3px;
}
.sheet-desc {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}
.sheet-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
  transition: .15s;
  width: 100%;
  text-align: left;
  background: #fff;
}
.sheet-option:active {
  transform: scale(.98);
  background: var(--bg);
}
.sheet-option .opt-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sheet-option .opt-icon.purple {
  background: var(--purple-soft);
  color: #7C3AED;
}
.sheet-option .opt-icon.blue {
  background: var(--blue-soft);
  color: #2563EB;
}
.sheet-option .opt-body { flex: 1; min-width: 0; }
.sheet-option .opt-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
}
.sheet-option .opt-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.sheet-option .opt-arrow {
  color: var(--muted);
  font-size: 20px;
  font-weight: 300;
  flex-shrink: 0;
}

/* Di desktop: sheet jadi modal tengah */
@media (min-width: 900px) {
  .overlay { align-items: center; padding: 20px; }
  .sheet {
    border-radius: 24px;
    max-width: 440px;
    padding: 26px;
    animation: pop .25s cubic-bezier(.34,1.56,.64,1);
  }
  @keyframes pop {
    from { transform: scale(.94); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
  }
  .sheet-handle { display: none; }
}
/* Sidebar logout */
.sidebar-logout {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(239,68,68,.1);
  color: #F87171;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .15s;
  width: 100%;
}
.sidebar-logout:hover {
  background: rgba(239,68,68,.2);
  color: #EF4444;
}
/* ============================================================
   SYNC BADGE
   ============================================================ */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  transition: .2s;
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.sync-badge .sync-dot {
  font-size: 12px;
  line-height: 1;
}

.sync-badge.synced {
  background: var(--green-soft);
  color: #059669;
  border-color: #A7F3D0;
}
.sync-badge.syncing {
  background: var(--blue-soft);
  color: #2563EB;
  border-color: #BFDBFE;
}
.sync-badge.syncing .sync-dot {
  animation: sync-pulse 1s ease-in-out infinite;
}
.sync-badge.offline {
  background: var(--orange-soft);
  color: #D97706;
  border-color: #FDE68A;
}
.sync-badge.error {
  background: var(--red-soft);
  color: #DC2626;
  border-color: #FECACA;
}
.sync-badge.idle {
  background: var(--bg);
  color: var(--muted);
  border-color: var(--border);
}

@keyframes sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}

/* Versi compact untuk mobile */
.sync-badge.compact {
  padding: 4px 8px;
  font-size: 10px;
}
.sync-badge.compact .sync-text {
  display: none;
}


/* Badge sync versi mobile header (dark background) */
.header .sync-badge {
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 100px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #94A3B8;
  letter-spacing: .2px;
}
.header .sync-badge .sync-dot { font-size: 11px; line-height: 1; }

.header .sync-badge.synced {
  background: rgba(16,185,129,.15);
  color: #34D399;
  border-color: rgba(16,185,129,.3);
}
.header .sync-badge.syncing {
  background: rgba(59,130,246,.15);
  color: #60A5FA;
  border-color: rgba(59,130,246,.3);
}
.header .sync-badge.offline {
  background: rgba(245,158,11,.15);
  color: #FBBF24;
  border-color: rgba(245,158,11,.3);
}
.header .sync-badge.error {
  background: rgba(239,68,68,.15);
  color: #F87171;
  border-color: rgba(239,68,68,.3);
}