:root {
  --primary: #2563eb;         /* electric blue */
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --navy: #0f172a;
  --warning-orange: #f97316;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-h: 60px;
  --bottomnav-h: 64px;
  --sidebar-w: 262px;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding-bottom: calc(var(--bottomnav-h) + 8px);
}

/* ── Layout Shell ── */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0;
  background: var(--navy); color: white; z-index: 200; overflow: hidden;
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  transform: translateX(-100%); transition: transform .25s ease, width .2s ease;
}
.app-sidebar.open { transform: translateX(0); }
.app-content { flex: 1; min-width: 0; }
.app-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190; }
.app-overlay.open { display: block; }

@media (min-width: 992px) {
  .app-sidebar { transform: translateX(0); }
  .app-content { margin-left: var(--sidebar-w); transition: margin-left .2s ease; }
  .app-overlay { display: none !important; }
  .bottom-nav { display: none !important; }
  .container-page { max-width: 1140px; padding: 28px 24px; }
}
@media (max-width: 991.98px) {
  .container-page { max-width: 100%; padding: 16px; }
}

/* ── Topbar ── */
.app-topbar {
  height: var(--topbar-h); background: white; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  position: sticky; top: 0; z-index: 150;
}
.topbar-toggle { border: none; background: var(--primary-light); color: var(--primary); width: 38px; height: 38px; border-radius: 10px; }

/* ── Sidebar nav items ── */
.sidebar-brand { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); font-weight: 800; font-size: 15px; }
.sidebar-nav { padding: 12px 10px; }
.sidebar-section { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.4); padding: 14px 10px 6px; }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.8); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.sidebar-item:hover { background: rgba(255,255,255,.07); color: white; }
.sidebar-item.active { background: rgba(255,255,255,.14); color: white; box-shadow: inset 3px 0 0 #60a5fa; font-weight: 700; }
.sidebar-item i { width: 18px; text-align: center; }

/* ── Bottom Navigation (mobile) ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h);
  background: white; border-top: 1px solid var(--border); z-index: 180;
  display: flex; align-items: center; justify-content: space-around;
}
.bottom-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-muted); text-decoration: none; font-size: 10.5px; font-weight: 600; flex: 1; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item i { font-size: 18px; }
.bottom-nav-item { position: relative; }
.bottom-nav-item .bottom-nav-lock { position: absolute; top: -4px; left: calc(50% + 8px); font-size: 9px; opacity: .6; }
.bottom-nav-fab {
  width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 20px; margin-top: -26px;
  box-shadow: 0 4px 14px rgba(37,99,235,.4); border: 4px solid white;
}

/* ── Cards ── */
.card-app { background: white; border-radius: var(--radius); border: 1px solid var(--border); }
.card-app-pad { padding: 18px; }
.hero-balance { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: var(--radius); padding: 20px; }

/* ── Quick Action Sheet (bottom "+") ── */
.action-sheet { position: fixed; inset: 0; z-index: 300; display: none; }
.action-sheet.open { display: block; }
.action-sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.action-sheet-panel {
  position: absolute; bottom: 0; left: 0; right: 0; background: white;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + var(--bottomnav-h));
  max-height: 85vh; overflow-y: auto;
}
.action-sheet-item { display: flex; align-items: center; gap: 14px; padding: 14px 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); }
.action-sheet-item:last-child { border-bottom: none; }
.action-sheet-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; }

