:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --income: #059669;
  --danger: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #2a2e36;
    --accent: #3b82f6;
    --income: #34d399;
    --danger: #f87171;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

main { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }

.login { max-width: 280px; margin: 22vh auto 0; text-align: center; padding: 0 16px; }
.login h1 { font-size: 28px; margin: 0 0 24px; }
.login form { display: flex; gap: 8px; }
.login input { flex: 1; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); text-align: center; letter-spacing: 4px; }
.login button { padding: 0 18px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 6px; }
.top h1 { font-size: 18px; margin: 0; }
.icon { width: 40px; height: 40px; border: 0; background: none; font-size: 26px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { padding: 10px 12px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.summary span { display: block; font-size: 12px; color: var(--muted); }
.summary strong { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }

.cats { margin: 12px 0 4px; display: grid; gap: 6px; }
.cat { display: grid; grid-template-columns: 72px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.cat .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.cat .bar i { display: block; height: 100%; background: var(--accent); }
.cat .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.cat .amt { font-variant-numeric: tabular-nums; }

.day { margin-top: 16px; }
.day h3 { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.rows { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; }
.row:first-child { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.income { color: var(--income); }
.amt.cancel { color: var(--muted); }
.chip { display: inline-block; padding: 0 6px; margin-right: 4px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); font-size: 11px; }

.noti { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.noti .meta { font-size: 12px; color: var(--muted); }
.noti .body { white-space: pre-wrap; word-break: break-all; margin: 6px 0 10px; font-size: 14px; }
.noti .btns { display: flex; gap: 8px; justify-content: flex-end; }
.noti button, .actions button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }

.hint, .empty { color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 40px 0; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 8px 0 0; }

.fab {
  position: fixed; right: max(16px, calc(50% - 304px)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 28px; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}

dialog { width: min(440px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { font-size: 17px; margin: 0 0 12px; }
dialog label { display: block; font-size: 12px; color: var(--muted); margin-top: 10px; }
dialog input:not([type=radio]), dialog textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 15px; }
.kind { display: flex; gap: 6px; }
.kind label { flex: 1; margin: 0; }
.kind input { position: absolute; opacity: 0; }
.kind label { text-align: center; padding: 8px 0; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 14px; }
.kind label:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
details { margin-top: 10px; font-size: 12px; color: var(--muted); }
pre { white-space: pre-wrap; word-break: break-all; font: 12px/1.4 inherit; background: var(--bg); padding: 8px; border-radius: 8px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions span { flex: 1; }
