* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -webkit-body;
  background: #eef1f8;
  color: #1c1c1e;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #5c3a1e;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='110' viewBox='0 0 200 110'><g transform='rotate(-6 100 55)'><rect x='4' y='4' width='192' height='102' rx='10' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='2'/><rect x='14' y='14' width='172' height='82' rx='6' fill='none' stroke='white' stroke-opacity='0.25' stroke-width='1'/><circle cx='100' cy='55' r='26' fill='none' stroke='white' stroke-opacity='0.4' stroke-width='2'/><text x='84' y='63' font-size='20' fill='white' fill-opacity='0.45' font-family='Georgia, serif' font-weight='bold'>Rp</text><text x='20' y='28' font-size='13' fill='white' fill-opacity='0.3' font-family='Georgia, serif'>100</text><text x='158' y='90' font-size='13' fill='white' fill-opacity='0.3' font-family='Georgia, serif'>100</text></g></svg>"),
    linear-gradient(135deg, #5c3a1e, #c9971f);
  background-repeat: no-repeat, no-repeat;
  background-position: right 18px center, center;
  background-size: 150px 84px, cover;
  color: #fff;
  padding: 1.1rem 1.5rem;
  box-shadow: 0 2px 10px rgba(92, 58, 30, 0.3);
}

.topbar h1 { margin: 0; font-size: 1.3rem; letter-spacing: 0.2px; }

.userbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem 0;
}

.userbar-right { display: flex; align-items: center; gap: 0.6rem; }

.greeting { font-weight: 600; font-size: 0.9rem; color: #5c3a1e; }
#userName { font-weight: 600; font-size: 0.9rem; }

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #e5e5ea;
  color: #1c1c1e;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-icon:hover { opacity: 0.85; }
.btn-icon:active { transform: scale(0.95); }

@media (max-width: 480px) {
  .topbar {
    background-position: left 8px center, center;
    background-size: 95px 53px, cover;
  }
  .topbar h1 { font-size: 1.1rem; }
  .userbar { padding: 0.6rem 1rem 0; }
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem;
}

.view { background: #fff; border-radius: 16px; padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 4px 16px rgba(28, 28, 30, 0.07); }

.view h2 { margin-top: 0; }

.hidden { display: none !important; }

form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 420px; }

label { display: flex; flex-direction: column; font-size: 0.9rem; gap: 0.25rem; }

input, select {
  padding: 0.5rem 0.6rem;
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  font-size: 1rem;
}

.btn {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  font-weight: 600;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.97); }

.btn-primary { background: linear-gradient(135deg, #5b3df0, #0a84ff); color: #fff; }
.btn-secondary { background: #e5e5ea; color: #1c1c1e; }
.btn-danger { background: #d62e22; color: #fff; }

.error { color: #ff3b30; }
.success { color: #34c759; }
.muted { color: #6e6e73; font-size: 0.9rem; }

.period-bar { display: flex; gap: 1rem; margin-bottom: 1rem; }
.period-bar label { flex-direction: row; align-items: center; gap: 0.5rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.card {
  background: #f5f5f7;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  border-left: 4px solid transparent;
  transition: transform 0.15s;
}
.card:hover { transform: translateY(-2px); }

.card-projected { border-left-color: #8e8e93; }
.card-actual { border-left-color: #0a84ff; }
.card-diff { border-left-color: #ff9f0a; }
.card-income { border-left-color: #34c759; }
.card-balance { border-left-color: #5b3df0; }

.card-label { font-size: 0.8rem; color: #6e6e73; }
.card-value { font-size: 1.15rem; font-weight: 700; }

.card-value-row { display: flex; align-items: center; gap: 0.4rem; }

.btn-eye {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
}
.btn-eye:hover { opacity: 1; }

.chart-wrap { max-width: 360px; height: 320px; margin: 0 auto 1.5rem; }
.chart-wrap-wide { max-width: 100%; height: 280px; }

@media (max-width: 480px) {
  .chart-wrap { max-width: 100%; height: 300px; }
  .chart-wrap-wide { height: 240px; }
}

.accordion {
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.accordion-header {
  list-style: none;
  cursor: pointer;
  padding: 0.9rem 1.1rem;
  font-weight: 700;
  font-size: 1rem;
  background: #f5f5f7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.accordion-header::-webkit-details-marker { display: none; }
.accordion-header::after {
  content: "\25BE";
  color: #6e6e73;
  transition: transform 0.2s;
}
.accordion[open] .accordion-header::after { transform: rotate(180deg); }
.accordion-header:hover { background: #ececef; }

.accordion-body { padding: 1.1rem; }

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e5ea;
  border-top-color: #5b3df0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 240px;
  max-width: 360px;
  padding: 0.9rem 1.1rem;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.25s ease-out, toast-out 0.3s ease-in 2.7s forwards;
}

.toast-success { background: linear-gradient(135deg, #34c759, #28a745); }
.toast-error { background: linear-gradient(135deg, #ff3b30, #d70015); }

.toast-icon { font-size: 1.3rem; line-height: 1; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

@media (max-width: 480px) {
  .toast-container { left: 1rem; right: 1rem; top: 1rem; }
  .toast { max-width: none; }
}

.tx-form { margin-bottom: 1rem; }

.tx-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; overflow-x: auto; display: block; }
.tx-table thead, .tx-table tbody { display: table; width: 100%; table-layout: fixed; }
.tx-table th, .tx-table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #e5e5ea; }

.row-actions { display: flex; gap: 0.4rem; }
.row-actions button { font-size: 0.8rem; padding: 0.3rem 0.5rem; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}

.modal-box { background: #fff; border-radius: 12px; padding: 1.5rem; width: 90%; max-width: 360px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.75rem;
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

@media (max-width: 640px) {
  /* Tabel 7 kolom kepenuhan di layar sempit -- tiap baris diubah jadi "kartu" vertikal,
     label kolom ditampilkan lewat data-label (lihat renderTransactionsPage() di app.js). */
  .tx-table thead { display: none; }
  .tx-table, .tx-table tbody, .tx-table tr, .tx-table td {
    display: block;
    width: 100%;
  }
  .tx-table tr {
    margin-bottom: 0.75rem;
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    padding: 0.4rem 0.75rem;
    background: #fff;
  }
  .tx-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid #f0f0f2;
    text-align: right;
  }
  .tx-table tr td:last-child { border-bottom: none; }
  .tx-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6e6e73;
    text-align: left;
    flex-shrink: 0;
  }
  .tx-table td[data-label="Deskripsi"],
  .tx-table td[data-label="Item"] {
    text-align: right;
    overflow-wrap: anywhere;
  }
  .tx-table .row-actions { justify-content: flex-end; }
}
