:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1b; --muted: #6b6a66; --line: #e3e1db;
  --accent: #1f5f8b; --accent-text: #ffffff; --open: #a4441c; --ok: #2e6b3a;
  --ok-bg: #e6f2e8; --err-bg: #f8e3dc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #22221f; --text: #ecebe6; --muted: #a09e97; --line: #3a3934;
    --accent: #6aa9d6; --accent-text: #0f1a22; --open: #e8915f; --ok: #8fcf9b;
    --ok-bg: #1f3324; --err-bg: #3d2219;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif; }
.top-right { display: flex; align-items: center; gap: 16px; }
.langs { display: flex; gap: 10px; font-size: .875rem; }
.langs a { text-decoration: none; }
.langs span { font-weight: 600; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }
.top { display: flex; justify-content: space-between; align-items: center;
  max-width: 640px; margin: 0 auto; padding: 14px 16px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
a { color: var(--accent); }
.small { font-size: .875rem; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin: 16px 0; }
.card.narrow { max-width: 360px; margin: 48px auto; }
summary { font-weight: 600; cursor: pointer; }
details[open] summary { margin-bottom: 12px; }
label { display: block; margin: 0 0 12px; font-size: .9rem; color: var(--muted); }
input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
input[type=file] { padding: 8px; }
button { font: inherit; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent);
  color: var(--accent-text); cursor: pointer; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); white-space: nowrap; }
button.link { background: none; color: var(--accent); padding: 0; }
button.danger, .danger { color: var(--open); }
button:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: stretch; }
.row input { margin-top: 0; flex: 1; min-width: 0; }
label .row { margin-top: 4px; }
form.inline { display: inline; margin-left: 12px; }
.flash { padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); }
.flash.error { background: var(--err-bg); }
.balance { display: flex; justify-content: space-between; align-items: baseline; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.balance strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.balance.open strong { color: var(--open); }
.preview { font-weight: 600; min-height: 1.5em; margin: -4px 0 12px; }
.list, .entries { list-style: none; padding: 0; margin: 0; }
.list a { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.open { color: var(--open); }
.head-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 24px; }
.entry { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--open);
  border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; }
.entry.repayment { border-left-color: var(--ok); }
.line { display: flex; justify-content: space-between; gap: 12px; }
.meta, .foot { font-size: .85rem; color: var(--muted); }
.note { margin-top: 4px; }
.foot { margin-top: 6px; }
