:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #16211f;
  --ink-2: #4b5b57;
  --ink-3: #7c8b87;
  --line: #e2e8e5;
  --brand: #0f6b5c;
  --brand-2: #12897a;
  --brand-soft: #e3f3ef;
  --ok: #157f4a;
  --ok-soft: #e4f5ea;
  --warn: #a86a00;
  --warn-soft: #fdf1da;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 34, .06), 0 8px 24px rgba(16, 40, 34, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

/* ---------------- Login ---------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 10% -10%, #d9efe9 0%, transparent 60%),
    radial-gradient(700px 500px at 110% 110%, #e8f2df 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: 20px;
}

.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
}

.login-card h1 { font-size: 22px; margin: 22px 0 6px; letter-spacing: -.02em; }
.login-card p.sub { margin: 0 0 22px; color: var(--ink-2); font-size: 14px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(18, 137, 122, .12);
}

.field textarea { resize: vertical; min-height: 90px; }
.field .hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f7f9f8; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-danger { color: var(--bad); border-color: #f0cfcb; background: #fff; }
.btn-danger:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- Shell ---------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand-mark { padding: 4px 8px 18px; font-size: 18px; }
.sidebar .brand-mark small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: #f2f6f4; color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar .spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-chip .meta { flex: 1; min-width: 0; }
.user-chip .meta b { display: block; font-size: 13px; }
.user-chip .meta span { font-size: 11.5px; color: var(--ink-3); text-transform: capitalize; }

.main { flex: 1; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  background: rgba(244, 246, 245, .86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h2 { font-size: 18px; margin: 0; letter-spacing: -.02em; flex: 1; }
.topbar .periode-box { display: flex; align-items: center; gap: 8px; }
.topbar .periode-box label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.topbar input[type="month"] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 13.5px;
}

.content { padding: 24px 28px 60px; max-width: 1180px; }

/* ---------------- Cards ---------------- */

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 2px; font-size: 15px; letter-spacing: -.01em; }
.card .card-sub { color: var(--ink-3); font-size: 12.5px; margin: 0 0 14px; }
.card.tight { padding: 14px; }

.stat .label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.stat .value { font-size: 24px; font-weight: 700; letter-spacing: -.03em; }
.stat .value.small { font-size: 20px; }
.stat .foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat .value.pos { color: var(--ok); }
.stat .value.neg { color: var(--bad); }

.section-head {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 0 12px;
}
.section-head h3 { margin: 0; font-size: 15px; flex: 1; letter-spacing: -.01em; }

.progress {
  height: 9px; background: #edf1ef; border-radius: 99px; overflow: hidden; margin: 10px 0 6px;
}
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 99px; }

/* ---------------- Table ---------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; background: #fafcfb; }
tbody tr:hover { background: #fafcfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

.unit { font-weight: 700; }
.unit small { font-weight: 500; color: var(--ink-3); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.neutral { background: #eef2f0; color: var(--ink-2); }
.badge.info { background: var(--brand-soft); color: var(--brand); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------------- Misc ---------------- */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.toolbar input[type="search"], .toolbar select {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-size: 13.5px;
}

.empty {
  text-align: center; padding: 40px 20px; color: var(--ink-3); font-size: 14px;
}
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: #10241f; color: #fff; padding: 11px 18px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #6d1a15; }

/* ---------------- Modal ---------------- */

.modal-back {
  position: fixed; inset: 0; background: rgba(12, 26, 22, .45);
  display: grid; place-items: center; padding: 20px; z-index: 90;
  backdrop-filter: blur(2px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; letter-spacing: -.01em; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 20px; }
.icon-btn {
  border: 0; background: transparent; font-size: 20px; line-height: 1;
  color: var(--ink-3); cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: #f2f6f4; color: var(--ink); }

/* ---------------- Mobile ---------------- */

.mobile-nav { display: none; }

@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .shell { display: block; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .topbar h2 { font-size: 17px; }
  .content { padding: 16px 14px 100px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .stat .value { font-size: 21px; }

  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    overflow-x: auto;
  }
  .mobile-nav button {
    flex: 1; min-width: 64px; border: 0; background: transparent; padding: 6px 4px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 600; color: var(--ink-3); cursor: pointer; border-radius: 8px;
  }
  .mobile-nav button .ico { font-size: 17px; }
  .mobile-nav button.active { color: var(--brand); background: var(--brand-soft); }

  th, td { padding: 9px 8px; }
  .hide-sm { display: none; }
}

/* Daftar centang alokasi pembayaran */
.alokasi-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 260px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; margin-bottom: 8px; background: #fbfcfc;
}
.alokasi-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.alokasi-item:hover { background: var(--brand-soft); }
.alokasi-item input { margin: 0; width: 16px; height: 16px; }
.alokasi-item .alokasi-bulan { flex: 1; font-weight: 600; }
.alokasi-item b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.alokasi-item.lunas { opacity: .5; cursor: not-allowed; }
.alokasi-total { font-size: 13px; text-align: right; margin-bottom: 8px; }