/* ── Stat cards ── */
.stat-card { background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat-card .stat-value { font-size: 20px; font-weight: 800; color: var(--text); }
.stat-card .stat-label { font-size: 11.5px; color: var(--text-muted); }

/* ── Progress bar ── */
.progress-thin { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.progress-thin > div { height: 100%; background: var(--primary); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state i { font-size: 34px; margin-bottom: 10px; opacity: .5; }

/* ── Table responsive → card on mobile ── */
@media (max-width: 767.98px) {
  table.table-responsive-cards thead { display: none; }
  table.table-responsive-cards, table.table-responsive-cards tbody, table.table-responsive-cards tr, table.table-responsive-cards td { display: block; width: 100%; }
  table.table-responsive-cards tr { margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
  table.table-responsive-cards td { border: none; padding: 6px 0; }
  table.table-responsive-cards td::before { content: attr(data-label); font-weight: 700; display: block; font-size: 11px; color: var(--text-muted); }
}

/* ── Large screen guard ── */
@media (min-width: 1440px) {
  .container-page { max-width: 1280px; margin: 0 auto; }
}

/* ── Belanja Produk (member/shop.php) ── */
.shop-chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.shop-chip-row::-webkit-scrollbar { display: none; }
.shop-chip { display: inline-block; padding: 6px 12px; border-radius: 20px; font-size: 12.5px; white-space: nowrap; text-decoration: none; border: 1px solid var(--border); color: inherit; background: white; }
.shop-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.shop-thumb { position: relative; height: 130px; background: var(--primary-light); border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.shop-thumb img { width: 100%; height: 100%; object-fit: cover; }
.shop-badge { position: absolute; top: 8px; left: 8px; font-size: 10.5px; }

/* ── v1.14: sidebar berkelompok (details/summary) ── */
.sidebar-group { margin: 2px 0; }
.sidebar-group > summary { list-style: none; cursor: pointer; }
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group-title { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.85); font-size: 13.5px; font-weight: 700; user-select: none; }
.sidebar-group-title:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-group-name { flex: 1; display: flex; align-items: center; gap: 10px; }
.sidebar-group-name i { width: 18px; text-align: center; }
.sidebar-group-badge { font-size: 10px; }
.sidebar-chevron { font-size: 10px; opacity: .6; transition: transform .2s ease; }
.sidebar-group[open] > summary .sidebar-chevron { transform: rotate(180deg); }
.sidebar-group-items { padding: 2px 0 6px 10px; margin-left: 18px; border-left: 1px solid rgba(255,255,255,.12); }
.sidebar-group-items .sidebar-item { padding: 8px 10px; font-size: 13px; font-weight: 500; }
.sidebar-item .badge { font-size: 10px; }
.sidebar-lock { font-size: 11px; opacity: .55; }
/* v1.41.2: menu terkunci tampil redup supaya yang bisa dipakai langsung terlihat; terang lagi saat disentuh/hover */
.sidebar-item-locked { opacity: .6; }
.sidebar-item-locked:hover, .sidebar-item-locked.active { opacity: 1; }
/* v1.41.2: kotak cari menu (admin) */
.sidebar-search { position: relative; margin: 0 2px 10px; }
.sidebar-search input { width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 10px; color: #fff; font-size: 13px; padding: 8px 12px 8px 32px; outline: none; }
.sidebar-search input::placeholder { color: rgba(255,255,255,.45); }
.sidebar-search input:focus { border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.12); }
.sidebar-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; color: rgba(255,255,255,.5); pointer-events: none; }
.sidebar-search-empty { display: none; color: rgba(255,255,255,.5); font-size: 12.5px; padding: 8px 12px; }
.sidebar-logout:hover { color: #fca5a5; }

/* ── v1.62: sidebar — kartu profil, Perlu tindakan, Favorit, pencarian, mode ciut ── */
.sidebar-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sidebar-brand-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.sidebar-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; border: 0; border-radius: 9px;
  background: transparent; color: rgba(255,255,255,.65); font-size: 13px; text-decoration: none; cursor: pointer; }
.sidebar-iconbtn:hover, .sidebar-iconbtn:focus-visible { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-iconbtn.on { background: rgba(96,165,250,.22); color: #93c5fd; }
.sidebar-row { display: flex; align-items: center; position: relative; }
.sidebar-row > .sidebar-item { flex: 1; min-width: 0; }
.sidebar-row.kbd-focus > .sidebar-item { background: rgba(96,165,250,.2); box-shadow: inset 0 0 0 1px rgba(96,165,250,.55); }
.sidebar-search input { padding-right: 30px; }
.sidebar-kbd { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font: 600 11px/1 ui-monospace, monospace; color: rgba(255,255,255,.45);
  border: 1px solid rgba(255,255,255,.2); border-radius: 5px; padding: 3px 6px; pointer-events: none; }
@media (max-width: 991.98px) { .sidebar-kbd { display: none; } }
.sidebar-todo { margin: 0 2px 8px; background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.28); border-radius: 12px; }
.sidebar-todo > summary { list-style: none; cursor: pointer; }
.sidebar-todo > summary::-webkit-details-marker { display: none; }
.sidebar-todo-title { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 13px; font-weight: 700; color: #fecaca; user-select: none; }
.sidebar-todo-name { flex: 1; display: flex; align-items: center; gap: 10px; }
.sidebar-todo-name i { width: 18px; text-align: center; }
.sidebar-todo[open] > summary .sidebar-chevron { transform: rotate(180deg); }
.sidebar-todo-list { padding: 0 6px 6px; }
.sidebar-todo-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; color: rgba(255,255,255,.85); font-size: 12.5px; text-decoration: none; }
.sidebar-todo-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-todo-item i { width: 16px; text-align: center; font-size: 12px; opacity: .8; }
.sidebar-todo-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-todo-item b { font-size: 11px; background: rgba(255,255,255,.14); border-radius: 999px; padding: 1px 7px; }
.sidebar-todo-clear { margin: 0 2px 8px; padding: 8px 12px; font-size: 12.5px; color: #86efac; background: rgba(34,197,94,.08); border-radius: 10px; }
.sidebar-quick { margin: 0 0 6px; }
.sidebar-quick[hidden] { display: none; }
.sidebar-quick-title { font-size: 10.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: rgba(255,255,255,.4); padding: 8px 12px 4px; }
.sidebar-quick-title i { width: 14px; margin-right: 6px; }
.sidebar-quick .sidebar-item { padding: 7px 12px; font-size: 13px; font-weight: 500; }
.sidebar-upsell { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; padding: 7px 10px; border-radius: 9px; background: rgba(251,191,36,.09); color: #fde68a; font-size: 12px; text-decoration: none; }
.sidebar-upsell:hover { background: rgba(251,191,36,.16); color: #fef3c7; }
.sidebar-upsell span { flex: 1; min-width: 0; }
.sidebar-upsell b { font-size: 11.5px; text-decoration: underline; white-space: nowrap; }
.sidebar-foot { flex-shrink: 0; display: flex; align-items: center; gap: 4px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.18); }
.sidebar-profile { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 10px; color: #fff; text-decoration: none; }
.sidebar-profile:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-avatar { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 700; font-size: 14px; }
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-profile-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-profile-text strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile-text small { font-size: 11px; color: rgba(255,255,255,.55); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout { color: #fca5a5; }

/* Mode ciut (hanya desktop): lebar 68px, ikon saja. Klik ikon grup melebarkan sidebar lagi. */
@media (min-width: 992px) {
  html.sb-collapsed { --sidebar-w: 68px; }
  html.sb-collapsed .sidebar-brand { flex-direction: column; padding: 14px 6px; gap: 6px; }
  html.sb-collapsed .sidebar-brand-name { font-size: 0; }
  html.sb-collapsed .sidebar-brand-name i, html.sb-collapsed .sidebar-brand-name img { font-size: 18px; margin: 0 !important; }
  html.sb-collapsed #sb-collapse i { transform: rotate(180deg); }
  html.sb-collapsed .sidebar-search, html.sb-collapsed .sidebar-search-empty, html.sb-collapsed .sidebar-quick-title,
  html.sb-collapsed .sidebar-label, html.sb-collapsed .sidebar-chevron,
  html.sb-collapsed .sidebar-group-items, html.sb-collapsed .sidebar-todo-list, html.sb-collapsed .sidebar-profile-text,
  html.sb-collapsed .sidebar-item .badge:not(.sb-keep), html.sb-collapsed .sidebar-lock, html.sb-collapsed #sb-multi { display: none !important; }
  html.sb-collapsed .sidebar-nav { padding: 10px 8px; }
  html.sb-collapsed .sidebar-item, html.sb-collapsed .sidebar-group-title, html.sb-collapsed .sidebar-todo-title { justify-content: center; padding: 11px 0; gap: 0; }
  html.sb-collapsed .sidebar-group-name, html.sb-collapsed .sidebar-todo-name { flex: 0 0 auto; justify-content: center; }
  html.sb-collapsed .sidebar-group-title, html.sb-collapsed .sidebar-todo-title { position: relative; }
  html.sb-collapsed .sidebar-group-badge, html.sb-collapsed .sidebar-todo-title .badge { position: absolute; top: 2px; right: 6px; font-size: 9px; padding: 2px 5px; }
  html.sb-collapsed .sidebar-todo { background: transparent; border: 0; }
  html.sb-collapsed .sidebar-todo-clear { text-align: center; padding: 8px 0; }
  html.sb-collapsed .sidebar-quick .sidebar-item { padding: 11px 0; }
  html.sb-collapsed .sidebar-foot { flex-direction: column; padding: 10px 6px; }
  html.sb-collapsed .sidebar-profile { padding: 2px; }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar, .app-content, .sidebar-chevron { transition: none !important; } }
