:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64716d;
  --line: #d8e1dc;
  --paper: #f5f8f5;
  --card: #ffffff;
  --good: #0e7652;
  --caution: #a16108;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.page-shell { width: min(100% - 32px, 880px); margin: 0 auto; padding: 48px 0 72px; }
.site-header, .section-heading, .dialog-heading, .history-title-row, .history-item, .history-side, .dialog-actions { display: flex; align-items: center; }
.site-header, .section-heading { justify-content: space-between; gap: 20px; }
.site-header { margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -0.05em; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
h3 { margin-bottom: 12px; font-size: 1rem; }
.eyebrow { margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.muted, .updated-at, .transaction-meta, .transaction-notes { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.balance-card, .panel { border: 1px solid var(--line); background: var(--card); border-radius: 18px; }
.balance-card { margin-bottom: 18px; padding: 34px; text-align: center; box-shadow: 0 16px 32px rgb(22 54 42 / 7%); }
.balance-label { margin-bottom: 4px; color: var(--muted); font-weight: 700; }
.balance-value { margin-bottom: 8px; font-size: clamp(2.6rem, 9vw, 5.2rem); font-weight: 850; line-height: 1; letter-spacing: -0.07em; }
.balance-message { min-height: 1.6em; margin-bottom: 6px; font-weight: 700; }
.balance-card.is-caution { border-color: #f2c778; background: #fff9ed; }
.balance-card.is-danger { border-color: #efaaa4; background: #fff4f2; }
.balance-card.is-danger .balance-value, .form-error { color: var(--danger); }
.balance-card.is-caution .balance-value { color: var(--caution); }
.panel { margin-top: 18px; padding: 24px; }
.host-panel { background: #f1f6f2; }
.button { border: 1px solid transparent; border-radius: 10px; padding: .65rem .95rem; font-weight: 750; }
.button-primary { color: #fff; background: var(--good); }
.button-primary:hover { background: #095d40; }
.button-quiet { border-color: var(--line); color: var(--ink); background: var(--card); }
.button-danger { color: #fff; background: var(--danger); }
.history-heading { align-items: flex-end; }
.search-field input { width: min(100%, 220px); }
.history-list { display: grid; margin-top: 20px; border-top: 1px solid var(--line); }
.history-item { justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.history-item.is-cancelled { opacity: .58; }
.history-title-row { gap: 8px; }
.transaction-status { padding: .15rem .45rem; border-radius: 999px; color: var(--danger); background: #ffebe8; font-size: .75rem; font-weight: 750; }
.transaction-meta, .transaction-notes { margin: 4px 0 0; }
.history-side { flex-shrink: 0; flex-direction: column; align-items: flex-end; gap: 7px; }
.transaction-amount { font-variant-numeric: tabular-nums; }
.transaction-actions { display: flex; gap: 6px; }
.text-button { border: 0; padding: 0; color: var(--good); background: transparent; font-size: .82rem; font-weight: 750; }
.text-button.cancel-record { color: var(--danger); }
.dialog { width: min(100% - 32px, 580px); border: 0; border-radius: 16px; box-shadow: 0 24px 72px rgb(0 0 0 / 22%); }
.dialog::backdrop { background: rgb(20 30 27 / 52%); }
.dialog-content { display: grid; gap: 16px; padding: 24px; }
.dialog-heading { justify-content: space-between; gap: 12px; }
.icon-button { width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--ink); background: #edf2ee; font-size: 1.5rem; line-height: 1; }
label { display: grid; gap: 7px; font-size: .9rem; font-weight: 750; }
input, textarea { width: 100%; border: 1px solid #bdcac3; border-radius: 9px; padding: .68rem .72rem; color: var(--ink); background: #fff; font-weight: 400; }
input:focus, textarea:focus { outline: 3px solid rgb(14 118 82 / 18%); border-color: var(--good); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.optional { color: var(--muted); font-weight: 400; }
.form-error { min-height: 1.2em; margin-bottom: 0; font-size: .85rem; }
.dialog-actions { justify-content: flex-end; }
hr { width: 100%; margin: 3px 0; border: 0; border-top: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.empty { padding: 26px 0; color: var(--muted); text-align: center; }

@media (max-width: 580px) {
  .page-shell { width: min(100% - 24px, 880px); padding-top: 28px; }
  .balance-card, .panel { padding: 20px; }
  .history-heading, .site-header { align-items: flex-start; flex-direction: column; }
  .search-field, .search-field input { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .history-item { align-items: flex-start; }
  .history-side { align-items: flex-end; }
}
