/* 키사다 화면: 휴대폰 우선. 파란 띠 = 실제 계좌, 보라 띠 = 가상 기록. 한 카드 안에 둘을 섞지 않는다(명세 13-2). */
:root {
  --bg: #F4F5F7; --card: #FFFFFF; --ink: #14171C; --ink2: #3D4654; --mute: #566070;
  --line: #ECEEF1; --line2: #C9CED6; --track: #E3E6EB;
  --real: #1F4FD8; --real-dk: #173BA3; --virt: #5B3CC4; --virt-dk: #432B94; --virt-bg: #E9E3FA;
  --up: #0F7A46; --up-bg: #DDF2E6; --down: #C4321F; --down-bg: #FBE4E0; --warn: #6B4700; --warn-bg: #FFF4DB;
  --accent: var(--real);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
body.virtual { --accent: var(--virt); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { font-family: 'Noto Sans KR', system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif; font-size: 15px; line-height: 1.45; overscroll-behavior-y: contain; }
#app { height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; position: relative; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; }
[hidden] { display: none !important; }

.band { background: var(--real); color: #fff; padding: calc(6px + var(--safe-t)) 20px 6px; font-size: 12px; font-weight: 500; display: flex; justify-content: space-between; gap: 12px; flex: none; }
.band.virtual { background: var(--virt); }
.band span:last-child { text-align: right; }
.head { padding: 14px 20px 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none; min-height: 58px; }
.head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.head .sub { font-size: 13px; color: var(--ink2); text-align: right; }
.head .back { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; margin-left: -12px; padding: 0 12px; font-size: 15px; font-weight: 500; border: 0; background: none; color: var(--accent); cursor: pointer; }
.main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 12px; outline: none; -webkit-overflow-scrolling: touch; }
.main > * { flex: none; }

.tabs { flex: none; background: var(--card); border-top: 1px solid var(--track); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 6px 8px calc(8px + var(--safe-b)); }
.tabs a { min-height: 48px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--mute); position: relative; border-radius: 10px; }
.tabs a[aria-current="page"] { font-weight: 700; color: var(--tab-color, var(--real)); }
.tabs a[data-tab="lab"][aria-current="page"] { --tab-color: var(--virt); }
.tabs .dot { position: absolute; top: 8px; margin-left: 52px; width: 8px; height: 8px; border-radius: 50%; background: var(--down); }

.card { background: var(--card); border-radius: 12px; padding: 14px; }
.card.flush { padding: 4px 14px; }
.card h2 { font-size: 15px; font-weight: 700; }
.card h2.small { font-size: 13px; color: var(--mute); padding: 12px 0 6px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.lbl { font-size: 12px; color: var(--mute); }
.val { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.val.m { font-size: 18px; } .val.s { font-size: 17px; }
.note { font-size: 12px; color: var(--mute); margin-top: 2px; }
.up { color: var(--up); } .down { color: var(--down); } .mute { color: var(--mute); }
.num { font-variant-numeric: tabular-nums; }
.meter { height: 6px; border-radius: 3px; background: var(--track); margin-top: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter.warn > i { background: #C77700; } .meter.bad > i { background: var(--down); }

.banner { border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-size: 14px; line-height: 1.4; background: var(--warn-bg); color: var(--warn); }
.banner.bad { background: var(--down-bg); color: #8A1F10; }
.banner.info { background: #E8EEFC; color: var(--real-dk); }
.banner svg { flex: none; }
.banner.dark { background: var(--ink); color: #fff; justify-content: space-between; }
.banner.dark .sub { color: var(--line2); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.badge.long { background: var(--up); color: #fff; } .badge.short { background: var(--down); color: #fff; }
.badge.draft { background: var(--warn-bg); color: var(--warn); }
.badge.on { background: var(--up-bg); color: #0B5C34; } .badge.off { background: var(--track); color: var(--ink2); }
.badge.test { background: var(--virt-bg); color: var(--virt-dk); }
.badge.ready { background: var(--warn-bg); color: var(--warn); }
.badge.dark { background: var(--ink); color: #fff; }

.btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: #fff; font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:active { filter: brightness(0.95); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.danger { background: var(--down); border-color: var(--down); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.btn.white { background: #fff; border-color: #fff; color: var(--ink); font-weight: 700; }
.btn.ghost { border-color: transparent; background: none; color: var(--accent); }
.btn.full { width: 100%; }
.btn:disabled { background: var(--bg); color: var(--mute); border-color: var(--line2); cursor: not-allowed; font-weight: 500; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 13px; }
.btn.wrap { white-space: normal; text-align: center; line-height: 1.3; padding: 8px 14px; }

.seg { display: flex; background: var(--track); border-radius: 10px; padding: 3px; }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; font-size: 13px; font-weight: 500; color: var(--ink2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 700; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line2); background: #fff; font-size: 13px; cursor: pointer; color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.chip.sm { min-height: 36px; padding: 0 12px; }

.list { background: var(--card); border-radius: 12px; padding: 4px 14px; }
.list > h2 { font-size: 13px; font-weight: 700; color: var(--mute); padding: 12px 0 6px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 54px; border-top: 1px solid var(--line); color: var(--ink); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; padding: 8px 0; cursor: pointer; }
.list > h2 + .item, .list > .item:first-child { border-top: 0; }
.item .l { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; font-size: 15px; font-weight: 500; }
.item .r { font-size: 13px; color: var(--mute); text-align: right; flex: none; max-width: 52%; }
.item .chev { color: var(--line2); margin-left: 4px; }
.item.static { cursor: default; }

.bars { display: grid; gap: 6px; align-items: end; height: 110px; border-bottom: 1px solid var(--line2); }
.bars .b { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bars .b > i { display: block; border-radius: 3px 3px 0 0; min-height: 3px; background: var(--up); }
.bars .b > i.neg { background: var(--down); } .bars .b > i.zero { background: var(--line2); }
.bars .b.sel > i { outline: 2px solid var(--ink); }
.barlbl { display: grid; gap: 6px; font-size: 11px; color: var(--mute); text-align: center; margin-top: 4px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--mute); font-weight: 500; padding: 8px 4px; }
table.t th.r, table.t td.r { text-align: right; }
table.t td { padding: 11px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.t tr.tap { cursor: pointer; }
table.t tr.more td { background: var(--bg); font-size: 13px; color: var(--ink2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; text-align: right; word-break: break-all; }

/* 입력 */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .flabel { font-size: 13px; font-weight: 500; color: var(--ink2); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; font-size: 16px; }
textarea.input { padding: 10px 12px; min-height: 76px; }
.input:focus-visible, .btn:focus-visible, .chip:focus-visible, .item:focus-visible, .seg button:focus-visible, .tabs a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, white); outline-offset: 1px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 16px; background: var(--line2); transition: background .15s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid color-mix(in srgb, var(--accent) 45%, white); outline-offset: 2px; }
.switch input:disabled + i { opacity: .5; }
.multi { display: flex; flex-wrap: wrap; gap: 8px; }

/* 시트 */
#sheet-root .scrim { position: fixed; inset: 0; background: rgba(20, 23, 28, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#sheet-root .sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .sh-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; gap: 8px; }
.sheet .sh-head h2 { font-size: 18px; font-weight: 700; }
.sheet .sh-body { overflow-y: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.sheet .sh-foot { padding: 10px 16px calc(12px + var(--safe-b)); display: flex; gap: 10px; border-top: 1px solid var(--track); background: var(--card); }
.sheet .sh-foot .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: 90vw; text-align: center; }
.toast.bad { background: var(--down); }

.diff { display: flex; flex-direction: column; gap: 8px; }
.diff .d { background: var(--card); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.diff .d .t { font-weight: 700; font-size: 13px; color: var(--mute); }
.diff .from { color: var(--mute); text-decoration: line-through; } .diff .to { font-weight: 700; }
.empty { text-align: center; color: var(--mute); padding: 28px 12px; font-size: 14px; }
.skel { background: linear-gradient(90deg, var(--track), #f0f1f4, var(--track)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: 12px; height: 80px; }
@keyframes sk { to { background-position: -200% 0; } }
.stale { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 6px 10px; }
.login { margin: auto 0; display: flex; flex-direction: column; gap: 14px; padding: 8px 4px; }
.login h2 { font-size: 20px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
