:root {
  --hijau: #15803d;
  --hijau-terang: #22c55e;
  --hijau-bg: #effaf2;
  --hijau-soft: #dcf5e3;
  --merah: #b91c1c;
  --merah-soft: #fdeaea;
  --kuning: #b45309;
  --kuning-soft: #fef3e2;
  --tinta: #10291c;
  --abu: #5a7166;
  --garis: #d9ebe0;
  --putih: #ffffff;
  --radius: 18px;
  --bayang: 0 6px 24px rgba(21, 128, 61, .08);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--tinta);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9f7e3 0%, rgba(217,247,227,0) 60%),
    radial-gradient(900px 500px at 100% 0%, #fff5d6 0%, rgba(255,245,214,0) 55%),
    #f6fcf8;
  min-height: 100vh;
}

a { color: var(--hijau); }

/* ---------- Topbar ---------- */
.topbar {
  background: linear-gradient(120deg, #16a34a 0%, #22c55e 55%, #4ade80 100%);
  box-shadow: 0 4px 18px rgba(21, 128, 61, .22);
}
.topbar-in {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}
.brand-ico {
  font-size: 30px;
  background: rgba(255,255,255,.22);
  border-radius: 14px;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.brand-txt strong { font-size: 21px; letter-spacing: .2px; }
.brand-txt small { font-size: 14px; opacity: .92; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 16.5px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  transition: background .15s ease, transform .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,.3); }
.nav-link.active { background: #fff; color: var(--hijau); border-color: #fff; }
.nav-link.nav-out { background: rgba(0,0,0,.12); }
.ni { font-size: 17px; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.foot {
  text-align: center;
  color: var(--abu);
  font-size: 15px;
  padding: 18px 20px 40px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 26px;
}
.page-head h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.3px;
}
.page-head p { margin: 6px 0 0; color: var(--abu); font-size: 16.5px; }

/* ---------- Card ---------- */
.card {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--garis);
  border-radius: var(--radius);
  box-shadow: var(--bayang);
  padding: 22px 24px;
}
.card + .card { margin-top: 22px; }
.card h2 {
  margin: 0 0 16px;
  font-size: 21px;
}
.card h2 small { font-weight: 500; color: var(--abu); font-size: 15.5px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-petani { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------- Stat ---------- */
.stat {
  background: #fff;
  border: 1px solid var(--garis);
  border-radius: var(--radius);
  box-shadow: var(--bayang);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat .lbl {
  font-size: 15.5px;
  color: var(--abu);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.stat .val { font-size: 29px; font-weight: 800; letter-spacing: -.5px; }
.stat .sub { font-size: 15px; color: var(--abu); }
.stat.uang-hijau .val { color: var(--hijau); }
.stat.uang-merah .val { color: var(--merah); }
.stat.uang-biru .val { color: #1d4ed8; }

/* ---------- Petani card ---------- */
.pcard {
  background: #fff;
  border: 1px solid var(--garis);
  border-left: 8px solid var(--hijau-terang);
  border-radius: var(--radius);
  box-shadow: var(--bayang);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pcard.minus { border-left-color: #ef4444; }
.pcard .nama { font-size: 22px; font-weight: 800; margin: 0; }
.pcard .meta { color: var(--abu); font-size: 15.5px; margin-top: 2px; }
.pcard .baris {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 16.5px;
  padding: 5px 0;
  border-bottom: 1px dashed #e8f3ec;
}
.pcard .baris:last-of-type { border-bottom: 0; }
.pcard .baris b { font-variant-numeric: tabular-nums; }
.saldo-box {
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.saldo-box .t { font-size: 15px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.saldo-box .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.saldo-box.plus { background: var(--hijau-soft); color: #14532d; }
.saldo-box.minus { background: var(--merah-soft); color: #7f1d1d; }
.saldo-box.nol { background: #eef1f0; color: #334155; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 17px;
  background: #fff;
  min-width: 560px;
}
table.tbl th, table.tbl td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid #eaf4ee;
  vertical-align: top;
}
table.tbl thead th {
  background: #f1faf4;
  color: #14532d;
  font-size: 15.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  border-bottom: 2px solid #d5ecdd;
  position: sticky;
  top: 0;
}
table.tbl tbody tr:nth-child(even) { background: #fafefb; }
table.tbl tbody tr:hover { background: #f1faf4; }
table.tbl td.num, table.tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.tbl tfoot td { font-weight: 800; background: #f1faf4; border-top: 2px solid #d5ecdd; }
.masuk { color: #15803d; font-weight: 700; }
.keluar { color: #b91c1c; font-weight: 700; }
.detail-item { display: block; font-size: 14.5px; color: var(--abu); margin-top: 3px; }

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.plus { background: var(--hijau-soft); color: #14532d; }
.badge.minus { background: var(--merah-soft); color: #7f1d1d; }
.badge.nol { background: #eef1f0; color: #334155; }
.badge.netral { background: #e8f1fd; color: #1e40af; }
.badge.off { background: #f1f5f9; color: #64748b; }

/* ---------- Form ---------- */
.form-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-weight: 700; font-size: 16px; }
.field .hint { font-size: 14.5px; color: var(--abu); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  font-family: inherit;
  font-size: 18px;
  padding: 13px 15px;
  border: 2px solid #dbeae1;
  border-radius: 12px;
  background: #fff;
  color: var(--tinta);
  width: 100%;
  min-height: 52px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--hijau-terang);
  box-shadow: 0 0 0 4px rgba(34,197,94,.15);
}
textarea { min-height: 78px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  padding: 14px 24px;
  min-height: 54px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  background: #eef4f0;
  color: #1f3a2c;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(120deg, #16a34a, #22c55e);
  color: #fff;
  box-shadow: 0 8px 20px rgba(22,163,74,.28);
}
.btn-beli {
  background: linear-gradient(120deg, #0284c7, #0ea5e9);
  color: #fff;
  box-shadow: 0 8px 20px rgba(2,132,199,.25);
}
.btn-soft { background: #eafaf0; color: #14532d; border: 1.5px solid #bfe8cd; }
.btn-danger { background: var(--merah-soft); color: #991b1b; border: 1.5px solid #f5c2c2; }
.btn-sm { font-size: 16px; padding: 9px 15px; min-height: 44px; border-radius: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.alert {
  padding: 15px 20px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
  border: 1.5px solid;
}
.alert.ok { background: #e9fbef; border-color: #b6e8c6; color: #14532d; }
.alert.err { background: var(--merah-soft); border-color: #f3bdbd; color: #7f1d1d; }

.empty {
  padding: 26px 20px;
  text-align: center;
  color: var(--abu);
  background: #f8fdf9;
  border: 2px dashed #d5ecdd;
  border-radius: 14px;
  font-size: 17px;
}

/* ---------- Mode lihat saja ---------- */
.mode-strip {
  background: #fff8e1;
  border-bottom: 2px solid #f3d99b;
  color: #7a4b00;
  font-size: 16px;
  text-align: center;
  padding: 11px 16px;
  line-height: 1.45;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 16px;
  color: var(--abu);
  font-size: 15px;
  font-weight: 700;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1.5px;
  background: var(--garis);
}

/* ---------- Quick action ---------- */
.quick { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.qa {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid var(--garis);
  text-decoration: none;
  color: var(--tinta);
  font-weight: 700;
  font-size: 18px;
  box-shadow: var(--bayang);
}
.qa:hover { border-color: var(--hijau-terang); background: #f7fdf9; }
.qa .ico { font-size: 26px; }
.qa small { display: block; font-weight: 500; color: var(--abu); font-size: 14.5px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 18px;
}
.login-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(21,128,61,.16);
  padding: 34px 30px;
  border: 1px solid var(--garis);
}
.login-card .logo { font-size: 48px; text-align: center; }
.login-card h1 { text-align: center; font-size: 25px; margin: 10px 0 4px; }
.login-card p.sub { text-align: center; color: var(--abu); margin: 0 0 24px; font-size: 16px; }

/* ---------- Filter bar ---------- */
.filters {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
}
.filters .btn { width: 100%; }

/* ---------- Item rows (pembelian) ---------- */
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr 44px;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1.5px solid #e3f1e8;
  border-radius: 14px;
  background: #fbfefc;
  margin-bottom: 12px;
}
.item-row .field label { font-size: 14.5px; }
.item-row .subtotal {
  font-weight: 800;
  font-size: 18px;
  padding: 13px 4px;
  white-space: nowrap;
}
.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-radius: 14px;
  background: var(--hijau-soft);
  font-size: 20px;
  font-weight: 800;
  margin: 16px 0 6px;
}
.icon-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1.5px solid #f5c2c2;
  background: var(--merah-soft);
  color: #991b1b;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.link-plain { color: var(--abu); text-decoration: underline; font-size: 15px; }

/* ---------- Print ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 13px; }
  .wrap { padding: 0; max-width: none; }
  .card, .stat, .pcard { box-shadow: none; border: 1px solid #ccc; }
  table.tbl { font-size: 12px; min-width: 0; }
  table.tbl thead th { position: static; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

@media (max-width: 720px) {
  body { font-size: 17px; }
  .topbar-in { padding: 12px 14px; }
  .brand-txt strong { font-size: 18px; }
  .brand-ico { width: 42px; height: 42px; font-size: 24px; border-radius: 12px; }
  .nav { margin-left: 0; width: 100%; }
  .nav-link { flex: 1 1 auto; justify-content: center; padding: 10px 12px; font-size: 15px; }
  .wrap { padding: 20px 14px 50px; }
  .page-head h1 { font-size: 24px; }
  .stat .val { font-size: 24px; }
  .card { padding: 18px 16px; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .field:nth-child(1) { grid-column: 1 / -1; }
}
