:root {
  --biru-tua: #1155CC;
  --biru-muda: #29ABE2;
  --biru-bg: #eef4fd;
  --abu: #64748b;
  --abu-bg: #f3f5f9;
  --sukses: #1a7f37;
  --bahaya: #d93025;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(17, 85, 204, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, var(--biru-bg) 0%, #f7f9fc 220px);
  color: #1f2937;
  padding-bottom: 60px;
}
.header {
  background: linear-gradient(135deg, #ffffff, var(--biru-bg));
  color: var(--biru-tua);
  padding: 22px 20px 60px;
  text-align: center;
  box-shadow: var(--shadow);
  border-bottom: 1px solid #e1e9f5;
}
.header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--biru-tua);
}
.header p {
  margin: 0;
  font-size: 13px;
  color: var(--abu);
}
.container {
  max-width: 780px;
  margin: -38px auto 0;
  padding: 0 16px;
}

/* ============ HEADER ACTIONS (badge + tombol kelola/logout) ============ */
.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 780px;
  margin: 0 auto 8px;
}
.chip {
  font-size: 11.5px;
  background: var(--biru-bg);
  color: var(--biru-tua);
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.chip-btn {
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip-badge { display: inline-flex; align-items: center; }
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
  margin-bottom: 16px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--biru-tua);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.card-title .num {
  background: var(--biru-tua);
  color: #fff;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.field { flex: 1; min-width: 180px; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--abu);
  margin-bottom: 5px;
}
input[type="text"], input[type="date"], select, .flatpickr-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #dbe3ee;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: #1f2937;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--biru-muda);
}
.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--biru-tua); color: #fff; }
.btn-outline { background: #fff; color: var(--biru-tua); border: 1.5px solid var(--biru-tua); }
.btn-soft { background: var(--biru-bg); color: var(--biru-tua); }
.btn-sukses { background: var(--sukses); color: #fff; }
.btn-bahaya { background: #fff; color: var(--bahaya); border: 1.5px solid #f3c6c2; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.sheet-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.sheet-row .field { flex: 1; min-width: 160px; }
.sheet-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 100%;
}
.sheet-row-actions .btn { flex: 1; min-width: 0; white-space: nowrap; }

.field-btn-aturan { flex: 0 0 auto; }

.custom-select { position: relative; }
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid #dbe3ee;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
}
.custom-select-trigger span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.custom-select-trigger:focus, .custom-select.tampil .custom-select-trigger {
  outline: none;
  border-color: var(--biru-muda);
}
.custom-select-chevron { color: var(--abu); transition: transform .15s ease; flex-shrink: 0; }
.custom-select.tampil .custom-select-chevron { transform: rotate(180deg); }

.custom-select-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1.5px solid #dbe3ee;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 40, 80, 0.18);
  z-index: 40;
}
.custom-select.tampil .custom-select-panel { display: block; }
.custom-select-option {
  padding: 9px 12px;
  font-size: 13.5px;
  cursor: pointer;
  color: #1f2937;
}
.custom-select-option:hover { background: var(--biru-bg); }
.custom-select-option.aktif { background: var(--biru-bg); color: var(--biru-tua); font-weight: 600; }
.custom-select-kosong { padding: 10px 12px; font-size: 13px; color: var(--abu); }

.info-badge {
  background: var(--biru-bg);
  color: var(--biru-tua);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 10px;
  display: none;
}
.info-badge.tampil { display: block; }

.tabel-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.tabel-item {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}
table.tabel-item th {
  background: var(--abu-bg);
  color: var(--abu);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 6px;
  text-align: center;
  border-bottom: 2px solid #e5e9f0;
}
table.tabel-item td {
  padding: 5px 6px;
  border-bottom: 1px solid #eef1f6;
  vertical-align: middle;
  text-align: center;
}
table.tabel-item td input,
table.tabel-item td select {
  padding: 7px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  text-align: center;
}
table.tabel-item td select {
  cursor: pointer;
  background: #fff;
}
table.tabel-item td.col-no { width: 28px; text-align: center; color: var(--abu); font-weight: 600; }
table.tabel-item td.col-hapus { width: 30px; text-align: center; }
.col-nominal input { text-align: center; }

