* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  color-scheme: dark;
  --bg: #0b0b0b; --card: #161616; --card2: #202020;
  --txt: #f5f5f5; --muted: #9ca3af;
  --pri: #ffc400; --pri2: #ffd60a; --pri-dim: #3a2e00;
  --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
  --kupu: #c084fc; --dauroh: #4ade80; --kolam: #38bdf8;
  --line: #2c2c2c;
  --radius: 14px;
  --input-bg: #0d0d0d;
  --bar-bg: rgba(11,11,11,.94); --bar-bg2: rgba(11,11,11,.97);
  --ghost-bg: #2a2a2a;
  --toast-bg: #0d0d0d; --toast-txt: var(--txt);
  --avatar-a: #333; --avatar-b: #1c1c1c;
  --shadow: 0 20px 60px rgba(0,0,0,.6);
  --track: rgba(255,255,255,.06);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff; --card: #ffffff; --card2: #f1f5f9;
  --txt: #0f172a; --muted: #64748b;
  --pri: #f59e0b; --pri2: #fbbf24; --pri-dim: #fef3c7;
  --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
  --kupu: #9333ea; --dauroh: #16a34a; --kolam: #0284c7;
  --line: #e2e8f0;
  --input-bg: #ffffff;
  --bar-bg: rgba(255,255,255,.96); --bar-bg2: rgba(255,255,255,.98);
  --ghost-bg: #f1f5f9;
  --toast-bg: #1f2937; --toast-txt: #f9fafb;
  --avatar-a: #e2e8f0; --avatar-b: #cbd5e1;
  --shadow: 0 20px 60px rgba(15,23,42,.12);
  --track: rgba(15,23,42,.06);
}
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- login ---------- */
.screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.6); text-align: center; }

/* ====== Mode Terang (light) global ====== */
:root[data-theme="light"] .login-box { box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.login-logo { width: auto; max-width: 240px; max-height: 90px; border-radius: 14px; margin: 0 auto 16px; display: block; }
.login-box h1 { font-size: 24px; letter-spacing: .5px; color: var(--pri); }
.login-box .sub { color: var(--muted); margin: 2px 0 20px; font-size: 13.5px; }
form label { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 6px; text-align: left; }
input[type=text], input:not([type]), input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; background: var(--input-bg); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 12px 14px; outline: none;
  height: 46px; -webkit-appearance: none; appearance: none;
}
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--txt);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: background-color 9999s ease-in-out 0s;
  caret-color: var(--txt);
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; }
.btn.primary { background: var(--pri); color: #111; }
.btn.primary:active { background: var(--pri2); }
.btn.ghost { background: var(--ghost-bg); color: var(--txt); border: 1px solid var(--line); }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: #3f1212; color: #fecaca; border: 1px solid #6b1d1d; }
:root[data-theme="light"] .btn.danger { background: #dc2626; color: #fff; border: 1px solid #b91c1c; }
.btn.block { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .5; }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--bar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; }
.brand-logo { height: 30px; width: auto; border-radius: 6px; display: block; }
.brand-txt { color: var(--txt); }
.brand-txt::after { content: '+'; color: var(--pri); }
.top-user { display: flex; align-items: center; gap: 10px; }
#user-name { color: var(--muted); font-size: 13px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.container { max-width: 720px; margin: 0 auto; padding: 14px 14px 90px; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--bar-bg2); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px 8px; background: none; border: 0; color: var(--muted); font-size: 11px; }
.nav-btn span { font-size: 20px; }
.nav-btn.active { color: var(--pri); }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.page-title { font-size: 19px; font-weight: 700; margin: 6px 2px 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.badge.kolam { background: rgba(56,189,248,.16); color: var(--kolam); }
.badge.kupu { background: rgba(192,132,252,.16); color: var(--kupu); }
.badge.dauroh { background: rgba(74,222,128,.16); color: var(--dauroh); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ===== Dashboard baru (build 7) ===== */
.d-head { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.d-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.d-kartu { background: linear-gradient(160deg, var(--card), var(--card2)); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; text-align: center; position: relative; overflow: hidden; }
.d-kartu::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--warna, var(--pri)); opacity: .9; }
.d-ikon { font-size: 22px; margin-bottom: 6px; }
.d-num { font-size: 28px; font-weight: 800; color: var(--warna, var(--pri)); line-height: 1.1; }
.d-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }
.d-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.d-chart { min-width: 0; }
.d-donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center; padding: 6px 0; }
.d-legs { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.d-leg { display: flex; align-items: center; gap: 6px; color: var(--txt); }
.d-leg b { font-weight: 700; }
.d-leg i { font-style: normal; color: var(--muted); font-size: 12px; }
.d-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.d-bars { display: flex; gap: 18px; align-items: flex-end; justify-content: center; height: 150px; padding: 6px 4px 0; }
.d-bar-col { flex: 1; max-width: 70px; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 4px; }
.d-bar-val { font-size: 14px; font-weight: 700; }
.d-bar { width: 100%; max-width: 44px; height: 100%; background: var(--card2); border-radius: 8px 8px 4px 4px; display: flex; align-items: flex-end; overflow: hidden; border: 1px solid var(--line); }
.d-bar-fill { width: 100%; border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .5s ease; }
.d-bar-lbl { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) {
  .d-wrap { grid-template-columns: 1fr; }
}

.list-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.list-item .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list-item .title { font-weight: 600; font-size: 14.5px; }
.list-item .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tag { font-size: 11px; color: var(--muted); background: var(--card2); padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }

.detail-grid { display: grid; gap: 6px; margin: 10px 0; }
.detail-grid .d { font-size: 13.5px; }
.detail-grid .d b { color: var(--muted); font-weight: 600; margin-right: 6px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; }

.fab { position: fixed; right: 18px; bottom: 84px; z-index: 19; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--pri); color: #111; font-size: 28px; font-weight: 800; box-shadow: 0 8px 24px rgba(255,196,0,.35); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--toast-bg); border: 1px solid var(--line); color: var(--toast-txt); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.6); max-width: 90vw; }
.toast.ok { border-color: var(--ok); color: var(--ok); }
.toast.err { border-color: var(--danger); color: var(--danger); }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--avatar-a), var(--avatar-b)); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: var(--pri); border: 1px solid var(--line); }

