:root {
  --bg: #f5f6f2;
  --bg-2: #eef1ec;
  --card: #ffffff;
  --ink: #131d19;
  --ink-2: #3c4a44;
  --muted: #6f7d77;
  --line: #e3e7e1;
  --line-2: #eef1ec;
  --accent: #0f766e;
  --accent-2: #0b5f58;
  --accent-soft: #e5f2ef;
  --income: #0e9f6e;
  --income-soft: #e4f6ee;
  --expense: #e0455c;
  --expense-soft: #fdecef;
  --warn: #b45309;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(19, 29, 25, 0.05), 0 12px 28px -18px rgba(19, 29, 25, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(15, 118, 110, 0.1), transparent 60%),
    radial-gradient(760px 380px at 92% 4%, rgba(245, 158, 11, 0.09), transparent 62%),
    var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- tombol & kontrol ---------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(15, 118, 110, 0.8);
}

.btn.primary:hover {
  background: var(--accent-2);
}

.btn.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}

.btn.ghost:hover {
  border-color: #cfd6d0;
  background: #fbfcfa;
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

.btn.block {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
}

.btn[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.btn .plus {
  font-size: 17px;
  line-height: 1;
  margin-top: -1px;
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
  font-size: 17px;
  transition: background 0.15s ease, border-color 0.15s ease;
  flex: none;
}

.icon-btn:hover {
  background: #f7f9f6;
  border-color: #cfd6d0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

input,
select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

input::placeholder {
  color: #a3aea8;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.01em;
}

/* segmented control */

.seg {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: 11px;
  padding: 3px;
  gap: 2px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg button:hover {
  color: var(--ink);
}

.seg button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(19, 29, 25, 0.1);
}

.seg.big {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 16px;
}

.seg.big button {
  padding: 10px;
  font-size: 14px;
}

.seg.big button[data-type="expense"].active {
  color: var(--expense);
  background: var(--expense-soft);
}

.seg.big button[data-type="income"].active {
  color: var(--income);
  background: var(--income-soft);
}

/* ---------- kartu ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}

.dot.income {
  background: var(--income);
}

.dot.expense {
  background: var(--expense);
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
}

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(245, 246, 242, 0.82);
  border-bottom: 1px solid rgba(227, 231, 225, 0.8);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(145deg, #12897f, #0b5f58);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 750;
  font-size: 19px;
  box-shadow: 0 6px 14px -8px rgba(15, 118, 110, 0.9);
  flex: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}

.brand-text em {
  font-style: normal;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}

.month-nav input {
  width: 150px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 8px;
}

.month-nav .icon-btn {
  font-size: 20px;
  padding-bottom: 2px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- layout ---------- */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.foot {
  text-align: center;
  color: #98a49e;
  font-size: 12.5px;
  padding: 0 24px 32px;
}

/* ---------- statistik ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat {
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  overflow: hidden;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  text-transform: none;
}

.stat-value {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.stat-value.income {
  color: var(--income);
}

.stat-value.expense {
  color: var(--expense);
}

.stat-hint {
  font-size: 11.5px;
  color: #93a09a;
}

/* ---------- grafik ---------- */

.charts {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 14px;
}

.chart-card {
  padding-bottom: 14px;
  min-width: 0;
}

.chart-box {
  padding: 6px 14px 0;
}

.chart-box svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px 4px;
  min-height: 220px;
}

.donut {
  flex: none;
}

.donut svg {
  width: 148px;
  height: 148px;
  display: block;
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}

.donut-legend .swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.donut-legend .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}

.donut-legend .val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12.5px;
}

