* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --ink: #0F172A; --ink2: #475569; --mute: #64748B; --faint: #94A3B8;
  --bg: #F2F4F6; --card: #FFFFFF; --line: #E2E8F0;
  --blue: #2563EB; --green: #059669; --mint: #10B981; --amber: #D97706; --red: #DC2626;
}
html, body { background: #E5E8EB; }
body {
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
  min-height: 100dvh;
  display: flex; justify-content: center;
}
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 16px; }

.app-shell {
  width: 100%; max-width: 480px; height: 100dvh;
  background: var(--bg); display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}
.header {
  background: var(--ink); color: #fff;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header h1 { font-size: 16px; font-weight: 800; }
.logo-box {
  width: 34px; height: 34px; border-radius: 12px; font-weight: 900;
  background: rgba(16,185,129,.2); border: 1px solid rgba(52,211,153,.35); color: #6EE7B7;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.sub-title { font-size: 11px; color: var(--faint); margin-top: 2px; }
.h-btn {
  background: rgba(255,255,255,.12); color: #F1F5F9; border: none;
  padding: 8px 12px; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}

.main-scroll {
  flex: 1; overflow-y: auto; padding: 14px 14px calc(150px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.card {
  background: var(--card); border-radius: 20px; padding: 16px;
  box-shadow: 0 1px 3px rgba(15,23,42,.05);
  display: flex; flex-direction: column; gap: 12px;
}
.card-dark {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  color: #fff; border-radius: 22px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
h2 { font-size: 15px; font-weight: 800; }
h3 { font-size: 14px; font-weight: 800; }
.small { font-size: 12px; color: var(--mute); line-height: 1.55; }
.tiny { font-size: 11px; color: var(--faint); }
.big { font-size: 26px; font-weight: 900; letter-spacing: -.5px; }
.num { font-variant-numeric: tabular-nums; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #ECFDF5; color: var(--green); white-space: nowrap; }
.pill.amber { background: #FFFBEB; color: var(--amber); }
.pill.red { background: #FEF2F2; color: var(--red); }
.pill.blue { background: #EFF6FF; color: var(--blue); }

.stat { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.stat span { font-size: 11px; color: var(--mute); }
.stat p { font-size: 13px; font-weight: 800; margin-top: 4px; }
.card-dark .stat { background: rgba(255,255,255,.08); }
.card-dark .stat span { color: #CBD5E1; }

.progress-bg { width: 100%; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .25s ease; }

.btn { border: none; border-radius: 14px; padding: 12px; font-weight: 800; font-size: 14px; cursor: pointer; }
.btn-primary { background: var(--mint); color: #062018; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-light { background: var(--bg); color: var(--ink2); }
.btn-danger { background: #FEF2F2; color: var(--red); }
.btn-sm { padding: 7px 11px; font-size: 12px; border-radius: 10px; white-space: nowrap; }
.btn-block { width: 100%; }

.search-bar { display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 14px; padding: 6px 6px 6px 12px; }
.search-bar input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; color: var(--ink); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 7px 11px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--ink2);
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.ghost { border-style: dashed; color: var(--mute); }

.tx {
  background: #fff; border-radius: 16px; padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.tx-title { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--bg); color: var(--ink2); }
.tx-amt { font-size: 15px; font-weight: 900; white-space: nowrap; }
.inc { color: var(--blue); }
.day-head { font-size: 12px; font-weight: 800; color: var(--mute); padding: 6px 4px 0; display: flex; justify-content: space-between; }
.empty { text-align: center; padding: 28px 12px; color: var(--mute); font-size: 13px; line-height: 1.6; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--mute); }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px;
  padding: 11px 12px; outline: none; color: var(--ink);
}
.input:focus { border-color: var(--blue); background: #fff; }
.amount-input { font-size: 26px; font-weight: 900; text-align: right; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--bg); padding: 4px; border-radius: 14px; }
.seg button { border: none; background: transparent; padding: 9px 4px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--mute); cursor: pointer; }
.seg button.on { background: #fff; color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg.exp button.on.exp-on { color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink2); }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
input[type="range"] { width: 100%; accent-color: var(--green); height: 24px; }

.month-nav { display: flex; align-items: center; justify-content: center; gap: 14px; }
.month-nav button { border: none; background: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.month-nav strong { font-size: 15px; min-width: 110px; text-align: center; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.bars .b i { display: block; width: 100%; background: #CBD5E1; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .b.cur i { background: var(--blue); }
.bars .b span { font-size: 10px; color: var(--faint); }

.fab {
  position: absolute; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  width: 58px; height: 58px; border-radius: 20px; border: none;
  background: var(--mint); color: #062018; font-size: 30px; font-weight: 700;
  box-shadow: 0 10px 22px -6px rgba(5,150,105,.6); cursor: pointer; z-index: 25;
}
.nav-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  background: rgba(255,255,255,.97); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 2px calc(8px + env(safe-area-inset-bottom, 0px));
}
.nav-item {
  background: none; border: none; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 4px 6px; color: var(--faint); font-size: 11px; font-weight: 600; cursor: pointer; flex: 1;
}
.nav-item.active { color: var(--blue); font-weight: 800; }
.nav-icon { font-size: 19px; line-height: 1; }

.modal-backdrop {
  position: absolute; inset: 0; background: rgba(9,14,26,.6); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: #fff; width: 100%; max-height: 92%; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.x-btn { border: none; background: var(--bg); width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; }

.toast {
  position: absolute; top: calc(16px + env(safe-area-inset-top, 0px)); left: 50%;
  transform: translateX(-50%) translateY(-20px); width: 90%; max-width: 380px;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px;
  font-size: 13px; font-weight: 600; text-align: center; z-index: 60;
  opacity: 0; pointer-events: none; transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.note { font-size: 11px; color: var(--faint); line-height: 1.6; padding: 0 4px; }
.banner { border-radius: 14px; padding: 12px; font-size: 13px; line-height: 1.55; border: 1px solid; }
.banner.ok { background: #ECFDF5; border-color: #A7F3D0; }
.banner.warn { background: #FFFBEB; border-color: #FDE68A; }
.banner.bad { background: #FEF2F2; border-color: #FECACA; }
.banner.info { background: #EFF6FF; border-color: #BFDBFE; }
.hold-row { display: grid; grid-template-columns: 1fr 1.1fr .6fr 30px; gap: 6px; align-items: center; }
.hold-row .input { padding: 9px 8px; font-size: 14px; }
