/* 지구별포켓 — 시안 A "맑은 낮" */
:root {
  --bg: #F5F7F8; --card: #FFFFFF; --ink: #16202A; --ink2: #2E3A44; --mute: #52606B; --mute2: #5F6B75;
  --line: #D5DCE0; --line2: #E3E8EB; --seg: #E6EBEE;
  --accent: #0F766E; --accent-d: #115E59; --accent-l: #E3F2F0; --accent-m: #9FD3CC;
  --exp: #B42318; --inc: #1D4ED8; --warn: #B45309;
  --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex-shrink: 0; }

#view {
  max-width: 520px; margin: 0 auto; min-height: 100%;
  padding: calc(var(--safe-t) + 12px) 0 calc(var(--tab-h) + var(--safe-b) + 16px);
}

/* 탭바 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line2);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1 1 0; max-width: 130px; height: var(--tab-h); border: 0; background: none; color: var(--mute2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px;
}
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 700; }
.tabbar .fab { color: var(--accent); font-weight: 700; justify-content: flex-start; gap: 2px; }
.tabbar .fab-c {
  width: 60px; height: 60px; margin-top: -24px; border-radius: 30px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; border: 4px solid var(--bg);
  box-shadow: 0 6px 16px rgba(15,118,110,.35); transition: transform .12s;
}
.tabbar .fab:active .fab-c { transform: scale(.94); background: var(--accent-d); }

/* 캘린더 */
.cal-sum { display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--mute2); padding: 0 0 10px; }
.cal { margin: 0 12px; padding: 8px 6px 6px; }
.cal-w { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-size: 11px; color: var(--mute2); padding-bottom: 4px; }
.cal-w .sat { color: var(--inc); } .cal-w .sun { color: var(--exp); }
.cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); row-gap: 2px; }
.cal-g button { height: 52px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 0 0; min-width: 0; border-radius: 10px; }
.cal-g button.out { opacity: .35; }
.cal-g .n { width: 26px; height: 26px; border-radius: 13px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.cal-g .e, .cal-g .i { font-size: 10px; line-height: 1.1; white-space: nowrap; max-width: 100%; overflow: hidden; }
.cal-g .e { color: var(--exp); } .cal-g .i { color: var(--inc); }
.cal-g .today .n { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-g .sel .n { background: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.chip.outline { background: var(--accent-l); color: var(--accent); border: 1px solid var(--accent); padding: 0 14px; }
.chip:disabled { opacity: .4; }

/* 공통 */
.row { display: flex; align-items: center; gap: 10px; }
.pad { padding: 0 20px; }
.grow { flex-grow: 1; min-width: 0; }
.seg { display: inline-flex; background: var(--seg); border-radius: 12px; padding: 4px; }
.seg button { height: 36px; padding: 0 18px; border: 0; border-radius: 9px; background: transparent; color: var(--mute); font-size: 15px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(22,32,42,.08); }
.iconbtn { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--card); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.iconbtn.plain { background: none; color: var(--ink2); }
.chip { height: 36px; padding: 0 12px 0 14px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.chip.light { background: var(--card); color: var(--ink2); font-weight: 500; border: 1px solid var(--line); padding: 0 12px; }
.card { background: var(--card); border-radius: 16px; padding: 16px 18px; }
.h2 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.mute { color: var(--mute2); }
.btn { height: 52px; width: 100%; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 700; }
.btn:active { background: var(--accent-d); }
.btn.ghost { background: var(--card); color: var(--ink2); border: 1px solid var(--line); font-weight: 500; }
.btn.danger { background: var(--card); color: var(--exp); border: 1px solid #F1C4BF; font-weight: 500; }
.input { height: 44px; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 16px; background: var(--card); }
.input:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 입력 화면 */
.amount { padding: 14px 20px 14px; }
.amount .big { display: flex; align-items: baseline; gap: 6px; }
.amount .sym { font-size: 28px; font-weight: 500; color: var(--mute); }
.amount .num { font-size: 52px; font-weight: 700; letter-spacing: -1px; line-height: 1.15; word-break: break-all; }
.amount .num.zero { color: #AEB8BF; }
.amount .conv { font-size: 17px; font-weight: 600; color: var(--accent); min-height: 24px; margin-top: 2px; }
.amount .conv:empty, .amount .rate:empty { display: none; }
.amount .rate { font-size: 12px; color: var(--mute2); min-height: 17px; margin-top: 2px; }
.amount .rate.warn { color: var(--warn); }
.cats {
  display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 66px); grid-auto-columns: calc((100% - 24px) / 4.3);
  gap: 8px; padding: 0 20px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  border: 0; border-radius: 14px; background: var(--card); color: var(--ink2); scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 13px; font-weight: 500;
  padding: 0 4px; text-align: center; line-height: 1.15;
}
.cats button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.meta { display: flex; gap: 8px; padding: 12px 20px 10px; align-items: center; }
.meta .input { height: 40px; font-size: 14px; }
.meta .m { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--mute); font-size: 14px; flex-shrink: 0; }
.meta .m[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-l); color: var(--accent); font-weight: 700; }
.keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0 20px; }
.keys button { height: 46px; border: 0; border-radius: 12px; background: var(--card); font-size: 22px; font-weight: 500; }
.keys button:active { background: var(--accent-l); }
.save { padding: 10px 20px 0; }
.photo-row { display: flex; gap: 10px; align-items: center; padding: 0 20px 10px; }
.photo-row img { width: 40px; height: 40px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line2); }
.dateinput { position: relative; }
.dateinput input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.banner { margin: 0 20px 10px; padding: 10px 12px; border-radius: 12px; background: var(--accent-l); color: var(--accent-d); font-size: 13px; }
.banner.warn { background: #FEF3E2; color: var(--warn); }
.progress { height: 4px; border-radius: 2px; background: var(--seg); overflow: hidden; margin-top: 6px; }
.progress div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* 내역 */
.periodbar { display: flex; align-items: center; gap: 4px; padding: 0 12px 8px; }
.periodbar h1 { margin: 0; flex-grow: 1; text-align: center; font-size: 20px; font-weight: 700; }
.list-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.list-sum .k { font-size: 12px; color: var(--mute2); }
.list-sum .v { font-size: 16px; font-weight: 700; }
.day { margin-top: 14px; }
.day-h { display: flex; justify-content: space-between; font-size: 13px; color: var(--mute2); padding: 0 6px 6px; }
.item { width: 100%; border: 0; background: var(--card); display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line2); }
.day .item:first-of-type { border-radius: 14px 14px 0 0; }
.day .item:last-of-type { border-radius: 0 0 14px 14px; border-bottom: 0; }
.day .item:only-of-type { border-radius: 14px; }
.item .ic { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-l); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.item.inc .ic { background: #E6EEFE; color: var(--inc); }
.item .t1 { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t2 { font-size: 12px; color: var(--mute2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { text-align: right; flex-shrink: 0; }
.item .a1 { font-size: 15px; font-weight: 700; }
.item.inc .a1 { color: var(--inc); }
.item .a2 { font-size: 12px; color: var(--mute2); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: #FEF3E2; color: var(--warn); margin-left: 4px; font-weight: 600; }
.badge.ok { background: var(--accent-l); color: var(--accent-d); }
.searchbox { position: relative; margin: 10px 0 0; }
.searchbox svg { position: absolute; left: 12px; top: 11px; color: var(--mute2); }
.searchbox .input { padding-left: 40px; }
.empty { text-align: center; color: var(--mute2); padding: 48px 0; font-size: 14px; }

/* 통계 */
.stack { display: flex; flex-direction: column; gap: 10px; padding: 0 16px; }
.donut-wrap { display: flex; gap: 18px; align-items: center; }
.donut { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.donut .c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.legend { flex-grow: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.legend div { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend span:nth-child(2) { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: grid; gap: 8px; align-items: end; height: 140px; }
.bars > div { display: flex; flex-direction: column; align-items: center; gap: 4px; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar { width: 100%; border-radius: 6px 6px 2px 2px; background: var(--accent-m); min-height: 2px; }
.bars .bar.top { background: var(--accent); }
.bars .v { font-size: 10px; color: var(--mute2); white-space: nowrap; }
.bars .l { font-size: 12px; color: var(--ink2); }
.curbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin-bottom: 10px; background: var(--seg); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 3px 0; }
.kv b { font-weight: 600; text-align: right; }

/* 설정 */
.set-sec { margin: 0 16px 12px; }
.set-row { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--line2); }
.set-row:last-child { border-bottom: 0; }
.set-row select { border: 1px solid var(--line); border-radius: 10px; height: 40px; padding: 0 10px; background: var(--card); max-width: 60%; }
.catlist .set-row .ic { color: var(--accent); }
.small { font-size: 12px; color: var(--mute2); line-height: 1.5; }

/* 아래에서 올라오는 창 */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; }
.sheet-bg { position: absolute; inset: 0; background: rgba(22,32,42,.35); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; max-height: 82vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + var(--safe-b));
}
.sheet h2 { font-size: 17px; margin: 4px 4px 12px; }
.curlist button { width: 100%; border: 0; background: var(--card); display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line2); font-size: 15px; }
.curlist button .sym { width: 40px; font-weight: 700; color: var(--accent); }
.curlist button .code { margin-left: auto; color: var(--mute2); font-size: 13px; }
.curlist { border-radius: 14px; overflow: hidden; margin-bottom: 14px; }
.lbl { font-size: 12px; color: var(--mute2); margin: 0 4px 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 20px); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 40; max-width: 86vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
