:root {
  --primary: #0e7a3f;      /* hijau gudang */
  --primary-dark: #0a5c2f;
  --accent: #f5b301;      /* kuning gula */
  --accent-dark: #d99b00;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1d2b23;
  --muted: #6b7a70;
  --border: #e2e8e4;
  --danger: #d64545;
  --info: #2f7fb8;
  --shadow: 0 2px 10px rgba(14, 62, 36, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- TOP BAR (mobile) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; flex: 1; }
.topbar .brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.topbar h1 { font-size: 16px; font-weight: 700; line-height: 1.2; }
.topbar small { display: block; font-weight: 400; font-size: 11px; opacity: .85; }

.hamburger {
  background: rgba(255,255,255,.15);
  border: none; color: #fff; font-size: 22px;
  width: 40px; height: 40px; border-radius: 10px;
  cursor: pointer; line-height: 1;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  position: fixed; top: 0; left: -280px; width: 280px; height: 100vh;
  background: #ffffff; z-index: 100;
  transition: left .25s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,.12);
  overflow-y: auto;
}
.sidebar.open { left: 0; }
.sidebar .side-head {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; padding: 18px; display: flex; align-items: center; gap: 10px;
}
.sidebar .side-head .logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent);
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}
.sidebar .close-btn {
  margin-left: auto; background: rgba(255,255,255,.2); border: none; color: #fff;
  font-size: 18px; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 18px; color: var(--text); text-decoration: none;
  border-left: 3px solid transparent; font-size: 14.5px;
}
.sidebar nav a .ico { width: 22px; text-align: center; font-size: 17px; }
.sidebar nav a:hover { background: #f0f5f1; }
.sidebar nav a.active {
  background: #eaf4ee; border-left-color: var(--primary); color: var(--primary-dark); font-weight: 600;
}
.sidebar .section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 14px 18px 4px; font-weight: 700;
}
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90;
  opacity: 0; visibility: hidden; transition: opacity .25s;
}
.overlay.show { opacity: 1; visibility: visible; }

/* ---------- MAIN ---------- */
.main { padding: 18px 16px 90px; max-width: 1080px; margin: 0 auto; }
.page-title { margin-bottom: 14px; }
.page-title h2 { font-size: 20px; color: var(--primary-dark); }
.page-title p { color: var(--muted); font-size: 13px; }

/* ---------- CARD ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 16px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; color: var(--primary-dark); }
.card h3 .ico { margin-right: 6px; }

/* ---------- STAT CARDS ---------- */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.stat .badge-ico {
  position: absolute; right: 10px; top: 10px; width: 34px; height: 34px;
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.stat.green .badge-ico { background: #e6f4ea; }
.stat.amber .badge-ico { background: #fdf3d9; }
.stat.blue .badge-ico { background: #e3f0f9; }
.stat.red .badge-ico { background: #fbe6e6; }

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 15px; background: #fbfdfc; color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; padding: 12px 18px; border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: .15s;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:active { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ---------- TABLE ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 480px; }
th, td { padding: 10px 12px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--border); }
th { background: #f0f5f1; color: var(--primary-dark); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-green { background: #e6f4ea; color: var(--primary-dark); }
.badge-amber { background: #fdf3d9; color: var(--accent-dark); }
.badge-blue { background: #e3f0f9; color: var(--info); }
.badge-red { background: #fbe6e6; color: var(--danger); }

/* ---------- ALERT / FLASH ---------- */
.flashes { list-style: none; margin-bottom: 14px; }
.flashes li {
  padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 8px;
  border-left: 4px solid;
}
.flashes .success { background: #e6f4ea; color: var(--primary-dark); border-color: var(--primary); }
.flashes .danger { background: #fbe6e6; color: var(--danger); border-color: var(--danger); }
.flashes .info { background: #e3f0f9; color: var(--info); border-color: var(--info); }

/* ---------- LOGIN ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.login-card {
  background: #fff; border-radius: 20px; padding: 28px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.login-card .login-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 24px;
}
.login-card h2 { text-align: center; color: var(--primary-dark); font-size: 20px; }
.login-card p { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* ---------- INFO STRIP ---------- */
.strip {
  background: #eef6f1; border: 1px solid #cfe5d8; border-radius: 12px;
  padding: 12px 14px; font-size: 13px; color: var(--primary-dark);
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px;
}
.strip .eq { font-size: 13px; color: var(--muted); }

/* ---------- BOTTOM NAV (mobile) ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.bottomnav a {
  text-decoration: none; color: var(--muted); text-align: center;
  font-size: 10px; padding: 4px 8px; border-radius: 8px; flex: 1; max-width: 80px;
}
.bottomnav a .nb-ico { font-size: 20px; display: block; margin-bottom: 2px; }
.bottomnav a.active { color: var(--primary); font-weight: 700; }

/* ---------- RESPONSIVE ---------- */
@media (min-width: 768px) {
  .bottomnav, .hamburger { display: none !important; }
  .sidebar { left: 0; width: 250px; }
  .main { margin-left: 250px; padding: 24px; }
}
@media (max-width: 720px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .form-row { grid-template-columns: 1fr; }
  .stat .value { font-size: 17px; }
}

/* misc */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px){ .two-col{ grid-template-columns: 1fr; } }
.mt { margin-top: 14px; }
.muted { color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 22px; font-size: 13.5px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ==== PWA: tombol "Pasang Aplikasi" ==== */
#gb-install-btn {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 76px; z-index: 999;
  display: none; align-items: center; gap: 8px;
  background: #0e7a3f; color: #fff; font-weight: 700; font-size: 13.5px;
  padding: 12px 18px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(0,0,0,.30);
  cursor: pointer; user-select: none;
  max-width: 90vw; white-space: nowrap;
}
@media (min-width: 780px) { #gb-install-btn { bottom: 22px; } }
#gb-install-btn span { font-size: 17px; }