.donut-legend .pct {
  color: var(--muted);
  font-size: 11.5px;
  width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- tabel transaksi ---------- */

.txns {
  overflow: hidden;
}

.wrap-head {
  flex-wrap: wrap;
  padding-bottom: 14px;
}

.count {
  color: var(--muted);
  font-weight: 500;
  font-size: 12.5px;
  margin-left: 4px;
}

.txn-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search {
  width: 190px;
  background: #fbfcfa;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
  white-space: nowrap;
}

tbody td {
  padding: 11px 20px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbf8;
}

.right {
  text-align: right;
}

.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.amount.income {
  color: var(--income);
}

.amount.expense {
  color: var(--expense);
}

.date {
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cat {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  white-space: nowrap;
}

.cat .swatch {
  width: 8px;
  height: 8px;
  border-radius: 3px;
  flex: none;
}

.note {
  color: var(--muted);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.method {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.12s ease;
}

tbody tr:hover .row-actions,
.row-actions:focus-within {
  opacity: 1;
}

/* perangkat sentuh tidak punya hover: aksi harus selalu terlihat */
@media (hover: none) {
  .row-actions {
    opacity: 1;
  }
}

.mini {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 7px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.mini:hover {
  background: var(--bg-2);
  color: var(--ink);
}

.mini.danger:hover {
  background: var(--expense-soft);
  color: var(--expense);
}

.mini svg {
  width: 15px;
  height: 15px;
}

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 30px 20px 34px;
  margin: 0;
}

.empty .empty-mark {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
  opacity: 0.5;
}

.empty.small {
  padding: 16px 0;
  font-size: 13px;
}

/* ---------- anggaran ---------- */

.budgets {
  padding-bottom: 18px;
}

.budget-list {
  padding: 14px 20px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 26px;
}

.budget-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.budget-item:last-child,
.budget-item:nth-last-child(2):nth-child(odd) {
  border-bottom: 0;
}

.budget-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.budget-name {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.budget-name .swatch {
  width: 8px;
  height: 8px;
  border-radius: 3px;
}

.budget-figs {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.budget-figs b {
  color: var(--ink-2);
  font-weight: 650;
}

.bar {
  height: 7px;
  border-radius: 99px;
  background: var(--bg-2);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.bar.over > i {
  background: var(--expense);
}

.bar.warn > i {
  background: var(--warn);
}

.budget-item .remove {
  border: 0;
  background: none;
  color: #a9b3ae;
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
}

.budget-item .remove:hover {
  color: var(--expense);
}

.budget-form {
  display: flex;
  gap: 8px;
  padding: 14px 20px 0;
  flex-wrap: wrap;
}

.budget-form select {
  width: 190px;
}

.amount-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.amount-inline input {
  border: 0;
  padding: 9px 0;
  width: 130px;
  box-shadow: none;
}

.amount-inline:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.amount-inline input:focus {
  box-shadow: none;
}

/* ---------- login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 60px -30px rgba(19, 29, 25, 0.35);
  padding: 30px 28px 24px;
  animation: rise 0.35s ease both;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-brand-text {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13.5px;
}

.login-foot {
  margin: 16px 0 0;
  color: #98a49e;
  font-size: 11.5px;
  text-align: center;
}

.form-error {
  margin: 0 0 12px;
  color: var(--expense);
  background: var(--expense-soft);
  border: 1px solid #f7c9d1;
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 12.5px;
}

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 29, 25, 0.38);
  backdrop-filter: blur(3px);
  animation: fade 0.18s ease both;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 470px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.55);
  padding: 20px 22px 18px;
  animation: rise 0.22s ease both;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 {
  margin: 0;
  font-size: 17.5px;
  letter-spacing: -0.02em;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.amount-field .amount-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px 14px;
  background: #fbfcfa;
}

.amount-input span {
  color: var(--muted);
  font-size: 17px;
  font-weight: 600;
}

.amount-input input {
  border: 0;
  background: transparent;
  padding: 9px 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: none;
  font-variant-numeric: tabular-nums;
}

.amount-input input:focus {
  box-shadow: none;
}

.amount-field .amount-input:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: #131d19;
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 18px 36px -18px rgba(0, 0, 0, 0.6);
  z-index: 80;
  animation: toast-in 0.2s ease both;
  max-width: calc(100vw - 40px);
}

.toast.error {
  background: #8f1d2d;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- responsif ---------- */

@media (max-width: 960px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts {
    grid-template-columns: 1fr;
  }

  .budget-list {
    grid-template-columns: 1fr;
  }

  .budget-item:nth-last-child(2):nth-child(odd) {
    border-bottom: 1px dashed var(--line);
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
  }

  .brand-text em {
    display: none;
  }

  .topbar-actions {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .topbar-actions .btn.primary {
    flex: 1;
    justify-content: center;
  }

  .month-nav {
    margin-left: auto;
  }

  .wrap {
    padding: 18px 16px 32px;
  }

  .stat-value {
    font-size: 19px;
  }

  /* tabel jadi daftar kartu ringkas di layar kecil */
  .table-wrap table,
  .table-wrap tbody,
  .table-wrap td {
    display: block;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "cat amount"
      "date actions";
    align-items: center;
    gap: 2px 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line-2);
  }

  .table-wrap td {
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .table-wrap td:nth-child(2) {
    grid-area: cat;
  }

  .table-wrap td.date {
    grid-area: date;
    font-size: 12px;
    color: var(--muted);
  }

  .table-wrap td.amount {
    grid-area: amount;
    font-size: 13.5px;
  }

  .table-wrap td:last-child {
    grid-area: actions;
    justify-self: end;
  }

  .table-wrap td.col-note {
    grid-column: 1;
    font-size: 12px;
  }

  .table-wrap td.col-method {
    grid-column: 2;
    justify-self: end;
    font-size: 11.5px;
  }

  .donut-wrap {
    flex-direction: column;
    align-items: stretch;
  }

  .donut {
    align-self: center;
  }

  .budgets .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .search {
    width: 100%;
  }

  .txn-tools {
    width: 100%;
  }

  .row2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat {
    padding: 14px 14px 12px;
  }

  .stat-value {
    font-size: 17px;
  }

  .stat-label,
  .stat-hint {
    font-size: 11px;
  }
}