/* ---------- trend chart ---------- */
.trend { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: 3px; }
.trend-bar { width: 100%; max-width: 34px; height: 100%; display: flex; align-items: flex-end; background: var(--track); border-radius: 6px 6px 0 0; overflow: hidden; position: relative; }
.trend-fill { width: 100%; background: linear-gradient(180deg, var(--pri2), var(--pri)); border-radius: 6px 6px 0 0; transition: height .4s; min-height: 2px; }
.trend-n { font-size: 11px; font-weight: 700; color: var(--pri); }
.trend-m { font-size: 9px; color: var(--muted); text-align: center; line-height: 1.15; }
@media (max-width: 480px) { .trend { gap: 2px; } .trend-m { font-size: 8px; } }
@media (min-width: 600px) { .container { padding-top: 22px; } }
/* ===== Kalender 2 bulan (filter tanggal custom) ===== */
.cal-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.cal-twin { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:480px){ .cal-twin { grid-template-columns:1fr; } }
.cal-panel { background:var(--card2); border:1px solid var(--line); border-radius:10px; padding:8px; }
.cal-head { text-align:center; font-weight:600; font-size:13px; color:var(--txt); margin-bottom:6px; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:2px; }
.cal-wd { font-size:10px; color:var(--muted); text-align:center; padding:2px 0; }
.cal-cell { font-size:12px; text-align:center; padding:5px 0; border-radius:6px; cursor:pointer; color:var(--txt); background:transparent; border:1px solid transparent; }
.cal-cell.empty { cursor:default; }
.cal-cell:hover { background:rgba(59,130,246,.25); }
.cal-cell.sel-range { background:rgba(37,99,235,.35); color:#fff; border-radius:0; }
.cal-cell.sel-edge { background:#2563eb; color:#fff; font-weight:700; border-radius:6px; }
.cal-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
.cal-actions button[disabled] { opacity:.5; cursor:not-allowed; }

/* ===== Filter rapi (Tren) ===== */
.f-label { font-weight:700; font-size:14px; margin-bottom:10px; color:var(--txt); }
.f-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px 14px; }
.f-item { min-width:0; display:flex; flex-direction:column; gap:6px; }
.f-item-wide { grid-column:1 / -1; }
.f-lbl { font-size:12px; color:var(--muted); font-weight:600; }
.f-item select, .f-item input { width:100%; }
.f-actions { flex-direction:row; justify-content:flex-end; align-items:center; gap:8px; }
@media (max-width:480px){
  .f-grid { grid-template-columns:1fr; }
}

/* checkbox hak kelola member */
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: #3b82f6; }

/* ====== Desktop rapi (min-width 1024px; TIDAK memengaruhi mobile) ====== */
@media (min-width: 1024px) {
  .topbar { position: fixed; top: 0; left: 220px; right: 0; padding: 12px 28px; z-index: 30; }
  .bottomnav {
    position: fixed; top: 0; left: 0; bottom: 0; width: 220px;
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    gap: 4px; padding: 24px 14px; border-top: 0; border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .nav-btn { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 14px; font-size: 14px; border-radius: 10px; }
  .nav-btn span { font-size: 18px; }
  .nav-btn.active { color: var(--pri); background: var(--card2); }
  .container { max-width: 1080px; margin-left: 220px; padding: 84px 28px 32px; }
  .page-title { font-size: 22px; margin: 4px 2px 18px; }
  .brand { font-size: 18px; }
  #user-name { max-width: 220px; font-size: 14px; }
  .card { padding: 18px 20px; border-radius: 16px; }
  .d-grid { grid-template-columns: repeat(4, 1fr); }
  .d-kartu { padding: 20px 14px; }
  .d-num { font-size: 34px; }
  .d-lbl { font-size: 13px; }
  .d-wrap { gap: 16px; }
  .f-grid { grid-template-columns: repeat(3, 1fr); }
  .f-item-wide { grid-column: 1 / -1; }
  .list-item { padding: 14px 16px; }
  .list-item .title { font-size: 15px; }
  .list-item .meta { font-size: 13px; }
  .table { font-size: 14px; }
  .table th, .table td { padding: 10px 8px; }
  .toast { bottom: 30px; }
  .fab { right: 28px; bottom: 28px; }
  .cal-twin { gap: 14px; }
  .cal-cell { font-size: 13px; padding: 7px 0; }
}
@media (min-width: 1400px) {
  .container { max-width: 1280px; }
  .bottomnav { width: 240px; }
  .topbar { left: 240px; }
  .container { margin-left: 240px; }
}