.dropdown-tabel-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 7px 8px;
  font-size: 12.5px;
  border: 1.5px solid #dbe3ee;
  border-radius: 6px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.dropdown-tabel-trigger span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dropdown-tabel-trigger .custom-select-chevron { font-size: 10px; }
.dropdown-tabel-trigger:focus, .dropdown-tabel-trigger.aktif {
  outline: none;
  border-color: var(--biru-muda);
}
.penerima-panel {
  position: fixed;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 500;
  text-align: left;
}
.penerima-panel.tampil { display: block; }
.custom-select-manual-wrap {
  padding: 6px;
  border-bottom: 1px solid #eef1f6;
  position: sticky;
  top: 0;
  background: #fff;
}
.custom-select-manual-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  font-size: 13px;
  border: 1.5px solid #dbe3ee;
  border-radius: 6px;
  font-family: inherit;
}
.custom-select-manual-input:focus {
  outline: none;
  border-color: var(--biru-muda);
}
.custom-select-options-list { }
.btn-hapus-baris {
  background: none;
  border: none;
  color: var(--bahaya);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
}
.kosong-state {
  text-align: center;
  color: var(--abu);
  font-size: 13px;
  padding: 24px 10px;
  border: 1.5px dashed #dbe3ee;
  border-radius: 8px;
  margin-top: 10px;
}
.toolbar-tabel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.ringkasan {
  margin-top: 14px;
  background: linear-gradient(135deg, var(--biru-tua), var(--biru-muda));
  color: #fff;
  border-radius: 10px;
  padding: 14px 16px;
}
.ringkasan .label { font-size: 11px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.4px; }
.ringkasan .nominal { font-size: 24px; font-weight: 800; margin: 2px 0 4px; }
.ringkasan .terbilang { font-size: 12px; opacity: 0.92; font-style: italic; }

.preview-gambar {
  margin-top: 12px;
  border: 1.5px solid #dbe3ee;
  border-radius: 10px;
  padding: 10px;
  background: #f7f9fc;
}
.preview-gambar .label {
  font-size: 11px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  color: var(--biru-tua);
}
.preview-gambar img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #e3e8f0;
}

.aksi-utama {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.aksi-utama .btn { flex: 1 1 150px; }

.footer-link {
  text-align: center;
  font-size: 12px;
  color: var(--abu);
  margin-top: 6px;
}
.footer-link a { color: var(--biru-tua); text-decoration: none; font-weight: 600; }

::placeholder { color: #a8b3c4; }

/* ============ RESPONSIVE: TABLET / MOBILE BESAR ============ */
@media (max-width: 640px) {
  .header { padding: 18px 14px 54px; }
  .container { padding: 0 12px; }
  .card { padding: 15px; }

  .header-actions { justify-content: center; }

  /* Baris Tab/Sheet: dropdown penuh, tombol jadi grid rapi 2 kolom */
  .sheet-row { flex-direction: column; align-items: stretch; }
  .sheet-row .field { min-width: 0; width: 100%; }
  .sheet-row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .sheet-row-actions .btn#btnMuatData { grid-column: 1 / -1; }

  /* Baris tanggal: input dan tombol full width, ditumpuk */
  .row { flex-direction: column; }
  .row .field { min-width: 0; width: 100%; }
  .field-btn-aturan { width: 100%; }

  /* Tombol aksi utama: tumpuk penuh agar tidak berdesakan */
  .aksi-utama { flex-direction: column; }
  .aksi-utama .btn { flex: none; width: 100%; }
}

@media (max-width: 480px) {
  table.tabel-item { font-size: 11.5px; }
  table.tabel-item td input { font-size: 11.5px; padding: 6px; }
  .card { padding: 14px; }
}

/* ============ RESPONSIVE: MOBILE KECIL ============ */
@media (max-width: 380px) {
  .header-actions { gap: 6px; }
  .chip { font-size: 10.5px; padding: 5px 8px; }
  .chip-btn span { display: none; } /* sisakan ikon saja agar tidak sempit */
  .sheet-row-actions { grid-template-columns: 1fr; }
  .sheet-row-actions .btn#btnMuatData { grid-column: auto; }
}

.splash-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3.5px solid var(--biru-bg);
  border-top-color: var(--biru-tua);
  animation: splash-spin 0.8s linear infinite;
}
@keyframes splash-spin {
  to { transform: rotate(360deg); }
}
