/* 모아월렛 — 흰색·검정 미니멀 */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f5f3;
  --bg-softer: #faf9f7;
  --line: #ecebe8;
  --line-strong: #dcdad6;
  --text: #111111;
  --text-2: #57534e;
  --text-3: #8f8a84;
  --beige: #e6ddd2;
  --black: #111111;
  --inc: #2f6fde;   /* 수입 금액 */
  --exp: #e2474e;   /* 지출 금액 */
  --danger: #d6342c;
  --radius: 18px;
  --radius-sm: 12px;
  --pad: clamp(14px, 4.5vw, 28px);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 10px 40px rgba(0, 0, 0, .10);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.boot-loading { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--black); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 레이아웃 ---------- */
.shell { min-height: 100dvh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 24px); }
.page { width: 100%; max-width: 760px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) var(--pad) 24px; }
.page.wide { max-width: 1180px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, .94); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--text-3); font-size: 11px; font-weight: 600; }
.tabbar a svg.i { width: 23px; height: 23px; }
.tabbar a.on { color: var(--text); }

.fab {
  position: fixed; z-index: 41; right: max(var(--pad), calc((100vw - 760px) / 2 + var(--pad)));
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 58px; height: 58px; border-radius: 50%; background: var(--black); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.6; }

/* 태블릿·데스크톱·펼친 폴드: 왼쪽 메뉴 */
@media (min-width: 760px) {
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh;
    width: 228px; flex: none; padding: calc(var(--safe-t) + 26px) 14px 20px; border-right: 1px solid var(--line); background: var(--bg);
  }
  .side .brand { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin-bottom: 14px; border-radius: 12px; text-align: left; font-weight: 800; font-size: 17px; cursor: pointer; }
  .side .brand:hover { background: var(--bg-soft); }
  .side .brand .av { width: 36px; height: 36px; font-size: 18px; }
  .side a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 15px; }
  .side a:hover { background: var(--bg-soft); }
  .side a.on { background: var(--black); color: #fff; }
  .side .add { margin-top: 14px; justify-content: center; background: var(--bg-soft); color: var(--text); }
  .side .add:hover { background: var(--line); }
  .side .spacer { flex: 1; }
  .main { padding-bottom: 40px; }
  .fab { display: none; }
}
@media (min-width: 760px) and (max-width: 980px) {
  .side { width: 76px; padding-inline: 10px; align-items: center; }
  .side .brand span, .side a span { display: none; }
  .side .brand { width: auto; padding: 6px; }
  .side a { justify-content: center; padding: 12px; }
}

/* ---------- 헤더 (사진 스타일) ---------- */
.hh-head { display: flex; align-items: center; gap: 16px; padding: 14px 0 26px; }
.av { width: clamp(56px, 15vw, 76px); height: clamp(56px, 15vw, 76px); border-radius: 50%; background: var(--beige); display: grid; place-items: center; font-size: clamp(26px, 7vw, 36px); flex: none; }
.hh-head .t { flex: 1; min-width: 0; }
.hh-head .t b { display: block; font-size: clamp(19px, 5vw, 22px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hh-head .t small { display: block; color: var(--text-2); font-size: clamp(14px, 4vw, 17px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--text); flex: none; }
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn svg.i { width: 25px; height: 25px; }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm svg.i { width: 20px; height: 20px; }

.month-row { display: flex; align-items: center; gap: 6px; }
.month-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; font-size: clamp(18px, 5.4vw, 27px); font-weight: 800; letter-spacing: -0.03em; }
.month-title button { display: inline-flex; align-items: center; }
.month-title button[hidden] { display: none; }
.month-title .icon-btn.sm { width: 30px; height: 30px; }
.month-title .val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; margin: 16px 0 4px; }
.sum-grid .r { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: clamp(13.5px, 3.8vw, 15.5px); min-width: 0; }
.sum-grid .r b { font-weight: 700; white-space: nowrap; }
.sum-grid .r span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-grid .r span.zero { color: var(--text-3); }

