*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-dark: #1a4d2e;
  --green-main: #2d6a4f;
  --green-light: #40916c;
  --green-pale: #d8f3dc;
  --gold: #d4a017;
  --red-soft: #c1121f;
  --bg: #f0f4f1;
  --card: #ffffff;
  --text: #1b263b;
  --text-muted: #6c757d;
  --border: #dee2e6;
  --shadow: 0 4px 20px rgba(26, 77, 46, 0.1);
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 24px;
}

/* Page header */
.page-header {
  text-align: center;
  margin-bottom: 20px;
  padding: 8px 0 4px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Bottom navigation — game-style tab bar */
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  width: min(960px, 100%);
  max-width: 100%;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(15, 42, 28, 0.92) 0%, rgba(10, 30, 20, 0.98) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 -4px 24px rgba(0, 0, 0, 0.25),
    0 -1px 0 rgba(212, 160, 23, 0.15);
  border-radius: 20px 20px 0 0;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px 6px;
  min-width: 0;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.45);
  border-radius: 14px;
  transition: color 0.25s, transform 0.2s, background 0.25s;
  position: relative;
}

.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--gold);
  box-shadow: 0 0 12px rgba(212, 160, 23, 0.8);
  transition: transform 0.25s ease;
}

.bottom-nav-item:hover {
  color: rgba(255, 255, 255, 0.75);
}

.bottom-nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.bottom-nav-item.active::before {
  transform: translateX(-50%) scaleX(1);
}

.bottom-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.bottom-nav-icon svg {
  width: 24px;
  height: 24px;
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px) scale(1.1);
  filter: drop-shadow(0 0 6px rgba(212, 160, 23, 0.7));
  color: var(--gold);
}

.bottom-nav-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.bottom-nav-item.active .bottom-nav-label {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(212, 160, 23, 0.5);
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 1.25rem;
  color: var(--green-dark);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--green-pale);
}

.card-form {
  padding: 16px 20px 18px;
}

.card-form h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  padding-bottom: 6px;
  line-height: 1.25;
}

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.card-form .form-grid {
  gap: 8px 14px;
}

.form-group-full {
  grid-column: 1 / -1;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.card-form .form-group label {
  font-size: 0.8125rem;
  margin-bottom: 2px;
  line-height: 1.2;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  background: #fafafa;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card-form .form-group input,
.card-form .form-group select {
  padding: 6px 10px;
  font-size: 0.875rem;
  line-height: 1.25;
  border-radius: 6px;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
  background: #fff;
}

/* Preview */
.preview-card {
  border-left: 4px solid var(--green-main);
  padding: 16px 20px 18px;
}

.preview-card h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
  padding-bottom: 6px;
  line-height: 1.25;
}

.preview-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-block {
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8faf9;
}

.preview-block h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
  line-height: 1.2;
}

.preview-block.pendapatan {
  border-left: 3px solid var(--green-light);
}

.preview-block.pengeluaran {
  border-left: 3px solid var(--gold);
}

.preview-block.nominal {
  background: var(--green-dark);
  border-left: none;
  padding: 8px 12px;
}

.preview-block.nominal .preview-row {
  color: #fff;
}

.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: 0.8125rem;
  line-height: 1.25;
  gap: 10px;
}

.preview-row span {
  flex: 1;
  min-width: 0;
}

.preview-row strong {
  flex-shrink: 0;
  white-space: nowrap;
}

.preview-row.total-row {
  border-top: 1px dashed var(--border);
  margin-top: 3px;
  padding-top: 5px;
  font-weight: 600;
}

.nominal-value {
  font-size: 1.125rem;
  color: var(--green-pale) !important;
}

.preview-card .btn-submit {
  margin-top: 12px;
  padding: 10px;
  font-size: 0.9375rem;
}

.preview-card .form-message {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 0.8125rem;
}

/* Button */
.btn-submit {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: var(--green-main);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-submit:hover:not(:disabled) {
  background: var(--green-dark);
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-submit:disabled {
  background: #adb5bd;
  cursor: not-allowed;
}

.form-message {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
}

.form-message.success {
  background: var(--green-pale);
  color: var(--green-dark);
}

.form-message.error {
  background: #fde8e8;
  color: var(--red-soft);
}

/* Table */
.loading,
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

.table-wrapper {
  overflow-x: auto;
}

.table-summary {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: -8px 0 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--green-dark);
  color: #fff;
}

th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--green-pale);
}

tbody tr:last-child td {
  border-bottom: none;
}

.td-pendapatan {
  color: var(--green-main);
  font-weight: 600;
}

.td-pengeluaran {
  color: var(--gold);
  font-weight: 600;
}

.td-diterima {
  color: var(--green-dark);
  font-weight: 700;
}

.td-diterima.negative {
  color: var(--red-soft);
}

.btn-rincian {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--green-dark);
  background: var(--green-pale);
  border: 1px solid var(--green-light);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.btn-rincian:hover {
  background: #b7e4c7;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  padding-top: 4px;
}

.table-pagination[hidden] {
  display: none;
}

.btn-page {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1;
  color: var(--green-dark);
  background: #fff;
  border: 1.5px solid var(--green-light);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-page:hover:not(:disabled) {
  background: var(--green-pale);
}

.btn-page:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
  min-width: 100px;
  text-align: center;
}

/* Modal rincian */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-rincian {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.04),
    0 20px 40px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #eef1f4;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.btn-hapus {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.btn-hapus:hover {
  background: #fee2e2;
}

.modal-body {
  padding: 6px 14px 12px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 3px 0;
  font-size: 0.8125rem;
  line-height: 1.25;
}

.modal-row span {
  color: #64748b;
  font-weight: 500;
}

.modal-row strong {
  font-weight: 600;
  color: #0f172a;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.modal-row-total {
  padding-top: 5px;
  padding-bottom: 2px;
}

.modal-row-total span {
  color: #0f172a;
  font-weight: 700;
}

.modal-row-total strong {
  font-weight: 700;
}

.modal-blue {
  color: #2563eb !important;
}

.modal-green {
  color: #16a34a !important;
  font-size: 0.875rem;
}

.modal-row-sisa {
  padding-top: 4px;
  padding-bottom: 0;
}

.modal-row-sisa span,
.modal-row-sisa strong {
  font-weight: 700;
  font-style: italic;
  color: #0f172a;
}

.modal-row-sisa .modal-green {
  color: #15803d !important;
}

.modal-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 5px 0 3px;
}

/* Verifikasi keamanan */
.security-overlay {
  z-index: 1100;
}

.modal-security {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  padding: 16px 18px 18px;
}

.modal-security h3 {
  font-size: 1rem;
  color: var(--green-dark);
  margin-bottom: 8px;
}

.security-question {
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.35;
}

.security-input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.security-input:focus {
  outline: none;
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.12);
}

.security-error {
  font-size: 0.8125rem;
  color: var(--red-soft);
  margin-bottom: 8px;
}

.security-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn-security {
  padding: 8px 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
}

.btn-security-cancel {
  background: #f1f5f9;
  color: #334155;
}

.btn-security-ok {
  background: var(--green-main);
  color: #fff;
}

.btn-security-ok:hover {
  background: var(--green-dark);
}

/* Footer */
.footer {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 640px) {
  .page-title {
    font-size: 1.2rem;
  }

  .bottom-nav {
    border-radius: 16px 16px 0 0;
    padding-inline: 8px;
  }

  .bottom-nav-item {
    padding-inline: 8px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px 16px;
  }

  .preview-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  th, td {
    padding: 8px 6px;
    font-size: 0.8rem;
  }
}
