/* 입출금 모아보기 — 화면 */
:root {
  /* 역전 사이트와 같은 결: 흰 바탕 · 짙은 회색 글씨 · 푸른빛 얇은 선 */
  --bg: #f4f6f8; --card: #ffffff; --ink: #191919; --mute: #656565; --faint: #8e969d; --line: #dde3e8; --line2: #edf0f3;
  --in: #146c43; --out: #b42318; --warn: #b54708; --warnbg: #fffaf0; --warnline: #f3d9b5; --badge: #b54708;
  --hq: #323232; --hqbg: #eef0f1; --ex: #175cd3; --exbg: #eaf1fd; --misc: #656565; --miscbg: #eef0f1;
  --brand: #191919; --live: #0f9d58; --okbg: #e3efdf; --badbg: #fde8e5;
  --fs: 1;
}
/* 어두운 화면 — 색 토막만 갈아 끼운다 */
body.dark {
  --bg: #14171a; --card: #1c2025; --ink: #e7eaed; --mute: #98a1aa; --faint: #6d757d; --line: #2b3138; --line2: #23282e;
  --in: #4ade80; --out: #ff8b7e; --warn: #f3aa5c; --warnbg: #2a2318; --warnline: #4a3a1f; --badge: #f3aa5c;
  --hq: #cfd6dd; --hqbg: #262c33; --ex: #7cb1ff; --exbg: #1e2733; --misc: #98a1aa; --miscbg: #262c33;
  --brand: #e7eaed; --live: #4ade80; --okbg: #1e2f21; --badbg: #3a2220;
}
/* 어두울 때 뒤집히면 안 되는 것들 */
body.dark .brand .yj { color: #14171a; }
body.dark .strip.dark { background: #23282e; color: var(--ink); border: 1px solid var(--line); }
body.dark .strip.dark .mute { color: var(--mute); }
body.dark .strip.alert { background: #7f1d1a; }
body.dark .seg span.on { background: var(--ink); color: #14171a; }
body.dark .badge { color: #14171a; }
body.dark .badge.zero { color: var(--mute); }
body.dark input, body.dark select, body.dark textarea { background: var(--card); border-color: var(--line); }
body.dark .card.warn { background: var(--warnbg); }
body.dark .gapcb { accent-color: var(--in); }
/* 정산금 큰 칸: 어두울 땐 바탕을 어둡게 하고 글씨를 강조색으로 */
/* 동그란 이름표: 어두울 땐 밝은 바탕이라 글씨를 어둡게 */
body.dark .dotc { color: #14171a; }
/* 가는 구분선 */
body.dark .strip .sep { color: var(--faint); }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 -apple-system, "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
body.font-small { --fs: 0.9; } body.font-large { --fs: 1.15; } body.font-xl { --fs: 1.3; }
body.dull { --in: #3b6b4f; --out: #8c5049; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
.in { color: var(--in); } .out { color: var(--out); } .mute { color: var(--mute); } .faint { color: var(--faint); }
a { color: var(--hq); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

/* 머리 */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(8px + env(safe-area-inset-top)) 12px 6px; display: flex; align-items: center; gap: 6px; }
.top h1 { font-size: calc(16px * var(--fs)); font-weight: 800; margin: 0; flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.3px; }
/* YJ TXLive 상표 */
.brand { display: flex; align-items: baseline; gap: 5px; flex-grow: 1; min-width: 0; }
.brand .yj { background: var(--brand); color: #fff; border-radius: 4px; padding: 1px 5px; font-size: calc(12px * var(--fs)); font-weight: 800; letter-spacing: 0.2px; }
.brand .tx { font-size: calc(16px * var(--fs)); font-weight: 800; letter-spacing: -0.4px; }
.brand .tx i { font-style: normal; color: var(--live); }
.brand small { font-size: calc(10px * var(--fs)); font-weight: 500; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 400px) { .brand small { display: none; } }
/* 실시간 표시등 — 서버와 이어져 있으면 초록으로 숨쉰다 */
.livedot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex-shrink: 0; align-self: center; }
.livedot.on { background: var(--live); animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.top h1 small { font-size: 10px; font-weight: 400; color: var(--mute); margin-left: 4px; }
.top .sub { font-size: 11px; color: var(--mute); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; font-size: 11px; flex-shrink: 0; }
.seg span { padding: 5px 8px; cursor: pointer; white-space: nowrap; }
.seg span.on { background: var(--ink); color: var(--bg); font-weight: 700; }
.iconbtn { width: 30px; height: 30px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0; }
.iconbtn:active { background: var(--line); }
.back { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; margin-left: -8px; }

/* 얇은 줄들 */
.strip { margin: 0 12px; padding: 5px 10px; border-radius: 6px; display: flex; align-items: center; gap: 8px; font-size: calc(11px * var(--fs)); }
.strip.dark { background: var(--ink); color: var(--bg); }
.strip.alert { background: var(--out); color: #fff; cursor: pointer; font-weight: 700; }
.strip.alert b { font-size: 13px; }
.strip.dark .in { color: #6ce9a6; } .strip.dark .out { color: #ffa39e; } .strip.dark .mute { color: #b6bec5; }
.strip.light { margin-top: 4px; background: var(--card); border: 1px solid var(--line); font-size: calc(10px * var(--fs)); color: var(--mute); white-space: nowrap; overflow: hidden; }
.strip.light > a { flex-shrink: 0; }
.strip.light > .num:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.strip .grow { flex-grow: 1; }
.badge { background: var(--badge); color: var(--ink); border-radius: 999px; padding: 0 5px; font-weight: 800; font-size: 10px; }
.badge.zero { background: var(--line); color: var(--mute); font-weight: 600; }
.strip .sep { color: var(--line); }
.strip a { cursor: pointer; }

.tabs { margin: 6px 12px 0; padding: 2px; background: var(--line); border-radius: 8px; display: flex; }
.tabs span { flex: 1; text-align: center; padding: 6px 0; font-size: 12px; color: var(--mute); cursor: pointer; border-radius: 6px; }
.tabs span.on { background: var(--ink); color: var(--bg); font-weight: 700; }

/* 본문 */
main { padding: 6px 12px 96px; max-width: 760px; margin: 0 auto; width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.card.warn { border-color: var(--warnline); }
.ghead { display: flex; align-items: center; gap: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
.ghead .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ghead b { font-size: calc(12px * var(--fs)); }
.ghead .grow { flex-grow: 1; }
.daysep { font-size: 10px; font-weight: 700; color: var(--mute); padding: 6px 2px 3px; }
.h { padding: 12px 4px 4px; font-size: 12px; font-weight: 700; color: var(--mute); display: flex; align-items: center; justify-content: space-between; }
.h a { font-weight: 500; font-size: 11px; }

/* 거래 줄 */
.row { display: flex; align-items: center; gap: 5px; padding: 4px 8px; border-top: 1px solid var(--line2); cursor: pointer; min-height: 27px; }
.row:first-child { border-top: 0; }
.row.unparsed { background: var(--warnbg); }
.row .t { font-size: calc(11px * var(--fs)); font-weight: 600; width: 34px; flex-shrink: 0; }
.row .t.old { color: var(--faint); }
.row .mid { flex-grow: 1; min-width: 0; display: flex; align-items: baseline; gap: 4px; }
.row .who { font-size: calc(12px * var(--fs)); font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.row.unparsed .who { color: var(--warn); font-weight: 500; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.row .acc { display: flex; min-width: 0; font-size: calc(12px * var(--fs)); font-weight: 600; color: var(--mute); white-space: nowrap; overflow: hidden; }
/* 자리가 모자라면 앞쪽(은행 이름·앞자리)만 줄이고 뒷번호 네 자리는 끝까지 보이게 */
.row .acc .head { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row .acc .tail, .row .acc .rest { flex-shrink: 0; }
.row .acc .tail { color: var(--ink); font-weight: 700; }
.row .amt { font-size: calc(14px * var(--fs)); font-weight: 700; flex-shrink: 0; }
.row .amt.unparsed { color: var(--warn); } .row .amt.misc, .row .amt.adjust { color: #8f8a82; }
.tag { border-radius: 3px; padding: 0 3px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.tag.misc, .tag.adjust { background: var(--miscbg); color: var(--misc); }
.tag.loan { background: var(--hqbg); color: var(--hq); }
.tag.internal { background: #e4e9f3; color: #3b5a8a; } .row .amt.internal { color: #6b7fa3; }
.tag.ok { background: var(--okbg); color: var(--in); } .tag.bad { background: var(--badbg); color: var(--out); } .tag.warn { background: var(--warnbg); color: var(--warn); }
.ochip { border-radius: 4px; padding: 1px 5px; font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }

/* 격자 */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.tile { border-radius: 8px; padding: 6px 7px; display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; border: 1px solid var(--line); background: var(--card); }
.tile.sel { border: 2px solid var(--ink); }
.tile .name { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; min-width: 0; }
.tile .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .name .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tile .name .n { margin-left: auto; font-size: 9px; color: var(--mute); }
.tile .v { font-size: 10px; }
.tile.quiet .name { color: var(--faint); }

/* 칩·버튼·폼 */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { background: var(--line); color: var(--ink); border: 0; border-radius: 999px; padding: 5px 12px; font-size: 11px; }
.chip.on { background: var(--ink); color: var(--bg); font-weight: 700; }
.btn { min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 12px; font-weight: 700; padding: 0 12px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.big { width: 100%; min-height: 46px; font-size: 15px; border-radius: 12px; }
.btn.danger { color: var(--out); }
.btn.quiet { color: var(--mute); }
.btn:disabled { background: var(--line); border-color: var(--line); color: var(--faint); }
.btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.btns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.btns.one { grid-template-columns: 1fr; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; font-size: 16px; background: var(--card); color: var(--ink); min-height: 40px; }
.field.small { font-size: 13px; min-height: 34px; padding: 5px 8px; width: 90px; text-align: right; }
.lbl { font-size: 11px; color: var(--mute); font-weight: 700; margin: 10px 0 4px; }
.line { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line2); font-size: 13px; min-height: 40px; }
.line:first-child { border-top: 0; }
.line .grow { flex-grow: 1; min-width: 0; }
.line small { font-size: 10px; color: var(--mute); display: block; }
.sw { width: 38px; height: 22px; border-radius: 11px; background: var(--ink); position: relative; flex-shrink: 0; cursor: pointer; border: 0; padding: 0; }
.sw::after { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.sw.off { background: var(--line); } .sw.off::after { right: auto; left: 3px; }
.note { margin: 8px 0; padding: 8px 10px; background: var(--warnbg); border: 1px solid var(--warnline); border-radius: 8px; font-size: 11px; color: #6b5430; line-height: 1.5; }
.info { margin: 8px 0; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 11px; color: var(--mute); line-height: 1.5; }
.empty { text-align: center; color: var(--faint); font-size: 12px; padding: 24px 0; }
.tr { display: grid; padding: 7px 10px; border-top: 1px solid var(--line2); align-items: center; font-size: 12px; gap: 6px; }
.tr.head { background: var(--line2); font-size: 10px; color: var(--mute); font-weight: 700; border-top: 0; }
.tr.sum { background: var(--line2); font-weight: 700; }
.r { text-align: right; }
.stat3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0; }
.stat3 > div { border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 2px; background: var(--card); border: 1px solid var(--line); }
.stat3 > div.dark { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.stat3 .k { font-size: 10px; color: var(--mute); } .stat3 .dark .k { color: #b6bec5; }
body.dark .stat3 > div.dark { background: #23282e; color: var(--ink); border-color: var(--line); }
body.dark .stat3 .dark .k, body.dark .stat3 .dark small { color: var(--mute) !important; }
.stat3 .v { font-size: 15px; font-weight: 800; }
.dotc { width: 22px; height: 22px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.swatch { width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.swatch.sel { outline: 3px solid var(--ink); outline-offset: 2px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }

/* 아래 탭 */
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding: 11px 0 calc(20px + env(safe-area-inset-bottom)); z-index: 5;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x proximity; }
nav.bottom::-webkit-scrollbar { display: none; }
nav.bottom a { flex: 1 0 auto; min-width: 46px; padding: 4px 2px; text-align: center; font-size: calc(11px * var(--fs)); color: var(--mute); cursor: pointer; white-space: nowrap; scroll-snap-align: center;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
nav.bottom a .b { margin-left: 2px; padding: 0 4px; }
nav.bottom.reorder { overflow-x: hidden; touch-action: none; background: var(--line2); }
nav.bottom.reorder a { transition: transform .12s; }
nav.bottom a.dragging { background: var(--line); border-radius: 8px; transform: scale(1.15); font-weight: 700; color: var(--ink); }
nav.bottom a.done { color: var(--hq); font-weight: 700; }

/* 메뉴 순서 바꾸기 */
.line.drag { touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.line.drag.dragging { background: var(--line); }
.line.drag .handle { color: var(--faint); font-size: 16px; width: 16px; }
nav.bottom a.on { color: var(--ink); font-weight: 700; }
nav.bottom a .b { display: inline-block; margin-left: 3px; background: var(--badge); border-radius: 999px; padding: 0 5px; font-size: 9px; font-weight: 800; color: var(--ink); }

/* 시트 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: flex-end; z-index: 20; }
.modal.show { display: flex; }
.sheet { background: var(--card); width: 100%; max-width: 760px; margin: 0 auto; border-radius: 16px 16px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
.sheet h2 { margin: 0 0 6px; font-size: 16px; }
.sheet pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 8px; font-size: 12px; margin: 6px 0; }
.kv { font-size: 12px; color: var(--mute); margin: 3px 0; } .kv b { color: var(--ink); }
.err { color: var(--out); font-size: 12px; min-height: 16px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 999px; font-size: 12px; z-index: 30; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
#join { max-width: 420px; margin: 40px auto; padding: 16px; }
#join label { display: block; margin: 12px 0 4px; font-weight: 700; font-size: 13px; }
.stamp { font-size: 10px; color: var(--faint); text-align: center; padding: 6px 0; }

/* v4 */

/* 아주 좁은 폰(360px)에서는 계좌번호가 잘리지 않게 한 단계 줄인다 */
@media (max-width: 374px) { .row .acc { font-size: calc(11px * var(--fs)); } .ochip { font-size: 11px; padding: 1px 4px; } .row .amt { font-size: calc(13px * var(--fs)); } .row { gap: 4px; padding-left: 6px; padding-right: 6px; } }
.gapcb { width: 20px; height: 20px; accent-color: var(--ink); flex-shrink: 0; margin: 0; }