/* 좁은 화면(폴드 커버 등) */
@media (max-width: 360px) {
  :root { --pad: 12px; --nav-h: 58px; }
  .sum-grid { grid-template-columns: 1fr; gap: 4px; }
  .tabbar a span { display: none; }
  .hh-head { gap: 12px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* ---------- 공통 컴포넌트 ---------- */
.section { margin-top: 26px; }
.section-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.section-h h2 { font-size: 17px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }
.section-h .link { font-size: 14px; color: var(--text-2); font-weight: 600; padding: 6px 2px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.soft { background: var(--bg-soft); border-color: transparent; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--bg-soft); color: var(--text-2); font-size: 14px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.chip.on { background: var(--black); color: #fff; }
.chip.outline { background: var(--bg); border-color: var(--line-strong); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 6px; background: var(--bg-soft); color: var(--text-2); font-size: 11.5px; font-weight: 700; vertical-align: 1px; }
.badge.dark { background: var(--black); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg-soft); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { padding: 9px 6px; border-radius: 9px; font-weight: 700; font-size: 14.5px; color: var(--text-3); }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 18px; border-radius: 14px; background: var(--black); color: #fff; font-weight: 700; font-size: 15.5px; }
.btn:disabled { opacity: .45; }
.btn.ghost { background: var(--bg-soft); color: var(--text); }
.btn.line { background: var(--bg); color: var(--text); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--bg); color: var(--danger); border: 1px solid var(--line); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.block { width: 100%; }
.empty { text-align: center; color: var(--text-3); padding: 38px 10px; font-size: 14.5px; }
.empty .em { font-size: 34px; display: block; margin-bottom: 8px; }

/* 진행 막대 */
.bar { height: 8px; border-radius: 99px; background: var(--bg-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--black); border-radius: 99px; }
.bar.over > i { background: var(--danger); }

/* ---------- 거래 목록 ---------- */
.tools { display: flex; align-items: center; gap: 8px; margin: 22px 0 6px; }
.tools .chips { flex: 1; min-width: 0; }
.day { margin-top: 18px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 2px 6px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--text-3); font-weight: 600; }
.day-h .d { color: var(--text); font-weight: 700; }
.tx { display: flex; align-items: center; gap: 12px; padding: 12px 2px; width: 100%; text-align: left; border-radius: 12px; }
.tx:hover { background: var(--bg-softer); }
.tx .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--bg-soft); display: grid; place-items: center; font-size: 19px; flex: none; }
.tx .body { flex: 1; min-width: 0; }
.tx .body b { display: block; font-weight: 600; font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .body small { display: block; color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx .amt { font-weight: 700; font-size: 15.5px; white-space: nowrap; text-align: right; }
.tx .amt.in { color: var(--text); }
.tx .amt.out { color: var(--text); }
.tx .amt.tr { color: var(--text-3); font-weight: 600; }
.tx .amt small { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-3); }

/* 달력 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-top: 12px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--text-3); font-weight: 700; padding: 6px 0; }
.cal .c { min-height: clamp(54px, 13vw, 84px); border-radius: 10px; padding: 5px 2px; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.cal .c:hover { background: var(--bg-softer); }
.cal .c .n { font-size: 13px; font-weight: 700; width: 22px; height: 22px; display: grid; place-items: center; flex: none; } /* 날짜 숫자는 22px 동그라미 자리 안 가운데 */
.cal .c.today .n { background: var(--black); color: #fff; border-radius: 99px; }
.cal .c.sel { background: var(--bg-soft); }
.cal .c.other { opacity: .25; }
.cal .c .p, .cal .c .m { font-size: clamp(9.5px, 2.6vw, 12px); font-weight: 700; letter-spacing: -0.04em; white-space: nowrap; overflow: hidden; line-height: 1.25; }
.cal .c .p { color: var(--inc); }  /* 수입: 파랑 */
.cal .c .m { color: var(--exp); }  /* 지출: 빨강 */
.cal .sun .n, .cal .wd.sun { color: var(--danger); }

/* 두 칸 레이아웃 (넓은 화면) */
.cols { display: grid; gap: 0 36px; grid-template-columns: minmax(0, 1fr); }
.cols > * { min-width: 0; }
@media (min-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
  .cols > .aside { position: sticky; top: 24px; }
}

/* ---------- 자산 ---------- */
.total-box { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.total-box .k { background: var(--bg-soft); border-radius: var(--radius); padding: 16px; min-width: 0; }
.total-box .k.dark { background: var(--black); color: #fff; }
.total-box .k small { display: block; font-size: 13px; font-weight: 600; opacity: .7; }
.total-box .k b { display: block; font-size: clamp(18px, 5vw, 24px); font-weight: 800; letter-spacing: -0.03em; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 360px) { .total-box { grid-template-columns: 1fr; } }

.acc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.acc { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.acc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; text-align: left; width: 100%; }
.acc-top .nm { min-width: 0; }
.acc-top .nm b { font-size: 16px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-top .nm small { color: var(--text-3); font-size: 13px; }
.acc .bal { font-size: clamp(20px, 5.5vw, 24px); font-weight: 800; letter-spacing: -0.03em; }
.acc .rows { display: grid; gap: 4px; font-size: 13.5px; }
.acc .rows .r { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); }
.acc .rows .r b { color: var(--text); font-weight: 700; }
.acc .linked { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line); }
.acc .linked button { font-size: 12.5px; padding: 5px 10px; border-radius: 99px; background: var(--bg-soft); font-weight: 600; color: var(--text-2); }
.acc .linked button.add { background: none; border: 1px dashed var(--line-strong); color: var(--text-3); }

.cc { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cc .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; width: 100%; }
.cc .head b { font-size: 16px; }
.cc .bills { margin-top: 10px; display: grid; gap: 6px; }
.cc .bill { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 10px 12px; background: var(--bg-soft); border-radius: 12px; font-size: 14px; }
.cc .bill.cur { background: var(--black); color: #fff; }
.cc .bill small { display: block; font-size: 12px; opacity: .65; }
.cc .bill b { font-size: 16px; white-space: nowrap; }

/* ---------- 배분 ---------- */
.alloc-acc { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.alloc-acc .h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; background: var(--bg-soft); }
.alloc-acc .h b { font-size: 15.5px; }
.alloc-acc .h .tot { font-weight: 800; font-size: 16px; white-space: nowrap; }
.alloc-item { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.alloc-item:first-of-type { border-top: 0; }
.alloc-item .nm { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alloc-item .v { font-weight: 600; white-space: nowrap; }
.alloc-add { width: 100%; padding: 11px 16px; border-top: 1px solid var(--line); color: var(--text-3); font-size: 14px; font-weight: 600; text-align: left; }

/* ---------- 통계 ---------- */
.stat-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 10px; align-items: center; padding: 9px 0; }
.stat-row .ic { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-soft); display: grid; place-items: center; font-size: 16px; grid-row: span 2; }
.stat-row .nm { font-size: 14.5px; font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-row .v { font-weight: 700; font-size: 14.5px; text-align: right; white-space: nowrap; }
.stat-row .bar { grid-column: 2 / 4; height: 6px; }
.trend { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; align-items: end; height: 170px; padding-top: 10px; }
.trend .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.trend .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.trend .bars i { width: min(14px, 40%); border-radius: 5px 5px 2px 2px; background: var(--black); min-height: 2px; }
.trend .bars i.inc { background: var(--line-strong); }
.trend .lb { font-size: 12px; color: var(--text-3); font-weight: 600; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--black); margin-right: 5px; vertical-align: -1px; }
.legend i.inc { background: var(--line-strong); }
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

/* ---------- 설정 ---------- */
.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .it { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); width: 100%; text-align: left; font-size: 15px; min-height: 52px; }
.list .it:first-child { border-top: 0; }
.list .it:is(button, a):hover { background: var(--bg-softer); }
.list .it .l { flex: 1; min-width: 0; }
.list .it .l small { display: block; color: var(--text-3); font-size: 13px; }
.list .it .rv { color: var(--text-3); font-size: 14px; white-space: nowrap; }
.list .it.danger { color: var(--danger); }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 20px; font-weight: 700; letter-spacing: .12em; }

/* ---------- 폼 / 시트 ---------- */
.field { display: grid; gap: 6px; margin-top: 14px; }
.field > label, .field > .lb { font-size: 13px; font-weight: 700; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23111' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.input:focus { border-color: var(--black); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
@media (max-width: 360px) { .row2, .row3 { grid-template-columns: 1fr; } }
.amount-input { display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--black); padding: 6px 0; margin-top: 18px; }
.amount-input input { flex: 1; min-width: 0; border: 0; outline: none; font-size: clamp(28px, 8vw, 36px); font-weight: 800; letter-spacing: -0.03em; padding: 0; background: transparent; }
.amount-input span { font-size: 22px; font-weight: 700; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.cat-grid button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px; border-radius: 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); border: 1px solid transparent; min-width: 0; }
.cat-grid button span:first-child { font-size: 21px; }
.cat-grid button span:last-child { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-grid button.on { background: var(--black); color: #fff; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.err { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: calc(100dvh - var(--safe-t) - 24px); background: var(--bg);
  border-radius: 24px 24px 0 0; display: flex; flex-direction: column; animation: up .24s cubic-bezier(.2, .9, .3, 1); overflow: hidden;
}
.sheet .sh { display: flex; align-items: center; gap: 8px; padding: 18px var(--pad) 6px; }
.sheet .sh h3 { flex: 1; margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.sheet .sb { padding: 4px var(--pad) 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet .sf { padding: 12px var(--pad) calc(14px + var(--safe-b)); display: flex; gap: 8px; border-top: 1px solid var(--line); background: var(--bg); }
.sheet .sf .btn { flex: 1; }
.sheet .sf .btn.danger, .sheet .sf .btn.ghost.narrow { flex: 0 0 auto; }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line-strong); margin: 8px auto 0; }
@media (min-width: 760px) {
  .overlay { align-items: center; padding: 24px; }
  .sheet { border-radius: 24px; box-shadow: var(--shadow); max-height: min(860px, calc(100dvh - 48px)); }
  .grab { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 90px); transform: translate(-50%, 20px); background: var(--black); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: .22s; z-index: 80; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { #toast { bottom: 32px; } }

/* ---------- 로그인 ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(var(--safe-t) + 24px) var(--pad) calc(var(--safe-b) + 24px); }
.auth .box { width: 100%; max-width: 380px; }
.auth .logo { width: 72px; height: 72px; font-size: 34px; margin-bottom: 18px; }
.auth h1 { font-size: 26px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.03em; }
.auth p { margin: 0 0 18px; color: var(--text-2); }
.auth .switch { margin-top: 18px; text-align: center; font-size: 14px; color: var(--text-3); }
.auth .switch button { font-weight: 700; color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.search-bar { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 14px; padding: 0 12px; }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: none; padding: 12px 0; font-size: 16px; }

/* ---------- 체크박스 ---------- */
.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 4px 0; font-size: 14.5px; font-weight: 500; color: var(--text-2); cursor: pointer; user-select: none; line-height: 1.4; }
.check:has(input:checked) { color: var(--text); }
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none; flex: none; margin: 0;
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--bg);
  display: grid; place-items: center; cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
input[type="checkbox"]::after {
  content: ''; width: 12px; height: 12px; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.2 6.3 4.8 8.8 9.8 3.4' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="checkbox"]:hover { border-color: var(--text-3); }
input[type="checkbox"]:checked { background: var(--black); border-color: var(--black); }
input[type="checkbox"]:checked::after { opacity: 1; transform: scale(1); }
input[type="checkbox"]:active { transform: scale(.92); }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; }

/* ---------- 카드값 · 영수증 ---------- */
.cc .bill { width: 100%; text-align: left; }
.bill-row .ic { background: var(--black); }
.cal .c .k { font-size: clamp(9.5px, 2.6vw, 12px); font-weight: 600; letter-spacing: -0.04em; color: var(--text-3); white-space: nowrap; overflow: hidden; line-height: 1.25; } /* 카드값 나가는 날: 회색 */
.receipt-btn { margin-bottom: 14px; }
.rc-list { display: grid; gap: 8px; }
.rc-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) 110px; gap: 6px 8px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 14px; }
.rc-item .cat { grid-column: 2 / 4; }
.rc-item .input { padding: 10px 11px; font-size: 15px; }
.rc-item.off { opacity: .45; }
@media (max-width: 360px) { .rc-item { grid-template-columns: 22px minmax(0, 1fr); } .rc-item .input.num, .rc-item .cat { grid-column: 2 / 3; } }

/* 지출 결제수단별 */
.exp-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.exp-split > div { position: relative; overflow: hidden; background: var(--bg-soft); border-radius: 12px; padding: 9px 11px 11px; min-width: 0; }
.exp-split small { display: block; font-size: 12px; color: var(--text-3); font-weight: 600; }
.exp-split b { display: block; font-size: clamp(13px, 3.8vw, 15.5px); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exp-split i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--black); }
.exp-split .zero b { color: var(--text-3); font-weight: 600; }
/* 4칸(용돈 통장 포함)일 땐 좁은 화면에서 2×2 */
.exp-split.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 620px) { .exp-split.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 300px) {
  .exp-split, .exp-split.four { grid-template-columns: 1fr; gap: 4px; }
  .exp-split > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 7px 10px 9px; }
}

