:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --text: #1a2332;
  --text-muted: #5c6b7a;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --table-head: #1e40af;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(165deg, #e8eef5 0%, #f0f4f8 45%, #eef6ff 100%);
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.hero {
  margin-bottom: 1.75rem;
}

.hero__title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.hero__subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.8);
  overflow: hidden;
}

.card__head {
  padding: 1.25rem 1.35rem 0.5rem;
}

.card__head--split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
}

.card__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.card__meta {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.card--form .card__head {
  padding-bottom: 0.75rem;
}

.card--form {
  padding-bottom: 0.25rem;
}

.form {
  padding: 0 1.35rem 1.35rem;
}

/* Satu baris horizontal: Tanggal | Keterangan (fleksibel) | Tipe | Jumlah */
.form__grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  -webkit-overflow-scrolling: touch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.field--tanggal {
  flex: 0 0 auto;
  width: min(100%, 11rem);
}

.field--keterangan {
  flex: 1 1 8rem;
  min-width: 6rem;
}

.field--tipe {
  flex: 0 0 auto;
  width: min(100%, 12rem);
}

.field--jumlah {
  flex: 0 0 auto;
  width: min(100%, 10rem);
}

@media (max-width: 640px) {
  .form__grid {
    flex-direction: column;
    align-items: stretch;
    overflow-x: visible;
    gap: 0.75rem;
  }

  .field--tanggal,
  .field--keterangan,
  .field--tipe,
  .field--jumlah {
    flex: 0 0 auto;
    width: 100%;
  }
}

.field__label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field__input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
  background: var(--surface);
}

.field__input--sm {
  padding: 0.45rem 0.65rem;
  max-width: 160px;
}

.field__input--rupiah {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.field__select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c6b7a' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: linear-gradient(180deg, var(--success), #047857);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.35);
}

.btn--primary:hover {
  background: linear-gradient(180deg, #10b981, var(--success));
}

.btn--danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.btn--danger:hover {
  background: var(--danger-soft);
}

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--bg);
}

.btn--sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.btn--outline-primary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.45);
}

.btn--outline-primary:hover {
  background: var(--primary-soft);
}

.btn--outline-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.45);
}

.btn--outline-danger:hover {
  background: var(--danger-soft);
}

.btn--danger-solid {
  background: var(--danger);
  color: #fff;
  border: 1px solid transparent;
}

.btn--danger-solid:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn--danger-solid:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.filter__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.filter__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}

.filter__sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border-top: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table thead th {
  background: var(--table-head);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.data-table thead th.num {
  text-align: right;
}

.data-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

/* Baris ganjil putih, baris genap sama nuansa kartu ringkasan pemasukan */
.data-table tbody tr:nth-child(odd) td {
  background: #ffffff;
}

.data-table tbody tr:nth-child(even) td {
  background: #eff6ff;
}

.data-table tbody td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table__empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.summary__card {
  border-radius: var(--radius);
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.summary__card--income {
  background: #dcfce7;
  border: 1px solid rgba(22, 163, 74, 0.35);
}

.summary__card--expense {
  background: #fee2e2;
  border: 1px solid rgba(220, 38, 38, 0.35);
}

.summary__card--balance {
  background: #ffedd5;
  border: 1px solid rgba(234, 88, 12, 0.4);
}

.summary__label {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.summary__card--income .summary__label {
  color: #166534;
}

.summary__card--expense .summary__label {
  color: #991b1b;
}

.summary__card--balance .summary__label {
  color: #c2410c;
}

.summary__value {
  margin: 0;
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.summary__rp {
  font-size: 0.75em;
  font-weight: 600;
  opacity: 0.85;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 0.85rem 1.35rem;
  background: var(--text);
  color: #fff;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 100;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modal popup */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal__dialog {
  position: relative;
  width: min(100%, 26rem);
  max-height: min(90vh, 36rem);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  padding: 1.35rem 1.5rem;
  border: 1px solid var(--border);
}

.modal__dialog--wide {
  width: min(100%, 32rem);
}

.modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal__text {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.modal__field {
  width: 100%;
}

.modal__block {
  margin-top: 0.75rem;
}

.modal__form-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.modal__form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.modal__field--full {
  width: 100%;
}

.modal__hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  min-height: 1.25em;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 0.25rem;
}

body.modal-open {
  overflow: hidden;
}
