:root{
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --border: #eaeaea;
  --border-strong: #e0e0e0;
  --fg: #171717;
  --fg-muted: #666666;
  --fg-subtle: #999999;
  --black: #000000;
  --green: #0a7d3c;
  --green-bg: #e9f9ee;
  --red: #c8290b;
  --red-bg: #fdeeed;
  --blue: #0070f3;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 14px rgba(0,0,0,.06);
  --sidebar-w: 240px;
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0; overflow-x:hidden; width:100%;}
body{
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-subtle);
  color: var(--fg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a{color:inherit;text-decoration:none;}
ul{list-style:none;margin:0;padding:0;}
h1,h2,h3,h4{margin:0;font-weight:600;letter-spacing:-.01em;}
img{max-width:100%;}

/* ---------- Layout ---------- */
.app{
  display:flex;
  min-height:100vh;
  min-height:100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar{
  width: var(--sidebar-w);
  background: var(--black);
  color: #fff;
  padding: 20px 14px;
  position: fixed;
  top:0; left:0; bottom:0;
  display:flex;
  flex-direction:column;
  z-index: 110;
  transition: transform .25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sidebar .brand{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px 24px;
  font-weight:700;
  font-size:15px;
}
.sidebar .brand .dot{
  width:22px;height:22px;border-radius:6px;
  background:#fff;
  display:flex;align-items:center;justify-content:center;
  color:#000;font-size:13px;font-weight:800;
  flex-shrink:0;
}
.sidebar .brand .sidebar-close{
  margin-left:auto;
  display:none;
  background:transparent;
  border:none;
  color:#a1a1a1;
  font-size:20px;
  line-height:1;
  cursor:pointer;
  padding:4px 6px;
}
.sidebar nav a{
  display:flex;
  align-items:center;
  gap:10px;
  padding:9px 12px;
  border-radius:6px;
  color:#a1a1a1;
  font-size:13.5px;
  font-weight:500;
  margin-bottom:2px;
  transition:.15s;
}
.sidebar nav a:hover{ color:#fff; background:#1a1a1a; }
.sidebar nav a.active{ color:#000; background:#fff; }
.sidebar nav .icon{ width:16px; text-align:center; font-size:14px; flex-shrink:0; }
.sidebar .group-label{
  color:#666; font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  padding: 18px 12px 6px;
  font-weight:600;
}
.sidebar .foot{
  margin-top:auto;
  padding:12px 10px;
  color:#666;
  font-size:11.5px;
  border-top:1px solid #262626;
}

/* Overlay backdrop shown behind the sidebar drawer on small screens */
.sidebar-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  z-index:105;
  opacity:0;
  transition:opacity .2s ease;
}
.sidebar-overlay.show{ display:block; opacity:1; }

/* Hamburger button - hidden on desktop, shown on small screens via media query */
.menu-toggle{
  display:none;
  align-items:center;
  justify-content:center;
  width:36px;
  height:36px;
  border:1px solid var(--border-strong);
  border-radius:6px;
  background:#fff;
  cursor:pointer;
  flex-shrink:0;
  margin-right:12px;
  padding:0;
}
.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after{
  content:'';
  display:block;
  width:18px;
  height:2px;
  background:var(--fg);
  position:relative;
  transition:.15s;
}
.menu-toggle span::before{ position:absolute; top:-6px; }
.menu-toggle span::after{ position:absolute; top:6px; }

/* ---------- Main ---------- */
.main{
  margin-left: var(--sidebar-w);
  flex:1;
  min-width:0;
  width:100%;
}
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:nowrap;
  gap:12px;
  padding: 16px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position:sticky;
  top:0;
  z-index:20;
}
.topbar-left{ display:flex; align-items:center; min-width:0; flex:1 1 auto; overflow:hidden; }
.topbar-left .title-wrap{ min-width:0; overflow:hidden; }
.topbar h1{ font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar .sub{ color:var(--fg-muted); font-size:12.5px; margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.content{ padding: 24px 28px 60px; max-width:1200px; }

/* ---------- Card ---------- */
.card{
  background: var(--bg);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  max-width:100%;
}
.card-pad{ padding:20px; }
.card-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:16px 20px;
  border-bottom:1px solid var(--border);
  flex-wrap:wrap;
}
.card-head h3{ font-size:13.5px; }
.card-head .muted{ color:var(--fg-subtle); font-size:12px; }

/* ---------- Stat grid ---------- */
.stat-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:16px;
  margin-bottom:20px;
  width:100%;
}
.stat-card{
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:18px 20px;
  box-shadow: var(--shadow-sm);
  min-width:0;
  max-width:100%;
  overflow:hidden;
}
.stat-card .label{
  color:var(--fg-muted); font-size:12.5px; font-weight:500;
  display:flex; align-items:center; gap:6px; margin-bottom:10px;
  min-width:0;
}
.stat-card .value{
  font-size: clamp(17px, 4.8vw, 24px);
  font-weight:700;
  letter-spacing:-.02em;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.stat-card .delta{ font-size:12px; margin-top:6px; font-weight:500; }
.stat-card.masuk .value{ color:var(--green); }
.stat-card.keluar .value{ color:var(--red); }
.badge-dot{ width:8px;height:8px;border-radius:50%; display:inline-block; flex-shrink:0; }
.badge-dot.masuk{ background:var(--green); }
.badge-dot.keluar{ background:var(--red); }

/* ---------- Grid 2 col ---------- */
.grid-2{
  display:grid;
  grid-template-columns: minmax(0,1.6fr) minmax(0,1fr);
  gap:16px;
  align-items:start;
}

/* ---------- Table ---------- */
.table-responsive{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}
table{ width:100%; border-collapse:collapse; }
th{
  text-align:left;
  font-size:11.5px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--fg-subtle);
  font-weight:600;
  padding:10px 20px;
  border-bottom:1px solid var(--border);
  background:var(--bg-subtle);
  white-space:nowrap;
}
td{
  padding:13px 20px;
  border-bottom:1px solid var(--border);
  font-size:13.5px;
  vertical-align:middle;
}
tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:var(--bg-subtle); }
.text-right{ text-align:right; }
.text-muted{ color:var(--fg-muted); }
.mono{ font-variant-numeric: tabular-nums; }

/* ---------- Pill / Tag ---------- */
.pill{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:3px 9px;
  border-radius:20px;
  font-size:11.5px;
  font-weight:600;
  white-space:nowrap;
}
.pill.masuk{ background:var(--green-bg); color:var(--green); }
.pill.keluar{ background:var(--red-bg); color:var(--red); }
.pill.neutral{ background:#f1f1f1; color:var(--fg-muted); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 14px;
  border-radius:6px;
  font-size:13px;
  font-weight:500;
  border:1px solid var(--border-strong);
  background:#fff;
  color:var(--fg);
  cursor:pointer;
  transition:.15s;
  white-space:nowrap;
}
.btn:hover{ border-color:#c9c9c9; background:#f7f7f7; }
.btn-primary{ background:var(--black); color:#fff; border-color:var(--black); }
.btn-primary:hover{ background:#2a2a2a; border-color:#2a2a2a; }
.btn-green{ background:var(--green); color:#fff; border-color:var(--green); }
.btn-green:hover{ opacity:.9; }
.btn-red{ background:var(--red); color:#fff; border-color:var(--red); }
.btn-red:hover{ opacity:.9; }
.btn-sm{ padding:5px 10px; font-size:12px; }
.btn-ghost{ background:transparent; border-color:transparent; }
.btn-ghost:hover{ background:var(--bg-subtle); }

/* Keeps action buttons (Edit/Hapus) aligned on one row instead of stacking on small screens.
   Plain inline links wrap like text when space runs out; a nowrap flex row forces them
   to stay side-by-side, scrolling horizontally with the table instead of dropping down. */
.row-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  flex-wrap:nowrap;
  white-space:nowrap;
}

/* ---------- Forms ---------- */
.form-group{ margin-bottom:16px; }
label{ display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:var(--fg); }
input[type=text], input[type=date], input[type=month], input[type=number], input[type=password], select, textarea{
  width:100%;
  padding:9px 12px;
  border:1px solid var(--border-strong);
  border-radius:6px;
  font-size:13.5px;
  font-family:inherit;
  background:#fff;
  color:var(--fg);
  transition:.15s;
  max-width:100%;
}
input:focus, select:focus, textarea:focus{
  outline:none;
  border-color:var(--black);
  box-shadow:0 0 0 3px rgba(0,0,0,.06);
}
.form-row{ display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; }
.help-text{ font-size:11.5px; color:var(--fg-subtle); margin-top:5px; }
.type-toggle{ display:flex; gap:8px; margin-bottom:20px; }
.type-toggle a{
  flex:1; text-align:center; padding:10px; border-radius:6px;
  border:1px solid var(--border-strong); font-weight:600; font-size:13px;
  color:var(--fg-muted);
}
.type-toggle a.active.masuk{ background:var(--green-bg); color:var(--green); border-color:var(--green); }
.type-toggle a.active.keluar{ background:var(--red-bg); color:var(--red); border-color:var(--red); }

/* ---------- Alerts ---------- */
.alert{
  padding:12px 16px;
  border-radius:6px;
  font-size:13px;
  margin-bottom:18px;
  border:1px solid;
}
.alert-success{ background:var(--green-bg); color:var(--green); border-color:#bfe8cc; }

/* ---------- Filter bar ---------- */
.filter-bar{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:16px;
  flex-wrap:wrap;
}
.filter-bar select, .filter-bar input{ width:auto; }
.filter-bar .btn-filter{ padding:9px 16px; font-size:13.5px; line-height:1.2; }
.filter-bar > div[style*="margin-left:auto"]{ flex-wrap:wrap; }
.tabs{ display:flex; gap:4px; background:#f1f1f1; padding:4px; border-radius:8px; }
.tabs a{ padding:7px 14px; border-radius:6px; font-size:12.5px; font-weight:600; color:var(--fg-muted); white-space:nowrap; }
.tabs a.active{ background:#fff; color:var(--fg); box-shadow:var(--shadow-sm); }

/* ---------- Periode filter (Tanggal / Bulan / Tahun fields on the Laporan page) ---------- */
.filter-field{ display:flex; align-items:center; gap:6px; min-width:0; }
.filter-field-label{ margin:0; font-weight:400; color:var(--fg-muted); font-size:12px; white-space:nowrap; flex-shrink:0; }
.filter-field-range{ flex-wrap:nowrap; }

/* ---------- Empty state ---------- */
.empty-state{ padding:50px 20px; text-align:center; color:var(--fg-subtle); }

/* ---------- Bar chart (css based) ---------- */
.bars-scroll{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.bars{ display:flex; align-items:flex-end; gap:4px; height:160px; padding:10px 4px 0; min-width:340px; }
.bars .bar-wrap{ flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:100%; gap:2px; }
.bars .bar{ width:100%; border-radius:3px 3px 0 0; min-height:2px; }
.bars .bar.masuk{ background:var(--green); }
.bars .bar.keluar{ background:var(--red); }
.bars .lbl{ font-size:9.5px; color:var(--fg-subtle); margin-top:6px; }

/* ---------- Kategori list mini ---------- */
.kat-row{ display:flex; align-items:center; justify-content:space-between; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; }
.kat-row:last-child{ border-bottom:none; }
.kat-bar-bg{ background:#f1f1f1; border-radius:4px; height:6px; margin-top:6px; overflow:hidden; }
.kat-bar-fill{ background:var(--red); height:100%; border-radius:4px; }

/* ---------- Alert error ---------- */
.alert-error{ background:var(--red-bg); color:var(--red); border-color:#f6c6bd; }

/* ---------- Login page ---------- */
.login-page{
  min-height:100vh;
  min-height:100dvh;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--bg-subtle);
  padding:20px;
}
.login-card{
  width:100%;
  max-width:380px;
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow: var(--shadow-md);
  padding:32px 28px;
}
.login-brand{
  display:flex; align-items:center; gap:10px;
  font-weight:700; font-size:16px; margin-bottom:6px;
}
.login-brand .dot{
  width:26px;height:26px;border-radius:7px;
  background:var(--black); color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-size:14px;font-weight:800;
  flex-shrink:0;
}
.login-sub{ color:var(--fg-muted); font-size:12.5px; margin:0 0 20px; }
.login-footer{ margin-top:22px; padding-top:16px; border-top:1px solid var(--border); text-align:center; color:var(--fg-subtle); font-size:11.5px; }

/* ---------- Topbar user menu (avatar + dropdown) ---------- */
.user-menu{ position:relative; flex-shrink:0; }
.user-trigger{
  display:flex;
  align-items:center;
  gap:8px;
  padding:5px 8px 5px 5px;
  border-radius:24px;
  border:1px solid transparent;
  background:transparent;
  cursor:pointer;
  transition:.15s;
}
.user-trigger:hover{ background:var(--bg-subtle); border-color:var(--border); }
.user-menu.open .user-trigger{ background:var(--bg-subtle); border-color:var(--border); }
.avatar-circle{
  width:32px; height:32px; border-radius:50%;
  background:var(--black); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:700; letter-spacing:0;
  flex-shrink:0;
}
.avatar-circle-lg{ width:40px; height:40px; font-size:15px; }
.user-trigger-info{ display:flex; flex-direction:column; align-items:flex-start; gap:2px; min-width:0; }
.user-trigger-name{ font-size:12.5px; font-weight:600; color:var(--fg); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:140px; }
.user-caret{ font-size:10px; color:var(--fg-subtle); transition:transform .15s; flex-shrink:0; }
.user-menu.open .user-caret{ transform:rotate(180deg); }

.user-dropdown{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  min-width:220px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow:var(--shadow-md);
  padding:14px;
  opacity:0;
  visibility:hidden;
  transform:translateY(-6px);
  transition:.15s ease;
  z-index:200;
}
.user-menu.open .user-dropdown{ opacity:1; visibility:visible; transform:translateY(0); }
.user-dropdown-head{ display:flex; align-items:center; gap:10px; }
.user-dropdown-meta{ min-width:0; }
.user-dropdown-name{ font-size:13.5px; font-weight:700; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-dropdown-divider{ height:1px; background:var(--border); margin:12px 0; }
.user-dropdown-logout{
  display:flex; align-items:center; gap:8px;
  padding:9px 10px;
  border-radius:6px;
  font-size:13px; font-weight:600;
  color:var(--red);
  background:var(--red-bg);
}
.user-dropdown-logout:hover{ opacity:.85; }

.role-badge{
  display:inline-flex; align-items:center; padding:3px 9px;
  border-radius:20px; font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.02em;
  white-space:nowrap;
}
.role-badge.admin{ background:#e9f9ee; color:var(--green); }
.role-badge.bendahara{ background:#eaf2ff; color:var(--blue); }
.role-badge.viewer{ background:#f1f1f1; color:var(--fg-muted); }

/* =========================================================
   RESPONSIVE BREAKPOINTS
   ========================================================= */

/* ----- Tablet / small laptop (<=1024px): tighten spacing a bit ----- */
@media (max-width: 1024px){
  .content{ padding: 20px 20px 50px; }
  .topbar{ padding: 14px 20px; }
}

/* ----- Below 900px: sidebar becomes an off-canvas drawer ----- */
@media (max-width: 900px){
  .sidebar{
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
    width: min(var(--sidebar-w), 82vw);
  }
  .sidebar.open{ transform: translateX(0); }
  .sidebar .brand .sidebar-close{ display:block; }
  .main{ margin-left:0; }
  .menu-toggle{ display:inline-flex; }
  .stat-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .grid-2{ grid-template-columns:minmax(0,1fr); }
}

/* ----- Below 640px: collapse user info to avatar-only, dropdown shows the details ----- */
@media (max-width: 640px){
  .user-trigger-info{ display:none; }
  .user-caret{ display:none; }
  .user-trigger{ padding:4px; border-radius:50%; }
  .user-dropdown{ min-width:200px; }

  /* subtle fade hint so it's obvious a table can be scrolled sideways */
  .table-responsive{ position:relative; }
  .table-responsive::after{
    content:'';
    position:absolute; top:0; right:0; bottom:0; width:22px;
    background:linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,.95));
    pointer-events:none;
  }
}

/* ----- Tablet portrait / larger phones (<=680px) ----- */
@media (max-width: 680px){
  .content{ padding: 16px 14px 44px; }
  .topbar{ padding: 12px 14px; }
  .topbar h1{ font-size:15px; }
  .card-pad{ padding:16px; }
  .card-head{ padding:14px 16px; }
  th, td{ padding:10px 14px; }
  .form-row{ grid-template-columns:minmax(0,1fr); }
  .filter-bar{ gap:8px; }
  .filter-bar input[type=text]{ width:100%; flex:1 1 100%; }
  .filter-bar > div[style*="margin-left:auto"]{ margin-left:0 !important; width:100%; }
  .filter-bar > div[style*="margin-left:auto"] .btn{ flex:1; justify-content:center; }

  /* Periode filter: one full-width row per field, no inline labels */
  .periode-filter{ flex-direction:column; align-items:stretch; }
  .periode-title{ margin-bottom:2px; }
  .filter-field{ width:100%; }
  .filter-field-label{ display:none; }
  .filter-field input[type=date],
  .filter-field input[type=month],
  .filter-field select{ width:100% !important; flex:1 1 0; min-width:0; }
  .filter-field-range{ gap:8px; }
  .periode-filter .btn-filter{ width:100%; justify-content:center; }
}

/* ----- Phones (<=480px) ----- */
@media (max-width: 480px){
  :root{ --radius: 7px; }
  body{ font-size:13.5px; }
  .content{ padding: 14px 10px 40px; }
  .topbar{ padding: 10px 12px; gap:8px; }
  .topbar .sub{ display:none; }
  .stat-grid{ grid-template-columns:minmax(0,1fr); gap:10px; }
  .stat-card{ padding:14px 16px; }
  .stat-card .value{ font-size:20px; }
  th, td{ padding:9px 12px; font-size:12.5px; }
  .btn{ padding:7px 11px; font-size:12.5px; }
  .row-actions{ gap:5px; }
  .row-actions .btn-sm{ padding:6px 9px; font-size:12px; }
  .type-toggle a{ padding:9px 6px; font-size:12px; }
  .login-card{ padding:24px 18px; }
  .card-head{ flex-direction:column; align-items:flex-start; gap:6px; }
}