/* 이용건별 선결제 */
.pp-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 2px 8px; font-size: 14.5px; }
.pp-head .link { font-weight: 700; font-size: 14px; color: var(--text-2); padding: 4px 2px; }
.pp-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pp-group { padding: 9px 14px; background: var(--bg-soft); font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.pp-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.pp-group + .pp-item { border-top: 0; }
.pp-item .l { flex: 1; min-width: 0; }
.pp-item .l b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-item .l small { display: block; font-size: 12.5px; color: var(--text-3); }
.pp-item > b { font-size: 15px; white-space: nowrap; }

/* ---------- 가계부 첫 화면: 한 화면에 들어오게 ---------- */
.home.page { padding-top: calc(var(--safe-t) + 8px); }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; min-height: 48px; }
.hh-mini { display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; padding: 4px 0; }
.hh-mini .av { width: 32px; height: 32px; font-size: 16px; }
.hh-mini b { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mnav { display: flex; align-items: center; gap: 0; }
.mnav b { font-size: clamp(18px, 5vw, 22px); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; padding: 0 2px; }
.mnav .icon-btn.sm { width: 30px; height: 30px; }
.tb-icons { display: flex; justify-content: flex-end; gap: 0; }
.tb-icons .icon-btn.sm { width: 36px; height: 36px; }
.tb-icons .icon-btn.sm svg.i { width: 21px; height: 21px; }

.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.hero > div { min-width: 0; }
.hero small { display: block; font-size: 13px; font-weight: 700; color: var(--text-3); }
.hero b { display: block; font-size: clamp(20px, 6vw, 28px); font-weight: 800; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.home .mini { margin-top: 4px; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home .mini b { color: var(--text-2); font-weight: 700; }
.bal-strip { display: flex; align-items: center; gap: 12px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg-soft); text-decoration: none; font-size: 13.5px; color: var(--text-2); min-width: 0; }
.bal-strip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bal-strip span:first-child b { color: var(--text); font-size: 15px; }
.bal-strip b { font-weight: 700; }
.bal-strip svg.i { width: 16px; height: 16px; margin-left: auto; flex: none; color: var(--text-3); }
.home .bar { margin-top: 0; }
.home .budget { margin-top: 10px; }
.home .chips.who { margin-top: 10px; }

/* 달력: 휴대폰에서 칸 높이를 줄여 아래 내역까지 한 화면에 */
.home .cal { margin-top: 8px; gap: 1px; }
.home .cal .wd { padding: 4px 0; }
.home .cal .c { min-height: clamp(44px, 11.5vw, 84px); padding: 4px 3px; }
.home .day { margin-top: 12px; }
@media (max-width: 360px) {
  .hh-mini b { display: none; }
  .hero b { font-size: 19px; }
  .bal-strip { gap: 8px; font-size: 12.5px; }
  .bal-strip span:first-child b { font-size: 13.5px; }
}

.home .sum-grid { margin: 8px 0 0; gap: 5px 24px; }
.home .sum-grid .r { font-size: clamp(13.5px, 3.9vw, 15.5px); }
.home .sum-grid .r span { color: var(--text); font-weight: 600; }
.home .sum-grid .r span.zero { color: var(--text-3); font-weight: 400; }
.home .mini { margin-top: 6px; }

/* 달력 스와이프: 세로 스크롤은 브라우저가, 가로 밀기는 앱이 처리 */
.home .cal { touch-action: pan-y; will-change: transform; backface-visibility: hidden; }

/* 금액은 '…'로 자르지 않기 */
.cal .c .wrap { white-space: normal; line-height: 1.1; }
.home .sum-grid .r span { overflow: visible; text-overflow: clip; flex: none; }
.home .sum-grid .r b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.home .mini { white-space: normal; overflow: visible; }
.bal-strip { flex-wrap: wrap; row-gap: 2px; }
.bal-strip span { overflow: visible; text-overflow: clip; }
.bal-strip svg.i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.bal-strip { position: relative; padding-right: 32px; }
.total-box .k b, .acc .bal, .hero b { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
.tx .amt { flex: none; }

.acc-act { display: flex; gap: 6px; flex-wrap: wrap; }
.acc-act .btn { flex: 1; }

/* 지출 중 현금·체크·신용 */
.exp-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13.5px; color: var(--text-2); }
.exp-line .lb { font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.exp-line b { color: var(--text); font-weight: 700; }
.exp-line .zero b { color: var(--text-3); font-weight: 500; }

.warn { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: #fff6e5; border: 1px solid #f3d9a6; font-size: 13.5px; line-height: 1.5; color: #6b4a10; }
.warn .btn { display: flex; width: 100%; margin: 8px 0 4px; }
.warn small { display: block; color: #8a6a2c; font-size: 12px; }

/* ---------- 내역 입력: 한눈에 ---------- */
.tx-top { display: flex; gap: 8px; align-items: stretch; }
.tx-top .seg { flex: 1; min-width: 0; }
.date-chip { position: relative; flex: none; display: flex; align-items: center; justify-content: center; padding: 0 14px; min-width: 92px; border-radius: 12px; background: var(--bg-soft); font-weight: 700; font-size: 14.5px; cursor: pointer; }
.date-chip input, .date-chip select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; -webkit-appearance: none; appearance: none; }
.amt-row { display: flex; align-items: flex-end; gap: 10px; }
.amt-row .amount-input { flex: 1; min-width: 0; }
.receipt-chip { flex: none; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 10px; margin-bottom: 6px; border-radius: 12px; background: var(--bg-soft); font-size: 18px; line-height: 1.1; }
.receipt-chip span { font-size: 11px; font-weight: 700; color: var(--text-2); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.pills.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 6px; padding-bottom: 2px; }
.pills.scroll::-webkit-scrollbar { display: none; }
.pill { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); font-size: 14.5px; font-weight: 600; color: var(--text); white-space: nowrap; }
.pill .e { font-size: 16px; line-height: 1; }
.pill.on { background: var(--black); border-color: var(--black); color: #fff; }
.pill.more { color: var(--text-3); border-style: dashed; }
.pill.pay { flex-direction: column; justify-content: center; gap: 0; line-height: 1.2; padding: 8px 15px; min-height: 50px; }
.pill.pay small { font-size: 11px; font-weight: 600; color: var(--text-3); }
.pill.pay.on small { color: rgba(255, 255, 255, .7); }
.sub-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 16px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.sub-h span { font-size: 12px; font-weight: 600; color: var(--text-3); text-align: right; }
.memo-input { margin-top: 16px; }
.sheet .amount-input { margin-top: 12px; }

.paymode { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-top: 6px; padding: 3px; border-radius: 11px; background: var(--bg-soft); }
.paymode button { padding: 7px 18px; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--text-3); }
.paymode button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.pills.sugg { margin-top: 8px; }
.pills.sugg .pill { padding: 6px 12px; font-size: 13.5px; font-weight: 500; color: var(--text-2); background: var(--bg-soft); border-color: transparent; }
.add-memo { margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--text-3); padding: 4px 2px; }
.memo-area { margin-top: 10px; resize: vertical; min-height: 64px; line-height: 1.5; }

.run-item { display: grid; grid-template-columns: 22px minmax(0, 1fr) 118px; gap: 10px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.run-item .nm { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-item .input { padding: 8px 10px; font-size: 15px; text-align: right; }
.run-item.off .nm, .run-item.off .input { opacity: .4; }

/* 분류별 예산 */
button.stat-row { width: 100%; text-align: left; border-radius: 10px; }
button.stat-row:hover { background: var(--bg-softer); }
.stat-row .bud { margin-left: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-3); }
.stat-row .v.over { color: var(--exp); }

/* 예산 목록: 바로 입력 */
.bud-row { cursor: text; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.bud-row .input { width: 130px; flex: none; padding: 9px 10px; text-align: right; font-size: 15px; }
.bud-row .won { font-size: 14px; color: var(--text-2); }
.bud-row .saved { width: 16px; font-weight: 800; color: var(--inc); opacity: 0; transition: opacity .2s; }
.bud-row.ok .saved { opacity: 1; }
@media (max-width: 360px) { .bud-row .input { width: 100px; } }
.bud-row { gap: 6px; }
.bud-row .l { white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bud-row .input { width: 112px; }
@media (max-width: 360px) { .bud-row .input { width: 92px; } }

/* 주별 표 */
.wk { padding: 16px 0 14px; }
.wk > .section-h, .wk > .chips, .wk > .hint, .wk > .empty { padding: 0 16px; }
.wk-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.wk-t { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
.wk-t th, .wk-t td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.wk-t thead th { font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--bg-soft); }
.wk-t thead th small { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-3); }
.wk-t .sticky { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--bg); font-weight: 600; box-shadow: 1px 0 0 var(--line); }
.wk-t thead .sticky { background: var(--bg-soft); }
.wk-t tfoot th, .wk-t tfoot td { font-weight: 800; border-bottom: 0; border-top: 2px solid var(--text); }
.wk-t .b { font-weight: 700; }
.wk-t .bud { color: var(--text-2); }
.wk-t .z { color: var(--line-strong); }
.wk-t .neg { color: var(--exp); font-weight: 700; }

/* 요약: 왼쪽 수입·적금, 오른쪽 지출과 그 아래 현금·체크·신용 */
.sum2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin-top: 8px; }
.sum2 .col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sum2 .r { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: clamp(13.5px, 3.9vw, 15.5px); }
.sum2 .r b { font-weight: 700; white-space: nowrap; }
.sum2 .r span { font-weight: 600; white-space: nowrap; }
.sum2 .r span.zero { color: var(--text-3); font-weight: 400; }
.sum2 .r.sub { font-size: clamp(12px, 3.4vw, 13.5px); padding-left: 12px; color: var(--text-2); }
.sum2 .r.sub b { font-weight: 600; color: var(--text-3); }
.sum2 .r.sub span { font-weight: 600; }
@media (max-width: 360px) { .sum2 { grid-template-columns: 1fr; gap: 5px; } }
/* 지출 아래 항목 표시 */
.sum2 .r.sub { padding-left: 4px; }
.sum2 .r.sub b::before { content: '└'; margin-right: 5px; color: var(--line-strong); font-weight: 400; }
/* 조금 더 진하게 */
.sum2 .r.sub b::before { color: var(--text-3); }
.cal .c.sel { background: #f1efeb; }
.cal .c.sel:hover { background: #edeae5; }

.total-box .k b.over-t { color: var(--exp); }
/* PC·태블릿은 왼쪽 메뉴에 가계부 이름이 있으니 달력 위 이름은 숨겨요 (자리는 남겨서 달 이동 버튼은 가운데 그대로) */
@media (min-width: 760px) { .hh-mini { visibility: hidden; } }
/* 날짜 메모 */
.cal .c .n { position: relative; align-self: flex-start; }
.cal .c .nd { position: absolute; top: 2px; right: -3px; width: 5px; height: 5px; border-radius: 50%; background: var(--text); }
.cal .c.today .n .nd { top: -1px; right: -2px; box-shadow: 0 0 0 1.5px #fff; }
.day-acts { display: flex; gap: 14px; align-items: baseline; }
.day-note { display: flex; gap: 6px; align-items: flex-start; width: 100%; text-align: left; margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: var(--bg-soft); font-size: 14px; font-weight: 600; color: var(--text); }
.day-note span { min-width: 0; overflow-wrap: anywhere; }
.bud-row .bs { display: block; font-size: 12px; color: var(--text-3); font-weight: 500; white-space: normal; }
.bud-row .bs:empty { display: none; }
.bud-row .bs .neg { color: var(--exp); font-weight: 700; }
/* 다가오는 카드값: 자산의 카드값 칸과 같은 모양, 지금 이용기간(다음 결제분)은 검정 */
.up-bills { display: grid; gap: 8px; }
.up-bill { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 14px; background: var(--bg-soft); border-radius: 12px; font-size: 14.5px; font-weight: 600; }
.up-bill small { display: block; margin-top: 2px; font-size: 12.5px; font-weight: 500; color: var(--text-3); }
.up-bill b { font-size: 15px; white-space: nowrap; }
.up-bill.cur { background: var(--black); color: #fff; }
.up-bill.cur small { color: rgba(255, 255, 255, 0.65); }
/* 통계: 분류별 비율 · 전월 대비 */
.ratio { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--bg-soft); margin: 2px 0 10px; }
.ratio i { display: block; height: 100%; min-width: 2px; }
.ratio-lg { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.ratio-lg span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ratio-lg i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.ratio-lg b { color: var(--text); font-weight: 700; }
.stat-row .pc { font-size: 12px; font-weight: 600; color: var(--text-3); margin-left: 4px; }
.stat-row.cmp .v small { display: block; font-size: 11.5px; font-weight: 600; margin-top: 1px; }
.dlt.bad { color: var(--exp); }
.dlt.good { color: var(--inc); }
.dlt.same { color: var(--text-3); }
.icon-btn.on { background: var(--black); color: #fff; } /* 통장 골라 보는 중 */
.icon-btn.on:hover { background: var(--black); }
/* 달력 칸: 날짜 동그라미와 금액을 가운데 정렬 (모서리에 붙지 않게) */
.cal .c { align-items: center; text-align: center; padding-top: 5px; }
.cal .c .n { align-self: center; }
.cal .c .p, .cal .c .m, .cal .c .k { max-width: 100%; text-align: center; }
